Re: BUG #16051: PQgetvalue(res,0,0) is null, PQgetlength(res,0,0) is 10

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bart Smink <bartsmink(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16051: PQgetvalue(res,0,0) is null, PQgetlength(res,0,0) is 10
Date: 2019-10-12 14:17:37
Message-ID: 31796.1570889857@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Bart Smink <bartsmink(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

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