Re: Minor typo in 13.3.5. Advisory Locks - Mailing list pgsql-docs

From Tom Lane
Subject Re: Minor typo in 13.3.5. Advisory Locks
Date
Msg-id 387586.1680266155@sss.pgh.pa.us
Whole thread Raw
In response to Re: Minor typo in 13.3.5. Advisory Locks  (Daniel Gustafsson <daniel@yesql.se>)
Responses Re: Minor typo in 13.3.5. Advisory Locks
List pgsql-docs
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



pgsql-docs by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: Minor typo in 13.3.5. Advisory Locks
Next
From: Daniel Gustafsson
Date:
Subject: Re: Minor typo in 13.3.5. Advisory Locks