The appended patch addresses the outstanding issues of the recent guc patch. It makes PGCLIENTENCODING work again and uses bsearch() instead of iterating over the array of guc variables in guc_get_index().
Joachim
Index: src/backend/utils/misc/guc.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/utils/misc/guc.c,v retrieving revision 1.390 diff -c -r1.390 guc.c *** src/backend/utils/misc/guc.c 4 May 2007 01:13:44 -0000 1.390 --- src/backend/utils/misc/guc.c 4 May 2007 16:14:21 -0000 *************** *** 2692,2709 **** return true; } - static int - guc_get_index(const char *name) - { - int i; - - for (i = 0; i < num_guc_variables; i++) - if (guc_name_compare(name, guc_variables[i]->name) == 0) - return i; - - return -1; - } - /* * Create and add a placeholder variable. It's presumed to belong * to a valid custom variable class at this point. --- 2692,2697 ---- *************** *** 2843,2848 **** --- 2831,2860 ---- } + static int + guc_get_index(const char *name) + { + const char **key = &name; + struct config_generic **res; + + Assert(name); + + /* + * By equating const char ** with struct config_generic *, we are assuming + * the name field is first in config_generic. + */ + res = (struct config_generic **) bsearch((void *) &key, + (void *) guc_variables, + num_guc_variables, + sizeof(struct config_generic *), + guc_var_compare); + if (!res) + return -1; + + return res - guc_variables; + } + + /* * Initialize GUC options during program startup. * *************** *** 4095,4103 **** * we can't set the variable itself. There's one exception to * this rule: if we want to apply the default value to variables * that were removed from the configuration file. This is ! * indicated by source == PGC_S_DEFAULT. */ ! if (record->source > source && source != PGC_S_DEFAULT) { if (changeVal && !makeDefault) { --- 4107,4116 ---- * we can't set the variable itself. There's one exception to * this rule: if we want to apply the default value to variables * that were removed from the configuration file. This is ! * indicated by source == PGC_S_DEFAULT and context == PGC_SIGHUP. */ ! if (record->source > source ! && (source != PGC_S_DEFAULT || context != PGC_SIGHUP)) { if (changeVal && !makeDefault) {
---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster