mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Restructure command destination handling so that we pass around
DestReceiver pointers instead of just CommandDest values. The DestReceiver is made at the point where the destination is selected, rather than deep inside the executor. This cleans up the original kluge implementation of tstoreReceiver.c, and makes it easy to support retrieving results from utility statements inside portals. Thus, you can now do fun things like Bind and Execute a FETCH or EXPLAIN command, and it'll all work as expected (e.g., you can Describe the portal, or use Execute's count parameter to suspend the output partway through). Implementation involves stuffing the utility command's output into a Tuplestore, which would be kind of annoying for huge output sets, but should be quite acceptable for typical uses of utility commands.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.122 2003/05/02 22:02:47 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.123 2003/05/06 20:26:27 tgl Exp $
|
||||
*
|
||||
*--------------------------------------------------------------------
|
||||
*/
|
||||
@@ -2438,12 +2438,41 @@ set_config_by_name(PG_FUNCTION_ARGS)
|
||||
* SHOW command
|
||||
*/
|
||||
void
|
||||
GetPGVariable(const char *name)
|
||||
GetPGVariable(const char *name, DestReceiver *dest)
|
||||
{
|
||||
if (strcasecmp(name, "all") == 0)
|
||||
ShowAllGUCConfig();
|
||||
ShowAllGUCConfig(dest);
|
||||
else
|
||||
ShowGUCConfigOption(name);
|
||||
ShowGUCConfigOption(name, dest);
|
||||
}
|
||||
|
||||
TupleDesc
|
||||
GetPGVariableResultDesc(const char *name)
|
||||
{
|
||||
TupleDesc tupdesc;
|
||||
|
||||
if (strcasecmp(name, "all") == 0)
|
||||
{
|
||||
/* need a tuple descriptor representing two TEXT columns */
|
||||
tupdesc = CreateTemplateTupleDesc(2, false);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
|
||||
TEXTOID, -1, 0, false);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
|
||||
TEXTOID, -1, 0, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *varname;
|
||||
|
||||
/* Get the canonical spelling of name */
|
||||
(void) GetConfigOptionByName(name, &varname);
|
||||
|
||||
/* need a tuple descriptor representing a single TEXT column */
|
||||
tupdesc = CreateTemplateTupleDesc(1, false);
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, (char *) varname,
|
||||
TEXTOID, -1, 0, false);
|
||||
}
|
||||
return tupdesc;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2468,11 +2497,10 @@ ResetPGVariable(const char *name)
|
||||
* SHOW command
|
||||
*/
|
||||
void
|
||||
ShowGUCConfigOption(const char *name)
|
||||
ShowGUCConfigOption(const char *name, DestReceiver *dest)
|
||||
{
|
||||
TupOutputState *tstate;
|
||||
TupleDesc tupdesc;
|
||||
CommandDest dest = whereToSendOutput;
|
||||
const char *varname;
|
||||
char *value;
|
||||
|
||||
@@ -2497,12 +2525,11 @@ ShowGUCConfigOption(const char *name)
|
||||
* SHOW ALL command
|
||||
*/
|
||||
void
|
||||
ShowAllGUCConfig(void)
|
||||
ShowAllGUCConfig(DestReceiver *dest)
|
||||
{
|
||||
int i;
|
||||
TupOutputState *tstate;
|
||||
TupleDesc tupdesc;
|
||||
CommandDest dest = whereToSendOutput;
|
||||
char *values[2];
|
||||
|
||||
/* need a tuple descriptor representing two TEXT columns */
|
||||
|
||||
Reference in New Issue
Block a user