5
5
* command, configuration file, and command line options.
6
6
* See src/backend/utils/misc/README for more information.
7
7
*
8
- * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.74 2002/07/20 06:17:43 momjian Exp $
8
+ * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.75 2002/07/20 15:12:55 tgl Exp $
9
9
*
10
10
* Copyright 2000 by PostgreSQL Global Development Group
11
11
* Written by Peter Eisentraut <peter_e@gmx.net>.
@@ -2185,13 +2185,13 @@ set_config_by_name(PG_FUNCTION_ARGS)
2185
2185
elog (ERROR , "SET variable name is required" );
2186
2186
2187
2187
/* Get the GUC variable name */
2188
- name = DatumGetCString (DirectFunctionCall1 (textout , PointerGetDatum ( PG_GETARG_TEXT_P ( 0 ) )));
2188
+ name = DatumGetCString (DirectFunctionCall1 (textout , PG_GETARG_DATUM ( 0 )));
2189
2189
2190
2190
/* Get the desired value or set to NULL for a reset request */
2191
2191
if (PG_ARGISNULL (1 ))
2192
2192
value = NULL ;
2193
2193
else
2194
- value = DatumGetCString (DirectFunctionCall1 (textout , PointerGetDatum ( PG_GETARG_TEXT_P ( 1 ) )));
2194
+ value = DatumGetCString (DirectFunctionCall1 (textout , PG_GETARG_DATUM ( 1 )));
2195
2195
2196
2196
/*
2197
2197
* Get the desired state of is_local. Default to false
@@ -2211,7 +2211,7 @@ set_config_by_name(PG_FUNCTION_ARGS)
2211
2211
true);
2212
2212
2213
2213
/* get the new current value */
2214
- new_value = GetConfigOptionByName (name );
2214
+ new_value = GetConfigOptionByName (name , NULL );
2215
2215
2216
2216
/* Convert return string to text */
2217
2217
result_text = DatumGetTextP (DirectFunctionCall1 (textin , CStringGetDatum (new_value )));
@@ -2259,21 +2259,22 @@ ShowGUCConfigOption(const char *name)
2259
2259
TupOutputState * tstate ;
2260
2260
TupleDesc tupdesc ;
2261
2261
CommandDest dest = whereToSendOutput ;
2262
+ const char * varname ;
2262
2263
char * value ;
2263
2264
2265
+ /* Get the value and canonical spelling of name */
2266
+ value = GetConfigOptionByName (name , & varname );
2267
+
2264
2268
/* need a tuple descriptor representing a single TEXT column */
2265
2269
tupdesc = CreateTemplateTupleDesc (1 , WITHOUTOID );
2266
- TupleDescInitEntry (tupdesc , (AttrNumber ) 1 , (char * ) name ,
2270
+ TupleDescInitEntry (tupdesc , (AttrNumber ) 1 , (char * ) varname ,
2267
2271
TEXTOID , -1 , 0 , false);
2268
2272
2269
2273
/* prepare for projection of tuples */
2270
2274
tstate = begin_tup_output_tupdesc (dest , tupdesc );
2271
2275
2272
- /* Get the value */
2273
- value = GetConfigOptionByName (name );
2274
-
2275
2276
/* Send it */
2276
- PROJECT_LINE_OF_TEXT (value );
2277
+ PROJECT_LINE_OF_TEXT (tstate , value );
2277
2278
2278
2279
end_tup_output (tstate );
2279
2280
}
@@ -2288,8 +2289,6 @@ ShowAllGUCConfig(void)
2288
2289
TupOutputState * tstate ;
2289
2290
TupleDesc tupdesc ;
2290
2291
CommandDest dest = whereToSendOutput ;
2291
- char * name ;
2292
- char * value ;
2293
2292
char * values [2 ];
2294
2293
2295
2294
/* need a tuple descriptor representing two TEXT columns */
@@ -2304,60 +2303,58 @@ ShowAllGUCConfig(void)
2304
2303
2305
2304
for (i = 0 ; i < num_guc_variables ; i ++ )
2306
2305
{
2307
- /* Get the next GUC variable name and value */
2308
- value = GetConfigOptionByNum (i , & name );
2306
+ struct config_generic * conf = guc_variables [i ];
2307
+
2308
+ if (conf -> flags & GUC_NO_SHOW_ALL )
2309
+ continue ;
2309
2310
2310
2311
/* assign to the values array */
2311
- values [0 ] = name ;
2312
- values [1 ] = value ;
2312
+ values [0 ] = ( char * ) conf -> name ;
2313
+ values [1 ] = _ShowOption ( conf ) ;
2313
2314
2314
2315
/* send it to dest */
2315
2316
do_tup_output (tstate , values );
2316
2317
2317
- /*
2318
- * clean up
2319
- */
2320
- /* we always should have a name */
2321
- pfree (name );
2322
-
2323
- /* but value can be returned to us as a NULL */
2324
- if (value != NULL )
2325
- pfree (value );
2318
+ /* clean up */
2319
+ if (values [1 ] != NULL )
2320
+ pfree (values [1 ]);
2326
2321
}
2327
2322
2328
2323
end_tup_output (tstate );
2329
2324
}
2330
2325
2331
2326
/*
2332
- * Return GUC variable value by name
2327
+ * Return GUC variable value by name; optionally return canonical
2328
+ * form of name. Return value is palloc'd.
2333
2329
*/
2334
2330
char *
2335
- GetConfigOptionByName (const char * name )
2331
+ GetConfigOptionByName (const char * name , const char * * varname )
2336
2332
{
2337
2333
struct config_generic * record ;
2338
2334
2339
2335
record = find_option (name );
2340
2336
if (record == NULL )
2341
2337
elog (ERROR , "Option '%s' is not recognized" , name );
2342
2338
2339
+ if (varname )
2340
+ * varname = record -> name ;
2341
+
2343
2342
return _ShowOption (record );
2344
2343
}
2345
2344
2346
2345
/*
2347
- * Return GUC variable value and set varname for a specific
2348
- * variable by number .
2346
+ * Return GUC variable value by variable number; optionally return canonical
2347
+ * form of name. Return value is palloc'd .
2349
2348
*/
2350
2349
char *
2351
- GetConfigOptionByNum (int varnum , char * * varname )
2350
+ GetConfigOptionByNum (int varnum , const char * * varname )
2352
2351
{
2353
2352
struct config_generic * conf = guc_variables [varnum ];
2354
2353
2355
- * varname = pstrdup (conf -> name );
2354
+ if (varname )
2355
+ * varname = conf -> name ;
2356
2356
2357
- if ((conf -> flags & GUC_NO_SHOW_ALL ) == 0 )
2358
- return _ShowOption (conf );
2359
- else
2360
- return NULL ;
2357
+ return _ShowOption (conf );
2361
2358
}
2362
2359
2363
2360
/*
@@ -2381,10 +2378,10 @@ show_config_by_name(PG_FUNCTION_ARGS)
2381
2378
text * result_text ;
2382
2379
2383
2380
/* Get the GUC variable name */
2384
- varname = DatumGetCString (DirectFunctionCall1 (textout , PointerGetDatum ( PG_GETARG_TEXT_P ( 0 ) )));
2381
+ varname = DatumGetCString (DirectFunctionCall1 (textout , PG_GETARG_DATUM ( 0 )));
2385
2382
2386
2383
/* Get the value */
2387
- varval = GetConfigOptionByName (varname );
2384
+ varval = GetConfigOptionByName (varname , NULL );
2388
2385
2389
2386
/* Convert to text */
2390
2387
result_text = DatumGetTextP (DirectFunctionCall1 (textin , CStringGetDatum (varval )));
0 commit comments