mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
> 2. This patch includes the same Table Function API fixes that I
> submitted on July 9: > > http://archives.postgresql.org/pgsql-patches/2002-07/msg00056.php > > Please disregard that one *if* this one is applied. If this one is > rejected please go ahead with the July 9th patch. The July 9th Table Function API patch mentioned above is now in CVS, so here is an updated version of the guc patch which should apply cleanly against CVS tip. Joe Conway
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.55 2002/07/20 05:16:57 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.56 2002/07/20 05:49:27 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -791,3 +791,73 @@ BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
|
||||
return tuple;
|
||||
}
|
||||
|
||||
/*
|
||||
* Functions for sending tuples to the frontend (or other specified destination)
|
||||
* as though it is a SELECT result. These are used by utility commands that
|
||||
* need to project directly to the destination and don't need or want full
|
||||
* Table Function capability. Currently used by EXPLAIN and SHOW ALL
|
||||
*/
|
||||
TupOutputState *
|
||||
begin_tup_output_tupdesc(CommandDest dest, TupleDesc tupdesc)
|
||||
{
|
||||
TupOutputState *tstate;
|
||||
|
||||
tstate = (TupOutputState *) palloc(sizeof(TupOutputState));
|
||||
|
||||
tstate->tupdesc = tupdesc;
|
||||
tstate->destfunc = DestToFunction(dest);
|
||||
|
||||
(*tstate->destfunc->setup) (tstate->destfunc, (int) CMD_SELECT,
|
||||
NULL, tupdesc);
|
||||
|
||||
return tstate;
|
||||
}
|
||||
|
||||
/*
|
||||
* write a single tuple
|
||||
*
|
||||
* values is a list of the external C string representations of the values
|
||||
* to be projected.
|
||||
*/
|
||||
void
|
||||
do_tup_output(TupOutputState *tstate, char **values)
|
||||
{
|
||||
/* build a tuple from the input strings using the tupdesc */
|
||||
AttInMetadata *attinmeta = TupleDescGetAttInMetadata(tstate->tupdesc);
|
||||
HeapTuple tuple = BuildTupleFromCStrings(attinmeta, values);
|
||||
|
||||
/* send the tuple to the receiver */
|
||||
(*tstate->destfunc->receiveTuple) (tuple,
|
||||
tstate->tupdesc,
|
||||
tstate->destfunc);
|
||||
/* clean up */
|
||||
heap_freetuple(tuple);
|
||||
}
|
||||
|
||||
/* write a chunk of text, breaking at newline characters
|
||||
* NB: scribbles on its input!
|
||||
* Should only be used for a single TEXT attribute tupdesc.
|
||||
*/
|
||||
void
|
||||
do_text_output_multiline(TupOutputState *tstate, char *text)
|
||||
{
|
||||
while (*text)
|
||||
{
|
||||
char *eol;
|
||||
|
||||
eol = strchr(text, '\n');
|
||||
if (eol)
|
||||
*eol++ = '\0';
|
||||
else
|
||||
eol = text + strlen(text);
|
||||
do_tup_output(tstate, &text);
|
||||
text = eol;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
end_tup_output(TupOutputState *tstate)
|
||||
{
|
||||
(*tstate->destfunc->cleanup) (tstate->destfunc);
|
||||
pfree(tstate);
|
||||
}
|
||||
|
Reference in New Issue
Block a user