From 902d1cb35f69464e1e13015b9e05abdb76a7444d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 2 Nov 2008 01:45:28 +0000 Subject: Remove all uses of the deprecated functions heap_formtuple, heap_modifytuple, and heap_deformtuple in favor of the newer functions heap_form_tuple et al (which do the same things but use bool control flags instead of arbitrary char values). Eliminate the former duplicate coding of these functions, reducing the deprecated functions to mere wrappers around the newer ones. We can't get rid of them entirely because add-on modules probably still contain many instances of the old coding style. Kris Jurka --- src/backend/commands/copy.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/backend/commands/copy.c') diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index 69a059631bc..4d6fd988d77 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.299 2008/05/12 20:01:59 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.300 2008/11/02 01:45:27 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1638,7 +1638,7 @@ CopyFrom(CopyState cstate) int i; Oid in_func_oid; Datum *values; - char *nulls; + bool *nulls; int nfields; char **field_strings; bool done = false; @@ -1872,7 +1872,7 @@ CopyFrom(CopyState cstate) } values = (Datum *) palloc(num_phys_attrs * sizeof(Datum)); - nulls = (char *) palloc(num_phys_attrs * sizeof(char)); + nulls = (bool *) palloc(num_phys_attrs * sizeof(bool)); /* create workspace for CopyReadAttributes results */ nfields = file_has_oids ? (attr_count + 1) : attr_count; @@ -1916,7 +1916,7 @@ CopyFrom(CopyState cstate) /* Initialize all values for row to NULL */ MemSet(values, 0, num_phys_attrs * sizeof(Datum)); - MemSet(nulls, 'n', num_phys_attrs * sizeof(char)); + MemSet(nulls, true, num_phys_attrs * sizeof(bool)); if (!cstate->binary) { @@ -1998,7 +1998,7 @@ CopyFrom(CopyState cstate) typioparams[m], attr[m]->atttypmod); if (string != NULL) - nulls[m] = ' '; + nulls[m] = false; cstate->cur_attname = NULL; cstate->cur_attval = NULL; } @@ -2054,8 +2054,7 @@ CopyFrom(CopyState cstate) &in_functions[m], typioparams[m], attr[m]->atttypmod, - &isnull); - nulls[m] = isnull ? 'n' : ' '; + &nulls[m]); cstate->cur_attname = NULL; } } @@ -2068,13 +2067,11 @@ CopyFrom(CopyState cstate) for (i = 0; i < num_defaults; i++) { values[defmap[i]] = ExecEvalExpr(defexprs[i], econtext, - &isnull, NULL); - if (!isnull) - nulls[defmap[i]] = ' '; + &nulls[defmap[i]], NULL); } /* And now we can form the input tuple. */ - tuple = heap_formtuple(tupDesc, values, nulls); + tuple = heap_form_tuple(tupDesc, values, nulls); if (cstate->oids && file_has_oids) HeapTupleSetOid(tuple, loaded_oid); -- cgit v1.2.3