bigsql / plprofiler

Other
79 stars 22 forks source link

install profiler gives an error #15

Closed slavadba closed 1 year ago

slavadba commented 1 year ago

Hi,

postgres@student:~/plprofiler$ pwd
/var/lib/postgresql/plprofiler
postgres@student:~/plprofiler$
postgres@student:~/plprofiler$ sudo USE_PGXS=1 make install
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer -fPIC -I. -I./ -I/usr/include/postgresql/12/server -I/usr/include/postgresql/internal  -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2  -I/usr/include/mit-krb5  -c -o plprofiler.o plprofiler.c
plprofiler.c:20:10: fatal error: postgres.h: No such file or directory
   20 | #include "postgres.h"
      |          ^~~~~~~~~~~~
compilation terminated.
make: *** [<builtin>: plprofiler.o] Error 1
postgres@student:~/plprofiler$

If install from contrib directory I got another error:

postgres@student:/usr/share/postgresql/12/contrib/plprofiler$ make install
Makefile:27: /contrib/contrib-global.mk: No such file or directory
make: *** No rule to make target '/contrib/contrib-global.mk'.  Stop.
postgres@student:/usr/share/postgresql/12/contrib/plprofiler$

I cant find contrib-global.mk - so maybe its wrong contrib?? but in any case, this does not explain the error in the first case when the installation does not come from the contrib.

Postgres version :

postgres=# select version();
                                                             version                                                              
----------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 12.5 (Ubuntu 12.5-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, 64-bit
(1 row)

postgres=#
wieck commented 1 year ago

On 12/17/22 06:49, slavadba wrote:

Hi,

@.:~/plprofiler$ pwd /var/lib/postgresql/plprofiler @.:~/plprofiler$ @.:~/plprofiler$ sudo USE_PGXS=1 make install gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer -fPIC -I. -I./ -I/usr/include/postgresql/12/server -I/usr/include/postgresql/internal -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include/mit-krb5 -c -o plprofiler.o plprofiler.c plprofiler.c:20:10: fatal error: postgres.h: No such file or directory 20 | #include "postgres.h" | ^~~~ compilation terminated. make: [: plprofiler.o] Error 1 @.***:~/plprofiler$ |

Did you install the -dev or -devel packages (depending on your Linux Distribution), which are supposed to contain the necessary server header files?

If install from contrib directory I got another error:

@.:/usr/share/postgresql/12/contrib/plprofiler$ make install Makefile:27: /contrib/contrib-global.mk: No such file or directory make: No rule to make target '/contrib/contrib-global.mk'. Stop. @.***:/usr/share/postgresql/12/contrib/plprofiler$ |

Just cloning the PostgreSQL repository or unpacking the tarball isn't enough. You need to run ./configure. I usually do something like

 eval ./configure $(pg_config --configure)

to get a source tree that is configured exactly as the currently installed binaries.

Best Regards, Jan

wieck commented 1 year ago

The PL/pgSQL profiler is also available as binary packages (.rpm and .deb) in the PGDG repositories. It might be easier for you to just install binaries from there.

Best Regards, Jan

On 12/18/22 15:33, Jan Wieck wrote:

On 12/17/22 06:49, slavadba wrote:

Hi,

@.:~/plprofiler$ pwd /var/lib/postgresql/plprofiler @.:~/plprofiler$ @.:~/plprofiler$ sudo USE_PGXS=1 make install gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer -fPIC -I. -I./ -I/usr/include/postgresql/12/server -I/usr/include/postgresql/internal -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include/mit-krb5 -c -o plprofiler.o plprofiler.c plprofiler.c:20:10: fatal error: postgres.h: No such file or directory 20 | #include "postgres.h" | ^~~~ compilation terminated. make: [: plprofiler.o] Error 1 @.***:~/plprofiler$ |

Did you install the -dev or -devel packages (depending on your Linux Distribution), which are supposed to contain the necessary server header files?

If install from contrib directory I got another error:

@.:/usr/share/postgresql/12/contrib/plprofiler$ make install Makefile:27: /contrib/contrib-global.mk: No such file or directory make: No rule to make target '/contrib/contrib-global.mk'. Stop. @.***:/usr/share/postgresql/12/contrib/plprofiler$ |

Just cloning the PostgreSQL repository or unpacking the tarball isn't enough. You need to run ./configure. I usually do something like

  eval ./configure $(pg_config --configure)

to get a source tree that is configured exactly as the currently installed binaries.

Best Regards, Jan

slavadba commented 1 year ago

Installation from binary packages solve all problems. Thank you for help!

slavadba commented 1 year ago

one more question is off topic , but in order not to create a new issue, I 'll ask here if you don 't mind:


postgres=# SELECT pl_profiler_enable(true);
ERROR:  function pl_profiler_enable(boolean) does not exist
LINE 1: SELECT pl_profiler_enable(true);
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
postgres=#
postgres=# select * from pg_extension ;
  oid  |      extname       | extowner | extnamespace | extrelocatable | extversion | extconfig | extcondition 
-------+--------------------+----------+--------------+----------------+------------+-----------+--------------
 13449 | plpgsql            |       10 |           11 | f              | 1.0        |           | 
 24617 | plpgsql_check      |       10 |         2200 | f              | 1.14       |           | 
 32812 | pg_stat_statements |       10 |         2200 | t              | 1.7        |           | 
 32820 | plprofiler         |       10 |         2200 | t              | 4.2        |           | 
(4 rows)

postgres=# select count(*) from pg_proc where proname='pl_profiler_enable';
 count 
-------
     0
(1 row)

postgres=
```#
wieck commented 1 year ago

On 12/19/22 05:00, slavadba wrote:

one more question is off topic , but in order not to create a new issue, I 'll ask here if you don 't mind:

|postgres=# SELECT pl_profiler_enable(true); ERROR: function pl_profiler_enable(boolean) does not exist LINE 1: SELECT pl_profiler_enable(true); ^ HINT: No function matches the given name and

There are two functions, pl_profiler_set_enabled_local(bool) and pl_profiler_set_enabled_global(bool). The global one only works if plprofiler was loaded via shared_preload_libraries.

argument types. You might need to add explicit type casts. postgres=# postgres=# select from pg_extension ; oid | extname | extowner | extnamespace | extrelocatable | extversion | extconfig | extcondition -------+--------------------+----------+--------------+----------------+------------+-----------+-------------- 13449 | plpgsql | 10 | 11 | f | 1.0 | | 24617 | plpgsql_check | 10 | 2200 | f | 1.14 | | 32812 | pg_stat_statements | 10 | 2200 | t | 1.7 | | 32820 | plprofiler | 10 | 2200 | t | 4.2 | | (4 rows) postgres=# select count() from pg_proc where proname='pl_profiler_enable'; count ------- 0 (1 row) postgres= ```# |

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

slavadba commented 1 year ago

there is no mention in the examples https://github.com/bigsql/plprofiler/blob/master/doc/examples.md about pl_profiler_set_enabled_local - it says about pl_profiler_enable, therefore, it probably needs to be corrected. Thanks again for your help!