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

Поиск
Список
Период
Сортировка
От Bart Smink
Тема Re: BUG #16051: PQgetvalue(res,0,0) is null, PQgetlength(res,0,0) is 10
Дата
Msg-id CAN7LKwP1b_FmKv_KzEGN3LSat2PwqTvc1+=7sRRt1=qkq_=aSQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #16051: PQgetvalue(res,0,0) is null, PQgetlength(res,0,0) is 10  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: BUG #16051: PQgetvalue(res,0,0) is null, PQgetlength(res,0,0) is 10  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
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.


This is the main function that initalises the connection in this test file:

int main(int argc, char**argv){
    doctest::Context context;
        conn = PQconnectdb("host=127.0.0.1 port=5432 user=sab24 dbname=Testing options='-c search_path=\"Schema1\"'");
        if (PQstatus(conn) != CONNECTION_OK){
        fprintf(stderr, "Connection to database failed: %s",
            PQerrorMessage(conn));
        exit(1);
    }
    int res = context.run();
    PQfinish(conn);
    return res;
}

Debugging also shows the output of PQgetvalue not available:

Process 6345 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100015542 dbPostgres`_DOCTEST_ANON_FUNC_10() at dbPostgres.cpp:242:23
   239            PQclear(res);
   240        }
   241        else{
-> 242            std::cout << "value is: " << PQgetvalue(res, 0,0) << " length is: " << PQgetlength(res,0,0) << std::endl;
   243            REQUIRE(strcmp(PQgetvalue(res, 0,0), "1234") == 0);
   244        }
   245    }
(lldb) p (char*)PQgetvalue(res,0,0)
(char *) $0 = 0x000000010080af10 <no value available>

On Sat, 12 Oct 2019 at 05:30, Tom Lane <tgl@sss.pgh.pa.us> wrote:
PG Bug reporting form <noreply@postgresql.org> writes:
> I'm running unit tests in doctest and cannot make a simple test succeed.

Right offhand, I'd wonder about why your test is creating a table
with the fully qualified name \"Schema1\".testdata and then
querying it without the schema qualification.

                        regards, tom lane


--
**** DISCLAIMER ****

"This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: 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