Re: Upgrade Process Says "The database server was not shut down cleanly" but it was

2020-05-12 Thread TalGloz
Adrian Klaver-4 wrote > On 5/11/20 2:45 PM, TalGloz wrote: >> Well I tried your steps, both Postgres 10 and 12 are in perfect running >> conditions and were shut down using the "systemctl" command. When I >> execute: >> >> /usr/pgsql-12/bin/pg_upgra

Re: Upgrade Process Says "The database server was not shut down cleanly" but it was

2020-05-11 Thread TalGloz
Well I tried your steps, both Postgres 10 and 12 are in perfect running conditions and were shut down using the "systemctl" command. When I execute: /usr/pgsql-12/bin/pg_upgrade --old-bindir=/usr/pgsql-10/bin/ --new-bindir=/usr/pgsql-12/bin/ --old-datadir=/var/lib/pgsql/10/data --new-datadir=/var

Re: Upgrade Process Says "The database server was not shut down cleanly" but it was

2020-05-03 Thread TalGloz
Adrian Klaver-4 wrote > On 5/3/20 3:11 PM, TalGloz wrote: >> Adrian Klaver-4 wrote >>> On 5/3/20 2:53 PM, >>> >>> Looks like you did not shutdown the 12 instance. >>> >>> -- >>> Adrian Klaver >> >>> adrian.klaver@

Re: Upgrade Process Says "The database server was not shut down cleanly" but it was

2020-05-03 Thread TalGloz
Adrian Klaver-4 wrote > On 5/3/20 2:53 PM, > > Looks like you did not shutdown the 12 instance. > > -- > Adrian Klaver > adrian.klaver@ This is weird because "systemctl staus postgresql-12.service" shows that the service is dead. Best regards, TalGloz -- Se

Upgrade Process Says "The database server was not shut down cleanly" but it was

2020-05-03 Thread TalGloz
I'm in the process to update my Postgres 10 to 12 (it's my first server upgrade). I've shutdown my Postgres 10 using "systemctl stop postgresql-10.service" and "systemctl status postgresql-10.service" says: Active: inactive (dead) since Sun 2020-05-03 22:51:46 CEST; After that I've started the upg

Re: Compiling C Extension Functions against PostgreSQL 12

2020-05-03 Thread TalGloz
Tom Lane-2 wrote > TalGloz < > glozmantal@ > > writes: >> Andrew Gierth wrote >>> I didn't see an easy way of disabling bitcode emission for a module, >>> though I think that has been discussed before. > > After taking a quick look throug

Re: Compiling C Extension Functions against PostgreSQL 12

2020-05-03 Thread TalGloz
Andrew Gierth wrote >>>>>> "TalGloz" == TalGloz < > glozmantal@ > > writes: > > TalGloz> Which is good, my seal_mean_cxx_v2.so being created and copied > TalGloz> to /usr/pgsql-12/lib/. But right after that I get this and it > TalG

Re: Compiling C Extension Functions against PostgreSQL 12

2020-05-03 Thread TalGloz
Adrian Klaver-4 wrote > On 5/2/20 4:03 PM, TalGloz wrote: > > 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 > > -- > Adrian Klaver &

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_d

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 >>> -Wfor

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 reachi

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

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 >>>&g

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 Mak

Compiling C Extension Functions against PostgreSQL 12

2020-05-02 Thread TalGloz
erver ---> /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: 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 does

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

2020-05-01 Thread TalGloz
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

Checking for Presence of Required Libraries Fails during PostgreSQL Upgrade

2020-05-01 Thread TalGloz
I'm trying to upgrade my PostgreSQL form 10.2 to 11.7 (and eventually to 12.x), when I run: /usr/pgsql-11/bin/pg_upgrade --old-bindir=/usr/pgsql-10/bin/ --new-bindir=/usr/pgsql-11/bin/ --old-datadir=/var/lib/pgsql/10/data --new-datadir=/var/lib/pgsql/11/data --check I get: Checking for presence

Re: Executing a Function with an INSERT INTO command fails

2018-08-29 Thread TalGloz
> Tom's assumption is possibly correct. If the client does not have > autocommit set then you need to explicitly commit the transaction. I feel a little bit stupid , I forgot the use Work.commit(); in the function on the client side! Thanks for the help everybody! Tal -- Sent from: http://ww

RE: Executing a Function with an INSERT INTO command fails

2018-08-29 Thread TalGloz
> This is very strange, even if I comment all the loops in the function and > leave only the INSERT INTO command the insert still doesn't happen. Now If I execute the function locally in a query window like this: SELECT public.seal_diff_benchmark_pgsql('YW55IGNhcm5hbCBwbGVhc3VyZQ==') Then the

Re: Executing a Function with an INSERT INTO command fails

2018-08-29 Thread TalGloz
Tom Lane-2 wrote > Maybe you're rolling back the transaction after leaving the function? Why would it happen and how do I stop it if it is happening. I don't seem to have anything in the code to cause it Regards Tal -- Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f184378

Re: Executing a Function with an INSERT INTO command fails

2018-08-29 Thread TalGloz
> I was referring specifically to: > > https://www.postgresql.org/docs/10/static/plpgsql-errors-and-messages.html#PLPGSQL-STATEMENTS-RAISE > > I was going for a conceptual communication, not syntax. > > Though if you indeed get a syntax error then that precludes the "wrong > object" theory. I

Re: Executing a Function with an INSERT INTO command fails

2018-08-29 Thread TalGloz
> Add "RAISE ERROR" to the top function's BEGIN block and verify that the > next time you run your calling query it indeed fails. I'm suspecting that > the code you are iterating over is not the same code that is being > executed > (search_path dynamics probably). Do you mean like this BEGIN RA

RE: Executing a Function with an INSERT INTO command fails

2018-08-29 Thread TalGloz
This is very strange, even if I comment all the loops in the function and leave only the INSERT INTO command the insert still doesn't happen. > The sealArray creation is modified, because I don't know how the function > public.seal_diff_benchmark is defined. >> public.seal_diff_benchmark(tempVar1

RE: Executing a Function with an INSERT INTO command fails

2018-08-29 Thread TalGloz
Charles Clavadetscher wrote > Do you get any error? The function executes perfectly and does what it's supposed to except of the INSERT INTO part. I don't get any errors. > Does the select deliver any result at all? Yes, booth SELECT deliver everything they supposed to. > If yes, is there ma

Executing a Function with an INSERT INTO command fails

2018-08-29 Thread TalGloz
Hello, I have this function that executes a C extention function in it and returns a SETOF TEXT CREATE OR REPLACE FUNCTION seal_diff_benchmark_pgsql(sealparams CHARACTER VARYING) RETURNS SETOF TEXT AS $outputVar$ DECLARE tempVar1 CHARACTER VARYING; tempVar2 CHARACTER VARYI

Re: Returning Vector of Pairs with a PostgreSQL C Extension Function

2018-08-27 Thread TalGloz
Pavel Stehule wrote > There are already prepared macros > > #define CStringGetTextDatum(s) PointerGetDatum(cstring_to_text(s)) > #define TextDatumGetCString(d) text_to_cstring((text *) > DatumGetPointer(d)) Thanks for pointing out the macros, for some reason I've missed them. Best regards, Tal

Re: Returning Vector of Pairs with a PostgreSQL C Extension Function

2018-08-27 Thread TalGloz
It looks like changing the elements[0] = CStringGetDatum(localT1.c_str()); elements[1] = CStringGetDatum(localT2.c_str()); to: elements[0] = PointerGetDatum(cstring_to_text(localT1.c_str())); elements[1] = PointerGetDatum(cstring_to_text(localT2.c_str())); Solved the problem. If anyone thinks

Re: Returning Vector of Pairs with a PostgreSQL C Extension Function

2018-08-27 Thread TalGloz
Hello, I'm having a small problem. The code works but the array cells don't hold the whole length of *localT1* and *localT2* texts, I think it has something to do with *int16 typlen* in my set parameters: ArrayType *array; Datum elements[2]; int16 typlen; bool typbyval; char typalign; elements[0

Re: Linker errors while creating a PostgreSQL C extension function.

2018-08-25 Thread TalGloz
I removed the flag --no-undefined and it was compiled and worked like a charm. I needed the flag to spot the linker errors for linking with the external *libseal.a* library. As for my other question regarding the unused linker path *-L"/usr/local/lib"*. I'm using Fedora 28 (RedHat) and in this dis

Re: Returning Vector of Pairs with a PostgreSQL C Extension Function

2018-08-25 Thread TalGloz
Yes, that was the problem and now everything works. Thanks, Tal -- Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html

Re: Returning Vector of Pairs with a PostgreSQL C Extension Function

2018-08-25 Thread TalGloz
OK so I think I'm on the right way with this code and now my goal is to return a text array (text[ ]) with 2 fields extern "C" { Datum text_array(PG_FUNCTION_ARGS){ // For text aka. character varying parameter text *t1 = PG_GETARG_TEXT_PP(0); text *t2 = PG_GETARG_TEXT_

Returning Vector of Pairs with a PostgreSQL C Extension Function

2018-08-25 Thread TalGloz
Hello, I want to return an vector of pairs using a C extension. This is a simple code I have: extern "C" { Datum pair(PG_FUNCTION_ARGS){ // For text aka. character varying parameter text *t1 = PG_GETARG_TEXT_PP(0); text *t2 = PG_GETARG_TEXT_PP(1); std::string loca

Re: Linker errors while creating a PostgreSQL C extension function.

2018-08-21 Thread TalGloz
Hallo Do you or anyone know why is it trying to link with -L/usr/lib64 path and not -L/usr/local/lib as provided? After recompiling the libseal.a with the -fPIC flag and copying it manually from /usr/local/lib/ to /usr/lib64/ I get those errors: g++ -Wl,--no-undefined -shared -o seal_diff_cpp.so

Re: Linker errors while creating a PostgreSQL C extension function.

2018-08-20 Thread TalGloz
My CXXFLAGS has the -fPIC flag in it. As I understood from Tom Lane's previos post, I have to recompile the libseal.a if the -fPIC flag or turn the libseal.a into a libseal.so. Best regars, Tal -- Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html

Re: including header files in a C extension

2018-08-20 Thread TalGloz
Hi, Thanks for the reply but this question doesn't describe my problem. I've asked the question again with much more detailed information about my problem and got a solution, please see link below. http://www.postgresql-archive.org/Linker-errors-while-creating-a-PostgreSQL-C-extension-function-td

Re: Linker errors while creating a PostgreSQL C extension function.

2018-08-19 Thread TalGloz
Thanks, that did the trick. But now I'm getting this g++ -Wl,--no-undefined -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 /usr/bin/ld: /usr/lib64/libseal.a(bigpoly.cpp

Re: Linker errors while creating a PostgreSQL C extension function.

2018-08-19 Thread TalGloz
I'm using Fedora 28 OS and I'll check it with PGXS. The funny thing is that everything works when I comment every code line connected to the SEAL library. The cppcodec library is also an external library installed to /usr/local/include/cppcodec like the SEAL library. Regards, Tal -- Sent from:

Re: Linker errors while creating a PostgreSQL C extension function.

2018-08-19 Thread TalGloz
I'll try it later when I'm home. Is there a reason that you are linking like this $(CXX) -Wl,--no-undefined -shared -o seal_diff_cpp.so $(LDFLAGS) $(LDLIBS) seal_diff_cpp.o And not like this? $(CXX) -Wl,--no-undefined -shared -o seal_diff_cpp.so seal_diff_cpp.o $(LDFLAGS) $(LDLIBS) -- Sent f

Re: Linker errors while creating a PostgreSQL C extension function.

2018-08-19 Thread TalGloz
No, they still don't appear there and same errors are shown. -- Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html

Re: Linker errors while creating a PostgreSQL C extension function.

2018-08-19 Thread TalGloz
OK, I've changed my line to LDFLAGS = -L$(INCLUDE_SEAL_LIB) -lseal -lpthread In my Makefile this command is written like this (line numbers are just for orientation) 1: seal_diff_cpp.so: seal_diff_cpp.o 2:$(CXX) -Wl,--no-undefined -shared -o seal_diff_cpp.so seal_diff_cpp.o $(LDFLAGS) 3:

Re: Linker errors while creating a PostgreSQL C extension function.

2018-08-19 Thread TalGloz
Do you mean this command: seal_diff_cpp.so: seal_diff_cpp.o $(CXX) -Wl,--no-undefined -shared -o seal_diff_cpp.so seal_diff_cpp.o $(LDFLAGS) If yes then the -lseal is added with the $(LDFLAGS) at the end of the command. -- Sent from: http://www.postgresql-archive.org/PostgreSQL-general

Linker errors while creating a PostgreSQL C extension function.

2018-08-19 Thread TalGloz
Hello, *I have this code for my C extension function. * xtern "C" { // C Headers must be inside exter "C" { } block. #include #include #include #include #include #include #include #include PG_MODULE_MAGIC; } // CPP Header must be outside extern "C" { } block. #include #include #includ

including header files in a C extension

2018-08-17 Thread TalGloz
Hi, If I have an external library that I install using make install into the /usr/local/include/libraryname path by default and I want to include it in a C extension, the Makefile for the .so file includes the headers in /usr/local/include/libraryname path. Can I use #include when writing C/CPP

Re: PostgreSQL C Language Extension with C++ Code

2018-08-12 Thread TalGloz
OK It worked. This is how I did it, hopefully it is right extern "C" { #include #include #include #include #include #include #include #include PG_MODULE_MAGIC; } #include #include #include #include #include // external compiled c++ library linked on running 'make' extern "C" { Dat

Re: PostgreSQL C Language Extension with C++ Code

2018-08-12 Thread TalGloz
Let me see if I understood you correctly. I cant have a code like this: extern "C" { int sum_of_numbers(){ std::vector numbers {23, 445, 64}; int sum = 0; for (auto &item : numbers){ sum += item; }

Re: PostgreSQL C Language Extension with C++ Code

2018-08-12 Thread TalGloz
I did it with the macros extern "C" { Datum sum_of_numbers(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(sum_of_numbers); } But now my compiler throws some other errors when running make: g++ --std=c++17 -fPIC -Wall -Werror -g3 -O0 -o myfunc.o -c myfunc.cpp -I/usr/pgsql-10/include/server -L"/usr/local/

Re: PostgreSQL C Language Extension with C++ Code

2018-08-12 Thread TalGloz
OK now I have this code: 1: extern "C" { // The C header should go here 2: #include 3: #include 4: #include 5: #include 6: #include 7: #include 8: #include 9: #include 10: 11: PG_MODULE_MAGIC; 12: } 13: 14: // CPP header without extern "C" 15: #include 16: #include 1

PostgreSQL C Language Extension with C++ Code

2018-08-12 Thread TalGloz
Hi, I've searched information about my problem in the archives and on the internet, but it didn't help. I have this small myfunc.cpp 1: #include 2: #include 3: #include 4: #include 5: #include 6: #include 7: #include 8: #include 9: #include 10: #include 11: #include 1