pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Remove dependency on HeapTuple from predicate locking functions.
6+ messages / 3 participants
[nested] [flat]

* pgsql: Remove dependency on HeapTuple from predicate locking functions.
@ 2020-01-28 00:46  Thomas Munro <tmunro@postgresql.org>
  0 siblings, 1 reply; 6+ messages in thread

From: Thomas Munro @ 2020-01-28 00:46 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Remove dependency on HeapTuple from predicate locking functions.

The following changes make the predicate locking functions more
generic and suitable for use by future access methods:

- PredicateLockTuple() is renamed to PredicateLockTID().  It takes
  ItemPointer and inserting transaction ID instead of HeapTuple.

- CheckForSerializableConflictIn() takes blocknum instead of buffer.

- CheckForSerializableConflictOut() no longer takes HeapTuple or buffer.

Author: Ashwin Agrawal
Reviewed-by: Andres Freund, Kuntal Ghosh, Thomas Munro
Discussion: https://postgr.es/m/CALfoeiv0k3hkEb3Oqk%3DziWqtyk2Jys1UOK5hwRBNeANT_yX%2Bng%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6f38d4dac381b5b8bead302a0b4f81761042cd25

Modified Files
--------------
src/backend/access/gin/ginbtree.c        |   2 +-
src/backend/access/gin/ginfast.c         |   2 +-
src/backend/access/gin/gininsert.c       |   6 +-
src/backend/access/gist/gist.c           |   2 +-
src/backend/access/hash/hashinsert.c     |   2 +-
src/backend/access/heap/heapam.c         | 125 ++++++++++++++++++++++++----
src/backend/access/heap/heapam_handler.c |  11 +--
src/backend/access/index/indexam.c       |   4 +-
src/backend/access/nbtree/nbtinsert.c    |   4 +-
src/backend/storage/lmgr/predicate.c     | 137 ++++++++++---------------------
src/include/access/heapam.h              |   2 +
src/include/storage/predicate.h          |   9 +-
12 files changed, 176 insertions(+), 130 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: Remove dependency on HeapTuple from predicate locking functions.
@ 2020-01-28 05:59  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Thomas Munro <tmunro@postgresql.org>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2020-01-28 05:59 UTC (permalink / raw)
  To: Thomas Munro <tmunro@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org

Thomas Munro <tmunro@postgresql.org> writes:
> Remove dependency on HeapTuple from predicate locking functions.

anole's not terribly pleased with this:

"heapam.c", line 9137: error #2118: a void function may not return a value
  	return CheckForSerializableConflictOut(relation, xid, snapshot);
  	       ^

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: Remove dependency on HeapTuple from predicate locking functions.
@ 2020-01-28 07:41  Thomas Munro <thomas.munro@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: Thomas Munro @ 2020-01-28 07:41 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Thomas Munro <tmunro@postgresql.org>; pgsql-committers <pgsql-committers@lists.postgresql.org>

On Tue, Jan 28, 2020 at 6:59 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Thomas Munro <tmunro@postgresql.org> writes:
> > Remove dependency on HeapTuple from predicate locking functions.
>
> anole's not terribly pleased with this:
>
> "heapam.c", line 9137: error #2118: a void function may not return a value
>         return CheckForSerializableConflictOut(relation, xid, snapshot);
>                ^

Thanks.  I pushed a fix.

Wow, HP C spits out a lot of warnings.





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: Remove dependency on HeapTuple from predicate locking functions.
@ 2020-01-28 15:05  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Thomas Munro <thomas.munro@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2020-01-28 15:05 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@gmail.com>; +Cc: pgsql-committers <pgsql-committers@lists.postgresql.org>

Thomas Munro <thomas.munro@gmail.com> writes:
> On Tue, Jan 28, 2020 at 6:59 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> anole's not terribly pleased with this:
>> "heapam.c", line 9137: error #2118: a void function may not return a value
>> return CheckForSerializableConflictOut(relation, xid, snapshot);

> Thanks.  I pushed a fix.
> Wow, HP C spits out a lot of warnings.

It's pretty noisy, and most of 'em are useless :-(.  But as for this
particular complaint, I don't really understand why gcc lets it slide.
The C99 standard is not exactly ambiguous about this:

       6.8.6.4  The return statement

       Constraints

       [#1]  A return statement with an expression shall not appear
       in a function whose return type is void.  A return statement
       without  an expression shall only appear in a function whose
       return type is void.

There is absolutely no question that the original coding is illegal
per spec, and it isn't even a particularly useful shorthand; so why
can't we get even a warning about it?

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: Remove dependency on HeapTuple from predicate locking functions.
@ 2020-01-28 19:18  Thomas Munro <thomas.munro@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: Thomas Munro @ 2020-01-28 19:18 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers <pgsql-committers@lists.postgresql.org>

On Wed, Jan 29, 2020 at 4:05 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Thomas Munro <thomas.munro@gmail.com> writes:
> > On Tue, Jan 28, 2020 at 6:59 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >> anole's not terribly pleased with this:
> >> "heapam.c", line 9137: error #2118: a void function may not return a value
> >> return CheckForSerializableConflictOut(relation, xid, snapshot);
>
> > Thanks.  I pushed a fix.
> > Wow, HP C spits out a lot of warnings.
>
> It's pretty noisy, and most of 'em are useless :-(.  But as for this
> particular complaint, I don't really understand why gcc lets it slide.

Maybe because it's allowed in C++, and pretty harmless.

> There is absolutely no question that the original coding is illegal
> per spec, and it isn't even a particularly useful shorthand; so why
> can't we get even a warning about it?

$ cat test.c
void f() {}
void g() { return f(); }
$ cc -c -Wall test.c
$ cc -c -Wpedantic test.c
test.c:2:12: warning: void function 'g' should not return void
expression [-Wpedantic]
void g() { return f(); }
           ^      ~~~
1 warning generated.

Many other constructs in PostgreSQL are rejected by that switch,
though, and I don't see a way to ask for just that one warning.





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: Remove dependency on HeapTuple from predicate locking functions.
@ 2020-01-28 19:39  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Thomas Munro <thomas.munro@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2020-01-28 19:39 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@gmail.com>; +Cc: pgsql-committers <pgsql-committers@lists.postgresql.org>

Thomas Munro <thomas.munro@gmail.com> writes:
> On Wed, Jan 29, 2020 at 4:05 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> There is absolutely no question that the original coding is illegal
>> per spec, and it isn't even a particularly useful shorthand; so why
>> can't we get even a warning about it?

> $ cc -c -Wpedantic test.c
> test.c:2:12: warning: void function 'g' should not return void
> expression [-Wpedantic]
> void g() { return f(); }
>            ^      ~~~
> 1 warning generated.

> Many other constructs in PostgreSQL are rejected by that switch,
> though, and I don't see a way to ask for just that one warning.

Yeah, -Wpedantic is a little *too* pedantic I'm afraid.  Oh well.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2020-01-28 19:39 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-01-28 00:46 pgsql: Remove dependency on HeapTuple from predicate locking functions. Thomas Munro <tmunro@postgresql.org>
2020-01-28 05:59 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-01-28 07:41   ` Thomas Munro <thomas.munro@gmail.com>
2020-01-28 15:05     ` Tom Lane <tgl@sss.pgh.pa.us>
2020-01-28 19:18       ` Thomas Munro <thomas.munro@gmail.com>
2020-01-28 19:39         ` Tom Lane <tgl@sss.pgh.pa.us>

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