Re: BUG #16051: PQgetvalue(res,0,0) is null, PQgetlength(res,0,0) is 10 - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #16051: PQgetvalue(res,0,0) is null, PQgetlength(res,0,0) is 10
Date
Msg-id 31796.1570889857@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #16051: PQgetvalue(res,0,0) is null, PQgetlength(res,0,0) is 10  (Bart Smink <bartsmink@gmail.com>)
List pgsql-bugs
Bart Smink <bartsmink@gmail.com> writes:
> Thanks for taking a look at my code. The difference is because this table
> will be created once by a setup script that connects without the
> search_path option selecting a scheme  in connect, whereas the program that
> will run on this table connects with a search_path option. Changing the
> command to

> res = PQexecParams(conn,
>             "SELECT * FROM \"Schema1\".testdata;",
>             0,
>             NULL,
>             NULL,
>             NULL,
>             NULL,
>             1
>         );

> makes no difference, the test still fails.

[ looks closer... ]  Oh!  You are asking for binary result format
(resultFormat = 1 in the call), so what you get back is not a
pointer to the string "1234", it's a pointer to whatever the
defined binary format for a numeric is.  That likely begins with
a zero byte, causing your program to think it's an empty string.

            regards, tom lane



pgsql-bugs by date:

Previous
From: Andrew Gierth
Date:
Subject: Re: BUG #16051: PQgetvalue(res,0,0) is null, PQgetlength(res,0,0) is 10
Next
From: PG Bug reporting form
Date:
Subject: BUG #16052: pg_dump --no-comments not working