BUG #15226: (Changes in) LIBPQ prevents proper error captures andcrash client programs instead

Поиск
Список
Период
Сортировка
От PG Bug reporting form
Тема BUG #15226: (Changes in) LIBPQ prevents proper error captures andcrash client programs instead
Дата
Msg-id 152802743109.26715.6575483050681335303@wrigleys.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #15226: (Changes in) LIBPQ prevents proper error captures andcrash client programs instead  (Jeff Janes <jeff.janes@gmail.com>)
Список pgsql-bugs
The following bug has been logged on the website:

Bug reference:      15226
Logged by:          Lance Zhang
Email address:      lance.zhang@gmail.com
PostgreSQL version: 10.4
Operating system:   Windows 10
Description:

This mimimal test program will not run properly if the SQL supplied is
illegal. It crashes inside libqp. No chance is offered to client program to
detect and correct the error with facilities like PQerrorMessage(...).

#include <stdio.h>
#include <libpq-fe.h>
#include <libpq/libpq-fs.h>

int main()
{
    PGresult * r;
    PGconn * conn;
    ExecStatusType status;
    
        /* Note: if it's a wrong password, the error can be detected and
processed decently. Not when you supply an 
         * non-exisiting dbname, etc. But this is not the point of this bug
report
         */
    conn=PQconnectdb("host=localhost dbname=postgres user=postgres
password='/*YOUR PASSWORD*/'");
    
    if( PQstatus(conn)!=  CONNECTION_OK ){
        fprintf(stderr, "Error connecting to database:%s!\n",
PQerrorMessage(conn));
        PQfinish(conn);
        exit(-1);
    }

        /* The next statement will crash the program inside libpq, because
of the illegal SQL statement */
    r=PQexec(conn,"SELECT SELECT FROM FROM");

        /* the error detection mechanism in the next statement never gets a
chance to be used */
    status=PQresultStatus(r);
    if(status==PGRES_BAD_RESPONSE || status==PGRES_FATAL_ERROR)
    {
        fprintf(stderr,"Error executing SQL:%s!\n", PQerrorMessage(conn));
        PQclear(r);
        PQfinish(conn);
        exit(-2);
    }
    

    PQclear(r);
    PQfinish(conn);
    
    return 0;
}


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

Предыдущее
От: PG Bug reporting form
Дата:
Сообщение: BUG #15225: [XX000] ERROR: invalid DSA memory alloc request size1073741824 / Where: parallel worker
Следующее
От: Jeff Janes
Дата:
Сообщение: Re: BUG #15226: (Changes in) LIBPQ prevents proper error captures andcrash client programs instead