@@ -875,7 +875,8 @@ PQconndefaults(void)
875
875
connOptions = conninfo_init (& errorBuf );
876
876
if (connOptions != NULL )
877
877
{
878
- if (!conninfo_add_defaults (connOptions ,& errorBuf ))
878
+ /* pass NULL errorBuf to ignore errors */
879
+ if (!conninfo_add_defaults (connOptions ,NULL ))
879
880
{
880
881
PQconninfoFree (connOptions );
881
882
connOptions = NULL ;
@@ -4412,9 +4413,10 @@ conninfo_array_parse(const char *const * keywords, const char *const * values,
4412
4413
*
4413
4414
* Defaults are obtained from a service file, environment variables, etc.
4414
4415
*
4415
- * Returns TRUE if successful, otherwise FALSE; errorMessage is filled in
4416
- * upon failure. Note that failure to locate a default value is not an
4417
- * error condition here --- we just leave the option's value as NULL.
4416
+ * Returns TRUE if successful, otherwise FALSE; errorMessage, if supplied,
4417
+ * is filled in upon failure. Note that failure to locate a default value
4418
+ * is not an error condition here --- we just leave the option's value as
4419
+ * NULL.
4418
4420
*/
4419
4421
static bool
4420
4422
conninfo_add_defaults (PQconninfoOption * options ,PQExpBuffer errorMessage )
@@ -4424,9 +4426,10 @@ conninfo_add_defaults(PQconninfoOption *options, PQExpBuffer errorMessage)
4424
4426
4425
4427
/*
4426
4428
* If there's a service spec, use it to obtain any not-explicitly-given
4427
- * parameters.
4429
+ * parameters. Ignore error if no error message buffer is passed
4430
+ * because there is no way to pass back the failure message.
4428
4431
*/
4429
- if (parseServiceInfo (options ,errorMessage )!= 0 )
4432
+ if (parseServiceInfo (options ,errorMessage )!= 0 && errorMessage )
4430
4433
return false;
4431
4434
4432
4435
/*
@@ -4448,8 +4451,9 @@ conninfo_add_defaults(PQconninfoOption *options, PQExpBuffer errorMessage)
4448
4451
option -> val = strdup (tmp );
4449
4452
if (!option -> val )
4450
4453
{
4451
- printfPQExpBuffer (errorMessage ,
4452
- libpq_gettext ("out of memory\n" ));
4454
+ if (errorMessage )
4455
+ printfPQExpBuffer (errorMessage ,
4456
+ libpq_gettext ("out of memory\n" ));
4453
4457
return false;
4454
4458
}
4455
4459
continue ;
@@ -4465,8 +4469,9 @@ conninfo_add_defaults(PQconninfoOption *options, PQExpBuffer errorMessage)
4465
4469
option -> val = strdup (option -> compiled );
4466
4470
if (!option -> val )
4467
4471
{
4468
- printfPQExpBuffer (errorMessage ,
4469
- libpq_gettext ("out of memory\n" ));
4472
+ if (errorMessage )
4473
+ printfPQExpBuffer (errorMessage ,
4474
+ libpq_gettext ("out of memory\n" ));
4470
4475
return false;
4471
4476
}
4472
4477
continue ;
@@ -4477,7 +4482,7 @@ conninfo_add_defaults(PQconninfoOption *options, PQExpBuffer errorMessage)
4477
4482
*/
4478
4483
if (strcmp (option -> keyword ,"user" )== 0 )
4479
4484
{
4480
- option -> val = pg_fe_getauthname (errorMessage );
4485
+ option -> val = pg_fe_getauthname ();
4481
4486
continue ;
4482
4487
}
4483
4488
}