Index: src/interfaces/libpq/fe-connect.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v retrieving revision 1.326 diff -c -r1.326 fe-connect.c *** src/interfaces/libpq/fe-connect.c 13 Feb 2006 22:33:57 -0000 1.326 --- src/interfaces/libpq/fe-connect.c 15 Feb 2006 18:21:06 -0000 *************** *** 96,105 **** * fallback is available. If after all no value can be determined * for an option, an error is returned. * - * The value for the username is treated specially in conninfo_parse. - * If the Compiled-in resource is specified as a NULL value, the - * user is determined by pg_fe_getauthname(). - * * The Label and Disp-Char entries are provided for applications that * want to use PQconndefaults() to create a generic database connection * dialog. Disp-Char is defined as follows: --- 96,101 ---- *************** *** 423,434 **** --- 419,448 ---- * * Compute derived connection options after absorbing all user-supplied info. * + * The value for the username is treated specially in connectOptions2. + * If the Compiled-in resource is specified as a NULL value and the user + * doesn't provide a username to use then the user is determined by + * calling pg_fe_getauthname(). + * * Returns true if OK, false if trouble (in which case errorMessage is set * and so is conn->status). */ static bool connectOptions2(PGconn *conn) { + char errortmp[PQERRORMSG_LENGTH]; + + /* + * Find username to use if none given. This may call + * additional helpers (ie: krb5) if those auth methods + * are compiled in. + */ + if (conn->pguser == NULL || conn->pguser[0] == '\0') + { + conn->pguser = pg_fe_getauthname(errortmp); + /* note any error message is thrown away */ + } + /* * If database name was not given, default it to equal user name */ *************** *** 2505,2511 **** char *cp2; PQconninfoOption *options; PQconninfoOption *option; - char errortmp[PQERRORMSG_LENGTH]; /* Make a working copy of PQconninfoOptions */ options = malloc(sizeof(PQconninfoOptions)); --- 2519,2524 ---- *************** *** 2722,2737 **** } continue; } - - /* - * Special handling for user - */ - if (strcmp(option->keyword, "user") == 0) - { - option->val = pg_fe_getauthname(errortmp); - /* note any error message is thrown away */ - continue; - } } return options; --- 2735,2740 ----