pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15226: (Changes in) LIBPQ prevents proper error captures and crash client programs instead
2+ messages / 2 participants
[nested] [flat]

* BUG #15226: (Changes in) LIBPQ prevents proper error captures and crash client programs instead
@ 2018-06-03 12:03 PG Bug reporting form <noreply@postgresql.org>
  2018-06-03 12:55 ` Re: BUG #15226: (Changes in) LIBPQ prevents proper error captures and crash client programs instead Jeff Janes <jeff.janes@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2018-06-03 12:03 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: lance.zhang@gmail.com

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;
}



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #15226: (Changes in) LIBPQ prevents proper error captures and crash client programs instead
  2018-06-03 12:03 BUG #15226: (Changes in) LIBPQ prevents proper error captures and crash client programs instead PG Bug reporting form <noreply@postgresql.org>
@ 2018-06-03 12:55 ` Jeff Janes <jeff.janes@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Jeff Janes @ 2018-06-03 12:55 UTC (permalink / raw)
  To: lance.zhang@gmail.com; pgsql-bugs@lists.postgresql.org

On Sun, Jun 3, 2018 at 8:03 AM, PG Bug reporting form <
noreply@postgresql.org> wrote:

> 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(...).
>
>
Works for me.  What is your build chain and compilation command line?  How
did you install PostgreSQL?

Cheers,

Jeff

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-06-03 12:55 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-06-03 12:03 BUG #15226: (Changes in) LIBPQ prevents proper error captures and crash client programs instead PG Bug reporting form <noreply@postgresql.org>
2018-06-03 12:55 ` Jeff Janes <jeff.janes@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox