mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +03:00
Here is a patch for the Table Function API. It fixes a bug found by Neil
Conway (BuildTupleFromCStrings sets NULL for pass-by-value types when intended value is 0). It also implements some other improvements suggested by Neil. Joe Conway
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.53 2002/06/20 20:29:27 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.54 2002/07/18 04:40:30 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -759,6 +759,7 @@ BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
|
||||
natts = tupdesc->natts;
|
||||
|
||||
dvalues = (Datum *) palloc(natts * sizeof(Datum));
|
||||
nulls = (char *) palloc(natts * sizeof(char));
|
||||
|
||||
/* Call the "in" function for each attribute */
|
||||
for (i = 0; i < natts; i++)
|
||||
@@ -772,22 +773,18 @@ BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
|
||||
dvalues[i] = FunctionCall3(&attinfuncinfo, CStringGetDatum(values[i]),
|
||||
ObjectIdGetDatum(attelem),
|
||||
Int32GetDatum(atttypmod));
|
||||
nulls[i] = ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
dvalues[i] = PointerGetDatum(NULL);
|
||||
nulls[i] = 'n';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Form a tuple
|
||||
*/
|
||||
nulls = (char *) palloc(natts * sizeof(char));
|
||||
for (i = 0; i < natts; i++)
|
||||
{
|
||||
if (DatumGetPointer(dvalues[i]) != NULL)
|
||||
nulls[i] = ' ';
|
||||
else
|
||||
nulls[i] = 'n';
|
||||
}
|
||||
tuple = heap_formtuple(tupdesc, dvalues, nulls);
|
||||
|
||||
return tuple;
|
||||
|
||||
@@ -52,7 +52,7 @@ init_MultiFuncCall(PG_FUNCTION_ARGS)
|
||||
retval->call_cntr = 0;
|
||||
retval->max_calls = 0;
|
||||
retval->slot = NULL;
|
||||
retval->fctx = NULL;
|
||||
retval->user_fctx = NULL;
|
||||
retval->attinmeta = NULL;
|
||||
retval->fmctx = fcinfo->flinfo->fn_mcxt;
|
||||
|
||||
@@ -75,6 +75,23 @@ init_MultiFuncCall(PG_FUNCTION_ARGS)
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* per_MultiFuncCall
|
||||
*
|
||||
* Do Multi-function per-call setup
|
||||
*/
|
||||
FuncCallContext *
|
||||
per_MultiFuncCall(PG_FUNCTION_ARGS)
|
||||
{
|
||||
FuncCallContext *retval = (FuncCallContext *) fcinfo->flinfo->fn_extra;
|
||||
|
||||
/* make sure we start with a fresh slot */
|
||||
if(retval->slot != NULL)
|
||||
ExecClearTuple(retval->slot);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* end_MultiFuncCall
|
||||
* Clean up after init_MultiFuncCall
|
||||
|
||||
Reference in New Issue
Block a user