bigsql / plprofiler

Other
79 stars 22 forks source link

Compatibility/Updates with Postgres 16 #16

Closed Deltaus closed 11 months ago

Deltaus commented 1 year ago

Recently when I tried to build this extension with latest postgres 16, it threw errors like below

plprofiler.c: In function ‘pl_profiler_get_stack’:
plprofiler.c:1254:24: warning: passing argument 1 of ‘PointerGetDatum’ makes pointer from integer without a cast [-Wint-conversion]
  PG_RETURN_ARRAYTYPE_P(PointerGetDatum(construct_array(funcdefs, nelems,
                        ^
../../src/include/fmgr.h:361:53: note: in definition of macro ‘PG_RETURN_POINTER’
 #define PG_RETURN_POINTER(x) return PointerGetDatum(x)
                                                     ^
plprofiler.c:1254:2: note: in expansion of macro ‘PG_RETURN_ARRAYTYPE_P’
  PG_RETURN_ARRAYTYPE_P(PointerGetDatum(construct_array(funcdefs, nelems,
  ^~~~~~~~~~~~~~~~~~~~~
In file included from plprofiler.c:20:0:
../../src/include/postgres.h:322:1: note: expected ‘const void *’ but argument is of type ‘Datum {aka long unsigned int}’
 PointerGetDatum(const void *X)
 ^~~~~~~~~~~~~~~
In file included from ../../src/include/postgres.h:45:0,
                 from plprofiler.c:20:
plprofiler.c: In function ‘pl_profiler_callgraph_local’:
../../src/include/c.h:916:7: error: static assertion failed: "entry->totalTime does not have type int64"
  do { _Static_assert(condition, errmessage); } while(0)
       ^
../../src/include/c.h:918:13: note: in expansion of macro ‘StaticAssertStmt’
  ((void) ({ StaticAssertStmt(condition, errmessage); true; }))
             ^~~~~~~~~~~~~~~~
../../src/include/c.h:962:3: note: in expansion of macro ‘StaticAssertExpr’
  (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
   ^~~~~~~~~~~~~~~~
../../src/include/postgres.h:550:3: note: in expansion of macro ‘AssertVariableIsOfTypeMacro’
  (AssertVariableIsOfTypeMacro(X, int64), Int64GetDatum(X))
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
plprofiler.c:1502:18: note: in expansion of macro ‘Int64GetDatumFast’
    values[j++] = Int64GetDatumFast(entry->totalTime);
                  ^~~~~~~~~~~~~~~~~
../../src/include/c.h:916:7: error: static assertion failed: "entry->childTime does not have type int64"
  do { _Static_assert(condition, errmessage); } while(0)
       ^
../../src/include/c.h:918:13: note: in expansion of macro ‘StaticAssertStmt’
  ((void) ({ StaticAssertStmt(condition, errmessage); true; }))
             ^~~~~~~~~~~~~~~~
../../src/include/c.h:962:3: note: in expansion of macro ‘StaticAssertExpr’
  (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
   ^~~~~~~~~~~~~~~~
../../src/include/postgres.h:550:3: note: in expansion of macro ‘AssertVariableIsOfTypeMacro’
  (AssertVariableIsOfTypeMacro(X, int64), Int64GetDatum(X))
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
plprofiler.c:1503:18: note: in expansion of macro ‘Int64GetDatumFast’
    values[j++] = Int64GetDatumFast(entry->childTime);
                  ^~~~~~~~~~~~~~~~~
../../src/include/c.h:916:7: error: static assertion failed: "entry->selfTime does not have type int64"
  do { _Static_assert(condition, errmessage); } while(0)
       ^
../../src/include/c.h:918:13: note: in expansion of macro ‘StaticAssertStmt’
  ((void) ({ StaticAssertStmt(condition, errmessage); true; }))
             ^~~~~~~~~~~~~~~~
../../src/include/c.h:962:3: note: in expansion of macro ‘StaticAssertExpr’
  (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
   ^~~~~~~~~~~~~~~~
../../src/include/postgres.h:550:3: note: in expansion of macro ‘AssertVariableIsOfTypeMacro’
  (AssertVariableIsOfTypeMacro(X, int64), Int64GetDatum(X))
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
plprofiler.c:1504:18: note: in expansion of macro ‘Int64GetDatumFast’
    values[j++] = Int64GetDatumFast(entry->selfTime);
                  ^~~~~~~~~~~~~~~~~
plprofiler.c: In function ‘pl_profiler_callgraph_shared’:
../../src/include/c.h:916:7: error: static assertion failed: "entry->totalTime does not have type int64"
  do { _Static_assert(condition, errmessage); } while(0)
       ^
../../src/include/c.h:918:13: note: in expansion of macro ‘StaticAssertStmt’
  ((void) ({ StaticAssertStmt(condition, errmessage); true; }))
             ^~~~~~~~~~~~~~~~
../../src/include/c.h:962:3: note: in expansion of macro ‘StaticAssertExpr’
  (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
   ^~~~~~~~~~~~~~~~
../../src/include/postgres.h:550:3: note: in expansion of macro ‘AssertVariableIsOfTypeMacro’
  (AssertVariableIsOfTypeMacro(X, int64), Int64GetDatum(X))
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
plprofiler.c:1598:17: note: in expansion of macro ‘Int64GetDatumFast’
   values[j++] = Int64GetDatumFast(entry->totalTime);
                 ^~~~~~~~~~~~~~~~~
../../src/include/c.h:916:7: error: static assertion failed: "entry->childTime does not have type int64"
  do { _Static_assert(condition, errmessage); } while(0)
       ^
../../src/include/c.h:918:13: note: in expansion of macro ‘StaticAssertStmt’
  ((void) ({ StaticAssertStmt(condition, errmessage); true; }))
             ^~~~~~~~~~~~~~~~
../../src/include/c.h:962:3: note: in expansion of macro ‘StaticAssertExpr’
  (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
   ^~~~~~~~~~~~~~~~
../../src/include/postgres.h:550:3: note: in expansion of macro ‘AssertVariableIsOfTypeMacro’
  (AssertVariableIsOfTypeMacro(X, int64), Int64GetDatum(X))
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
plprofiler.c:1599:17: note: in expansion of macro ‘Int64GetDatumFast’
   values[j++] = Int64GetDatumFast(entry->childTime);
                 ^~~~~~~~~~~~~~~~~
../../src/include/c.h:916:7: error: static assertion failed: "entry->selfTime does not have type int64"
  do { _Static_assert(condition, errmessage); } while(0)
       ^
../../src/include/c.h:918:13: note: in expansion of macro ‘StaticAssertStmt’
  ((void) ({ StaticAssertStmt(condition, errmessage); true; }))
             ^~~~~~~~~~~~~~~~
../../src/include/c.h:962:3: note: in expansion of macro ‘StaticAssertExpr’
  (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
   ^~~~~~~~~~~~~~~~
../../src/include/postgres.h:550:3: note: in expansion of macro ‘AssertVariableIsOfTypeMacro’
  (AssertVariableIsOfTypeMacro(X, int64), Int64GetDatum(X))
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
plprofiler.c:1600:17: note: in expansion of macro ‘Int64GetDatumFast’
   values[j++] = Int64GetDatumFast(entry->selfTime);
                 ^~~~~~~~~~~~~~~~~
In file included from ../../src/include/access/skey.h:19:0,
                 from ../../src/include/access/genam.h:18,
                 from ../../src/include/access/amapi.h:15,
                 from ../../src/include/access/hash.h:20,
                 from plprofiler.h:26,
                 from plprofiler.c:22:
plprofiler.c: In function ‘pl_profiler_func_oids_local’:
plprofiler.c:1665:24: warning: passing argument 1 of ‘PointerGetDatum’ makes pointer from integer without a cast [-Wint-conversion]
  PG_RETURN_ARRAYTYPE_P(PointerGetDatum(construct_array(result, i,
                        ^
../../src/include/fmgr.h:361:53: note: in definition of macro ‘PG_RETURN_POINTER’
 #define PG_RETURN_POINTER(x) return PointerGetDatum(x)
                                                     ^
plprofiler.c:1665:2: note: in expansion of macro ‘PG_RETURN_ARRAYTYPE_P’
  PG_RETURN_ARRAYTYPE_P(PointerGetDatum(construct_array(result, i,
  ^~~~~~~~~~~~~~~~~~~~~
In file included from plprofiler.c:20:0:
../../src/include/postgres.h:322:1: note: expected ‘const void *’ but argument is of type ‘Datum {aka long unsigned int}’
 PointerGetDatum(const void *X)
 ^~~~~~~~~~~~~~~
In file included from ../../src/include/access/skey.h:19:0,
                 from ../../src/include/access/genam.h:18,
                 from ../../src/include/access/amapi.h:15,
                 from ../../src/include/access/hash.h:20,
                 from plprofiler.h:26,
                 from plprofiler.c:22:
plprofiler.c: In function ‘pl_profiler_func_oids_shared’:
plprofiler.c:1727:24: warning: passing argument 1 of ‘PointerGetDatum’ makes pointer from integer without a cast [-Wint-conversion]
  PG_RETURN_ARRAYTYPE_P(PointerGetDatum(construct_array(result, i,
                        ^
../../src/include/fmgr.h:361:53: note: in definition of macro ‘PG_RETURN_POINTER’
 #define PG_RETURN_POINTER(x) return PointerGetDatum(x)
                                                     ^
plprofiler.c:1727:2: note: in expansion of macro ‘PG_RETURN_ARRAYTYPE_P’
  PG_RETURN_ARRAYTYPE_P(PointerGetDatum(construct_array(result, i,
  ^~~~~~~~~~~~~~~~~~~~~
In file included from plprofiler.c:20:0:
../../src/include/postgres.h:322:1: note: expected ‘const void *’ but argument is of type ‘Datum {aka long unsigned int}’
 PointerGetDatum(const void *X)
 ^~~~~~~~~~~~~~~
make[1]: *** [plprofiler.o] Error 1
make[1]: *** Waiting for unfinished jobs....
plprofiler.c:1254:24: warning: incompatible integer to pointer conversion passing 'Datum' (aka 'unsigned long') to parameter of type
      'const void *' [-Wint-conversion]
        PG_RETURN_ARRAYTYPE_P(PointerGetDatum(construct_array(funcdefs, nelems,
        ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/utils/array.h:258:54: note: expanded from macro 'PG_RETURN_ARRAYTYPE_P'
#define PG_RETURN_ARRAYTYPE_P(x)          PG_RETURN_POINTER(x)
                                          ~~~~~~~~~~~~~~~~~~^~
../../src/include/fmgr.h:361:53: note: expanded from macro 'PG_RETURN_POINTER'
#define PG_RETURN_POINTER(x) return PointerGetDatum(x)
                                                    ^
../../src/include/postgres.h:322:29: note: passing argument to parameter 'X' here
PointerGetDatum(const void *X)
                            ^
plprofiler.c:1502:18: error: static_assert failed due to requirement '__builtin_types_compatible_p(typeof (entry->totalTime), int64)'
      "entry->totalTime does not have type int64"
                        values[j++] = Int64GetDatumFast(entry->totalTime);
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/postgres.h:550:3: note: expanded from macro 'Int64GetDatumFast'
        (AssertVariableIsOfTypeMacro(X, int64), Int64GetDatum(X))
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:962:3: note: expanded from macro 'AssertVariableIsOfTypeMacro'
        (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:918:13: note: expanded from macro 'StaticAssertExpr'
        ((void) ({ StaticAssertStmt(condition, errmessage); true; }))
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:916:7: note: expanded from macro 'StaticAssertStmt'
        do { _Static_assert(condition, errmessage); } while(0)
             ^              ~~~~~~~~~
plprofiler.c:1503:18: error: static_assert failed due to requirement '__builtin_types_compatible_p(typeof (entry->childTime), int64)'
      "entry->childTime does not have type int64"
                        values[j++] = Int64GetDatumFast(entry->childTime);
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/postgres.h:550:3: note: expanded from macro 'Int64GetDatumFast'
        (AssertVariableIsOfTypeMacro(X, int64), Int64GetDatum(X))
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:962:3: note: expanded from macro 'AssertVariableIsOfTypeMacro'
        (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:918:13: note: expanded from macro 'StaticAssertExpr'
        ((void) ({ StaticAssertStmt(condition, errmessage); true; }))
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:916:7: note: expanded from macro 'StaticAssertStmt'
        do { _Static_assert(condition, errmessage); } while(0)
             ^              ~~~~~~~~~
plprofiler.c:1504:18: error: static_assert failed due to requirement '__builtin_types_compatible_p(typeof (entry->selfTime), int64)'
      "entry->selfTime does not have type int64"
                        values[j++] = Int64GetDatumFast(entry->selfTime);
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/postgres.h:550:3: note: expanded from macro 'Int64GetDatumFast'
        (AssertVariableIsOfTypeMacro(X, int64), Int64GetDatum(X))
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:962:3: note: expanded from macro 'AssertVariableIsOfTypeMacro'
        (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:918:13: note: expanded from macro 'StaticAssertExpr'
        ((void) ({ StaticAssertStmt(condition, errmessage); true; }))
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:916:7: note: expanded from macro 'StaticAssertStmt'
        do { _Static_assert(condition, errmessage); } while(0)
             ^              ~~~~~~~~~
plprofiler.c:1598:17: error: static_assert failed due to requirement '__builtin_types_compatible_p(typeof (entry->totalTime), int64)'
      "entry->totalTime does not have type int64"
                values[j++] = Int64GetDatumFast(entry->totalTime);
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/postgres.h:550:3: note: expanded from macro 'Int64GetDatumFast'
        (AssertVariableIsOfTypeMacro(X, int64), Int64GetDatum(X))
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:962:3: note: expanded from macro 'AssertVariableIsOfTypeMacro'
        (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:918:13: note: expanded from macro 'StaticAssertExpr'
        ((void) ({ StaticAssertStmt(condition, errmessage); true; }))
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:916:7: note: expanded from macro 'StaticAssertStmt'
        do { _Static_assert(condition, errmessage); } while(0)
             ^              ~~~~~~~~~
plprofiler.c:1599:17: error: static_assert failed due to requirement '__builtin_types_compatible_p(typeof (entry->childTime), int64)'
      "entry->childTime does not have type int64"
                values[j++] = Int64GetDatumFast(entry->childTime);
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/postgres.h:550:3: note: expanded from macro 'Int64GetDatumFast'
        (AssertVariableIsOfTypeMacro(X, int64), Int64GetDatum(X))
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:962:3: note: expanded from macro 'AssertVariableIsOfTypeMacro'
        (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:918:13: note: expanded from macro 'StaticAssertExpr'
        ((void) ({ StaticAssertStmt(condition, errmessage); true; }))
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:916:7: note: expanded from macro 'StaticAssertStmt'
        do { _Static_assert(condition, errmessage); } while(0)
             ^              ~~~~~~~~~
plprofiler.c:1600:17: error: static_assert failed due to requirement '__builtin_types_compatible_p(typeof (entry->selfTime), int64)'
      "entry->selfTime does not have type int64"
                values[j++] = Int64GetDatumFast(entry->selfTime);
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/postgres.h:550:3: note: expanded from macro 'Int64GetDatumFast'
        (AssertVariableIsOfTypeMacro(X, int64), Int64GetDatum(X))
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:962:3: note: expanded from macro 'AssertVariableIsOfTypeMacro'
        (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:918:13: note: expanded from macro 'StaticAssertExpr'
        ((void) ({ StaticAssertStmt(condition, errmessage); true; }))
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/c.h:916:7: note: expanded from macro 'StaticAssertStmt'
        do { _Static_assert(condition, errmessage); } while(0)
             ^              ~~~~~~~~~
plprofiler.c:1665:24: warning: incompatible integer to pointer conversion passing 'Datum' (aka 'unsigned long') to parameter of type
      'const void *' [-Wint-conversion]
        PG_RETURN_ARRAYTYPE_P(PointerGetDatum(construct_array(result, i,
        ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/utils/array.h:258:54: note: expanded from macro 'PG_RETURN_ARRAYTYPE_P'
#define PG_RETURN_ARRAYTYPE_P(x)          PG_RETURN_POINTER(x)
                                          ~~~~~~~~~~~~~~~~~~^~
../../src/include/fmgr.h:361:53: note: expanded from macro 'PG_RETURN_POINTER'
#define PG_RETURN_POINTER(x) return PointerGetDatum(x)
                                                    ^
../../src/include/postgres.h:322:29: note: passing argument to parameter 'X' here
PointerGetDatum(const void *X)
                            ^
plprofiler.c:1727:24: warning: incompatible integer to pointer conversion passing 'Datum' (aka 'unsigned long') to parameter of type
      'const void *' [-Wint-conversion]
        PG_RETURN_ARRAYTYPE_P(PointerGetDatum(construct_array(result, i,
        ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/include/utils/array.h:258:54: note: expanded from macro 'PG_RETURN_ARRAYTYPE_P'
#define PG_RETURN_ARRAYTYPE_P(x)          PG_RETURN_POINTER(x)
                                          ~~~~~~~~~~~~~~~~~~^~
../../src/include/fmgr.h:361:53: note: expanded from macro 'PG_RETURN_POINTER'
#define PG_RETURN_POINTER(x) return PointerGetDatum(x)
                                                    ^
../../src/include/postgres.h:322:29: note: passing argument to parameter 'X' here
PointerGetDatum(const void *X)
                            ^
3 warnings and 6 errors generated.

After some investigation, I think it's because community changed definition of Int64GetDatumFast https://github.com/postgres/postgres/commit/c8b2ef05f481ef06326d7b9f3eb14b303f215c7e#diff-eacba6996e6eb6b6a80a36b056cb95fa3ca94b57d8a30cb5de6bffd251687fafR897 from:

#define Int64GetDatumFast(X)  Int64GetDatum(X)

to:

#define Int64GetDatumFast(X) \
(AssertVariableIsOfTypeMacro(X, int64), Int64GetDatum(X))

while in plprofiler code, the variable is uint64 https://github.com/bigsql/plprofiler/blob/master/plprofiler.h#L160

Is it possible that this issue get fixed in the future release? And when can I expect a postgres16 compatible version to be released? Thank you!

luss commented 1 year ago

I shall put it on Jan's TODO list to make the plprofiler compatible with pg16. I suspect that this will be easy for him to accomplish and that we'll do this in the very near future. Most defintely before pg16 GA in the fall, probably sooner.

luss commented 11 months ago

We are starting on this project (thank you AsifR and Jan) and we hope to version 4.4.2 supporting pg16 within 10 days or so

Deltaus commented 11 months ago

Got it, thank you!

devrimgunduz commented 11 months ago

I can confirm that 4.4.2 builds against v16.

luss commented 11 months ago

Thanks Devrim. I'm also building it against pg15 & pg16 in the pgEdge environment.

On Tue, Aug 1, 2023 at 6:33 AM Devrim Gündüz @.***> wrote:

I can confirm that 4.4.2 builds against v16.

— Reply to this email directly, view it on GitHub https://github.com/bigsql/plprofiler/issues/16#issuecomment-1660038265, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMWOHRHNSSPXISTQRPJCLDXTDLPDANCNFSM6AAAAAAZN4PUGA . You are receiving this because you commented.Message ID: @.***>

luss commented 11 months ago

done in 4.4.2

luss commented 11 months ago

:-)