Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c33a634

Browse files
committed
Code review for SHOW output changes; fix horology expected files for
new SHOW output format.
1 parent a58930b commit c33a634

File tree

8 files changed

+105
-68
lines changed

8 files changed

+105
-68
lines changed

doc/src/sgml/release.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.142 2002/07/18 23:11:27 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.143 2002/07/20 15:12:55 tgl Exp $
33
-->
44

55
<appendix id="release">
@@ -40,7 +40,7 @@ Readline and Zlib are now required by default and must be turned off explicitly
4040
Define a third class of function volatility to allow indexscans in more cases
4141
Locale support is now built by default; choice of locale is set by initdb and/or at run-time
4242
ALTER TABLE ALTER COLUMN SET/DROP NOT NULL
43-
EXPLAIN output comes out as a query result, not a NOTICE message
43+
EXPLAIN and SHOW output comes out as a query result, not a NOTICE message
4444
DOMAINs (types that are constrained versions of base types)
4545
Access privileges on functions
4646
Access privileges on procedural languages

src/backend/commands/explain.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994-5, Regents of the University of California
77
*
8-
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.83 2002/07/20 06:17:43 momjian Exp $
8+
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.84 2002/07/20 15:12:55 tgl Exp $
99
*
1010
*/
1111

@@ -79,7 +79,7 @@ ExplainQuery(ExplainStmt *stmt, CommandDest dest)
7979
if (query->commandType == CMD_UTILITY)
8080
{
8181
/* rewriter will not cope with utility statements */
82-
PROJECT_LINE_OF_TEXT("Utility statements have no plan structure");
82+
PROJECT_LINE_OF_TEXT(tstate, "Utility statements have no plan structure");
8383
}
8484
else
8585
{
@@ -89,7 +89,7 @@ ExplainQuery(ExplainStmt *stmt, CommandDest dest)
8989
if (rewritten == NIL)
9090
{
9191
/* In the case of an INSTEAD NOTHING, tell at least that */
92-
PROJECT_LINE_OF_TEXT("Query rewrites to nothing");
92+
PROJECT_LINE_OF_TEXT(tstate, "Query rewrites to nothing");
9393
}
9494
else
9595
{
@@ -99,7 +99,7 @@ ExplainQuery(ExplainStmt *stmt, CommandDest dest)
9999
ExplainOneQuery(lfirst(l), stmt, tstate);
100100
/* put a blank line between plans */
101101
if (lnext(l) != NIL)
102-
PROJECT_LINE_OF_TEXT("");
102+
PROJECT_LINE_OF_TEXT(tstate, "");
103103
}
104104
}
105105
}
@@ -122,9 +122,9 @@ ExplainOneQuery(Query *query, ExplainStmt *stmt, TupOutputState *tstate)
122122
if (query->commandType == CMD_UTILITY)
123123
{
124124
if (query->utilityStmt && IsA(query->utilityStmt, NotifyStmt))
125-
PROJECT_LINE_OF_TEXT("NOTIFY");
125+
PROJECT_LINE_OF_TEXT(tstate, "NOTIFY");
126126
else
127-
PROJECT_LINE_OF_TEXT("UTILITY");
127+
PROJECT_LINE_OF_TEXT(tstate, "UTILITY");
128128
return;
129129
}
130130

@@ -189,7 +189,7 @@ ExplainOneQuery(Query *query, ExplainStmt *stmt, TupOutputState *tstate)
189189
do_text_output_multiline(tstate, f);
190190
pfree(f);
191191
if (es->printCost)
192-
PROJECT_LINE_OF_TEXT(""); /* separator line */
192+
PROJECT_LINE_OF_TEXT(tstate, ""); /* separator line */
193193
}
194194
}
195195

src/backend/utils/misc/guc.c

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* command, configuration file, and command line options.
66
* See src/backend/utils/misc/README for more information.
77
*
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 $
99
*
1010
* Copyright 2000 by PostgreSQL Global Development Group
1111
* Written by Peter Eisentraut <peter_e@gmx.net>.
@@ -2185,13 +2185,13 @@ set_config_by_name(PG_FUNCTION_ARGS)
21852185
elog(ERROR, "SET variable name is required");
21862186

21872187
/* 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)));
21892189

21902190
/* Get the desired value or set to NULL for a reset request */
21912191
if (PG_ARGISNULL(1))
21922192
value = NULL;
21932193
else
2194-
value = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(1))));
2194+
value = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(1)));
21952195

21962196
/*
21972197
* Get the desired state of is_local. Default to false
@@ -2211,7 +2211,7 @@ set_config_by_name(PG_FUNCTION_ARGS)
22112211
true);
22122212

22132213
/* get the new current value */
2214-
new_value = GetConfigOptionByName(name);
2214+
new_value = GetConfigOptionByName(name, NULL);
22152215

22162216
/* Convert return string to text */
22172217
result_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(new_value)));
@@ -2259,21 +2259,22 @@ ShowGUCConfigOption(const char *name)
22592259
TupOutputState *tstate;
22602260
TupleDesc tupdesc;
22612261
CommandDest dest = whereToSendOutput;
2262+
const char *varname;
22622263
char *value;
22632264

2265+
/* Get the value and canonical spelling of name */
2266+
value = GetConfigOptionByName(name, &varname);
2267+
22642268
/* need a tuple descriptor representing a single TEXT column */
22652269
tupdesc = CreateTemplateTupleDesc(1, WITHOUTOID);
2266-
TupleDescInitEntry(tupdesc, (AttrNumber) 1, (char *) name,
2270+
TupleDescInitEntry(tupdesc, (AttrNumber) 1, (char *) varname,
22672271
TEXTOID, -1, 0, false);
22682272

22692273
/* prepare for projection of tuples */
22702274
tstate = begin_tup_output_tupdesc(dest, tupdesc);
22712275

2272-
/* Get the value */
2273-
value = GetConfigOptionByName(name);
2274-
22752276
/* Send it */
2276-
PROJECT_LINE_OF_TEXT(value);
2277+
PROJECT_LINE_OF_TEXT(tstate, value);
22772278

22782279
end_tup_output(tstate);
22792280
}
@@ -2288,8 +2289,6 @@ ShowAllGUCConfig(void)
22882289
TupOutputState *tstate;
22892290
TupleDesc tupdesc;
22902291
CommandDest dest = whereToSendOutput;
2291-
char *name;
2292-
char *value;
22932292
char *values[2];
22942293

22952294
/* need a tuple descriptor representing two TEXT columns */
@@ -2304,60 +2303,58 @@ ShowAllGUCConfig(void)
23042303

23052304
for (i = 0; i < num_guc_variables; i++)
23062305
{
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;
23092310

23102311
/* assign to the values array */
2311-
values[0] = name;
2312-
values[1] = value;
2312+
values[0] = (char *) conf->name;
2313+
values[1] = _ShowOption(conf);
23132314

23142315
/* send it to dest */
23152316
do_tup_output(tstate, values);
23162317

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]);
23262321
}
23272322

23282323
end_tup_output(tstate);
23292324
}
23302325

23312326
/*
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.
23332329
*/
23342330
char *
2335-
GetConfigOptionByName(const char *name)
2331+
GetConfigOptionByName(const char *name, const char **varname)
23362332
{
23372333
struct config_generic *record;
23382334

23392335
record = find_option(name);
23402336
if (record == NULL)
23412337
elog(ERROR, "Option '%s' is not recognized", name);
23422338

2339+
if (varname)
2340+
*varname = record->name;
2341+
23432342
return _ShowOption(record);
23442343
}
23452344

23462345
/*
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.
23492348
*/
23502349
char *
2351-
GetConfigOptionByNum(int varnum, char **varname)
2350+
GetConfigOptionByNum(int varnum, const char **varname)
23522351
{
23532352
struct config_generic *conf = guc_variables[varnum];
23542353

2355-
*varname = pstrdup(conf->name);
2354+
if (varname)
2355+
*varname = conf->name;
23562356

2357-
if ((conf->flags & GUC_NO_SHOW_ALL) == 0)
2358-
return _ShowOption(conf);
2359-
else
2360-
return NULL;
2357+
return _ShowOption(conf);
23612358
}
23622359

23632360
/*
@@ -2381,10 +2378,10 @@ show_config_by_name(PG_FUNCTION_ARGS)
23812378
text *result_text;
23822379

23832380
/* 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)));
23852382

23862383
/* Get the value */
2387-
varval = GetConfigOptionByName(varname);
2384+
varval = GetConfigOptionByName(varname, NULL);
23882385

23892386
/* Convert to text */
23902387
result_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(varval)));

src/include/executor/executor.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: executor.h,v 1.71 2002/07/20 05:49:28 momjian Exp $
10+
* $Id: executor.h,v 1.72 2002/07/20 15:12:55 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -132,11 +132,11 @@ extern void do_tup_output(TupOutputState *tstate, char **values);
132132
extern void do_text_output_multiline(TupOutputState *tstate, char *text);
133133
extern void end_tup_output(TupOutputState *tstate);
134134

135-
#define PROJECT_LINE_OF_TEXT(text_to_project) \
135+
#define PROJECT_LINE_OF_TEXT(tstate, text_to_project) \
136136
do { \
137-
char *values[1]; \
138-
values[0] = text_to_project; \
139-
do_tup_output(tstate, values); \
137+
char *values_[1]; \
138+
values_[0] = (text_to_project); \
139+
do_tup_output(tstate, values_); \
140140
} while (0)
141141

142142

src/include/utils/guc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* External declarations pertaining to backend/utils/misc/guc.c and
55
* backend/utils/misc/guc-file.l
66
*
7-
* $Id: guc.h,v 1.18 2002/07/20 05:49:28 momjian Exp $
7+
* $Id: guc.h,v 1.19 2002/07/20 15:12:56 tgl Exp $
88
*/
99
#ifndef GUC_H
1010
#define GUC_H
@@ -86,8 +86,8 @@ extern bool set_config_option(const char *name, const char *value,
8686
bool isLocal, bool DoIt);
8787
extern void ShowGUCConfigOption(const char *name);
8888
extern void ShowAllGUCConfig(void);
89-
extern char *GetConfigOptionByName(const char *name);
90-
extern char *GetConfigOptionByNum(int varnum, char **varname);
89+
extern char *GetConfigOptionByName(const char *name, const char **varname);
90+
extern char *GetConfigOptionByNum(int varnum, const char **varname);
9191
extern int GetNumConfigOptions(void);
9292

9393
extern void SetPGVariable(const char *name, List *args, bool is_local);

src/test/regress/expected/horology-no-DST-before-1970.out

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2341,7 +2341,11 @@ DROP TABLE TEMP_TIMESTAMP;
23412341
--
23422342
SET DateStyle TO 'US,Postgres';
23432343
SHOW DateStyle;
2344-
INFO: DateStyle is Postgres with US (NonEuropean) conventions
2344+
DateStyle
2345+
--------------------------------------------
2346+
Postgres with US (NonEuropean) conventions
2347+
(1 row)
2348+
23452349
SELECT '' AS "64", d1 AS us_postgres FROM TIMESTAMP_TBL;
23462350
64 | us_postgres
23472351
----+-----------------------------
@@ -2507,7 +2511,11 @@ SELECT '' AS seven, f1 AS us_iso FROM ABSTIME_TBL;
25072511

25082512
SET DateStyle TO 'US,SQL';
25092513
SHOW DateStyle;
2510-
INFO: DateStyle is SQL with US (NonEuropean) conventions
2514+
DateStyle
2515+
---------------------------------------
2516+
SQL with US (NonEuropean) conventions
2517+
(1 row)
2518+
25112519
SELECT '' AS "64", d1 AS us_sql FROM TIMESTAMP_TBL;
25122520
64 | us_sql
25132521
----+------------------------
@@ -2591,7 +2599,11 @@ SELECT '' AS seven, f1 AS us_sql FROM ABSTIME_TBL;
25912599

25922600
SET DateStyle TO 'European,Postgres';
25932601
SHOW DateStyle;
2594-
INFO: DateStyle is Postgres with European conventions
2602+
DateStyle
2603+
------------------------------------
2604+
Postgres with European conventions
2605+
(1 row)
2606+
25952607
INSERT INTO TIMESTAMP_TBL VALUES('13/06/1957');
25962608
SELECT count(*) as one FROM TIMESTAMP_TBL WHERE d1 = 'Jun 13 1957';
25972609
one
@@ -2683,7 +2695,11 @@ SELECT '' AS seven, f1 AS european_postgres FROM ABSTIME_TBL;
26832695

26842696
SET DateStyle TO 'European,ISO';
26852697
SHOW DateStyle;
2686-
INFO: DateStyle is ISO with European conventions
2698+
DateStyle
2699+
-------------------------------
2700+
ISO with European conventions
2701+
(1 row)
2702+
26872703
SELECT '' AS "65", d1 AS european_iso FROM TIMESTAMP_TBL;
26882704
65 | european_iso
26892705
----+------------------------
@@ -2768,7 +2784,11 @@ SELECT '' AS seven, f1 AS european_iso FROM ABSTIME_TBL;
27682784

27692785
SET DateStyle TO 'European,SQL';
27702786
SHOW DateStyle;
2771-
INFO: DateStyle is SQL with European conventions
2787+
DateStyle
2788+
-------------------------------
2789+
SQL with European conventions
2790+
(1 row)
2791+
27722792
SELECT '' AS "65", d1 AS european_sql FROM TIMESTAMP_TBL;
27732793
65 | european_sql
27742794
----+------------------------

0 commit comments

Comments
 (0)