From: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
---|---|
To: | 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:12 |
Message-ID: | 87mue6xdf1.fsf@news-spur.riddles.org.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
>>>>> "PG" == PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
PG> res = PQexecParams(conn,
PG> "SELECT * FROM testdata;",
PG> 0,
PG> NULL,
PG> NULL,
PG> NULL,
PG> NULL,
PG> 1);
That "1" on the end there indicates that you are requesting binary
format results. But this:
PG> std::cout << "value is: " << PQgetvalue(res, 0,0) << " length
PG> is: " << PQgetlength(res,0,0) << std::endl;
PG> REQUIRE(strcmp(PQgetvalue(res, 0,0), "1234") == 0);
is assuming text format.
The binary result for numeric '1234' will be 10 bytes long and consist
of: 00 01 00 00 00 00 00 00 04 d2:
0001 = ndigits (meaning: 1 base-10000 digit)
0000 = weight (first digit is * 10000^0)
0000 = sign (0 = positive)
0000 = dscale (0 base-10 digits after the point)
04d2 = decimal 1234
--
Andrew (irc:RhodiumToad)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2019-10-12 14:17:37 | Re: BUG #16051: PQgetvalue(res,0,0) is null, PQgetlength(res,0,0) is 10 |
Previous Message | Bart Smink | 2019-10-12 08:42:52 | Re: BUG #16051: PQgetvalue(res,0,0) is null, PQgetlength(res,0,0) is 10 |