new SHOW output format.
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
* 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 $
*
*/
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
{
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
{
ExplainOneQuery(lfirst(l), stmt, tstate);
/* put a blank line between plans */
if (lnext(l) != NIL)
- PROJECT_LINE_OF_TEXT("");
+ PROJECT_LINE_OF_TEXT(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;
}
do_text_output_multiline(tstate, f);
pfree(f);
if (es->printCost)
- PROJECT_LINE_OF_TEXT(""); /* separator line */
+ PROJECT_LINE_OF_TEXT(tstate, ""); /* separator line */
}
}
* 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
.
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
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)));
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);
}
TupOutputState *tstate;
TupleDesc tupdesc;
CommandDest dest = whereToSendOutput;
- char *name;
- char *value;
char *values[2];
/* need a tuple descriptor representing two TEXT columns */
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;
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);
}
/*
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)));
* 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 $
*
*-------------------------------------------------------------------------
*/
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)
* 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
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);
--
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
----+-----------------------------
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
----+------------------------
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
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
----+------------------------
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
----+------------------------
--
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
----+-----------------------------
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
----+------------------------
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
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
----+------------------------
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
----+------------------------
--
SET DateStyle TO 'US,Postgres';
SHOW DateStyle;
- datestyle
+ DateStyle
--------------------------------------------
Postgres with US (NonEuropean) conventions
(1 row)
SET DateStyle TO 'US,SQL';
SHOW DateStyle;
- datestyle
+ DateStyle
---------------------------------------
SQL with US (NonEuropean) conventions
(1 row)
SET DateStyle TO 'European,Postgres';
SHOW DateStyle;
- datestyle
+ DateStyle
------------------------------------
Postgres with European conventions
(1 row)
SET DateStyle TO 'European,ISO';
SHOW DateStyle;
- datestyle
+ DateStyle
-------------------------------
ISO with European conventions
(1 row)
SET DateStyle TO 'European,SQL';
SHOW DateStyle;
- datestyle
+ DateStyle
-------------------------------
SQL with European conventions
(1 row)