pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Lane Van Ingen <lvaningen@esncc.com>
To: pgsql-sql@postgresql.org
Subject: How to Force Transactions to Process Serially on A Table
Date: Mon, 19 Dec 2005 08:07:20 -0500
Message-ID: <EKEMKEFLOMKDDLIALABICEGLCGAA.lvaningen@esncc.com> (raw)

I am using PL/SQL functions on Windows 2003, version 8.0.1.

I have not used explicit PostgreSQL LOCKing before, but I need some advice
on how properly to use some explicit locking. I think that duplicate key
violations I am now getting are the result.

I want to force transactions being used to update a table to be processed on
a first-come, first-served basis. I want my Pl/sql function to execute to
completion on each transaction before another starts.

Need some advice on how to do this. From what I can read in the docs, it
looks like I need to solve the problem by using the following, but doing so
gives me an SPI_execution error:
  BEGIN;
  LOCK <table> IN SHARE ROW  EXCLUSIVE MODE;
    lock adns_report_hour_history in share row exclusive mode;
  INSERT INTO <table> VALUES ...  - or - UPDATE <table> SET ....
  COMMIT;
Will this make the next transaction wait until the previous transaction has
completed? Do I need to set any config parameters?

If you can include an actual code snippet in the response, it would help ...





view thread (5+ messages)  latest in thread

Message-ID: <EKEMKEFLOMKDDLIALABICEGLCGAA.lvaningen@esncc.com>
Permalink:  ../EKEMKEFLOMKDDLIALABICEGLCGAA.lvaningen@esncc.com/
Also on:    postgresql.org/message-id/EKEMKEFLOMKDDLIALABICEGLCGAA.lvaningen@esncc.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: lvaningen@esncc.com
  Subject: Re: How to Force Transactions to Process Serially on A Table
  In-Reply-To: <EKEMKEFLOMKDDLIALABICEGLCGAA.lvaningen@esncc.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox