From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | bartsmink(at)gmail(dot)com |
Subject: | BUG #16051: PQgetvalue(res,0,0) is null, PQgetlength(res,0,0) is 10 |
Date: | 2019-10-11 22:42:06 |
Message-ID: | 16051-cf9069d07dd1df16@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 16051
Logged by: Libpq does not fetch first result in table
Email address: bartsmink(at)gmail(dot)com
PostgreSQL version: 12.0
Operating system: Macos 10.15
Description:
Hi,
I'm running unit tests in doctest and cannot make a simple test succeed. The
code is below:
SUBCASE("TEST first column first row value is stored in db"){
res = PQexec(conn, "CREATE TABLE \"Schema1\".testdata\
(\
\"Time\" decimal,\
\"RAW\" bytea,\
\"EPC\" bytea,\
\"RSSI\" bytea,\
\"PC\" bytea);\
ALTER TABLE \"Schema1\".testdata\
OWNER to sab24;"
);
CHECK(PQresultStatus(res) == PGRES_COMMAND_OK);
if (PQresultStatus(res) != PGRES_COMMAND_OK){
fprintf(stderr, "CREATE TABLE FAILED: %s",
PQerrorMessage(conn));
PQclear(res);
}
res = PQexec(conn, "INSERT INTO \"Schema1\".testdata values(1234,
'abc', 'abc', 'abc', 'abc');");
CHECK(PQresultStatus(res) == PGRES_COMMAND_OK);
if (PQresultStatus(res) != PGRES_COMMAND_OK){
fprintf(stderr, "CREATE TABLE FAILED: %s",
PQerrorMessage(conn));
PQclear(res);
}
res = PQexecParams(conn,
"SELECT * FROM testdata;",
0,
NULL,
NULL,
NULL,
NULL,
1);
CHECK(PQresultStatus(res) == PGRES_TUPLES_OK);
if (PQresultStatus(res) != PGRES_TUPLES_OK){
fprintf(stderr, "SELECT TABLE FAILED: %s",
PQerrorMessage(conn));
PQclear(res);
}
else{
std::cout << "value is: " << PQgetvalue(res, 0,0) << " length
is: " << PQgetlength(res,0,0) << std::endl;
REQUIRE(strcmp(PQgetvalue(res, 0,0), "1234") == 0);
}
}
Output is:
value is: length is: 10
===============================================================================
../tests/dbPostgres.cpp:39:
TEST CASE: Database related tests
TEST first column first row value is stored in db
../tests/dbPostgres.cpp:242: FATAL ERROR: REQUIRE( strcmp(PQgetvalue(res,
0,0), "1234") == 0 ) is NOT correct!
values: REQUIRE( -49 == 0 )
===============================================================================
[doctest] test cases: 2 | 1 passed | 1 failed | 0
skipped
[doctest] assertions: 32 | 31 passed | 1 failed |
[doctest] Status: FAILURE!
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2019-10-12 03:30:49 | Re: BUG #16051: PQgetvalue(res,0,0) is null, PQgetlength(res,0,0) is 10 |
Previous Message | Tomas Vondra | 2019-10-11 18:35:30 | Re: BUG #16050: Server crash on CREATE TEXT SEARCH DICTIONARY with a wrong AffFile |