On Sun, Oct 06, 2019 at 05:57:38PM +0200, Christoph Zwerschke wrote:
> Am 06.10.2019 um 15:20 schrieb Justin Pryzby:
> > Remember, lazy binding is the default on my machine, and my patch
> > doesn't DWIW here..  So I don't think adding lazy link options
> > is going to help.  I think because of something python is doing (??)
> 
> Another difference is that in your example you're using libpq as shared lib
> directly, whereas with Python you create a shared lib that then uses libpq
> as a shared lib. Maybe it has something to do with that?

That doesn't explain it :(

Find attached t.c building t.so...

$ ldd t |sed 3q
        linux-vdso.so.1 =>  (0x00007ffd3fd32000)
        t.so => not found
        libpq.so.5 => /usr/lib/x86_64-linux-gnu/libpq.so.5 (0x00007f27a8ba6000)
$ PGDATABASE=postgres LD_LIBRARY_PATH=. ./t 0
$ PGDATABASE=postgres LD_LIBRARY_PATH=. ./t 1
./t: symbol lookup error: ./t.so: undefined symbol: PQresultMemorySize

// sh -exc 'gcc -Wall -Wextra -O3 -g -I /usr/include/postgresql -o t.so -shared -fPIC -DSHARED=1 t.c && gcc -Wall -Wextra -O3 -g -o t -DSHARED=0 t.c t.so -lpq'
// $ PGDATABASE=postgres LD_LIBRARY_PATH=. ./t 1

#if	SHARED
#include <libpq-fe.h>                                                                                                                            
#include <stdio.h>
#include <stdlib.h>
void f(char **argv)
{
	PGconn *conn = PQconnectdb("");
	if (PQstatus(conn) != CONNECTION_OK)
		exit(1);
	PGresult *res = PQexec(conn, "SELECT generate_series(1,99999)");
	if (argv[1][0] == '1')
		printf("%zd\n", PQresultMemorySize(res));
}

#else

void f(char **argv);
int main(int argc, char **argv)
{
	f(argv);
	return 0;
}
#endif // SHARED
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo/pygresql

Reply via email to