[BUG?] strange PQgetisnull
Hi all,
I got strange result with PQgetisnull, say
for empty table(I think that it's empty so null)
I guess that
after fetch some selection
PQgetisnull(result, 0, 0) should give me "1 or true"
But
it gives me
ERROR! field 0(of 0) of row 0(of 0) is not available... Segmentation
Fault
so I tried
if (PQntuples(result) == 0)
...
But PQntules gives me "1" not "0" !
do I have to check result with
char* value = PQgetvalue(result, 0, 0);
and test value is "" or not? any idea???
I'm using v6.3.2 on linux && Solaris.
Best Regards, C.S.Park
"Park, Chul-Su" <pcs@mhlx01.kek.jp> writes:
I got strange result with PQgetisnull, say
for empty table(I think that it's empty so null)
I guess that
after fetch some selection
PQgetisnull(result, 0, 0) should give me "1 or true"
But
it gives me
ERROR! field 0(of 0) of row 0(of 0) is not available... Segmentation
Fault
PQgetisnull is buggy in 6.3.2: it range-checks the tuple and field
numbers, and complains if they are out of range ... but then falls
through and tries to reference the tuple info anyway. Thus, segfault.
It should return a default value (probably 1 to pretend the field is
NULL) when the indexes are out of range. This is already fixed in the
current development sources, but if you want to stick with a 6.3.2
server then you will have to modify fe-exec.c yourself.
so I tried
if (PQntuples(result) == 0)
...
But PQntules gives me "1" not "0" !
The PQgetisnull error message you quoted above indicates (after looking
at the 6.3.2 sources) that nfields was 1 and ntuples was 0. I think you
are testing the results of a different query here.
do I have to check result with
char* value = PQgetvalue(result, 0, 0);
and test value is "" or not? any idea???
No, you should be checking PQntuples and perhaps also PQnfields to be
sure that the indexes you are going to use are OK.
regards, tom lane
Import Notes
Reply to msg id not found: YourmessageofThu16Jul1998171043+090035ADB583.4FFBE4CD@mhlx01.kek.jp | Resolved by subject fallback
Hi all,
I got strange result with PQgetisnull, say
for empty table(I think that it's empty so null)
I guess that
after fetch some selection
PQgetisnull(result, 0, 0) should give me "1 or true"
But
it gives me
ERROR! field 0(of 0) of row 0(of 0) is not available... Segmentation
Fault
You can't check for isnull on a Result that returns no rows. It is only
for looking at fields of an existing returned row.
--
Bruce Momjian | 830 Blythe Avenue
maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026
+ If your life is a hard drive, | (610) 353-9879(w)
+ Christ can be your backup. | (610) 853-3000(h)