Code review for SHOW output changes; fix horology expected files for

new SHOW output format.
This commit is contained in:
Tom Lane 2002-07-20 15:12:56 +00:00
parent a58930bbd5
commit c33a6343cd
8 changed files with 105 additions and 68 deletions

View File

@ -1,5 +1,5 @@
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.142 2002/07/18 23:11:27 petere Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.143 2002/07/20 15:12:55 tgl Exp $
-->
<appendix id="release">
@ -40,7 +40,7 @@ Readline and Zlib are now required by default and must be turned off explicitly
Define a third class of function volatility to allow indexscans in more cases
Locale support is now built by default; choice of locale is set by initdb and/or at run-time
ALTER TABLE ALTER COLUMN SET/DROP NOT NULL
EXPLAIN output comes out as a query result, not a NOTICE message
EXPLAIN and SHOW output comes out as a query result, not a NOTICE message
DOMAINs (types that are constrained versions of base types)
Access privileges on functions
Access privileges on procedural languages

View File

@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994-5, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.83 2002/07/20 06:17:43 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.84 2002/07/20 15:12:55 tgl Exp $
*
*/
@ -79,7 +79,7 @@ ExplainQuery(ExplainStmt *stmt, CommandDest dest)
if (query->commandType == CMD_UTILITY)
{
/* rewriter will not cope with utility statements */
PROJECT_LINE_OF_TEXT("Utility statements have no plan structure");
PROJECT_LINE_OF_TEXT(tstate, "Utility statements have no plan structure");
}
else
{
@ -89,7 +89,7 @@ ExplainQuery(ExplainStmt *stmt, CommandDest dest)
if (rewritten == NIL)
{
/* In the case of an INSTEAD NOTHING, tell at least that */
PROJECT_LINE_OF_TEXT("Query rewrites to nothing");
PROJECT_LINE_OF_TEXT(tstate, "Query rewrites to nothing");
}
else
{
@ -99,7 +99,7 @@ ExplainQuery(ExplainStmt *stmt, CommandDest dest)
ExplainOneQuery(lfirst(l), stmt, tstate);
/* put a blank line between plans */
if (lnext(l) != NIL)
PROJECT_LINE_OF_TEXT("");
PROJECT_LINE_OF_TEXT(tstate, "");
}
}
}
@ -122,9 +122,9 @@ ExplainOneQuery(Query *query, ExplainStmt *stmt, TupOutputState *tstate)
if (query->commandType == CMD_UTILITY)
{
if (query->utilityStmt && IsA(query->utilityStmt, NotifyStmt))
PROJECT_LINE_OF_TEXT("NOTIFY");
PROJECT_LINE_OF_TEXT(tstate, "NOTIFY");
else
PROJECT_LINE_OF_TEXT("UTILITY");
PROJECT_LINE_OF_TEXT(tstate, "UTILITY");
return;
}
@ -189,7 +189,7 @@ ExplainOneQuery(Query *query, ExplainStmt *stmt, TupOutputState *tstate)
do_text_output_multiline(tstate, f);
pfree(f);
if (es->printCost)
PROJECT_LINE_OF_TEXT(""); /* separator line */
PROJECT_LINE_OF_TEXT(tstate, ""); /* separator line */
}
}

View File

@ -5,7 +5,7 @@
* command, configuration file, and command line options.
* See src/backend/utils/misc/README for more information.
*
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.74 2002/07/20 06:17:43 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.75 2002/07/20 15:12:55 tgl Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
@ -2185,13 +2185,13 @@ set_config_by_name(PG_FUNCTION_ARGS)
elog(ERROR, "SET variable name is required");
/* Get the GUC variable name */
name = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(0))));
name = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(0)));
/* Get the desired value or set to NULL for a reset request */
if (PG_ARGISNULL(1))
value = NULL;
else
value = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(1))));
value = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(1)));
/*
* Get the desired state of is_local. Default to false
@ -2211,7 +2211,7 @@ set_config_by_name(PG_FUNCTION_ARGS)
true);
/* get the new current value */
new_value = GetConfigOptionByName(name);
new_value = GetConfigOptionByName(name, NULL);
/* Convert return string to text */
result_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(new_value)));
@ -2259,21 +2259,22 @@ ShowGUCConfigOption(const char *name)
TupOutputState *tstate;
TupleDesc tupdesc;
CommandDest dest = whereToSendOutput;
const char *varname;
char *value;
/* Get the value and canonical spelling of name */
value = GetConfigOptionByName(name, &varname);
/* need a tuple descriptor representing a single TEXT column */
tupdesc = CreateTemplateTupleDesc(1, WITHOUTOID);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, (char *) name,
TupleDescInitEntry(tupdesc, (AttrNumber) 1, (char *) varname,
TEXTOID, -1, 0, false);
/* prepare for projection of tuples */
tstate = begin_tup_output_tupdesc(dest, tupdesc);
/* Get the value */
value = GetConfigOptionByName(name);
/* Send it */
PROJECT_LINE_OF_TEXT(value);
PROJECT_LINE_OF_TEXT(tstate, value);
end_tup_output(tstate);
}
@ -2288,8 +2289,6 @@ ShowAllGUCConfig(void)
TupOutputState *tstate;
TupleDesc tupdesc;
CommandDest dest = whereToSendOutput;
char *name;
char *value;
char *values[2];
/* need a tuple descriptor representing two TEXT columns */
@ -2304,35 +2303,32 @@ ShowAllGUCConfig(void)
for (i = 0; i < num_guc_variables; i++)
{
/* Get the next GUC variable name and value */
value = GetConfigOptionByNum(i, &name);
struct config_generic *conf = guc_variables[i];
if (conf->flags & GUC_NO_SHOW_ALL)
continue;
/* assign to the values array */
values[0] = name;
values[1] = value;
values[0] = (char *) conf->name;
values[1] = _ShowOption(conf);
/* send it to dest */
do_tup_output(tstate, values);
/*
* clean up
*/
/* we always should have a name */
pfree(name);
/* but value can be returned to us as a NULL */
if (value != NULL)
pfree(value);
/* clean up */
if (values[1] != NULL)
pfree(values[1]);
}
end_tup_output(tstate);
}
/*
* Return GUC variable value by name
* Return GUC variable value by name; optionally return canonical
* form of name. Return value is palloc'd.
*/
char *
GetConfigOptionByName(const char *name)
GetConfigOptionByName(const char *name, const char **varname)
{
struct config_generic *record;
@ -2340,24 +2336,25 @@ GetConfigOptionByName(const char *name)
if (record == NULL)
elog(ERROR, "Option '%s' is not recognized", name);
if (varname)
*varname = record->name;
return _ShowOption(record);
}
/*
* Return GUC variable value and set varname for a specific
* variable by number.
* Return GUC variable value by variable number; optionally return canonical
* form of name. Return value is palloc'd.
*/
char *
GetConfigOptionByNum(int varnum, char **varname)
GetConfigOptionByNum(int varnum, const char **varname)
{
struct config_generic *conf = guc_variables[varnum];
*varname = pstrdup(conf->name);
if (varname)
*varname = conf->name;
if ((conf->flags & GUC_NO_SHOW_ALL) == 0)
return _ShowOption(conf);
else
return NULL;
return _ShowOption(conf);
}
/*
@ -2381,10 +2378,10 @@ show_config_by_name(PG_FUNCTION_ARGS)
text *result_text;
/* Get the GUC variable name */
varname = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(0))));
varname = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(0)));
/* Get the value */
varval = GetConfigOptionByName(varname);
varval = GetConfigOptionByName(varname, NULL);
/* Convert to text */
result_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(varval)));

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: executor.h,v 1.71 2002/07/20 05:49:28 momjian Exp $
* $Id: executor.h,v 1.72 2002/07/20 15:12:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -132,11 +132,11 @@ extern void do_tup_output(TupOutputState *tstate, char **values);
extern void do_text_output_multiline(TupOutputState *tstate, char *text);
extern void end_tup_output(TupOutputState *tstate);
#define PROJECT_LINE_OF_TEXT(text_to_project) \
#define PROJECT_LINE_OF_TEXT(tstate, text_to_project) \
do { \
char *values[1]; \
values[0] = text_to_project; \
do_tup_output(tstate, values); \
char *values_[1]; \
values_[0] = (text_to_project); \
do_tup_output(tstate, values_); \
} while (0)

View File

@ -4,7 +4,7 @@
* External declarations pertaining to backend/utils/misc/guc.c and
* backend/utils/misc/guc-file.l
*
* $Id: guc.h,v 1.18 2002/07/20 05:49:28 momjian Exp $
* $Id: guc.h,v 1.19 2002/07/20 15:12:56 tgl Exp $
*/
#ifndef GUC_H
#define GUC_H
@ -86,8 +86,8 @@ extern bool set_config_option(const char *name, const char *value,
bool isLocal, bool DoIt);
extern void ShowGUCConfigOption(const char *name);
extern void ShowAllGUCConfig(void);
extern char *GetConfigOptionByName(const char *name);
extern char *GetConfigOptionByNum(int varnum, char **varname);
extern char *GetConfigOptionByName(const char *name, const char **varname);
extern char *GetConfigOptionByNum(int varnum, const char **varname);
extern int GetNumConfigOptions(void);
extern void SetPGVariable(const char *name, List *args, bool is_local);

View File

@ -2341,7 +2341,11 @@ DROP TABLE TEMP_TIMESTAMP;
--
SET DateStyle TO 'US,Postgres';
SHOW DateStyle;
INFO: DateStyle is Postgres with US (NonEuropean) conventions
DateStyle
--------------------------------------------
Postgres with US (NonEuropean) conventions
(1 row)
SELECT '' AS "64", d1 AS us_postgres FROM TIMESTAMP_TBL;
64 | us_postgres
----+-----------------------------
@ -2507,7 +2511,11 @@ SELECT '' AS seven, f1 AS us_iso FROM ABSTIME_TBL;
SET DateStyle TO 'US,SQL';
SHOW DateStyle;
INFO: DateStyle is SQL with US (NonEuropean) conventions
DateStyle
---------------------------------------
SQL with US (NonEuropean) conventions
(1 row)
SELECT '' AS "64", d1 AS us_sql FROM TIMESTAMP_TBL;
64 | us_sql
----+------------------------
@ -2591,7 +2599,11 @@ SELECT '' AS seven, f1 AS us_sql FROM ABSTIME_TBL;
SET DateStyle TO 'European,Postgres';
SHOW DateStyle;
INFO: DateStyle is Postgres with European conventions
DateStyle
------------------------------------
Postgres with European conventions
(1 row)
INSERT INTO TIMESTAMP_TBL VALUES('13/06/1957');
SELECT count(*) as one FROM TIMESTAMP_TBL WHERE d1 = 'Jun 13 1957';
one
@ -2683,7 +2695,11 @@ SELECT '' AS seven, f1 AS european_postgres FROM ABSTIME_TBL;
SET DateStyle TO 'European,ISO';
SHOW DateStyle;
INFO: DateStyle is ISO with European conventions
DateStyle
-------------------------------
ISO with European conventions
(1 row)
SELECT '' AS "65", d1 AS european_iso FROM TIMESTAMP_TBL;
65 | european_iso
----+------------------------
@ -2768,7 +2784,11 @@ SELECT '' AS seven, f1 AS european_iso FROM ABSTIME_TBL;
SET DateStyle TO 'European,SQL';
SHOW DateStyle;
INFO: DateStyle is SQL with European conventions
DateStyle
-------------------------------
SQL with European conventions
(1 row)
SELECT '' AS "65", d1 AS european_sql FROM TIMESTAMP_TBL;
65 | european_sql
----+------------------------

View File

@ -2341,7 +2341,11 @@ DROP TABLE TEMP_TIMESTAMP;
--
SET DateStyle TO 'US,Postgres';
SHOW DateStyle;
INFO: DateStyle is Postgres with US (NonEuropean) conventions
DateStyle
--------------------------------------------
Postgres with US (NonEuropean) conventions
(1 row)
SELECT '' AS "64", d1 AS us_postgres FROM TIMESTAMP_TBL;
64 | us_postgres
----+-----------------------------
@ -2507,7 +2511,11 @@ SELECT '' AS seven, f1 AS us_iso FROM ABSTIME_TBL;
SET DateStyle TO 'US,SQL';
SHOW DateStyle;
INFO: DateStyle is SQL with US (NonEuropean) conventions
DateStyle
---------------------------------------
SQL with US (NonEuropean) conventions
(1 row)
SELECT '' AS "64", d1 AS us_sql FROM TIMESTAMP_TBL;
64 | us_sql
----+------------------------
@ -2591,7 +2599,11 @@ SELECT '' AS seven, f1 AS us_sql FROM ABSTIME_TBL;
SET DateStyle TO 'European,Postgres';
SHOW DateStyle;
INFO: DateStyle is Postgres with European conventions
DateStyle
------------------------------------
Postgres with European conventions
(1 row)
INSERT INTO TIMESTAMP_TBL VALUES('13/06/1957');
SELECT count(*) as one FROM TIMESTAMP_TBL WHERE d1 = 'Jun 13 1957';
one
@ -2683,7 +2695,11 @@ SELECT '' AS seven, f1 AS european_postgres FROM ABSTIME_TBL;
SET DateStyle TO 'European,ISO';
SHOW DateStyle;
INFO: DateStyle is ISO with European conventions
DateStyle
-------------------------------
ISO with European conventions
(1 row)
SELECT '' AS "65", d1 AS european_iso FROM TIMESTAMP_TBL;
65 | european_iso
----+------------------------
@ -2768,7 +2784,11 @@ SELECT '' AS seven, f1 AS european_iso FROM ABSTIME_TBL;
SET DateStyle TO 'European,SQL';
SHOW DateStyle;
INFO: DateStyle is SQL with European conventions
DateStyle
-------------------------------
SQL with European conventions
(1 row)
SELECT '' AS "65", d1 AS european_sql FROM TIMESTAMP_TBL;
65 | european_sql
----+------------------------

View File

@ -2341,7 +2341,7 @@ DROP TABLE TEMP_TIMESTAMP;
--
SET DateStyle TO 'US,Postgres';
SHOW DateStyle;
datestyle
DateStyle
--------------------------------------------
Postgres with US (NonEuropean) conventions
(1 row)
@ -2511,7 +2511,7 @@ SELECT '' AS seven, f1 AS us_iso FROM ABSTIME_TBL;
SET DateStyle TO 'US,SQL';
SHOW DateStyle;
datestyle
DateStyle
---------------------------------------
SQL with US (NonEuropean) conventions
(1 row)
@ -2599,7 +2599,7 @@ SELECT '' AS seven, f1 AS us_sql FROM ABSTIME_TBL;
SET DateStyle TO 'European,Postgres';
SHOW DateStyle;
datestyle
DateStyle
------------------------------------
Postgres with European conventions
(1 row)
@ -2695,7 +2695,7 @@ SELECT '' AS seven, f1 AS european_postgres FROM ABSTIME_TBL;
SET DateStyle TO 'European,ISO';
SHOW DateStyle;
datestyle
DateStyle
-------------------------------
ISO with European conventions
(1 row)
@ -2784,7 +2784,7 @@ SELECT '' AS seven, f1 AS european_iso FROM ABSTIME_TBL;
SET DateStyle TO 'European,SQL';
SHOW DateStyle;
datestyle
DateStyle
-------------------------------
SQL with European conventions
(1 row)