Re: Checking for Presence of Required Libraries Fails during PostgreSQL Upgrade

2020-05-02 Thread TalGloz
Adrian Klaver-4 wrote
> On 5/1/20 3:39 PM, TalGloz wrote:
>> Adrian Klaver-4 wrote
>>> Why not compile them against 11?
>>>
>>> Then follow step 5) here:
>>>
>>> https://www.postgresql.org/docs/12/pgupgrade.html
>> 
>> Step 5 doesn’t actually say how to compile them during the upgrade
>> process
>> it just gives a warning about not to use "CREATE EXTENSION my_lib"
>> because
>> this won't effect the target version. Do you mean that I'll have to
>> compile
>> them manually to my target PostgreSQL Version?
> 
> You haven't said how you installed the various versions of Postgres in 
> the first place. Bottom line is that the libraries that existed in the 
> old version need to exist on the new version. If they where not included 
> as part of the install process them they need to be manually
> created/added.
> 
>> 
>> 
>> 
>> 
>> --
>> Sent from:
>> https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
>> 
>> 
> 
> 
> -- 
> Adrian Klaver

> adrian.klaver@


I use Fedora OS and I've a set up and running PostgreSQL10 instance that
I've installed using 
*dnf install postgresql10**. Sicne I've decided to upgrade directly to 12
instead of to 11 I've installed the 12 version using *dnf install
postgresql12**. I'm currently following the steps described in:

1.  UPGRADE POSTGRESQL 10 To 11
  . It
has some syntax errors in the suggested command lines that I've corrected on
my side.

2.  How to upgrade PostgreSQL from 11 to 12
  . The steps
were written for Ubuntu / Debian, It should work the same by updating the
paths to correct Fedora related paths of PostreSQL installation.

Unfortunately, none of the tutorials describes the steps on how to port /
handle some manually created C extension functions libraries to the new
PostgreSQL instance.

TalGloz



--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html




Re: How to move a 11.4 cluster to another Linux host, but empty?

2020-05-02 Thread Matthias Apitz
El día viernes, mayo 01, 2020 a las 10:31:48a. m. +0200, Matthias Apitz 
escribió:

> Hi Paul,
> 
> El día viernes, mayo 01, 2020 a las 10:23:37a. m. +0200, Paul Förster 
> escribió:
> 
> > 
> > you may have a look at the tar man page. tar in Linux has the 
> > --exclude=PATTERN option.
> 
> I do know the man page(s) of tar ant the --exclude=PATTERN.
> 
> > You may specify the PGDATA directory there.
> 
> This is, what I wanted to know: that the cluster can be moved without
> the PGDATA dir and still works fine.
> 

This will not work! The cluster was created with:

$ /usr/local/sisis-pap/pgsql/bin/pg_ctl -D /data/prosgresql11/data initdb

and consequently, PGDATA is /data/prosgresql11/data. This directory contains a
lot of subirs and config files:

srap32dxr1:/home/sisis/guru # du -s /data/postgresql11/data/* | sort -n
4   /data/postgresql11/data/PG_VERSION
4   /data/postgresql11/data/pg_commit_ts
4   /data/postgresql11/data/pg_dynshmem
4   /data/postgresql11/data/pg_ident.conf
4   /data/postgresql11/data/pg_replslot
4   /data/postgresql11/data/pg_serial
4   /data/postgresql11/data/pg_snapshots
4   /data/postgresql11/data/pg_stat
4   /data/postgresql11/data/pg_tblspc
4   /data/postgresql11/data/pg_twophase
4   /data/postgresql11/data/postgresql.auto.conf
4   /data/postgresql11/data/postmaster.opts
4   /data/postgresql11/data/postmaster.pid
8   /data/postgresql11/data/pg_hba.conf
12  /data/postgresql11/data/pg_notify
16  /data/postgresql11/data/pg_logical
24  /data/postgresql11/data/postgresql.conf
28  /data/postgresql11/data/pg_multixact
196 /data/postgresql11/data/pg_subtrans
732 /data/postgresql11/data/pg_stat_tmp
940 /data/postgresql11/data/global
1328/data/postgresql11/data/pg_xact
76076   /data/postgresql11/data/serverlog.20200414
81988   /data/postgresql11/data/pg_wal
90268   /data/postgresql11/data/serverlog
16672568/data/postgresql11/data/base

The databases (or it least their content) are below /data/postgresql11/data/base
(because of the size of ~81 GByte).

So the question remains: What I have to move by tar to get the cluster
setup on the new host, but without the databases in it?

If this is not possible, I will only copy over the software from 
/usr/local/sisis-pap/pgsql/
and create the cluster from scratch.

Thanks

matthias

-- 
Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub




Re: How to move a 11.4 cluster to another Linux host, but empty?

2020-05-02 Thread Paul Förster
Hi Matthias,

> On 02. May, 2020, at 12:23, Matthias Apitz  wrote:
> $ /usr/local/sisis-pap/pgsql/bin/pg_ctl -D /data/prosgresql11/data initdb

I don't get it. Is the setup now as follows

/data/postgresql11   <= software with bin, lib64, share, etc...
/data/postgresql11/data  <= PGDATA

or

/usr/local/sisis-pap/pgsql  <= software with bin, lib64, share, etc...
/data/postgresql11/data <= PGDATA

?

In the first case, your tar command would be:
tar cvf /tmp/postgresql11.tar --exclude=/data/postgresql11/data 
/data/postgresql11

Note that the --exclude option must appear BEFORE the directory tree to archive 
in the command line! => man tar

In the second case, your tar command would be:
tar cvf /tmp/postgresql11.tar /usr/local/sisis-pap/pgsql

to package the software only without the database.

Cheers,
Paul



Re: How to move a 11.4 cluster to another Linux host, but empty?

2020-05-02 Thread Matthias Apitz
El día sábado, mayo 02, 2020 a las 03:23:52p. m. +0200, Paul Förster escribió:

> /usr/local/sisis-pap/pgsql  <= software with bin, lib64, share, etc...
> /data/postgresql11/data <= PGDATA

Exactly, his is the setup above.

I will move /usr/local/sisis-pap/pgsql by tar; and I want to move some parts(!)
of the cluster /data/postgresql11/data (configuration etc.), but not the 
databases
included in /data/postgresql11/data, like the cluster(!) in PGDATA was before 
having
created any database(!) in it. 

As I said from the beginning: moving the cluster but without the
databases in it.

Thanks

matthias
-- 
Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub




Re: How to move a 11.4 cluster to another Linux host, but empty?

2020-05-02 Thread Paul Förster
Hi Matthias,

> On 02. May, 2020, at 16:30, Matthias Apitz  wrote:
> 
> El día sábado, mayo 02, 2020 a las 03:23:52p. m. +0200, Paul Förster escribió:
> 
>> /usr/local/sisis-pap/pgsql  <= software with bin, lib64, share, etc...
>> /data/postgresql11/data <= PGDATA
> 
> Exactly, his is the setup above.
> 
> I will move /usr/local/sisis-pap/pgsql by tar; and I want to move some 
> parts(!)
> of the cluster /data/postgresql11/data (configuration etc.), but not the 
> databases
> included in /data/postgresql11/data, like the cluster(!) in PGDATA was before 
> having
> created any database(!) in it. 
> 
> As I said from the beginning: moving the cluster but without the
> databases in it.

you don't want to move the database cluster in this case!

Add the database cluster's config files postgresql.conf, pg_hba.conf, 
pg_ident.conf or whatever to the tar file. Then, on the new host, do an initdb 
and after that, copy the old config files into the new PGDATA. Then start the 
new (empty and free of databases) database cluster.

So:
tar cvf /tmp/postgresql11.tar /usr/local/sisis-pap/pgsql 
/data/postgresql11/*.conf

Cheers,
Paul



Re: How to move a 11.4 cluster to another Linux host, but empty?

2020-05-02 Thread Adrian Klaver

On 5/2/20 7:30 AM, Matthias Apitz wrote:

El día sábado, mayo 02, 2020 a las 03:23:52p. m. +0200, Paul Förster escribió:


/usr/local/sisis-pap/pgsql  <= software with bin, lib64, share, etc...
/data/postgresql11/data <= PGDATA


Exactly, his is the setup above.

I will move /usr/local/sisis-pap/pgsql by tar; and I want to move some parts(!)
of the cluster /data/postgresql11/data (configuration etc.), but not the 
databases
included in /data/postgresql11/data, like the cluster(!) in PGDATA was before 
having
created any database(!) in it.


That won't work for the following reasons:

1) A lot of the files/dirs included in /data/postgresql11/data are 
specific to the files in /data/postgresql11/data/base as they where 
created over time. They will fail when you try to merge them with new 
data. More importantly see 2) below.


2) To create a new base/ you will need to initdb data/ and that is not 
possible as initdb will not work on a populated data/.




As I said from the beginning: moving the cluster but without the
databases in it.

Thanks

matthias




--
Adrian Klaver
adrian.kla...@aklaver.com




Re: How to move a 11.4 cluster to another Linux host, but empty?

2020-05-02 Thread Paul Förster
Hi Adrian,

> On 02. May, 2020, at 16:59, Adrian Klaver  wrote:
> 2) To create a new base/ you will need to initdb data/ and that is not 
> possible as initdb will not work on a populated data/.

you do the initdb and then copy the *.conf files from the tar over the newly 
created ones. After that, launch the cluster.

Cheers,
Paul



Re: How to move a 11.4 cluster to another Linux host, but empty?

2020-05-02 Thread Adrian Klaver

On 5/2/20 8:02 AM, Paul Förster wrote:

Hi Adrian,


On 02. May, 2020, at 16:59, Adrian Klaver  wrote:
2) To create a new base/ you will need to initdb data/ and that is not possible 
as initdb will not work on a populated data/.


you do the initdb and then copy the *.conf files from the tar over the newly 
created ones. After that, launch the cluster.


Yeah I know, I do that on a fairly regular basis. The intent was to let 
the OP know that ripping base/ out of cluster and transplanting a new 
one in is not possible.




Cheers,
Paul




--
Adrian Klaver
adrian.kla...@aklaver.com




Re: Checking for Presence of Required Libraries Fails during PostgreSQL Upgrade

2020-05-02 Thread Adrian Klaver

On 5/2/20 12:30 AM, TalGloz wrote:

Adrian Klaver-4 wrote

On 5/1/20 3:39 PM, TalGloz wrote:

Adrian Klaver-4 wrote

Why not compile them against 11?

Then follow step 5) here:

https://www.postgresql.org/docs/12/pgupgrade.html


Step 5 doesn’t actually say how to compile them during the upgrade
process
it just gives a warning about not to use "CREATE EXTENSION my_lib"
because
this won't effect the target version. Do you mean that I'll have to
compile
them manually to my target PostgreSQL Version?


You haven't said how you installed the various versions of Postgres in
the first place. Bottom line is that the libraries that existed in the
old version need to exist on the new version. If they where not included
as part of the install process them they need to be manually
created/added.






--
Sent from:
https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html





--
Adrian Klaver



adrian.klaver@



I use Fedora OS and I've a set up and running PostgreSQL10 instance that
I've installed using
*dnf install postgresql10**. Sicne I've decided to upgrade directly to 12
instead of to 11 I've installed the 12 version using *dnf install
postgresql12**. I'm currently following the steps described in:

1.  UPGRADE POSTGRESQL 10 To 11
  . It
has some syntax errors in the suggested command lines that I've corrected on
my side.

2.  How to upgrade PostgreSQL from 11 to 12
  . The steps
were written for Ubuntu / Debian, It should work the same by updating the
paths to correct Fedora related paths of PostreSQL installation.

Unfortunately, none of the tutorials describes the steps on how to port /
handle some manually created C extension functions libraries to the new
PostgreSQL instance.


Follow the same procedure you used to build/install them for the 
Postgres 10, except run against the 12 instance. Do this before you do 
the pg_upgrade procedure.





TalGloz



--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html





--
Adrian Klaver
adrian.kla...@aklaver.com




Re: Checking for Presence of Required Libraries Fails during PostgreSQL Upgrade

2020-05-02 Thread David G. Johnston
On Sat, May 2, 2020 at 12:31 AM TalGloz  wrote:

> Adrian Klaver-4 wrote
> > On 5/1/20 3:39 PM, TalGloz wrote:
> >> Adrian Klaver-4 wrote
> >>> Why not compile them against 11?
> >>>
> >>> Then follow step 5) here:
> >>>
> >>> https://www.postgresql.org/docs/12/pgupgrade.html
>
> 2.  How to upgrade PostgreSQL from 11 to 12
>   . The
> steps
> were written for Ubuntu / Debian, It should work the same by updating the
> paths to correct Fedora related paths of PostreSQL installation.
>
> Unfortunately, none of the tutorials describes the steps on how to port /
> handle some manually created C extension functions libraries to the new
> PostgreSQL instance.
>
>
Yes, the but guide for upgrading in the documentation does describe the
step of porting extension libraries.  It says you need to do that before
you run pg_upgrade and ensure that whatever is being installed onto the new
server is binary compatible.  It even says explicitly that pg_upgrade
cannot do this for you.

https://www.postgresql.org/docs/12/pgupgrade.html

David J.


Re: How to move a 11.4 cluster to another Linux host, but empty?

2020-05-02 Thread Matthias Apitz
El día sábado, mayo 02, 2020 a las 08:23:52a. m. -0700, Adrian Klaver escribió:

> On 5/2/20 8:02 AM, Paul Förster wrote:
> > Hi Adrian,
> > 
> >> On 02. May, 2020, at 16:59, Adrian Klaver  
> >> wrote:
> >> 2) To create a new base/ you will need to initdb data/ and that is not 
> >> possible as initdb will not work on a populated data/.
> > 
> > you do the initdb and then copy the *.conf files from the tar over the 
> > newly created ones. After that, launch the cluster.
> 
> Yeah I know, I do that on a fairly regular basis. The intent was to let 
> the OP know that ripping base/ out of cluster and transplanting a new 
> one in is not possible.

OK, lesson learned: Next time I will do a tar backup of PGDATA after
the configuration of the cluster and before creating any database in it.

Thanks

matthias

-- 
Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub




Re: How to move a 11.4 cluster to another Linux host, but empty?

2020-05-02 Thread Paul Förster
Hi Matthias,

> On 02. May, 2020, at 20:58, Matthias Apitz  wrote:
> OK, lesson learned: Next time I will do a tar backup of PGDATA after
> the configuration of the cluster and before creating any database in it.

that tar would still contain too much. :-) You really only need the config 
files. All else is created by initdb.

Cheers,
Paul



Re: How to move a 11.4 cluster to another Linux host, but empty?

2020-05-02 Thread Adrian Klaver

On 5/2/20 11:58 AM, Matthias Apitz wrote:

El día sábado, mayo 02, 2020 a las 08:23:52a. m. -0700, Adrian Klaver escribió:


On 5/2/20 8:02 AM, Paul Förster wrote:

Hi Adrian,


On 02. May, 2020, at 16:59, Adrian Klaver  wrote:
2) To create a new base/ you will need to initdb data/ and that is not possible 
as initdb will not work on a populated data/.


you do the initdb and then copy the *.conf files from the tar over the newly 
created ones. After that, launch the cluster.


Yeah I know, I do that on a fairly regular basis. The intent was to let
the OP know that ripping base/ out of cluster and transplanting a new
one in is not possible.


OK, lesson learned: Next time I will do a tar backup of PGDATA after
the configuration of the cluster and before creating any database in it.


As Paul said this is probably more then you want to do. If for no other 
reason then that the env(in particular locale) where you untar the 
PGDATA may be different from where you tar(ed) it. This will leave you 
with cluster that is out of sync with its environment.




Thanks

matthias




--
Adrian Klaver
adrian.kla...@aklaver.com




Compiling C Extension Functions against PostgreSQL 12

2020-05-02 Thread TalGloz
I'm trying to upgrade from PostgreSQL 10 to 12 and I need to compile all my
manually created C extension functions against PostrgreSQL 12 before
starting the upgrade process. I have this Makefile that compiles perfectly
the seal_diff_cpp.cpp C extension function against PostgreSQL 10:

MODULES = seal_diff_cpp
PG_CONFIG = /usr/pgsql-10/bin/pg_config
PGXS = $(shell $(PG_CONFIG) --pgxs)
INCLUDEDIR = $(shell $(PG_CONFIG) --includedir-server)
INCLUDE_SEAL = /usr/local/include
INCLUDE_SEAL_LIB = /usr/local/lib
INCLUDE_CPPCODEC = /usr/local/include/cppcodec
CXX = g++
CXXFLAGS = -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread \
   -I$(INCLUDEDIR) -I$(INCLUDE_SEAL) -I$(INCLUDE_CPPCODEC)
SEAL_LDFLAGS = -L$(INCLUDE_SEAL_LIB) -lseal -pthread
include $(PGXS)
seal_diff_cpp.so: seal_diff_cpp.o
#   $(CXX) -Wl,--no-undefined -shared -o seal_diff_cpp.so
seal_diff_cpp.o $(LDFLAGS) $(SEAL_LDFLAGS)
$(CXX) -shared -o seal_diff_cpp.so seal_diff_cpp.o $(LDFLAGS)
$(SEAL_LDFLAGS)
seal_diff_cpp.o: seal_diff_cpp.cpp
 $(CXX) $(CXXFLAGS) -o seal_diff_cpp.o -c seal_diff_cpp.cpp

When I execute it the output looks like this:

g++ -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread
-I/usr/pgsql-10/include/server -I/usr/local/include
-I/usr/local/include/cppcodec -o seal_diff_cpp.o -c seal_diff_cpp.cpp
g++ -shared -o seal_diff_cpp.so seal_diff_cpp.o -L/usr/pgsql-10/lib  
-L/usr/lib64 -Wl,--as-needed
-Wl,-rpath,'/usr/pgsql-10/lib',--enable-new-dtags -L/usr/local/lib -lseal
-pthread

And the seal_diff_cpp.so gets created without any problems. But when I use
PG_CONFIG = /usr/pgsql-12/bin/pg_config I get:

g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c
seal_diff_cpp.cpp
seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or directory
2 | #include 
  |  ^~~~
compilation terminated.
make: *** [Makefile:19: seal_diff_cpp.o] Error 1

The Makefile has all the needed information to compile the seal_diff_cpp.so
against PostgreSQL 12:
/usr/pgsql-10/bin/pg_config --pgxs --->
/usr/pgsql-10/lib/pgxs/src/makefiles/pgxs.mk
/usr/pgsql-12/bin/pg_config --pgxs --->
/usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk

/usr/pgsql-10/bin/pg_config --includedir-server --->
/usr/pgsql-10/include/server
/usr/pgsql-12/bin/pg_config --includedir-server --->
/usr/pgsql-12/include/server (postgres.h is there)

I can't understand why it doesn't work.

TalGloz



--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html




Re: Compiling C Extension Functions against PostgreSQL 12

2020-05-02 Thread Adrian Klaver

On 5/2/20 12:28 PM, TalGloz wrote:

I'm trying to upgrade from PostgreSQL 10 to 12 and I need to compile all my
manually created C extension functions against PostrgreSQL 12 before
starting the upgrade process. I have this Makefile that compiles perfectly
the seal_diff_cpp.cpp C extension function against PostgreSQL 10:

MODULES = seal_diff_cpp
PG_CONFIG = /usr/pgsql-10/bin/pg_config
PGXS = $(shell $(PG_CONFIG) --pgxs)
INCLUDEDIR = $(shell $(PG_CONFIG) --includedir-server)
INCLUDE_SEAL = /usr/local/include
INCLUDE_SEAL_LIB = /usr/local/lib
INCLUDE_CPPCODEC = /usr/local/include/cppcodec
CXX = g++
CXXFLAGS = -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread \
-I$(INCLUDEDIR) -I$(INCLUDE_SEAL) -I$(INCLUDE_CPPCODEC)
SEAL_LDFLAGS = -L$(INCLUDE_SEAL_LIB) -lseal -pthread
include $(PGXS)
seal_diff_cpp.so: seal_diff_cpp.o
#   $(CXX) -Wl,--no-undefined -shared -o seal_diff_cpp.so
seal_diff_cpp.o $(LDFLAGS) $(SEAL_LDFLAGS)
 $(CXX) -shared -o seal_diff_cpp.so seal_diff_cpp.o $(LDFLAGS)
$(SEAL_LDFLAGS)
seal_diff_cpp.o: seal_diff_cpp.cpp
  $(CXX) $(CXXFLAGS) -o seal_diff_cpp.o -c seal_diff_cpp.cpp

When I execute it the output looks like this:

g++ -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread
-I/usr/pgsql-10/include/server -I/usr/local/include
-I/usr/local/include/cppcodec -o seal_diff_cpp.o -c seal_diff_cpp.cpp
g++ -shared -o seal_diff_cpp.so seal_diff_cpp.o -L/usr/pgsql-10/lib
-L/usr/lib64 -Wl,--as-needed
-Wl,-rpath,'/usr/pgsql-10/lib',--enable-new-dtags -L/usr/local/lib -lseal
-pthread

And the seal_diff_cpp.so gets created without any problems. But when I use
PG_CONFIG = /usr/pgsql-12/bin/pg_config I get:

g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c
seal_diff_cpp.cpp
seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or directory
 2 | #include 
   |  ^~~~
compilation terminated.
make: *** [Makefile:19: seal_diff_cpp.o] Error 1

The Makefile has all the needed information to compile the seal_diff_cpp.so
against PostgreSQL 12:
/usr/pgsql-10/bin/pg_config --pgxs --->
/usr/pgsql-10/lib/pgxs/src/makefiles/pgxs.mk
/usr/pgsql-12/bin/pg_config --pgxs --->
/usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk

/usr/pgsql-10/bin/pg_config --includedir-server --->
/usr/pgsql-10/include/server
/usr/pgsql-12/bin/pg_config --includedir-server --->
/usr/pgsql-12/include/server (postgres.h is there)

I can't understand why it doesn't work.


Do you have Postgres 12 -dev package installed?



TalGloz



--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html





--
Adrian Klaver
adrian.kla...@aklaver.com




Re: Compiling C Extension Functions against PostgreSQL 12

2020-05-02 Thread TalGloz
Adrian Klaver-4 wrote
> On 5/2/20 12:28 PM, TalGloz wrote:
>> I'm trying to upgrade from PostgreSQL 10 to 12 and I need to compile all
>> my
>> manually created C extension functions against PostrgreSQL 12 before
>> starting the upgrade process. I have this Makefile that compiles
>> perfectly
>> the seal_diff_cpp.cpp C extension function against PostgreSQL 10:
>> 
>> MODULES = seal_diff_cpp
>> PG_CONFIG = /usr/pgsql-10/bin/pg_config
>> PGXS = $(shell $(PG_CONFIG) --pgxs)
>> INCLUDEDIR = $(shell $(PG_CONFIG) --includedir-server)
>> INCLUDE_SEAL = /usr/local/include
>> INCLUDE_SEAL_LIB = /usr/local/lib
>> INCLUDE_CPPCODEC = /usr/local/include/cppcodec
>> CXX = g++
>> CXXFLAGS = -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread \
>> -I$(INCLUDEDIR) -I$(INCLUDE_SEAL) -I$(INCLUDE_CPPCODEC)
>> SEAL_LDFLAGS = -L$(INCLUDE_SEAL_LIB) -lseal -pthread
>> include $(PGXS)
>> seal_diff_cpp.so: seal_diff_cpp.o
>> #   $(CXX) -Wl,--no-undefined -shared -o seal_diff_cpp.so
>> seal_diff_cpp.o $(LDFLAGS) $(SEAL_LDFLAGS)
>>  $(CXX) -shared -o seal_diff_cpp.so seal_diff_cpp.o $(LDFLAGS)
>> $(SEAL_LDFLAGS)
>> seal_diff_cpp.o: seal_diff_cpp.cpp
>>   $(CXX) $(CXXFLAGS) -o seal_diff_cpp.o -c seal_diff_cpp.cpp
>> 
>> When I execute it the output looks like this:
>> 
>> g++ -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread
>> -I/usr/pgsql-10/include/server -I/usr/local/include
>> -I/usr/local/include/cppcodec -o seal_diff_cpp.o -c seal_diff_cpp.cpp
>> g++ -shared -o seal_diff_cpp.so seal_diff_cpp.o -L/usr/pgsql-10/lib
>> -L/usr/lib64 -Wl,--as-needed
>> -Wl,-rpath,'/usr/pgsql-10/lib',--enable-new-dtags -L/usr/local/lib -lseal
>> -pthread
>> 
>> And the seal_diff_cpp.so gets created without any problems. But when I
>> use
>> PG_CONFIG = /usr/pgsql-12/bin/pg_config I get:
>> 
>> g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
>> -Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c
>> seal_diff_cpp.cpp
>> seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or
>> directory
>>  2 | #include 
> 
>>|  ^~~~
>> compilation terminated.
>> make: *** [Makefile:19: seal_diff_cpp.o] Error 1
>> 
>> The Makefile has all the needed information to compile the
>> seal_diff_cpp.so
>> against PostgreSQL 12:
>> /usr/pgsql-10/bin/pg_config --pgxs --->
>> /usr/pgsql-10/lib/pgxs/src/makefiles/pgxs.mk
>> /usr/pgsql-12/bin/pg_config --pgxs --->
>> /usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk
>> 
>> /usr/pgsql-10/bin/pg_config --includedir-server --->
>> /usr/pgsql-10/include/server
>> /usr/pgsql-12/bin/pg_config --includedir-server --->
>> /usr/pgsql-12/include/server (postgres.h is there)
>> 
>> I can't understand why it doesn't work.
> 
> Do you have Postgres 12 -dev package installed?
> 
>> 
>> TalGloz
>> 
>> 
>> 
>> --
>> Sent from:
>> https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
>> 
>> 
> 
> 
> -- 
> Adrian Klaver

> adrian.klaver@

Yes, I've installed everything PostgreSQL 12 has to offer:

dnf list installed | grep "postgresql12"
postgresql12.x86_6412.2-2PGDG.f31   
  
@pgdg12
postgresql12-contrib.x86_64 12.2-2PGDG.f31  
   
@pgdg12
postgresql12-devel.x86_64   12.2-2PGDG.f31  
   
@pgdg12
postgresql12-docs.x86_6412.2-2PGDG.f31  
   
@pgdg12
postgresql12-libs.x86_64  12.2-2PGDG.f31
 
@pgdg12
postgresql12-llvmjit.x86_64   12.2-2PGDG.f31
 
@pgdg12
postgresql12-odbc.x86_6412.01.-1PGDG.f31
@pgdg12
postgresql12-plperl.x86_64   12.2-2PGDG.f31 

@pgdg12
postgresql12-plpython.x86_64   12.2-2PGDG.f31   
  
@pgdg12
postgresql12-plpython3.x86_64  12.2-2PGDG.f31   
  
@pgdg12
postgresql12-pltcl.x86_64 12.2-2PGDG.f31
 
@pgdg12
postgresql12-server.x86_64   12.2-2PGDG.f31 

@pgdg12
postgresql12-tcl.x86_64   2.4.0-2.f31.2 
   
@pgdg12
postgresql12-test.x86_64 12.2-2PGDG.f31 

@pgdg12



--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html




Re: Compiling C Extension Functions against PostgreSQL 12

2020-05-02 Thread Adrian Klaver

On 5/2/20 12:39 PM, TalGloz wrote:

Adrian Klaver-4 wrote

On 5/2/20 12:28 PM, TalGloz wrote:

I'm trying to upgrade from PostgreSQL 10 to 12 and I need to compile all
my
manually created C extension functions against PostrgreSQL 12 before
starting the upgrade process. I have this Makefile that compiles
perfectly
the seal_diff_cpp.cpp C extension function against PostgreSQL 10:





Yes, I've installed everything PostgreSQL 12 has to offer:

dnf list installed | grep "postgresql12"
postgresql12.x86_6412.2-2PGDG.f31
@pgdg12
postgresql12-contrib.x86_64 12.2-2PGDG.f31
@pgdg12
postgresql12-devel.x86_64   12.2-2PGDG.f31
@pgdg12


Yeah, I missed part in your OP where said postgres.h was there. So:

1) Did you do both makes in the same directory?

2) If so did you do a make clean between builds?



--
Adrian Klaver
adrian.kla...@aklaver.com




Re: Compiling C Extension Functions against PostgreSQL 12

2020-05-02 Thread TalGloz
Adrian Klaver-4 wrote
> On 5/2/20 12:39 PM, TalGloz wrote:
>> Adrian Klaver-4 wrote
>>> On 5/2/20 12:28 PM, TalGloz wrote:
 I'm trying to upgrade from PostgreSQL 10 to 12 and I need to compile
 all
 my
 manually created C extension functions against PostrgreSQL 12 before
 starting the upgrade process. I have this Makefile that compiles
 perfectly
 the seal_diff_cpp.cpp C extension function against PostgreSQL 10:

> 
>> 
>> Yes, I've installed everything PostgreSQL 12 has to offer:
>> 
>> dnf list installed | grep "postgresql12"
>> postgresql12.x86_6412.2-2PGDG.f31
>> @pgdg12
>> postgresql12-contrib.x86_64 12.2-2PGDG.f31
>> @pgdg12
>> postgresql12-devel.x86_64   12.2-2PGDG.f31
>> @pgdg12
> 
> Yeah, I missed part in your OP where said postgres.h was there. So:
> 
> 1) Did you do both makes in the same directory?
> 
> 2) If so did you do a make clean between builds?
> 
> 
> 
> -- 
> Adrian Klaver

> adrian.klaver@

1) Yes I did.
2) Yes I did, though no .o .bc or .so files get created because of the error
when using PostgreSQL 12 settings.



--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html




Re: Compiling C Extension Functions against PostgreSQL 12

2020-05-02 Thread Adrian Klaver

On 5/2/20 1:03 PM, TalGloz wrote:

Adrian Klaver-4 wrote

On 5/2/20 12:39 PM, TalGloz wrote:

Adrian Klaver-4 wrote

On 5/2/20 12:28 PM, TalGloz wrote:

I'm trying to upgrade from PostgreSQL 10 to 12 and I need to compile
all
my
manually created C extension functions against PostrgreSQL 12 before
starting the upgrade process. I have this Makefile that compiles
perfectly
the seal_diff_cpp.cpp C extension function against PostgreSQL 10:





Yes, I've installed everything PostgreSQL 12 has to offer:

dnf list installed | grep "postgresql12"
postgresql12.x86_6412.2-2PGDG.f31
@pgdg12
postgresql12-contrib.x86_64 12.2-2PGDG.f31
@pgdg12
postgresql12-devel.x86_64   12.2-2PGDG.f31
@pgdg12


Yeah, I missed part in your OP where said postgres.h was there. So:

1) Did you do both makes in the same directory?

2) If so did you do a make clean between builds?



--
Adrian Klaver



adrian.klaver@


1) Yes I did.
2) Yes I did, though no .o .bc or .so files get created because of the error
when using PostgreSQL 12 settings.


But they where created when you did the make against Postgres 10, correct?
So where those cleaned up?




--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html





--
Adrian Klaver
adrian.kla...@aklaver.com




Re: Compiling C Extension Functions against PostgreSQL 12

2020-05-02 Thread TalGloz
Adrian Klaver-4 wrote
> On 5/2/20 1:03 PM, TalGloz wrote:
>> Adrian Klaver-4 wrote
>>> On 5/2/20 12:39 PM, TalGloz wrote:
 Adrian Klaver-4 wrote
> On 5/2/20 12:28 PM, TalGloz wrote:
>> I'm trying to upgrade from PostgreSQL 10 to 12 and I need to compile
>> all
>> my
>> manually created C extension functions against PostrgreSQL 12 before
>> starting the upgrade process. I have this Makefile that compiles
>> perfectly
>> the seal_diff_cpp.cpp C extension function against PostgreSQL 10:
>>
>>>

 Yes, I've installed everything PostgreSQL 12 has to offer:

 dnf list installed | grep "postgresql12"
 postgresql12.x86_6412.2-2PGDG.f31
 @pgdg12
 postgresql12-contrib.x86_64 12.2-2PGDG.f31
 @pgdg12
 postgresql12-devel.x86_64   12.2-2PGDG.f31
 @pgdg12
>>>
>>> Yeah, I missed part in your OP where said postgres.h was there. So:
>>>
>>> 1) Did you do both makes in the same directory?
>>>
>>> 2) If so did you do a make clean between builds?
>>>
>>>
>>>
>>> -- 
>>> Adrian Klaver
>> 
>>> adrian.klaver@
>> 
>> 1) Yes I did.
>> 2) Yes I did, though no .o .bc or .so files get created because of the
>> error
>> when using PostgreSQL 12 settings.
> 
> But they where created when you did the make against Postgres 10, correct?
> So where those cleaned up?
>> 
>> 
>> 
>> --
>> Sent from:
>> https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
>> 
>> 
> 
> 
> -- 
> Adrian Klaver

> adrian.klaver@


Yes, they were created when using make against Postgres 10 and I clean them
every time when I try a different version of Postgres.

TalGloz



--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html




Re: Compiling C Extension Functions against PostgreSQL 12

2020-05-02 Thread Adrian Klaver

On 5/2/20 1:09 PM, TalGloz wrote:

Adrian Klaver-4 wrote




Yes, they were created when using make against Postgres 10 and I clean them
every time when I try a different version of Postgres.


Well I'm reaching the end of what I can do. All I have left is that the 
examples I have seen use:


#include "postgres.h"

not

#include 



TalGloz




--
Adrian Klaver
adrian.kla...@aklaver.com




Re: Compiling C Extension Functions against PostgreSQL 12

2020-05-02 Thread TalGloz
Adrian Klaver-4 wrote
> On 5/2/20 1:09 PM, TalGloz wrote:
>> Adrian Klaver-4 wrote
> 
>> 
>> Yes, they were created when using make against Postgres 10 and I clean
>> them
>> every time when I try a different version of Postgres.
> 
> Well I'm reaching the end of what I can do. All I have left is that the 
> examples I have seen use:
> 
> #include "postgres.h"
> 
> not
> 
> #include 
> 
>> 
>> TalGloz
> 
> 
> 
> -- 
> Adrian Klaver

> adrian.klaver@

If it works for Postgres 10 it should also work for 12. I've changed from
#include  to #include "postgres.h" and I still get the same
error with Postgres 12 and it complies without any problem with Postgres 10

I dont understand why the output for Postgres  12 
g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c
seal_diff_cpp.cpp
seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or directory
2 | #include "postgres.h"
  |  ^~~~

looks different form the ones of Postgres 10
g++ -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread
-I/usr/pgsql-10/include/server -I/usr/local/include
-I/usr/local/include/cppcodec -o seal_diff_cpp.o -c seal_diff_cpp.cpp
g++ -shared -o seal_diff_cpp.so seal_diff_cpp.o -L/usr/pgsql-12/lib  
-L/usr/lib64 -Wl,--as-needed
-Wl,-rpath,'/usr/pgsql-12/lib',--enable-new-dtags -L/usr/local/lib -lseal
-pthread

All the includes with "-I" and "-std=c++17 -fPIC" are from the first line
gone. I even tried to use fixed paths in my Makefiles: "PGXS =
/usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk" and "INCLUDEDIR =
/usr/pgsql-12/include/server".

TalGloz



--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html




Re: Compiling C Extension Functions against PostgreSQL 12

2020-05-02 Thread Tom Lane
TalGloz  writes:
> I dont understand why the output for Postgres  12 
> g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
> -Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c
> seal_diff_cpp.cpp
> seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or directory
> 2 | #include "postgres.h"
>   |  ^~~~

> looks different form the ones of Postgres 10

Looking at your Makefile, it seems to be expecting that CXXFLAGS will
be honored in the build, and it isn't being.

As far as I can see from pgxs.mk, you're supposed to spell that
PG_CXXFLAGS.  Probably, it accidentally worked to do it the other
way in v10, but no longer does, likely as a result of the fact that
there's now some minimal amount of C++ code in core PG.

I'm a little dubious about whether overriding CXX is a good idea now, too.
(Likely the core setting is the same, but if it were pointing at a
different compiler that could cause trouble.)

regards, tom lane




Re: Compiling C Extension Functions against PostgreSQL 12

2020-05-02 Thread Adrian Klaver

On 5/2/20 2:18 PM, Tom Lane wrote:

TalGloz  writes:

I dont understand why the output for Postgres  12
g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c
seal_diff_cpp.cpp
seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or directory
 2 | #include "postgres.h"
   |  ^~~~



looks different form the ones of Postgres 10


Looking at your Makefile, it seems to be expecting that CXXFLAGS will
be honored in the build, and it isn't being.

As far as I can see from pgxs.mk, you're supposed to spell that
PG_CXXFLAGS.  Probably, it accidentally worked to do it the other
way in v10, but no longer does, likely as a result of the fact that
there's now some minimal amount of C++ code in core PG.


I was looking at that and was trying to figure out this from pgxs.mk:

#   PG_CXXFLAGS -- will be appended to CXXFLAGS

...

ifdef PG_CXXFLAGS
override CXXFLAGS := $(CXXFLAGS) $(PG_CXXFLAGS)

Was wondering if this might be culprit(from example in pgxs.mk):

#   include $(PGXS)

The OP does not have that in their make file.



I'm a little dubious about whether overriding CXX is a good idea now, too.
(Likely the core setting is the same, but if it were pointing at a
different compiler that could cause trouble.)

regards, tom lane





--
Adrian Klaver
adrian.kla...@aklaver.com




Re: Compiling C Extension Functions against PostgreSQL 12

2020-05-02 Thread TalGloz
Adrian Klaver-4 wrote
> On 5/2/20 2:18 PM, Tom Lane wrote:
>> TalGloz <

> glozmantal@

> > writes:
>>> I dont understand why the output for Postgres  12
>>> g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
>>> -Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c
>>> seal_diff_cpp.cpp
>>> seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or
>>> directory
>>>  2 | #include "postgres.h"
>>>|  ^~~~
>> 
>>> looks different form the ones of Postgres 10
>> 
>> Looking at your Makefile, it seems to be expecting that CXXFLAGS will
>> be honored in the build, and it isn't being.
>> 
>> As far as I can see from pgxs.mk, you're supposed to spell that
>> PG_CXXFLAGS.  Probably, it accidentally worked to do it the other
>> way in v10, but no longer does, likely as a result of the fact that
>> there's now some minimal amount of C++ code in core PG.
> 
> I was looking at that and was trying to figure out this from pgxs.mk:
> 
> #   PG_CXXFLAGS -- will be appended to CXXFLAGS
> 
> ...
> 
> ifdef PG_CXXFLAGS
> override CXXFLAGS := $(CXXFLAGS) $(PG_CXXFLAGS)
> 
> Was wondering if this might be culprit(from example in pgxs.mk):
> 
> #   include $(PGXS)
> 
> The OP does not have that in their make file.
> 
>> 
>> I'm a little dubious about whether overriding CXX is a good idea now,
>> too.
>> (Likely the core setting is the same, but if it were pointing at a
>> different compiler that could cause trouble.)
>> 
>>  regards, tom lane
>> 
>> 
> 
> 
> -- 
> Adrian Klaver

> adrian.klaver@

The "include $(PGXS)" is defined in the Makefile. After changig the CXXFLAGS
to PG_CXXFLAGS I get:

*g++ -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread
-I/usr/pgsql-12/include/server -I/usr/local/include
-I/usr/local/include/cppcodec -o seal_diff_cpp.o -c seal_diff_cpp.cpp
g++ -shared -o seal_diff_cpp.so seal_diff_cpp.o -L/usr/pgsql-12/lib 
-L/usr/lib64  -L/usr/lib64 -Wl,--as-needed
-Wl,-rpath,'/usr/pgsql-12/lib',--enable-new-dtags -L/usr/local/lib -lseal
-pthread
/usr/lib64/ccache/clang -xc++ -Wno-ignored-attributes -fno-strict-aliasing
-fwrapv -O2  -I. -I./ -I/usr/pgsql-12/include/server
-I/usr/pgsql-12/include/internal  -D_GNU_SOURCE -I/usr/include/libxml2 
-I/usr/include -flto=thin -emit-llvm -c -o seal_diff_cpp.bc
seal_diff_cpp.cpp*
In file included from seal_diff_cpp.cpp:23:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
In file included from /usr/local/include/seal/memorypoolhandle.h:6:
In file included from /usr/local/include/seal/util/mempool.h:12:
/usr/local/include/seal/util/locks.h:12:50: error: no template named
'shared_mutex' in namespace 'std'; did you mean 'shared_ptr'?
using ReaderLock = std::shared_lock;
~^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/shared_ptr.h:103:11:
note: 'shared_ptr' declared here
class shared_ptr : public __shared_ptr<_Tp>
  ^
In file included from seal_diff_cpp.cpp:23:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
In file included from /usr/local/include/seal/memorypoolhandle.h:6:
In file included from /usr/local/include/seal/util/mempool.h:12:
/usr/local/include/seal/util/locks.h:12:50: error: use of class template
'std::shared_ptr' requires template arguments
using ReaderLock = std::shared_lock;
 ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/shared_ptr.h:103:11:
note: template is declared here
class shared_ptr : public __shared_ptr<_Tp>
  ^
In file included from seal_diff_cpp.cpp:23:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
In file included from /usr/local/include/seal/memorypoolhandle.h:6:
In file included from /usr/local/include/seal/util/mempool.h:12:
/usr/local/include/seal/util/locks.h:14:50: error: no template named
'shared_mutex' in namespace 'std'; did you mean 'shared_ptr'?
using WriterLock = std::unique_lock;
~^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/shared_ptr.h:103:11:
note: 'shared_ptr' declared here
class shared_ptr : public __shared_ptr<_Tp>
  ^
In file included from seal_diff_cpp.cpp:23:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
In file included from /usr/local/include/seal/memorypoolhandle.h:6:
In file included from /usr/local/include/seal/util/mempool.h:12:
/usr/local/include/seal/util

Re: Compiling C Extension Functions against PostgreSQL 12

2020-05-02 Thread Adrian Klaver

On 5/2/20 2:44 PM, TalGloz wrote:

Adrian Klaver-4 wrote

On 5/2/20 2:18 PM, Tom Lane wrote:

TalGloz <







adrian.klaver@


The "include $(PGXS)" is defined in the Makefile. After changig the CXXFLAGS


Hmm, time to clean my glasses.

Have no idea what the below means.


to PG_CXXFLAGS I get:

*g++ -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread
-I/usr/pgsql-12/include/server -I/usr/local/include
-I/usr/local/include/cppcodec -o seal_diff_cpp.o -c seal_diff_cpp.cpp
g++ -shared -o seal_diff_cpp.so seal_diff_cpp.o -L/usr/pgsql-12/lib
-L/usr/lib64  -L/usr/lib64 -Wl,--as-needed
-Wl,-rpath,'/usr/pgsql-12/lib',--enable-new-dtags -L/usr/local/lib -lseal
-pthread
/usr/lib64/ccache/clang -xc++ -Wno-ignored-attributes -fno-strict-aliasing
-fwrapv -O2  -I. -I./ -I/usr/pgsql-12/include/server
-I/usr/pgsql-12/include/internal  -D_GNU_SOURCE -I/usr/include/libxml2
-I/usr/include -flto=thin -emit-llvm -c -o seal_diff_cpp.bc
seal_diff_cpp.cpp*
In file included from seal_diff_cpp.cpp:23:
In file included from /usr/local/include/seal/seal.h:3:
In file included from /usr/local/include/seal/bigpoly.h:9:
In file included from /usr/local/include/seal/biguint.h:6:
In file included from /usr/local/include/seal/memorypoolhandle.h:6:
In file included from /usr/local/include/seal/util/mempool.h:12:
/usr/local/include/seal/util/locks.h:12:50: error: no template named
'shared_mutex' in namespace 'std'; did you mean 'shared_ptr'?
 using ReaderLock = std::shared_lock;
 ~^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/shared_ptr.h:103:11:
note: 'shared_ptr' declared here
 class shared_ptr : public __shared_ptr<_Tp>
   ^




--
Adrian Klaver
adrian.kla...@aklaver.com




Re: Compiling C Extension Functions against PostgreSQL 12

2020-05-02 Thread TalGloz
Tom Lane-2 wrote
> TalGloz <

> glozmantal@

> > writes:
>> I dont understand why the output for Postgres  12 
>> g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
>> -Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c
>> seal_diff_cpp.cpp
>> seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or
>> directory
>> 2 | #include "postgres.h"
>>   |  ^~~~
> 
>> looks different form the ones of Postgres 10
> 
> Looking at your Makefile, it seems to be expecting that CXXFLAGS will
> be honored in the build, and it isn't being.
> 
> As far as I can see from pgxs.mk, you're supposed to spell that
> PG_CXXFLAGS.  Probably, it accidentally worked to do it the other
> way in v10, but no longer does, likely as a result of the fact that
> there's now some minimal amount of C++ code in core PG.
> 
> I'm a little dubious about whether overriding CXX is a good idea now, too.
> (Likely the core setting is the same, but if it were pointing at a
> different compiler that could cause trouble.)
> 
>   regards, tom lane

I've added some output to a different module Makefile that uses the same
libraries and Changed "CXXFLAGS" to "PG_CXXFLAGS" and "LDFLAGS" to
"PG_LDFLAGS":

# This file crates the seal_mean_cxx_v2.so library for the PostgreSQL
# Usage:
# make  # compiles all
# make clean# clean all binaries and objects

MODULES = seal_mean_cxx_v2

# Location of PostgreSQL pg_config file
PG_CONFIG = /usr/pgsql-10/bin/pg_config
# PostgreSQL path to PGXS
PGXS = $(shell $(PG_CONFIG) --pgxs)
# PostgreSQL path to server header files
INCLUDEDIR = $(shell $(PG_CONFIG) --includedir-server)
# PostgreSQL path to executable shared libraries
POSGRESLIBINSTALL = $(shell $(PG_CONFIG) --pkglibdir)

# Location of the installed seal library
INCLUDE_SEAL = /usr/local/include
# Location of the compiled seal lib library
INCLUDE_SEAL_LIB = /usr/local/lib
# Location of the installed cppcodec library
INCLUDE_CPPCODEC = /usr/local/include/cppcodec

# Compiler to use
CXX = g++
# Compiler flags
PG_CXXFLAGS = -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread \
   -I$(INCLUDEDIR) -I$(INCLUDE_SEAL) -I$(INCLUDE_CPPCODEC)
#PG_LDFLAGS= -L$(INCLUDE_SEAL_LIB) -lseal -pthread
# Seal linker flags
SEAL_LDFLAGS = -L$(INCLUDE_SEAL_LIB) -lseal -pthread
include $(PGXS)

seal_mean_cxx_v2.so: seal_mean_cxx_v2.o # Create the .so file
@echo ""
@echo "Cereating .so file."
# Needed when checking the linker errors against the external SEAL library
and must be commented when creating .so file
#   $(CXX) -Wl,--no-undefined -shared -o seal_mean_cxx.so seal_mean_cxx.o
$(PG_LDFLAGS) $(SEAL_LDFLAGS)
# Creates the .so file
$(CXX) -shared -o seal_mean_cxx_v2.so seal_mean_cxx_v2.o $(PG_LDFLAGS)
$(SEAL_LDFLAGS)
@echo "Done."
@echo ""
@echo "Copying the created .so library to \"${POSGRESLIBINSTALL}\"."
# Copies the .so file to PostgreSQL shared libraries
cp seal_mean_cxx_v2.so $(POSGRESLIBINSTALL)
@echo "Done."
@echo ""

seal_mean_cxx_v2.o: seal_mean_cxx_v2.cpp # Create the .o file
@echo ""
@echo "Creating .o file."
$(CXX) $(PG_CXXFLAGS) -o seal_mean_cxx_v2.o -c seal_mean_cxx_v2.cpp
@echo "Done."

.PHONY = clean
clean: # Clean .so and .o files
@echo ""
@echo "Cleaning the .so and .o files"
rm -f seal_mean_cxx_v2.so rm seal_mean_cxx_v2.o
@echo "Done."
@echo ""
 
I get this part for my code in the Makefile:

Makefile:57: warning: overriding recipe for target 'clean'
/usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk:342: warning: ignoring old
recipe for target 'clean'

Cleaning the .so and .o files
rm -f seal_mean_cxx_v2.so rm seal_mean_cxx_v2.o
Done.

[root@www seal_mean]# make
Makefile:57: warning: overriding recipe for target 'clean'
/usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk:342: warning: ignoring old
recipe for target 'clean'

Creating .o file.
g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv -O2 -std=c++17 -fPIC -Wall
-Werror -g -O0 -pthread -I/usr/pgsql-12/include/server -I/usr/local/include
-I/usr/local/include/cppcodec -o seal_mean_cxx_v2.o -c seal_mean_cxx_v2.cpp
Done.

Cereating .so file.
g++ -shared -o seal_mean_cxx_v2.so seal_mean_cxx_v2.o -L/usr/pgsql-12/lib 
-L/usr/lib64  -L/usr/lib64 -Wl,--as-needed
-Wl,-rpath,'/usr/pgsql-12/lib',--enable-new-dtags -L/usr/local/lib -lseal
-pthread
Done.

Copying the created .so library to "/usr/pgsql-12/lib".
cp seal_mean_cxx_v2.so /usr/pgsql-12/lib
Done.


Which is good, my seal_mean_cxx_v2.so being created and copied to
/usr/pgsql-12/lib/. But right after that I get this and it doesn't seem to
effect my seal_mean_cxx_v2.so library:
/usr/lib64/ccache/clang -xc++ -Wno-ignored-attributes -fno-strict-aliasing
-fwrapv -O2  -I. -I./ -I/usr/pgsql-12/include/server
-I/usr/pgsql-12/include/internal  -D_GNU_SOURCE -I/usr/include/libxml2

Re: Compiling C Extension Functions against PostgreSQL 12

2020-05-02 Thread Adrian Klaver

On 5/2/20 4:03 PM, TalGloz wrote:

Tom Lane-2 wrote

TalGloz <



glozmantal@



> writes:

I dont understand why the output for Postgres  12
g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv -O2 -o seal_diff_cpp.o -c
seal_diff_cpp.cpp
seal_diff_cpp.cpp:2:10: fatal error: postgres.h: No such file or
directory
 2 | #include "postgres.h"
   |  ^~~~



looks different form the ones of Postgres 10


Looking at your Makefile, it seems to be expecting that CXXFLAGS will
be honored in the build, and it isn't being.

As far as I can see from pgxs.mk, you're supposed to spell that
PG_CXXFLAGS.  Probably, it accidentally worked to do it the other
way in v10, but no longer does, likely as a result of the fact that
there's now some minimal amount of C++ code in core PG.

I'm a little dubious about whether overriding CXX is a good idea now, too.
(Likely the core setting is the same, but if it were pointing at a
different compiler that could cause trouble.)

regards, tom lane


I've added some output to a different module Makefile that uses the same
libraries and Changed "CXXFLAGS" to "PG_CXXFLAGS" and "LDFLAGS" to
"PG_LDFLAGS":


Did you?

In Makefile below I see:

#PG_LDFLAGS= -L$(INCLUDE_SEAL_LIB) -lseal -pthread
# Seal linker flags
SEAL_LDFLAGS = -L$(INCLUDE_SEAL_LIB) -lseal -pthread



# This file crates the seal_mean_cxx_v2.so library for the PostgreSQL
# Usage:
# make  # compiles all
# make clean# clean all binaries and objects

MODULES = seal_mean_cxx_v2

# Location of PostgreSQL pg_config file
PG_CONFIG = /usr/pgsql-10/bin/pg_config
# PostgreSQL path to PGXS
PGXS = $(shell $(PG_CONFIG) --pgxs)
# PostgreSQL path to server header files
INCLUDEDIR = $(shell $(PG_CONFIG) --includedir-server)
# PostgreSQL path to executable shared libraries
POSGRESLIBINSTALL = $(shell $(PG_CONFIG) --pkglibdir)

# Location of the installed seal library
INCLUDE_SEAL = /usr/local/include
# Location of the compiled seal lib library
INCLUDE_SEAL_LIB = /usr/local/lib
# Location of the installed cppcodec library
INCLUDE_CPPCODEC = /usr/local/include/cppcodec

# Compiler to use
CXX = g++
# Compiler flags
PG_CXXFLAGS = -std=c++17 -fPIC -Wall -Werror -g -O0 -pthread \
   -I$(INCLUDEDIR) -I$(INCLUDE_SEAL) -I$(INCLUDE_CPPCODEC)
#PG_LDFLAGS= -L$(INCLUDE_SEAL_LIB) -lseal -pthread
# Seal linker flags
SEAL_LDFLAGS = -L$(INCLUDE_SEAL_LIB) -lseal -pthread
include $(PGXS)

seal_mean_cxx_v2.so: seal_mean_cxx_v2.o # Create the .so file
@echo ""
@echo "Cereating .so file."
# Needed when checking the linker errors against the external SEAL library
and must be commented when creating .so file
#   $(CXX) -Wl,--no-undefined -shared -o seal_mean_cxx.so seal_mean_cxx.o
$(PG_LDFLAGS) $(SEAL_LDFLAGS)
# Creates the .so file
$(CXX) -shared -o seal_mean_cxx_v2.so seal_mean_cxx_v2.o $(PG_LDFLAGS)
$(SEAL_LDFLAGS)
@echo "Done."
@echo ""
@echo "Copying the created .so library to \"${POSGRESLIBINSTALL}\"."
# Copies the .so file to PostgreSQL shared libraries
cp seal_mean_cxx_v2.so $(POSGRESLIBINSTALL)
@echo "Done."
@echo ""

seal_mean_cxx_v2.o: seal_mean_cxx_v2.cpp # Create the .o file
@echo ""
@echo "Creating .o file."
$(CXX) $(PG_CXXFLAGS) -o seal_mean_cxx_v2.o -c seal_mean_cxx_v2.cpp
@echo "Done."

.PHONY = clean
clean: # Clean .so and .o files
@echo ""
@echo "Cleaning the .so and .o files"
rm -f seal_mean_cxx_v2.so rm seal_mean_cxx_v2.o
@echo "Done."
@echo ""
  
I get this part for my code in the Makefile:


Makefile:57: warning: overriding recipe for target 'clean'
/usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk:342: warning: ignoring old
recipe for target 'clean'

Cleaning the .so and .o files
rm -f seal_mean_cxx_v2.so rm seal_mean_cxx_v2.o
Done.

[root@www seal_mean]# make
Makefile:57: warning: overriding recipe for target 'clean'
/usr/pgsql-12/lib/pgxs/src/makefiles/pgxs.mk:342: warning: ignoring old
recipe for target 'clean'

Creating .o file.
g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv -O2 -std=c++17 -fPIC -Wall
-Werror -g -O0 -pthread -I/usr/pgsql-12/include/server -I/usr/local/include
-I/usr/local/include/cppcodec -o seal_mean_cxx_v2.o -c seal_mean_cxx_v2.cpp
Done.

Cereating .so file.
g++ -shared -o seal_mean_cxx_v2.so seal_mean_cxx_v2.o -L/usr/pgsql-12/lib
-L/usr/lib64  -L/usr/lib64 -Wl,--as-needed
-Wl,-rpath,'/usr/pgsql-12/lib',--enable-new-dtags -L/usr/local/lib -lseal
-pthread
Done.

Copying the created .so library to "/usr/pgsql-12/lib".
cp seal_mean_cxx_v2.so /usr/pgsql-12/lib
Done.


Which is good, my seal_mean_cxx_v2.so being created and copied to
/usr/pgsql-12/lib/. But right after that I get this and it doesn't seem to
effect my seal_mean_cxx_v2.so library:
/usr/lib64/ccache/clang -xc++ -Wno-ignored-attr