On 2015-08-17 12:30:56 -0400, Robert Haas wrote:
> As far as I can see, the anticipated benefits of what we're doing here are:
> 
> - Get a cleaner separation of frontend and backend headers (this could
> also be done independently of STATIC_IF_INLINE, but removing
> STATIC_IF_INLINE increases the urgency).
> - Eliminate multiple evaluations hazards.
> - Modest improvements to code generation.

Plus:
* Not having 7k long macros, that e.g. need extra flags to even be
  supported. C.f. 
http://archives.postgresql.org/message-id/4407.1435763473%40sss.pgh.pa.us
* Easier development due to actual type checking and such. Compare the
  errors from heap_getattr as a macro being passed a boolean with the
  same from an inline function: Inline:

/home/andres/src/postgresql/src/backend/executor/spi.c: In function 
‘SPI_getvalue’:
/home/andres/src/postgresql/src/backend/executor/spi.c:883:46: error: 
incompatible type for argument 4 of ‘heap_getattr’
  val = heap_getattr(tuple, fnumber, tupdesc, isnull);
                                              ^
In file included from 
/home/andres/src/postgresql/src/backend/executor/spi.c:17:0:
/home/andres/src/postgresql/src/include/access/htup_details.h:765:1: note: 
expected ‘_Bool *’ but argument is of type ‘_Bool’
 heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
 ^

Macro:

In file included from 
/home/andres/src/postgresql/src/backend/executor/spi.c:17:0:
/home/andres/src/postgresql/src/backend/executor/spi.c: In function 
‘SPI_getvalue’:
/home/andres/src/postgresql/src/include/access/htup_details.h:750:6: error: 
invalid type argument of unary ‘*’ (have ‘int’)
     (*(isnull) = true), \
      ^
/home/andres/src/postgresql/src/backend/executor/spi.c:883:8: note: in 
expansion of macro ‘heap_getattr’
  val = heap_getattr(tuple, fnumber, tupdesc, isnull);
        ^
/home/andres/src/postgresql/src/include/access/htup_details.h:750:23: warning: 
left-hand operand of comma expression has no effect [-Wunused-value]
     (*(isnull) = true), \
                       ^
/home/andres/src/postgresql/src/backend/executor/spi.c:883:8: note: in 
expansion of macro ‘heap_getattr’
  val = heap_getattr(tuple, fnumber, tupdesc, isnull);
        ^
/home/andres/src/postgresql/src/include/access/htup_details.h:697:3: error: 
invalid type argument of unary ‘*’ (have ‘int’)
  (*(isnull) = false),           \
   ^
/home/andres/src/postgresql/src/include/access/htup_details.h:754:5: note: in 
expansion of macro ‘fastgetattr’
     fastgetattr((tup), (attnum), (tupleDesc), (isnull)) \
     ^
/home/andres/src/postgresql/src/backend/executor/spi.c:883:8: note: in 
expansion of macro ‘heap_getattr’
  val = heap_getattr(tuple, fnumber, tupdesc, isnull);
        ^
/home/andres/src/postgresql/src/include/access/htup_details.h:713:5: error: 
invalid type argument of unary ‘*’ (have ‘int’)
    (*(isnull) = true),          \
     ^
/home/andres/src/postgresql/src/include/access/htup_details.h:754:5: note: in 
expansion of macro ‘fastgetattr’
     fastgetattr((tup), (attnum), (tupleDesc), (isnull)) \
     ^
/home/andres/src/postgresql/src/backend/executor/spi.c:883:8: note: in 
expansion of macro ‘heap_getattr’
  val = heap_getattr(tuple, fnumber, tupdesc, isnull);
        ^
/home/andres/src/postgresql/src/include/access/htup_details.h:713:22: warning: 
left-hand operand of comma expression has no effect [-Wunused-value]
    (*(isnull) = true),          \
                      ^
/home/andres/src/postgresql/src/include/access/htup_details.h:754:5: note: in 
expansion of macro ‘fastgetattr’
     fastgetattr((tup), (attnum), (tupleDesc), (isnull)) \
     ^
/home/andres/src/postgresql/src/backend/executor/spi.c:883:8: note: in 
expansion of macro ‘heap_getattr’
  val = heap_getattr(tuple, fnumber, tupdesc, isnull);
        ^
/home/andres/src/postgresql/src/include/access/htup_details.h:697:21: warning: 
left-hand operand of comma expression has no effect [-Wunused-value]
  (*(isnull) = false),           \
                     ^
/home/andres/src/postgresql/src/include/access/htup_details.h:754:5: note: in 
expansion of macro ‘fastgetattr’
     fastgetattr((tup), (attnum), (tupleDesc), (isnull)) \
     ^
/home/andres/src/postgresql/src/backend/executor/spi.c:883:8: note: in 
expansion of macro ‘heap_getattr’
  val = heap_getattr(tuple, fnumber, tupdesc, isnull);
        ^
/home/andres/src/postgresql/src/include/access/htup_details.h:757:50: warning: 
passing argument 4 of ‘heap_getsysattr’ makes pointer from integer without a 
cast [-Wint-conversion]
    heap_getsysattr((tup), (attnum), (tupleDesc), (isnull)) \
                                                  ^
/home/andres/src/postgresql/src/backend/executor/spi.c:883:8: note: in 
expansion of macro ‘heap_getattr’
  val = heap_getattr(tuple, fnumber, tupdesc, isnull);
        ^
/home/andres/src/postgresql/src/include/access/htup_details.h:771:14: note: 
expected ‘bool * {aka char *}’ but argument is of type ‘bool {aka char}’
 extern Datum heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
              ^


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to