pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-sql@hub.org
Subject: Re: SQL functions not locking properly?
Date: Mon, 25 Sep 2000 16:26:16 -0400
Message-ID: <6910.969913576@sss.pgh.pa.us> (raw)
In-Reply-To: <p87vss0kh2sroma0fpts3dsac5tlt1pdh4@4ax.com>
References: <p87vss0kh2sroma0fpts3dsac5tlt1pdh4@4ax.com>

Forest Wilkinson <fspam@home.com> writes:
> session2<< select nextid('myid');

> (session2 blocks until session1 completes its transaction)

> session1<< commit;
session1> COMMIT

> (session2 resumes)

session2> nextid
session2> --------
session2> 0
session2> (1 row)

> What gives???  I expected the second call to nextid() to return 2!

Hmm.  If you do the same commands without wrapping them in an SQL
function, they operate as expected.  I'll bet there's some nasty
interaction between the FOR UPDATE support and the way that SQL
functions twiddle the current-command counter.  Sigh, another bug.

You might try it in plpgsql to see if that language has the same
bug (and please report back the results!).  If so, the only workaround
right now is not to use a function, or possibly to code it in C using
the SPI interface.

I'm up to my armpits in subselect-in-FROM right now, but will put this
on my to-do list.  Will look at it in a week or two if no one else has
fixed it before then...

			regards, tom lane



view thread (4+ messages)  latest in thread

Message-ID: <6910.969913576@sss.pgh.pa.us>
Permalink:  ../6910.969913576@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/6910.969913576@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-sql@hub.org
  Subject: Re: SQL functions not locking properly?
  In-Reply-To: <6910.969913576@sss.pgh.pa.us>
  References: <p87vss0kh2sroma0fpts3dsac5tlt1pdh4@4ax.com> <6910.969913576@sss.pgh.pa.us>

* 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