From 147d4bf3e5e3da2ee0f0cc132718ab1c4912a877 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 4 Apr 2006 19:35:37 +0000 Subject: Modify all callers of datatype input and receive functions so that if these functions are not strict, they will be called (passing a NULL first parameter) during any attempt to input a NULL value of their datatype. Currently, all our input functions are strict and so this commit does not change any behavior. However, this will make it possible to build domain input functions that centralize checking of domain constraints, thereby closing numerous holes in our domain support, as per previous discussion. While at it, I took the opportunity to introduce convenience functions InputFunctionCall, OutputFunctionCall, etc to use in code that calls I/O functions. This eliminates a lot of grotty-looking casts, but the main motivation is to make it easier to grep for these places if we ever need to touch them again. --- src/backend/executor/execTuples.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'src/backend/executor/execTuples.c') diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c index bd50027f776..81f589fd44b 100644 --- a/src/backend/executor/execTuples.c +++ b/src/backend/executor/execTuples.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.92 2006/03/05 15:58:26 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.93 2006/04/04 19:35:34 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -928,6 +928,7 @@ TupleDescGetAttInMetadata(TupleDesc tupdesc) /* * BuildTupleFromCStrings - build a HeapTuple given user data in C string form. * values is an array of C strings, one for each attribute of the return tuple. + * A NULL string pointer indicates we want to create a NULL field. */ HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values) @@ -937,35 +938,25 @@ BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values) Datum *dvalues; char *nulls; int i; - Oid attioparam; - int32 atttypmod; HeapTuple tuple; dvalues = (Datum *) palloc(natts * sizeof(Datum)); nulls = (char *) palloc(natts * sizeof(char)); - /* Call the "in" function for each non-null, non-dropped attribute */ + /* Call the "in" function for each non-dropped attribute */ for (i = 0; i < natts; i++) { if (!tupdesc->attrs[i]->attisdropped) { /* Non-dropped attributes */ + dvalues[i] = InputFunctionCall(&attinmeta->attinfuncs[i], + values[i], + attinmeta->attioparams[i], + attinmeta->atttypmods[i]); if (values[i] != NULL) - { - attioparam = attinmeta->attioparams[i]; - atttypmod = attinmeta->atttypmods[i]; - - dvalues[i] = FunctionCall3(&attinmeta->attinfuncs[i], - CStringGetDatum(values[i]), - ObjectIdGetDatum(attioparam), - Int32GetDatum(atttypmod)); nulls[i] = ' '; - } else - { - dvalues[i] = (Datum) 0; nulls[i] = 'n'; - } } else { -- cgit v1.2.3