Code review for SHOW output changes; fix horology expected files for
authorTom Lane
Sat, 20 Jul 2002 15:12:56 +0000 (15:12 +0000)
committerTom Lane
Sat, 20 Jul 2002 15:12:56 +0000 (15:12 +0000)
new SHOW output format.

doc/src/sgml/release.sgml
src/backend/commands/explain.c
src/backend/utils/misc/guc.c
src/include/executor/executor.h
src/include/utils/guc.h
src/test/regress/expected/horology-no-DST-before-1970.out
src/test/regress/expected/horology-solaris-1947.out
src/test/regress/expected/horology.out

index 4f7911ff4e1dc543487b836663d10ae9556d9f9e..47f36858f9277811d10e7e93ddae1208c40e8701 100644 (file)
@@ -1,5 +1,5 @@
 
 
 
@@ -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
index 2f2178bf9a64298d259f447ccfc0390a5556f13b..13cf272525c85f79f68e039300fadb4af3def302 100644 (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 */
        }
    }
 
index 58ff0918a71eec70220834c3e8a1bca508f255b2..c90c52e8ccfd5a9f7dc9ac53903d2ec60e447bb1 100644 (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 .
@@ -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)));
index 5b121546d960529ef7d11bc1fe9c9f7590a06236..9eb7367f2e362b01708324c910f05511a24ff175 100644 (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)
 
 
index 35c56eba76e826008f24c2a529f27c523115b834..17e4f3d652f848b8acc90fa0cbe5049f2a4d84e7 100644 (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);
index 130b2bf3dd194f379076066450eecb071845f46d..3561fac04bf1fec0496d3392114f0b079e3f8c45 100644 (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      
 ----+------------------------
index 69048323c6a5184185a71d6a2f6f685ff7e10a1e..22d335c6c2c19eb60b6d9ee6d905c048d9ce3675 100644 (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      
 ----+------------------------
index ab496c387404e1d8b1c9fe4521f9b1681e1bd946..83d92182d085726ba638f8f5990c92e1c9b0f678 100644 (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)