From: Tom Lane <tgl@sss.pgh.pa.us>
To: Daniel Gustafsson <daniel@yesql.se>
Cc: zacharymschultz@gmail.com
Cc: pgsql-docs@lists.postgresql.org
Subject: Re: Minor typo in 13.3.5. Advisory Locks
Date: Fri, 31 Mar 2023 08:35:55 -0400
Message-ID: <387586.1680266155@sss.pgh.pa.us> (raw)
In-Reply-To: <76AEBCC7-5C7C-4A30-B3C3-8FAB1883C789@yesql.se>
References: <168001423502.628.12487124747594890228@wrigleys.postgresql.org>
<3663048.1680036353@sss.pgh.pa.us>
<76AEBCC7-5C7C-4A30-B3C3-8FAB1883C789@yesql.se>
Daniel Gustafsson <daniel@yesql.se> writes:
> Reading this section I agree that the mix of ok/danger in the same example can
> be tad misleading though. Something like the attached is what I would prefer
> as a reader.
I think in your rewrite, "this query" is dangling a bit because there's
several sentences more before the query actually appears. I suggest
ordering things more like:
expressions are evaluated. For example,
this query is dangerous because the
<literal>LIMIT</literal> is not guaranteed to be applied before the locking
function is executed:
<screen>
SELECT pg_advisory_lock(id) FROM foo WHERE id > 12345 LIMIT 100; -- danger!
</screen>
This might cause some locks to be acquired
that the application was not expecting, and hence would fail to
...
On the other hand, these queries are safe:
<screen>
SELECT pg_advisory_lock(id) FROM foo WHERE id = 12345; -- ok
...
Separately from that: now that I look at this example, it's really
quite safe for any plausible plan shape. It used to be dangerous if
you had an ORDER BY, but there's no ORDER BY, and even if there were
we fixed that in 9118d03a8. Do we want to choose another example, and
if so what? The "not guaranteed" wording isn't really wrong, but an
example that doesn't do what we're saying it does isn't good either.
regards, tom lane
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-docs@postgresql.org
Cc: tgl@sss.pgh.pa.us, daniel@yesql.se, zacharymschultz@gmail.com, pgsql-docs@lists.postgresql.org
Subject: Re: Minor typo in 13.3.5. Advisory Locks
In-Reply-To: <387586.1680266155@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