Don't segfault when PQparameterStatus(DateStyle) returns NULL

pgbouncer for example does not pass on DateStyle.
This commit is contained in:
Marti Raudsepp 2010-12-09 16:22:20 +02:00 committed by Daniele Varrazzo
parent 5a0cfad95f
commit a08419406c

View File

@ -299,6 +299,10 @@ conn_is_datestyle_ok(PGconn *pgconn)
ds = PQparameterStatus(pgconn, "DateStyle");
Dprintf("conn_connect: DateStyle %s", ds);
/* pgbouncer does not pass on DateStyle */
if (ds == NULL)
return 0;
/* Return true if ds starts with "ISO"
* e.g. "ISO, DMY" is fine, "German" not. */
return (ds[0] == 'I' && ds[1] == 'S' && ds[2] == 'O');