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

Поиск
Список
Период
Сортировка
От Andrew Gierth
Тема Re: BUG #16051: PQgetvalue(res,0,0) is null, PQgetlength(res,0,0) is 10
Дата
Msg-id 87mue6xdf1.fsf@news-spur.riddles.org.uk
обсуждение исходный текст
Ответ на BUG #16051: PQgetvalue(res,0,0) is null, PQgetlength(res,0,0) is 10  (PG Bug reporting form <noreply@postgresql.org>)
Список pgsql-bugs
>>>>> "PG" == PG Bug reporting form <noreply@postgresql.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)



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Bart Smink
Дата:
Сообщение: Re: BUG #16051: PQgetvalue(res,0,0) is null, PQgetlength(res,0,0) is 10
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #16051: PQgetvalue(res,0,0) is null, PQgetlength(res,0,0) is 10