Remove all uses of the deprecated functions heap_formtuple, heap_modifytuple,
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 2 Nov 2008 01:45:28 +0000 (01:45 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 2 Nov 2008 01:45:28 +0000 (01:45 +0000)
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

46 files changed:
contrib/hstore/hstore_op.c
src/backend/access/common/heaptuple.c
src/backend/access/heap/tuptoaster.c
src/backend/bootstrap/bootstrap.c
src/backend/catalog/aclchk.c
src/backend/catalog/heap.c
src/backend/catalog/index.c
src/backend/catalog/pg_aggregate.c
src/backend/catalog/pg_constraint.c
src/backend/catalog/pg_conversion.c
src/backend/catalog/pg_depend.c
src/backend/catalog/pg_enum.c
src/backend/catalog/pg_largeobject.c
src/backend/catalog/pg_namespace.c
src/backend/catalog/pg_operator.c
src/backend/catalog/pg_proc.c
src/backend/catalog/pg_shdepend.c
src/backend/catalog/pg_type.c
src/backend/commands/analyze.c
src/backend/commands/async.c
src/backend/commands/comment.c
src/backend/commands/copy.c
src/backend/commands/dbcommands.c
src/backend/commands/functioncmds.c
src/backend/commands/opclasscmds.c
src/backend/commands/proclang.c
src/backend/commands/schemacmds.c
src/backend/commands/sequence.c
src/backend/commands/tablecmds.c
src/backend/commands/tablespace.c
src/backend/commands/trigger.c
src/backend/commands/tsearchcmds.c
src/backend/commands/typecmds.c
src/backend/commands/user.c
src/backend/executor/execTuples.c
src/backend/executor/spi.c
src/backend/optimizer/prep/preptlist.c
src/backend/rewrite/rewriteDefine.c
src/backend/storage/large_object/inv_api.c
src/backend/utils/adt/lockfuncs.c
src/backend/utils/adt/rowtypes.c
src/backend/utils/cache/catcache.c
src/include/access/htup.h
src/include/funcapi.h
src/pl/plpgsql/src/pl_exec.c
src/pl/plpython/plpython.c

index 4f285ee633953d3ab5c13d2a26856183112912fa..bb1ebe4055f1a9e11d3e726c91ab53734ac47af1 100644 (file)
@@ -610,7 +610,7 @@ each(PG_FUNCTION_ARGS)
                HEntry     *ptr = &(ARRPTR(st->hs)[st->i]);
                Datum           res,
                                        dvalues[2];
-               char            nulls[] = {' ', ' '};
+               bool            nulls[2] = {false, false};
                text       *item;
                HeapTuple       tuple;
 
@@ -620,7 +620,7 @@ each(PG_FUNCTION_ARGS)
                if (ptr->valisnull)
                {
                        dvalues[1] = (Datum) 0;
-                       nulls[1] = 'n';
+                       nulls[1] = true;
                }
                else
                {
@@ -630,11 +630,11 @@ each(PG_FUNCTION_ARGS)
                }
                st->i++;
 
-               tuple = heap_formtuple(funcctx->attinmeta->tupdesc, dvalues, nulls);
+               tuple = heap_form_tuple(funcctx->attinmeta->tupdesc, dvalues, nulls);
                res = HeapTupleGetDatum(tuple);
 
                pfree(DatumGetPointer(dvalues[0]));
-               if (nulls[1] != 'n')
+               if (!nulls[1])
                        pfree(DatumGetPointer(dvalues[1]));
 
                SRF_RETURN_NEXT(funcctx, PointerGetDatum(res));
index db557f900bd2c2a64e767bab1563f8590452960d..201a3878bc6eec9b7f68c8254e2a3a4879fa45f8 100644 (file)
@@ -4,13 +4,6 @@
  *       This file contains heap tuple accessor and mutator routines, as well
  *       as various tuple utilities.
  *
- * NOTE: there is massive duplication of code in this module to
- * support both the convention that a null is marked by a bool TRUE,
- * and the convention that a null is marked by a char 'n'.     The latter
- * convention is deprecated but it'll probably be a long time before
- * we can get rid of it entirely.
- *
- *
  * Some notes about varlenas and this code:
  *
  * Before Postgres 8.3 varlenas always had a 4-byte length header, and
@@ -24,8 +17,8 @@
  * be expanded back to the normal 4-byte-header format by pg_detoast_datum.
  * (In performance-critical code paths we can use pg_detoast_datum_packed
  * and the appropriate access macros to avoid that overhead.)  Note that this
- * conversion is performed directly in heap_form_tuple (or heap_formtuple),
- * without explicitly invoking the toaster.
+ * conversion is performed directly in heap_form_tuple, without invoking
+ * tuptoaster.c.
  *
  * This change will break any code that assumes it needn't detoast values
  * that have been put into a tuple but never sent to disk.     Hopefully there
@@ -57,7 +50,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.122 2008/05/12 00:00:43 alvherre Exp $
+ *       $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.123 2008/11/02 01:45:26 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -128,54 +121,6 @@ heap_compute_data_size(TupleDesc tupleDesc,
        return data_length;
 }
 
-/* ----------------
- *             ComputeDataSize
- *
- * Determine size of the data area of a tuple to be constructed
- *
- * OLD API with char 'n'/' ' convention for indicating nulls
- * ----------------
- */
-static Size
-ComputeDataSize(TupleDesc tupleDesc,
-                               Datum *values,
-                               char *nulls)
-{
-       Size            data_length = 0;
-       int                     i;
-       int                     numberOfAttributes = tupleDesc->natts;
-       Form_pg_attribute *att = tupleDesc->attrs;
-
-       for (i = 0; i < numberOfAttributes; i++)
-       {
-               Datum           val;
-
-               if (nulls[i] != ' ')
-                       continue;
-
-               val = values[i];
-
-               if (ATT_IS_PACKABLE(att[i]) &&
-                       VARATT_CAN_MAKE_SHORT(DatumGetPointer(val)))
-               {
-                       /*
-                        * we're anticipating converting to a short varlena header, so
-                        * adjust length and don't count any alignment
-                        */
-                       data_length += VARATT_CONVERTED_SHORT_SIZE(DatumGetPointer(val));
-               }
-               else
-               {
-                       data_length = att_align_datum(data_length, att[i]->attalign,
-                                                                                 att[i]->attlen, val);
-                       data_length = att_addlength_datum(data_length, att[i]->attlen,
-                                                                                         val);
-               }
-       }
-
-       return data_length;
-}
-
 /*
  * heap_fill_tuple
  *             Load data portion of a tuple from values/isnull arrays
@@ -310,138 +255,6 @@ heap_fill_tuple(TupleDesc tupleDesc,
        Assert((data - start) == data_size);
 }
 
-/* ----------------
- *             DataFill
- *
- * Load data portion of a tuple from values/nulls arrays
- *
- * OLD API with char 'n'/' ' convention for indicating nulls
- * ----------------
- */
-static void
-DataFill(TupleDesc tupleDesc,
-                Datum *values, char *nulls,
-                char *data, Size data_size,
-                uint16 *infomask, bits8 *bit)
-{
-       bits8      *bitP;
-       int                     bitmask;
-       int                     i;
-       int                     numberOfAttributes = tupleDesc->natts;
-       Form_pg_attribute *att = tupleDesc->attrs;
-
-#ifdef USE_ASSERT_CHECKING
-       char       *start = data;
-#endif
-
-       if (bit != NULL)
-       {
-               bitP = &bit[-1];
-               bitmask = HIGHBIT;
-       }
-       else
-       {
-               /* just to keep compiler quiet */
-               bitP = NULL;
-               bitmask = 0;
-       }
-
-       *infomask &= ~(HEAP_HASNULL | HEAP_HASVARWIDTH | HEAP_HASEXTERNAL);
-
-       for (i = 0; i < numberOfAttributes; i++)
-       {
-               Size            data_length;
-
-               if (bit != NULL)
-               {
-                       if (bitmask != HIGHBIT)
-                               bitmask <<= 1;
-                       else
-                       {
-                               bitP += 1;
-                               *bitP = 0x0;
-                               bitmask = 1;
-                       }
-
-                       if (nulls[i] == 'n')
-                       {
-                               *infomask |= HEAP_HASNULL;
-                               continue;
-                       }
-
-                       *bitP |= bitmask;
-               }
-
-               /*
-                * XXX we use the att_align macros on the pointer value itself, not on
-                * an offset.  This is a bit of a hack.
-                */
-
-               if (att[i]->attbyval)
-               {
-                       /* pass-by-value */
-                       data = (char *) att_align_nominal((long) data, att[i]->attalign);
-                       store_att_byval(data, values[i], att[i]->attlen);
-                       data_length = att[i]->attlen;
-               }
-               else if (att[i]->attlen == -1)
-               {
-                       /* varlena */
-                       Pointer         val = DatumGetPointer(values[i]);
-
-                       *infomask |= HEAP_HASVARWIDTH;
-                       if (VARATT_IS_EXTERNAL(val))
-                       {
-                               *infomask |= HEAP_HASEXTERNAL;
-                               /* no alignment, since it's short by definition */
-                               data_length = VARSIZE_EXTERNAL(val);
-                               memcpy(data, val, data_length);
-                       }
-                       else if (VARATT_IS_SHORT(val))
-                       {
-                               /* no alignment for short varlenas */
-                               data_length = VARSIZE_SHORT(val);
-                               memcpy(data, val, data_length);
-                       }
-                       else if (VARLENA_ATT_IS_PACKABLE(att[i]) &&
-                                        VARATT_CAN_MAKE_SHORT(val))
-                       {
-                               /* convert to short varlena -- no alignment */
-                               data_length = VARATT_CONVERTED_SHORT_SIZE(val);
-                               SET_VARSIZE_SHORT(data, data_length);
-                               memcpy(data + 1, VARDATA(val), data_length - 1);
-                       }
-                       else
-                       {
-                               /* full 4-byte header varlena */
-                               data = (char *) att_align_nominal((long) data,
-                                                                                                 att[i]->attalign);
-                               data_length = VARSIZE(val);
-                               memcpy(data, val, data_length);
-                       }
-               }
-               else if (att[i]->attlen == -2)
-               {
-                       /* cstring ... never needs alignment */
-                       *infomask |= HEAP_HASVARWIDTH;
-                       Assert(att[i]->attalign == 'c');
-                       data_length = strlen(DatumGetCString(values[i])) + 1;
-                       memcpy(data, DatumGetPointer(values[i]), data_length);
-               }
-               else
-               {
-                       /* fixed-length pass-by-reference */
-                       data = (char *) att_align_nominal((long) data, att[i]->attalign);
-                       Assert(att[i]->attlen > 0);
-                       data_length = att[i]->attlen;
-                       memcpy(data, DatumGetPointer(values[i]), data_length);
-               }
-
-               data += data_length;
-       }
-
-       Assert((data - start) == data_size);
-}
 
 /* ----------------------------------------------------------------
  *                                             heap tuple interface
@@ -952,7 +765,7 @@ heap_form_tuple(TupleDesc tupleDescriptor,
        return tuple;
 }
 
-/* ----------------
+/*
  *             heap_formtuple
  *
  *             construct a tuple from the given values[] and nulls[] arrays
@@ -960,8 +773,9 @@ heap_form_tuple(TupleDesc tupleDescriptor,
  *             Null attributes are indicated by a 'n' in the appropriate byte
  *             of nulls[]. Non-null attributes are indicated by a ' ' (space).
  *
- * OLD API with char 'n'/' ' convention for indicating nulls
- * ----------------
+ * OLD API with char 'n'/' ' convention for indicating nulls.
+ * This is deprecated and should not be used in new code, but we keep it
+ * around for use by old add-on modules.
  */
 HeapTuple
 heap_formtuple(TupleDesc tupleDescriptor,
@@ -969,96 +783,16 @@ heap_formtuple(TupleDesc tupleDescriptor,
                           char *nulls)
 {
        HeapTuple       tuple;                  /* return tuple */
-       HeapTupleHeader td;                     /* tuple data */
-       Size            len,
-                               data_len;
-       int                     hoff;
-       bool            hasnull = false;
-       Form_pg_attribute *att = tupleDescriptor->attrs;
        int                     numberOfAttributes = tupleDescriptor->natts;
+       bool       *boolNulls = (bool *) palloc(numberOfAttributes * sizeof(bool));
        int                     i;
 
-       if (numberOfAttributes > MaxTupleAttributeNumber)
-               ereport(ERROR,
-                               (errcode(ERRCODE_TOO_MANY_COLUMNS),
-                                errmsg("number of columns (%d) exceeds limit (%d)",
-                                               numberOfAttributes, MaxTupleAttributeNumber)));
-
-       /*
-        * Check for nulls and embedded tuples; expand any toasted attributes in
-        * embedded tuples.  This preserves the invariant that toasting can only
-        * go one level deep.
-        *
-        * We can skip calling toast_flatten_tuple_attribute() if the attribute
-        * couldn't possibly be of composite type.  All composite datums are
-        * varlena and have alignment 'd'; furthermore they aren't arrays. Also,
-        * if an attribute is already toasted, it must have been sent to disk
-        * already and so cannot contain toasted attributes.
-        */
        for (i = 0; i < numberOfAttributes; i++)
-       {
-               if (nulls[i] != ' ')
-                       hasnull = true;
-               else if (att[i]->attlen == -1 &&
-                                att[i]->attalign == 'd' &&
-                                att[i]->attndims == 0 &&
-                                !VARATT_IS_EXTENDED(DatumGetPointer(values[i])))
-               {
-                       values[i] = toast_flatten_tuple_attribute(values[i],
-                                                                                                         att[i]->atttypid,
-                                                                                                         att[i]->atttypmod);
-               }
-       }
-
-       /*
-        * Determine total space needed
-        */
-       len = offsetof(HeapTupleHeaderData, t_bits);
+               boolNulls[i] = (nulls[i] == 'n');
 
-       if (hasnull)
-               len += BITMAPLEN(numberOfAttributes);
-
-       if (tupleDescriptor->tdhasoid)
-               len += sizeof(Oid);
+       tuple = heap_form_tuple(tupleDescriptor, values, boolNulls);
 
-       hoff = len = MAXALIGN(len); /* align user data safely */
-
-       data_len = ComputeDataSize(tupleDescriptor, values, nulls);
-
-       len += data_len;
-
-       /*
-        * Allocate and zero the space needed.  Note that the tuple body and
-        * HeapTupleData management structure are allocated in one chunk.
-        */
-       tuple = (HeapTuple) palloc0(HEAPTUPLESIZE + len);
-       tuple->t_data = td = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE);
-
-       /*
-        * And fill in the information.  Note we fill the Datum fields even though
-        * this tuple may never become a Datum.
-        */
-       tuple->t_len = len;
-       ItemPointerSetInvalid(&(tuple->t_self));
-       tuple->t_tableOid = InvalidOid;
-
-       HeapTupleHeaderSetDatumLength(td, len);
-       HeapTupleHeaderSetTypeId(td, tupleDescriptor->tdtypeid);
-       HeapTupleHeaderSetTypMod(td, tupleDescriptor->tdtypmod);
-
-       HeapTupleHeaderSetNatts(td, numberOfAttributes);
-       td->t_hoff = hoff;
-
-       if (tupleDescriptor->tdhasoid)          /* else leave infomask = 0 */
-               td->t_infomask = HEAP_HASOID;
-
-       DataFill(tupleDescriptor,
-                        values,
-                        nulls,
-                        (char *) td + hoff,
-                        data_len,
-                        &td->t_infomask,
-                        (hasnull ? td->t_bits : NULL));
+       pfree(boolNulls);
 
        return tuple;
 }
@@ -1134,7 +868,7 @@ heap_modify_tuple(HeapTuple tuple,
        return newTuple;
 }
 
-/* ----------------
+/*
  *             heap_modifytuple
  *
  *             forms a new tuple from an old tuple and a set of replacement values.
@@ -1142,7 +876,8 @@ heap_modify_tuple(HeapTuple tuple,
  *
  * OLD API with char 'n'/' ' convention for indicating nulls, and
  * char 'r'/' ' convention for indicating whether to replace columns.
- * ----------------
+ * This is deprecated and should not be used in new code, but we keep it
+ * around for use by old add-on modules.
  */
 HeapTuple
 heap_modifytuple(HeapTuple tuple,
@@ -1151,59 +886,24 @@ heap_modifytuple(HeapTuple tuple,
                                 char *replNulls,
                                 char *replActions)
 {
+       HeapTuple       result;
        int                     numberOfAttributes = tupleDesc->natts;
-       int                     attoff;
-       Datum      *values;
-       char       *nulls;
-       HeapTuple       newTuple;
-
-       /*
-        * allocate and fill values and nulls arrays from either the tuple or the
-        * repl information, as appropriate.
-        *
-        * NOTE: it's debatable whether to use heap_deformtuple() here or just
-        * heap_getattr() only the non-replaced colums.  The latter could win if
-        * there are many replaced columns and few non-replaced ones. However,
-        * heap_deformtuple costs only O(N) while the heap_getattr way would cost
-        * O(N^2) if there are many non-replaced columns, so it seems better to
-        * err on the side of linear cost.
-        */
-       values = (Datum *) palloc(numberOfAttributes * sizeof(Datum));
-       nulls = (char *) palloc(numberOfAttributes * sizeof(char));
-
-       heap_deformtuple(tuple, tupleDesc, values, nulls);
+       bool       *boolNulls = (bool *) palloc(numberOfAttributes * sizeof(bool));
+       bool       *boolActions = (bool *) palloc(numberOfAttributes * sizeof(bool));
+       int                     attnum;
 
-       for (attoff = 0; attoff < numberOfAttributes; attoff++)
+       for (attnum = 0; attnum < numberOfAttributes; attnum++)
        {
-               if (replActions[attoff] == 'r')
-               {
-                       values[attoff] = replValues[attoff];
-                       nulls[attoff] = replNulls[attoff];
-               }
-               else if (replActions[attoff] != ' ')
-                       elog(ERROR, "unrecognized replace flag: %d",
-                                (int) replActions[attoff]);
+               boolNulls[attnum] = (replNulls[attnum] == 'n');
+               boolActions[attnum] = (replActions[attnum] == 'r');
        }
 
-       /*
-        * create a new tuple from the values and nulls arrays
-        */
-       newTuple = heap_formtuple(tupleDesc, values, nulls);
+       result = heap_modify_tuple(tuple, tupleDesc, replValues, boolNulls, boolActions);
 
-       pfree(values);
-       pfree(nulls);
+       pfree(boolNulls);
+       pfree(boolActions);
 
-       /*
-        * copy the identification info of the old tuple: t_ctid, t_self, and OID
-        * (if any)
-        */
-       newTuple->t_data->t_ctid = tuple->t_data->t_ctid;
-       newTuple->t_self = tuple->t_self;
-       newTuple->t_tableOid = tuple->t_tableOid;
-       if (tupleDesc->tdhasoid)
-               HeapTupleSetOid(newTuple, HeapTupleGetOid(tuple));
-
-       return newTuple;
+       return result;
 }
 
 /*
@@ -1312,7 +1012,7 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
        }
 }
 
-/* ----------------
+/*
  *             heap_deformtuple
  *
  *             Given a tuple, extract data into values/nulls arrays; this is
@@ -1329,8 +1029,9 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc,
  *             heap_getattr; the loop will become O(N^2) as soon as any
  *             noncacheable attribute offsets are involved.
  *
- * OLD API with char 'n'/' ' convention for indicating nulls
- * ----------------
+ * OLD API with char 'n'/' ' convention for indicating nulls.
+ * This is deprecated and should not be used in new code, but we keep it
+ * around for use by old add-on modules.
  */
 void
 heap_deformtuple(HeapTuple tuple,
@@ -1338,90 +1039,16 @@ heap_deformtuple(HeapTuple tuple,
                                 Datum *values,
                                 char *nulls)
 {
-       HeapTupleHeader tup = tuple->t_data;
-       bool            hasnulls = HeapTupleHasNulls(tuple);
-       Form_pg_attribute *att = tupleDesc->attrs;
-       int                     tdesc_natts = tupleDesc->natts;
-       int                     natts;                  /* number of atts to extract */
+       int                     natts = tupleDesc->natts;
+       bool       *boolNulls = (bool *) palloc(natts * sizeof(bool));
        int                     attnum;
-       char       *tp;                         /* ptr to tuple data */
-       long            off;                    /* offset in tuple data */
-       bits8      *bp = tup->t_bits;           /* ptr to null bitmap in tuple */
-       bool            slow = false;   /* can we use/set attcacheoff? */
 
-       natts = HeapTupleHeaderGetNatts(tup);
-
-       /*
-        * In inheritance situations, it is possible that the given tuple actually
-        * has more fields than the caller is expecting.  Don't run off the end of
-        * the caller's arrays.
-        */
-       natts = Min(natts, tdesc_natts);
-
-       tp = (char *) tup + tup->t_hoff;
-
-       off = 0;
+       heap_deform_tuple(tuple, tupleDesc, values, boolNulls);
 
        for (attnum = 0; attnum < natts; attnum++)
-       {
-               Form_pg_attribute thisatt = att[attnum];
-
-               if (hasnulls && att_isnull(attnum, bp))
-               {
-                       values[attnum] = (Datum) 0;
-                       nulls[attnum] = 'n';
-                       slow = true;            /* can't use attcacheoff anymore */
-                       continue;
-               }
-
-               nulls[attnum] = ' ';
+               nulls[attnum] = (boolNulls[attnum] ? 'n' : ' ');
 
-               if (!slow && thisatt->attcacheoff >= 0)
-                       off = thisatt->attcacheoff;
-               else if (thisatt->attlen == -1)
-               {
-                       /*
-                        * We can only cache the offset for a varlena attribute if the
-                        * offset is already suitably aligned, so that there would be no
-                        * pad bytes in any case: then the offset will be valid for either
-                        * an aligned or unaligned value.
-                        */
-                       if (!slow &&
-                               off == att_align_nominal(off, thisatt->attalign))
-                               thisatt->attcacheoff = off;
-                       else
-                       {
-                               off = att_align_pointer(off, thisatt->attalign, -1,
-                                                                               tp + off);
-                               slow = true;
-                       }
-               }
-               else
-               {
-                       /* not varlena, so safe to use att_align_nominal */
-                       off = att_align_nominal(off, thisatt->attalign);
-
-                       if (!slow)
-                               thisatt->attcacheoff = off;
-               }
-
-               values[attnum] = fetchatt(thisatt, tp + off);
-
-               off = att_addlength_pointer(off, thisatt->attlen, tp + off);
-
-               if (thisatt->attlen <= 0)
-                       slow = true;            /* can't use attcacheoff anymore */
-       }
-
-       /*
-        * If tuple doesn't have all the atts indicated by tupleDesc, read the
-        * rest as null
-        */
-       for (; attnum < tdesc_natts; attnum++)
-       {
-               values[attnum] = (Datum) 0;
-               nulls[attnum] = 'n';
-       }
+       pfree(boolNulls);
 }
 
 /*
index 802b7f151b04823f88aa6907102805b324903ee8..e3014e288ab14a37fad7533579c3a67e0252f9b7 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.89 2008/06/19 00:46:03 alvherre Exp $
+ *       $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.90 2008/11/02 01:45:27 tgl Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -359,10 +359,10 @@ toast_delete(Relation rel, HeapTuple oldtup)
        /*
         * Get the tuple descriptor and break down the tuple into fields.
         *
-        * NOTE: it's debatable whether to use heap_deformtuple() here or just
+        * NOTE: it's debatable whether to use heap_deform_tuple() here or just
         * heap_getattr() only the varlena columns.  The latter could win if there
         * are few varlena columns and many non-varlena ones. However,
-        * heap_deformtuple costs only O(N) while the heap_getattr way would cost
+        * heap_deform_tuple costs only O(N) while the heap_getattr way would cost
         * O(N^2) if there are many varlena columns, so it seems better to err on
         * the side of linear cost.  (We won't even be here unless there's at
         * least one varlena column, by the way.)
index 04194acd3f2d0f2445a27c78195707567e3f6133..c7bcfd2456354ad62d90552343812f5438d0e334 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.246 2008/09/30 10:52:11 heikki Exp $
+ *       $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.247 2008/11/02 01:45:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -169,7 +169,7 @@ struct typmap
 static struct typmap **Typ = NULL;
 static struct typmap *Ap = NULL;
 
-static char Blanks[MAXATTR];
+static bool Nulls[MAXATTR];
 
 Form_pg_attribute attrtypes[MAXATTR];  /* points to attribute info */
 static Datum values[MAXATTR];  /* corresponding attribute values */
@@ -488,7 +488,7 @@ BootstrapModeMain(void)
        for (i = 0; i < MAXATTR; i++)
        {
                attrtypes[i] = NULL;
-               Blanks[i] = ' ';
+               Nulls[i] = false;
        }
        for (i = 0; i < STRTABLESIZE; ++i)
                strtable[i] = NULL;
@@ -797,7 +797,7 @@ InsertOneTuple(Oid objectid)
        tupDesc = CreateTupleDesc(numattr,
                                                          RelationGetForm(boot_reldesc)->relhasoids,
                                                          attrtypes);
-       tuple = heap_formtuple(tupDesc, values, Blanks);
+       tuple = heap_form_tuple(tupDesc, values, Nulls);
        if (objectid != (Oid) 0)
                HeapTupleSetOid(tuple, objectid);
        pfree(tupDesc);                         /* just free's tupDesc, not the attrtypes */
@@ -807,10 +807,10 @@ InsertOneTuple(Oid objectid)
        elog(DEBUG4, "row inserted");
 
        /*
-        * Reset blanks for next tuple
+        * Reset null markers for next tuple
         */
        for (i = 0; i < numattr; i++)
-               Blanks[i] = ' ';
+               Nulls[i] = false;
 }
 
 /* ----------------
@@ -857,7 +857,7 @@ InsertOneNull(int i)
        elog(DEBUG4, "inserting column %d NULL", i);
        Assert(i >= 0 || i < MAXATTR);
        values[i] = PointerGetDatum(NULL);
-       Blanks[i] = 'n';
+       Nulls[i] = true;
 }
 
 /* ----------------
index 941ee62da77fe396bd262c030971c2770ae649b1..f25c7608e41e4ee3d5f9e9207b1d44bf52f62570 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.148 2008/09/08 00:47:40 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.149 2008/11/02 01:45:27 tgl Exp $
  *
  * NOTES
  *       See acl.h.
@@ -554,8 +554,8 @@ ExecGrant_Relation(InternalGrant *istmt)
                HeapTuple       tuple;
                HeapTuple       newtuple;
                Datum           values[Natts_pg_class];
-               char            nulls[Natts_pg_class];
-               char            replaces[Natts_pg_class];
+               bool            nulls[Natts_pg_class];
+               bool            replaces[Natts_pg_class];
                int                     noldmembers;
                int                     nnewmembers;
                Oid                *oldmembers;
@@ -694,13 +694,13 @@ ExecGrant_Relation(InternalGrant *istmt)
 
                /* finished building new ACL value, now insert it */
                MemSet(values, 0, sizeof(values));
-               MemSet(nulls, ' ', sizeof(nulls));
-               MemSet(replaces, ' ', sizeof(replaces));
+               MemSet(nulls, false, sizeof(nulls));
+               MemSet(replaces, false, sizeof(replaces));
 
-               replaces[Anum_pg_class_relacl - 1] = 'r';
+               replaces[Anum_pg_class_relacl - 1] = true;
                values[Anum_pg_class_relacl - 1] = PointerGetDatum(new_acl);
 
-               newtuple = heap_modifytuple(tuple, RelationGetDescr(relation), values, nulls, replaces);
+               newtuple = heap_modify_tuple(tuple, RelationGetDescr(relation), values, nulls, replaces);
 
                simple_heap_update(relation, &newtuple->t_self, newtuple);
 
@@ -749,8 +749,8 @@ ExecGrant_Database(InternalGrant *istmt)
                Oid                     ownerId;
                HeapTuple       newtuple;
                Datum           values[Natts_pg_database];
-               char            nulls[Natts_pg_database];
-               char            replaces[Natts_pg_database];
+               bool            nulls[Natts_pg_database];
+               bool            replaces[Natts_pg_database];
                int                     noldmembers;
                int                     nnewmembers;
                Oid                *oldmembers;
@@ -809,14 +809,14 @@ ExecGrant_Database(InternalGrant *istmt)
 
                /* finished building new ACL value, now insert it */
                MemSet(values, 0, sizeof(values));
-               MemSet(nulls, ' ', sizeof(nulls));
-               MemSet(replaces, ' ', sizeof(replaces));
+               MemSet(nulls, false, sizeof(nulls));
+               MemSet(replaces, false, sizeof(replaces));
 
-               replaces[Anum_pg_database_datacl - 1] = 'r';
+               replaces[Anum_pg_database_datacl - 1] = true;
                values[Anum_pg_database_datacl - 1] = PointerGetDatum(new_acl);
 
-               newtuple = heap_modifytuple(tuple, RelationGetDescr(relation), values,
-                                                                       nulls, replaces);
+               newtuple = heap_modify_tuple(tuple, RelationGetDescr(relation), values,
+                                                                        nulls, replaces);
 
                simple_heap_update(relation, &newtuple->t_self, newtuple);
 
@@ -866,8 +866,8 @@ ExecGrant_Function(InternalGrant *istmt)
                HeapTuple       tuple;
                HeapTuple       newtuple;
                Datum           values[Natts_pg_proc];
-               char            nulls[Natts_pg_proc];
-               char            replaces[Natts_pg_proc];
+               bool            nulls[Natts_pg_proc];
+               bool            replaces[Natts_pg_proc];
                int                     noldmembers;
                int                     nnewmembers;
                Oid                *oldmembers;
@@ -925,14 +925,14 @@ ExecGrant_Function(InternalGrant *istmt)
 
                /* finished building new ACL value, now insert it */
                MemSet(values, 0, sizeof(values));
-               MemSet(nulls, ' ', sizeof(nulls));
-               MemSet(replaces, ' ', sizeof(replaces));
+               MemSet(nulls, false, sizeof(nulls));
+               MemSet(replaces, false, sizeof(replaces));
 
-               replaces[Anum_pg_proc_proacl - 1] = 'r';
+               replaces[Anum_pg_proc_proacl - 1] = true;
                values[Anum_pg_proc_proacl - 1] = PointerGetDatum(new_acl);
 
-               newtuple = heap_modifytuple(tuple, RelationGetDescr(relation), values,
-                                                                       nulls, replaces);
+               newtuple = heap_modify_tuple(tuple, RelationGetDescr(relation), values,
+                                                                        nulls, replaces);
 
                simple_heap_update(relation, &newtuple->t_self, newtuple);
 
@@ -982,8 +982,8 @@ ExecGrant_Language(InternalGrant *istmt)
                HeapTuple       tuple;
                HeapTuple       newtuple;
                Datum           values[Natts_pg_language];
-               char            nulls[Natts_pg_language];
-               char            replaces[Natts_pg_language];
+               bool            nulls[Natts_pg_language];
+               bool            replaces[Natts_pg_language];
                int                     noldmembers;
                int                     nnewmembers;
                Oid                *oldmembers;
@@ -1048,14 +1048,14 @@ ExecGrant_Language(InternalGrant *istmt)
 
                /* finished building new ACL value, now insert it */
                MemSet(values, 0, sizeof(values));
-               MemSet(nulls, ' ', sizeof(nulls));
-               MemSet(replaces, ' ', sizeof(replaces));
+               MemSet(nulls, false, sizeof(nulls));
+               MemSet(replaces, false, sizeof(replaces));
 
-               replaces[Anum_pg_language_lanacl - 1] = 'r';
+               replaces[Anum_pg_language_lanacl - 1] = true;
                values[Anum_pg_language_lanacl - 1] = PointerGetDatum(new_acl);
 
-               newtuple = heap_modifytuple(tuple, RelationGetDescr(relation), values,
-                                                                       nulls, replaces);
+               newtuple = heap_modify_tuple(tuple, RelationGetDescr(relation), values,
+                                                                        nulls, replaces);
 
                simple_heap_update(relation, &newtuple->t_self, newtuple);
 
@@ -1105,8 +1105,8 @@ ExecGrant_Namespace(InternalGrant *istmt)
                HeapTuple       tuple;
                HeapTuple       newtuple;
                Datum           values[Natts_pg_namespace];
-               char            nulls[Natts_pg_namespace];
-               char            replaces[Natts_pg_namespace];
+               bool            nulls[Natts_pg_namespace];
+               bool            replaces[Natts_pg_namespace];
                int                     noldmembers;
                int                     nnewmembers;
                Oid                *oldmembers;
@@ -1165,14 +1165,14 @@ ExecGrant_Namespace(InternalGrant *istmt)
 
                /* finished building new ACL value, now insert it */
                MemSet(values, 0, sizeof(values));
-               MemSet(nulls, ' ', sizeof(nulls));
-               MemSet(replaces, ' ', sizeof(replaces));
+               MemSet(nulls, false, sizeof(nulls));
+               MemSet(replaces, false, sizeof(replaces));
 
-               replaces[Anum_pg_namespace_nspacl - 1] = 'r';
+               replaces[Anum_pg_namespace_nspacl - 1] = true;
                values[Anum_pg_namespace_nspacl - 1] = PointerGetDatum(new_acl);
 
-               newtuple = heap_modifytuple(tuple, RelationGetDescr(relation), values,
-                                                                       nulls, replaces);
+               newtuple = heap_modify_tuple(tuple, RelationGetDescr(relation), values,
+                                                                        nulls, replaces);
 
                simple_heap_update(relation, &newtuple->t_self, newtuple);
 
@@ -1221,8 +1221,8 @@ ExecGrant_Tablespace(InternalGrant *istmt)
                Oid                     ownerId;
                HeapTuple       newtuple;
                Datum           values[Natts_pg_tablespace];
-               char            nulls[Natts_pg_tablespace];
-               char            replaces[Natts_pg_tablespace];
+               bool            nulls[Natts_pg_tablespace];
+               bool            replaces[Natts_pg_tablespace];
                int                     noldmembers;
                int                     nnewmembers;
                Oid                *oldmembers;
@@ -1288,14 +1288,14 @@ ExecGrant_Tablespace(InternalGrant *istmt)
 
                /* finished building new ACL value, now insert it */
                MemSet(values, 0, sizeof(values));
-               MemSet(nulls, ' ', sizeof(nulls));
-               MemSet(replaces, ' ', sizeof(replaces));
+               MemSet(nulls, false, sizeof(nulls));
+               MemSet(replaces, false, sizeof(replaces));
 
-               replaces[Anum_pg_tablespace_spcacl - 1] = 'r';
+               replaces[Anum_pg_tablespace_spcacl - 1] = true;
                values[Anum_pg_tablespace_spcacl - 1] = PointerGetDatum(new_acl);
 
-               newtuple = heap_modifytuple(tuple, RelationGetDescr(relation), values,
-                                                                       nulls, replaces);
+               newtuple = heap_modify_tuple(tuple, RelationGetDescr(relation), values,
+                                                                        nulls, replaces);
 
                simple_heap_update(relation, &newtuple->t_self, newtuple);
 
index 478eb045c0988dff9df748129062e2736371d537..f7585632e0519b626bbda1ba87286c49784266a7 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.341 2008/10/14 23:27:40 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.342 2008/11/02 01:45:27 tgl Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -618,12 +618,12 @@ InsertPgClassTuple(Relation pg_class_desc,
 {
        Form_pg_class rd_rel = new_rel_desc->rd_rel;
        Datum           values[Natts_pg_class];
-       char            nulls[Natts_pg_class];
+       bool            nulls[Natts_pg_class];
        HeapTuple       tup;
 
        /* This is a tad tedious, but way cleaner than what we used to do... */
        memset(values, 0, sizeof(values));
-       memset(nulls, ' ', sizeof(nulls));
+       memset(nulls, false, sizeof(nulls));
 
        values[Anum_pg_class_relname - 1] = NameGetDatum(&rd_rel->relname);
        values[Anum_pg_class_relnamespace - 1] = ObjectIdGetDatum(rd_rel->relnamespace);
@@ -651,13 +651,13 @@ InsertPgClassTuple(Relation pg_class_desc,
        values[Anum_pg_class_relhassubclass - 1] = BoolGetDatum(rd_rel->relhassubclass);
        values[Anum_pg_class_relfrozenxid - 1] = TransactionIdGetDatum(rd_rel->relfrozenxid);
        /* start out with empty permissions */
-       nulls[Anum_pg_class_relacl - 1] = 'n';
+       nulls[Anum_pg_class_relacl - 1] = true;
        if (reloptions != (Datum) 0)
                values[Anum_pg_class_reloptions - 1] = reloptions;
        else
-               nulls[Anum_pg_class_reloptions - 1] = 'n';
+               nulls[Anum_pg_class_reloptions - 1] = true;
 
-       tup = heap_formtuple(RelationGetDescr(pg_class_desc), values, nulls);
+       tup = heap_form_tuple(RelationGetDescr(pg_class_desc), values, nulls);
 
        /*
         * The new tuple must have the oid already chosen for the rel.  Sure would
@@ -1464,7 +1464,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, Node *expr)
        Relation        adrel;
        HeapTuple       tuple;
        Datum           values[4];
-       static char nulls[4] = {' ', ' ', ' ', ' '};
+       static bool nulls[4] = {false, false, false, false};
        Relation        attrrel;
        HeapTuple       atttup;
        Form_pg_attribute attStruct;
@@ -1495,7 +1495,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, Node *expr)
 
        adrel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
 
-       tuple = heap_formtuple(adrel->rd_att, values, nulls);
+       tuple = heap_form_tuple(adrel->rd_att, values, nulls);
        attrdefOid = simple_heap_insert(adrel, tuple);
 
        CatalogUpdateIndexes(adrel, tuple);
index 8172918252e005e27ac9693773e6f7299607d2d6..7c0c313e91b520c082fcae4e562f8cdaf1622ef5 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.306 2008/10/14 21:47:39 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.307 2008/11/02 01:45:27 tgl Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -389,7 +389,7 @@ UpdateIndexRelation(Oid indexoid,
        Datum           exprsDatum;
        Datum           predDatum;
        Datum           values[Natts_pg_index];
-       char            nulls[Natts_pg_index];
+       bool            nulls[Natts_pg_index];
        Relation        pg_index;
        HeapTuple       tuple;
        int                     i;
@@ -441,7 +441,7 @@ UpdateIndexRelation(Oid indexoid,
        /*
         * Build a pg_index tuple
         */
-       MemSet(nulls, ' ', sizeof(nulls));
+       MemSet(nulls, false, sizeof(nulls));
 
        values[Anum_pg_index_indexrelid - 1] = ObjectIdGetDatum(indexoid);
        values[Anum_pg_index_indrelid - 1] = ObjectIdGetDatum(heapoid);
@@ -458,12 +458,12 @@ UpdateIndexRelation(Oid indexoid,
        values[Anum_pg_index_indoption - 1] = PointerGetDatum(indoption);
        values[Anum_pg_index_indexprs - 1] = exprsDatum;
        if (exprsDatum == (Datum) 0)
-               nulls[Anum_pg_index_indexprs - 1] = 'n';
+               nulls[Anum_pg_index_indexprs - 1] = true;
        values[Anum_pg_index_indpred - 1] = predDatum;
        if (predDatum == (Datum) 0)
-               nulls[Anum_pg_index_indpred - 1] = 'n';
+               nulls[Anum_pg_index_indpred - 1] = true;
 
-       tuple = heap_formtuple(RelationGetDescr(pg_index), values, nulls);
+       tuple = heap_form_tuple(RelationGetDescr(pg_index), values, nulls);
 
        /*
         * insert the tuple into the pg_index catalog
index 42eadca1e2b2c03d93281657f27fd9b2e0bd2d80..69bfe4c1578d92d6639ad3384c18b65dfc9f743a 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/catalog/pg_aggregate.c,v 1.95 2008/07/16 16:55:23 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/catalog/pg_aggregate.c,v 1.96 2008/11/02 01:45:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -54,7 +54,7 @@ AggregateCreate(const char *aggName,
 {
        Relation        aggdesc;
        HeapTuple       tup;
-       char            nulls[Natts_pg_aggregate];
+       bool            nulls[Natts_pg_aggregate];
        Datum           values[Natts_pg_aggregate];
        Form_pg_proc proc;
        Oid                     transfn;
@@ -225,7 +225,7 @@ AggregateCreate(const char *aggName,
        /* initialize nulls and values */
        for (i = 0; i < Natts_pg_aggregate; i++)
        {
-               nulls[i] = ' ';
+               nulls[i] = false;
                values[i] = (Datum) NULL;
        }
        values[Anum_pg_aggregate_aggfnoid - 1] = ObjectIdGetDatum(procOid);
@@ -236,12 +236,12 @@ AggregateCreate(const char *aggName,
        if (agginitval)
                values[Anum_pg_aggregate_agginitval - 1] = CStringGetTextDatum(agginitval);
        else
-               nulls[Anum_pg_aggregate_agginitval - 1] = 'n';
+               nulls[Anum_pg_aggregate_agginitval - 1] = true;
 
        aggdesc = heap_open(AggregateRelationId, RowExclusiveLock);
        tupDesc = aggdesc->rd_att;
 
-       tup = heap_formtuple(tupDesc, values, nulls);
+       tup = heap_form_tuple(tupDesc, values, nulls);
        simple_heap_insert(aggdesc, tup);
 
        CatalogUpdateIndexes(aggdesc, tup);
index 1bf5c4ec3c86aeb87321e331aea276e73c9df5ef..6a5559dd3cb29274205ec13ea60f272f151a9d12 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/catalog/pg_constraint.c,v 1.42 2008/06/19 00:46:04 alvherre Exp $
+ *       $PostgreSQL: pgsql/src/backend/catalog/pg_constraint.c,v 1.43 2008/11/02 01:45:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -68,7 +68,7 @@ CreateConstraintEntry(const char *constraintName,
        Relation        conDesc;
        Oid                     conOid;
        HeapTuple       tup;
-       char            nulls[Natts_pg_constraint];
+       bool            nulls[Natts_pg_constraint];
        Datum           values[Natts_pg_constraint];
        ArrayType  *conkeyArray;
        ArrayType  *confkeyArray;
@@ -133,7 +133,7 @@ CreateConstraintEntry(const char *constraintName,
        /* initialize nulls and values */
        for (i = 0; i < Natts_pg_constraint; i++)
        {
-               nulls[i] = ' ';
+               nulls[i] = false;
                values[i] = (Datum) NULL;
        }
 
@@ -154,27 +154,27 @@ CreateConstraintEntry(const char *constraintName,
        if (conkeyArray)
                values[Anum_pg_constraint_conkey - 1] = PointerGetDatum(conkeyArray);
        else
-               nulls[Anum_pg_constraint_conkey - 1] = 'n';
+               nulls[Anum_pg_constraint_conkey - 1] = true;
 
        if (confkeyArray)
                values[Anum_pg_constraint_confkey - 1] = PointerGetDatum(confkeyArray);
        else
-               nulls[Anum_pg_constraint_confkey - 1] = 'n';
+               nulls[Anum_pg_constraint_confkey - 1] = true;
 
        if (conpfeqopArray)
                values[Anum_pg_constraint_conpfeqop - 1] = PointerGetDatum(conpfeqopArray);
        else
-               nulls[Anum_pg_constraint_conpfeqop - 1] = 'n';
+               nulls[Anum_pg_constraint_conpfeqop - 1] = true;
 
        if (conppeqopArray)
                values[Anum_pg_constraint_conppeqop - 1] = PointerGetDatum(conppeqopArray);
        else
-               nulls[Anum_pg_constraint_conppeqop - 1] = 'n';
+               nulls[Anum_pg_constraint_conppeqop - 1] = true;
 
        if (conffeqopArray)
                values[Anum_pg_constraint_conffeqop - 1] = PointerGetDatum(conffeqopArray);
        else
-               nulls[Anum_pg_constraint_conffeqop - 1] = 'n';
+               nulls[Anum_pg_constraint_conffeqop - 1] = true;
 
        /*
         * initialize the binary form of the check constraint.
@@ -182,7 +182,7 @@ CreateConstraintEntry(const char *constraintName,
        if (conBin)
                values[Anum_pg_constraint_conbin - 1] = CStringGetTextDatum(conBin);
        else
-               nulls[Anum_pg_constraint_conbin - 1] = 'n';
+               nulls[Anum_pg_constraint_conbin - 1] = true;
 
        /*
         * initialize the text form of the check constraint
@@ -190,9 +190,9 @@ CreateConstraintEntry(const char *constraintName,
        if (conSrc)
                values[Anum_pg_constraint_consrc - 1] = CStringGetTextDatum(conSrc);
        else
-               nulls[Anum_pg_constraint_consrc - 1] = 'n';
+               nulls[Anum_pg_constraint_consrc - 1] = true;
 
-       tup = heap_formtuple(RelationGetDescr(conDesc), values, nulls);
+       tup = heap_form_tuple(RelationGetDescr(conDesc), values, nulls);
 
        conOid = simple_heap_insert(conDesc, tup);
 
index d03cb647eeba66365fd2561838ac8855ca03c15d..4937ae3f02664b9709fb24b7f687827ef75099ba 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/catalog/pg_conversion.c,v 1.45 2008/06/19 00:46:04 alvherre Exp $
+ *       $PostgreSQL: pgsql/src/backend/catalog/pg_conversion.c,v 1.46 2008/11/02 01:45:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -46,7 +46,7 @@ ConversionCreate(const char *conname, Oid connamespace,
        Relation        rel;
        TupleDesc       tupDesc;
        HeapTuple       tup;
-       char            nulls[Natts_pg_conversion];
+       bool            nulls[Natts_pg_conversion];
        Datum           values[Natts_pg_conversion];
        NameData        cname;
        Oid                     oid;
@@ -89,7 +89,7 @@ ConversionCreate(const char *conname, Oid connamespace,
        /* initialize nulls and values */
        for (i = 0; i < Natts_pg_conversion; i++)
        {
-               nulls[i] = ' ';
+               nulls[i] = false;
                values[i] = (Datum) NULL;
        }
 
@@ -103,7 +103,7 @@ ConversionCreate(const char *conname, Oid connamespace,
        values[Anum_pg_conversion_conproc - 1] = ObjectIdGetDatum(conproc);
        values[Anum_pg_conversion_condefault - 1] = BoolGetDatum(def);
 
-       tup = heap_formtuple(tupDesc, values, nulls);
+       tup = heap_form_tuple(tupDesc, values, nulls);
 
        /* insert a new tuple */
        oid = simple_heap_insert(rel, tup);
index 405510ce90c1273b0dd0f1835a6f0fce6528d813..6dd043e5046fe1a311afb827bdd231b587525b1e 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/catalog/pg_depend.c,v 1.29 2008/06/19 00:46:04 alvherre Exp $
+ *       $PostgreSQL: pgsql/src/backend/catalog/pg_depend.c,v 1.30 2008/11/02 01:45:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -59,7 +59,7 @@ recordMultipleDependencies(const ObjectAddress *depender,
        CatalogIndexState indstate;
        HeapTuple       tup;
        int                     i;
-       char            nulls[Natts_pg_depend];
+       bool            nulls[Natts_pg_depend];
        Datum           values[Natts_pg_depend];
 
        if (nreferenced <= 0)
@@ -77,7 +77,7 @@ recordMultipleDependencies(const ObjectAddress *depender,
        /* Don't open indexes unless we need to make an update */
        indstate = NULL;
 
-       memset(nulls, ' ', sizeof(nulls));
+       memset(nulls, false, sizeof(nulls));
 
        for (i = 0; i < nreferenced; i++, referenced++)
        {
@@ -102,7 +102,7 @@ recordMultipleDependencies(const ObjectAddress *depender,
 
                        values[Anum_pg_depend_deptype - 1] = CharGetDatum((char) behavior);
 
-                       tup = heap_formtuple(dependDesc->rd_att, values, nulls);
+                       tup = heap_form_tuple(dependDesc->rd_att, values, nulls);
 
                        simple_heap_insert(dependDesc, tup);
 
index 846c623df6c72b45f3cdb30386bd0df873b80bbc..2a221da97a4feba77ac08b6cf4334ef4cec43a13 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/catalog/pg_enum.c,v 1.7 2008/06/19 00:46:04 alvherre Exp $
+ *       $PostgreSQL: pgsql/src/backend/catalog/pg_enum.c,v 1.8 2008/11/02 01:45:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -42,7 +42,7 @@ EnumValuesCreate(Oid enumTypeOid, List *vals)
        int                     i,
                                n;
        Datum           values[Natts_pg_enum];
-       char            nulls[Natts_pg_enum];
+       bool            nulls[Natts_pg_enum];
        ListCell   *lc;
        HeapTuple       tup;
 
@@ -74,7 +74,7 @@ EnumValuesCreate(Oid enumTypeOid, List *vals)
        qsort(oids, n, sizeof(Oid), oid_cmp);
 
        /* and make the entries */
-       memset(nulls, ' ', sizeof(nulls));
+       memset(nulls, false, sizeof(nulls));
 
        i = 0;
        foreach(lc, vals)
@@ -96,7 +96,7 @@ EnumValuesCreate(Oid enumTypeOid, List *vals)
                namestrcpy(&enumlabel, lab);
                values[Anum_pg_enum_enumlabel - 1] = NameGetDatum(&enumlabel);
 
-               tup = heap_formtuple(tupDesc, values, nulls);
+               tup = heap_form_tuple(tupDesc, values, nulls);
                HeapTupleSetOid(tup, oids[i]);
 
                simple_heap_insert(pg_enum, tup);
index 308c4162f4746b6cf8d04fab5a64f821e3128596..d9d7c8a9e80ed681e960e703d82bd3ea13f50d0c 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/catalog/pg_largeobject.c,v 1.30 2008/06/19 00:46:04 alvherre Exp $
+ *       $PostgreSQL: pgsql/src/backend/catalog/pg_largeobject.c,v 1.31 2008/11/02 01:45:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -37,7 +37,7 @@ LargeObjectCreate(Oid loid)
        Relation        pg_largeobject;
        HeapTuple       ntup;
        Datum           values[Natts_pg_largeobject];
-       char            nulls[Natts_pg_largeobject];
+       bool            nulls[Natts_pg_largeobject];
        int                     i;
 
        pg_largeobject = heap_open(LargeObjectRelationId, RowExclusiveLock);
@@ -48,7 +48,7 @@ LargeObjectCreate(Oid loid)
        for (i = 0; i < Natts_pg_largeobject; i++)
        {
                values[i] = (Datum) NULL;
-               nulls[i] = ' ';
+               nulls[i] = false;
        }
 
        i = 0;
@@ -57,7 +57,7 @@ LargeObjectCreate(Oid loid)
        values[i++] = DirectFunctionCall1(byteain,
                                                                          CStringGetDatum(""));
 
-       ntup = heap_formtuple(pg_largeobject->rd_att, values, nulls);
+       ntup = heap_form_tuple(pg_largeobject->rd_att, values, nulls);
 
        /*
         * Insert it
index 804dfc80161960079de3e53a24bdf42f361fdb0d..121f6a17b94a94271dfe1f94ef3c65c3d7788e87 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/catalog/pg_namespace.c,v 1.19 2008/06/19 00:46:04 alvherre Exp $
+ *       $PostgreSQL: pgsql/src/backend/catalog/pg_namespace.c,v 1.20 2008/11/02 01:45:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -33,7 +33,7 @@ NamespaceCreate(const char *nspName, Oid ownerId)
        Relation        nspdesc;
        HeapTuple       tup;
        Oid                     nspoid;
-       char            nulls[Natts_pg_namespace];
+       bool            nulls[Natts_pg_namespace];
        Datum           values[Natts_pg_namespace];
        NameData        nname;
        TupleDesc       tupDesc;
@@ -54,18 +54,18 @@ NamespaceCreate(const char *nspName, Oid ownerId)
        /* initialize nulls and values */
        for (i = 0; i < Natts_pg_namespace; i++)
        {
-               nulls[i] = ' ';
+               nulls[i] = false;
                values[i] = (Datum) NULL;
        }
        namestrcpy(&nname, nspName);
        values[Anum_pg_namespace_nspname - 1] = NameGetDatum(&nname);
        values[Anum_pg_namespace_nspowner - 1] = ObjectIdGetDatum(ownerId);
-       nulls[Anum_pg_namespace_nspacl - 1] = 'n';
+       nulls[Anum_pg_namespace_nspacl - 1] = true;
 
        nspdesc = heap_open(NamespaceRelationId, RowExclusiveLock);
        tupDesc = nspdesc->rd_att;
 
-       tup = heap_formtuple(tupDesc, values, nulls);
+       tup = heap_form_tuple(tupDesc, values, nulls);
 
        nspoid = simple_heap_insert(nspdesc, tup);
        Assert(OidIsValid(nspoid));
index 94b3bf28625e6b138ca6b9b36b3cb87aa18fb7b3..30b29aab260a735e1b8eb8d44287ca10c96f51b5 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/catalog/pg_operator.c,v 1.105 2008/08/16 00:01:35 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/catalog/pg_operator.c,v 1.106 2008/11/02 01:45:27 tgl Exp $
  *
  * NOTES
  *       these routines moved here from commands/define.c and somewhat cleaned up.
@@ -207,7 +207,7 @@ OperatorShellMake(const char *operatorName,
        int                     i;
        HeapTuple       tup;
        Datum           values[Natts_pg_operator];
-       char            nulls[Natts_pg_operator];
+       bool            nulls[Natts_pg_operator];
        NameData        oname;
        TupleDesc       tupDesc;
 
@@ -225,7 +225,7 @@ OperatorShellMake(const char *operatorName,
         */
        for (i = 0; i < Natts_pg_operator; ++i)
        {
-               nulls[i] = ' ';
+               nulls[i] = false;
                values[i] = (Datum) NULL;               /* redundant, but safe */
        }
 
@@ -259,7 +259,7 @@ OperatorShellMake(const char *operatorName,
        /*
         * create a new operator tuple
         */
-       tup = heap_formtuple(tupDesc, values, nulls);
+       tup = heap_form_tuple(tupDesc, values, nulls);
 
        /*
         * insert our "shell" operator tuple
@@ -336,8 +336,8 @@ OperatorCreate(const char *operatorName,
 {
        Relation        pg_operator_desc;
        HeapTuple       tup;
-       char            nulls[Natts_pg_operator];
-       char            replaces[Natts_pg_operator];
+       bool            nulls[Natts_pg_operator];
+       bool            replaces[Natts_pg_operator];
        Datum           values[Natts_pg_operator];
        Oid                     operatorObjectId;
        bool            operatorAlreadyDefined;
@@ -483,8 +483,8 @@ OperatorCreate(const char *operatorName,
        for (i = 0; i < Natts_pg_operator; ++i)
        {
                values[i] = (Datum) NULL;
-               replaces[i] = 'r';
-               nulls[i] = ' ';
+               replaces[i] = true;
+               nulls[i] = false;
        }
 
        i = 0;
@@ -518,7 +518,7 @@ OperatorCreate(const char *operatorName,
                        elog(ERROR, "cache lookup failed for operator %u",
                                 operatorObjectId);
 
-               tup = heap_modifytuple(tup,
+               tup = heap_modify_tuple(tup,
                                                           RelationGetDescr(pg_operator_desc),
                                                           values,
                                                           nulls,
@@ -529,7 +529,7 @@ OperatorCreate(const char *operatorName,
        else
        {
                tupDesc = pg_operator_desc->rd_att;
-               tup = heap_formtuple(tupDesc, values, nulls);
+               tup = heap_form_tuple(tupDesc, values, nulls);
 
                operatorObjectId = simple_heap_insert(pg_operator_desc, tup);
        }
@@ -639,15 +639,15 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
        int                     i;
        Relation        pg_operator_desc;
        HeapTuple       tup;
-       char            nulls[Natts_pg_operator];
-       char            replaces[Natts_pg_operator];
+       bool            nulls[Natts_pg_operator];
+       bool            replaces[Natts_pg_operator];
        Datum           values[Natts_pg_operator];
 
        for (i = 0; i < Natts_pg_operator; ++i)
        {
                values[i] = (Datum) 0;
-               replaces[i] = ' ';
-               nulls[i] = ' ';
+               replaces[i] = false;
+               nulls[i] = false;
        }
 
        /*
@@ -680,16 +680,16 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
                                if (!OidIsValid(t->oprnegate))
                                {
                                        values[Anum_pg_operator_oprnegate - 1] = ObjectIdGetDatum(baseId);
-                                       replaces[Anum_pg_operator_oprnegate - 1] = 'r';
+                                       replaces[Anum_pg_operator_oprnegate - 1] = true;
                                }
 
                                if (!OidIsValid(t->oprcom))
                                {
                                        values[Anum_pg_operator_oprcom - 1] = ObjectIdGetDatum(baseId);
-                                       replaces[Anum_pg_operator_oprcom - 1] = 'r';
+                                       replaces[Anum_pg_operator_oprcom - 1] = true;
                                }
 
-                               tup = heap_modifytuple(tup,
+                               tup = heap_modify_tuple(tup,
                                                                           RelationGetDescr(pg_operator_desc),
                                                                           values,
                                                                           nulls,
@@ -712,9 +712,9 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
                !(OidIsValid(((Form_pg_operator) GETSTRUCT(tup))->oprcom)))
        {
                values[Anum_pg_operator_oprcom - 1] = ObjectIdGetDatum(baseId);
-               replaces[Anum_pg_operator_oprcom - 1] = 'r';
+               replaces[Anum_pg_operator_oprcom - 1] = true;
 
-               tup = heap_modifytuple(tup,
+               tup = heap_modify_tuple(tup,
                                                           RelationGetDescr(pg_operator_desc),
                                                           values,
                                                           nulls,
@@ -725,7 +725,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
                CatalogUpdateIndexes(pg_operator_desc, tup);
 
                values[Anum_pg_operator_oprcom - 1] = (Datum) NULL;
-               replaces[Anum_pg_operator_oprcom - 1] = ' ';
+               replaces[Anum_pg_operator_oprcom - 1] = false;
        }
 
        /* check and update the negator, if necessary */
@@ -738,9 +738,9 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
                !(OidIsValid(((Form_pg_operator) GETSTRUCT(tup))->oprnegate)))
        {
                values[Anum_pg_operator_oprnegate - 1] = ObjectIdGetDatum(baseId);
-               replaces[Anum_pg_operator_oprnegate - 1] = 'r';
+               replaces[Anum_pg_operator_oprnegate - 1] = true;
 
-               tup = heap_modifytuple(tup,
+               tup = heap_modify_tuple(tup,
                                                           RelationGetDescr(pg_operator_desc),
                                                           values,
                                                           nulls,
index e2513eb7dde1df0253103237e7a1be78fc7e6996..e17aa43fd5c22f019f58280681cdbc43c7a335ad 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.153 2008/07/18 03:32:52 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.154 2008/11/02 01:45:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -89,9 +89,9 @@ ProcedureCreate(const char *procedureName,
        Relation        rel;
        HeapTuple       tup;
        HeapTuple       oldtup;
-       char            nulls[Natts_pg_proc];
+       bool            nulls[Natts_pg_proc];
        Datum           values[Natts_pg_proc];
-       char            replaces[Natts_pg_proc];
+       bool            replaces[Natts_pg_proc];
        Oid                     relid;
        NameData        procname;
        TupleDesc       tupDesc;
@@ -276,9 +276,9 @@ ProcedureCreate(const char *procedureName,
 
        for (i = 0; i < Natts_pg_proc; ++i)
        {
-               nulls[i] = ' ';
+               nulls[i] = false;
                values[i] = (Datum) 0;
-               replaces[i] = 'r';
+               replaces[i] = true;
        }
 
        namestrcpy(&procname, procedureName);
@@ -300,26 +300,26 @@ ProcedureCreate(const char *procedureName,
        if (allParameterTypes != PointerGetDatum(NULL))
                values[Anum_pg_proc_proallargtypes - 1] = allParameterTypes;
        else
-               nulls[Anum_pg_proc_proallargtypes - 1] = 'n';
+               nulls[Anum_pg_proc_proallargtypes - 1] = true;
        if (parameterModes != PointerGetDatum(NULL))
                values[Anum_pg_proc_proargmodes - 1] = parameterModes;
        else
-               nulls[Anum_pg_proc_proargmodes - 1] = 'n';
+               nulls[Anum_pg_proc_proargmodes - 1] = true;
        if (parameterNames != PointerGetDatum(NULL))
                values[Anum_pg_proc_proargnames - 1] = parameterNames;
        else
-               nulls[Anum_pg_proc_proargnames - 1] = 'n';
+               nulls[Anum_pg_proc_proargnames - 1] = true;
        values[Anum_pg_proc_prosrc - 1] = CStringGetTextDatum(prosrc);
        if (probin)
                values[Anum_pg_proc_probin - 1] = CStringGetTextDatum(probin);
        else
-               nulls[Anum_pg_proc_probin - 1] = 'n';
+               nulls[Anum_pg_proc_probin - 1] = true;
        if (proconfig != PointerGetDatum(NULL))
                values[Anum_pg_proc_proconfig - 1] = proconfig;
        else
-               nulls[Anum_pg_proc_proconfig - 1] = 'n';
+               nulls[Anum_pg_proc_proconfig - 1] = true;
        /* start out with empty permissions */
-       nulls[Anum_pg_proc_proacl - 1] = 'n';
+       nulls[Anum_pg_proc_proacl - 1] = true;
 
        rel = heap_open(ProcedureRelationId, RowExclusiveLock);
        tupDesc = RelationGetDescr(rel);
@@ -396,11 +396,11 @@ ProcedureCreate(const char *procedureName,
                }
 
                /* do not change existing ownership or permissions, either */
-               replaces[Anum_pg_proc_proowner - 1] = ' ';
-               replaces[Anum_pg_proc_proacl - 1] = ' ';
+               replaces[Anum_pg_proc_proowner - 1] = false;
+               replaces[Anum_pg_proc_proacl - 1] = false;
 
                /* Okay, do it... */
-               tup = heap_modifytuple(oldtup, tupDesc, values, nulls, replaces);
+               tup = heap_modify_tuple(oldtup, tupDesc, values, nulls, replaces);
                simple_heap_update(rel, &tup->t_self, tup);
 
                ReleaseSysCache(oldtup);
@@ -409,7 +409,7 @@ ProcedureCreate(const char *procedureName,
        else
        {
                /* Creating a new procedure */
-               tup = heap_formtuple(tupDesc, values, nulls);
+               tup = heap_form_tuple(tupDesc, values, nulls);
                simple_heap_insert(rel, tup);
                is_update = false;
        }
index 0ca342bdce5ba762fe014d38e4be43d2f1767c29..08150139194d72eb46ad18efe1a784c1f5279f82 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.28 2008/05/12 00:00:47 alvherre Exp $
+ *       $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.29 2008/11/02 01:45:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -239,7 +239,7 @@ shdepChangeDep(Relation sdepRel, Oid classid, Oid objid,
                Datum           values[Natts_pg_shdepend];
                bool            nulls[Natts_pg_shdepend];
 
-               memset(nulls, 0, sizeof(nulls));
+               memset(nulls, false, sizeof(nulls));
 
                values[Anum_pg_shdepend_dbid - 1] = ObjectIdGetDatum(dbid);
                values[Anum_pg_shdepend_classid - 1] = ObjectIdGetDatum(classid);
index a43ebec60268c065e6c0aa2705ad0d264781eb2d..bae51024b9836ac86680545677c8693d0d6753b0 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.121 2008/08/03 15:23:58 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.122 2008/11/02 01:45:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -54,7 +54,7 @@ TypeShellMake(const char *typeName, Oid typeNamespace)
        int                     i;
        HeapTuple       tup;
        Datum           values[Natts_pg_type];
-       char            nulls[Natts_pg_type];
+       bool            nulls[Natts_pg_type];
        Oid                     typoid;
        NameData        name;
 
@@ -71,7 +71,7 @@ TypeShellMake(const char *typeName, Oid typeNamespace)
         */
        for (i = 0; i < Natts_pg_type; ++i)
        {
-               nulls[i] = ' ';
+               nulls[i] = false;
                values[i] = (Datum) NULL;               /* redundant, but safe */
        }
 
@@ -111,13 +111,13 @@ TypeShellMake(const char *typeName, Oid typeNamespace)
        values[i++] = ObjectIdGetDatum(InvalidOid); /* typbasetype */
        values[i++] = Int32GetDatum(-1);        /* typtypmod */
        values[i++] = Int32GetDatum(0);         /* typndims */
-       nulls[i++] = 'n';                       /* typdefaultbin */
-       nulls[i++] = 'n';                       /* typdefault */
+       nulls[i++] = true;                      /* typdefaultbin */
+       nulls[i++] = true;                      /* typdefault */
 
        /*
         * create a new type tuple
         */
-       tup = heap_formtuple(tupDesc, values, nulls);
+       tup = heap_form_tuple(tupDesc, values, nulls);
 
        /*
         * insert the tuple in the relation and get the tuple's oid.
@@ -202,8 +202,8 @@ TypeCreate(Oid newTypeOid,
        Oid                     typeObjectId;
        bool            rebuildDeps = false;
        HeapTuple       tup;
-       char            nulls[Natts_pg_type];
-       char            replaces[Natts_pg_type];
+       bool            nulls[Natts_pg_type];
+       bool            replaces[Natts_pg_type];
        Datum           values[Natts_pg_type];
        NameData        name;
        int                     i;
@@ -294,12 +294,12 @@ TypeCreate(Oid newTypeOid,
                                 errmsg("fixed-size types must have storage PLAIN")));
 
        /*
-        * initialize arrays needed for heap_formtuple or heap_modifytuple
+        * initialize arrays needed for heap_form_tuple or heap_modify_tuple
         */
        for (i = 0; i < Natts_pg_type; ++i)
        {
-               nulls[i] = ' ';
-               replaces[i] = 'r';
+               nulls[i] = false;
+               replaces[i] = true;
                values[i] = (Datum) 0;
        }
 
@@ -342,7 +342,7 @@ TypeCreate(Oid newTypeOid,
        if (defaultTypeBin)
                values[i] = CStringGetTextDatum(defaultTypeBin);
        else
-               nulls[i] = 'n';
+               nulls[i] = true;
        i++;                                            /* typdefaultbin */
 
        /*
@@ -351,7 +351,7 @@ TypeCreate(Oid newTypeOid,
        if (defaultTypeValue)
                values[i] = CStringGetTextDatum(defaultTypeValue);
        else
-               nulls[i] = 'n';
+               nulls[i] = true;
        i++;                                            /* typdefault */
 
        /*
@@ -390,7 +390,7 @@ TypeCreate(Oid newTypeOid,
                /*
                 * Okay to update existing shell type tuple
                 */
-               tup = heap_modifytuple(tup,
+               tup = heap_modify_tuple(tup,
                                                           RelationGetDescr(pg_type_desc),
                                                           values,
                                                           nulls,
@@ -404,7 +404,7 @@ TypeCreate(Oid newTypeOid,
        }
        else
        {
-               tup = heap_formtuple(RelationGetDescr(pg_type_desc),
+               tup = heap_form_tuple(RelationGetDescr(pg_type_desc),
                                                         values,
                                                         nulls);
 
index 4b164aa7c5f3e8a81b9265236710b1d34b3a98c1..13a66e17e98027daab945241351ae86b458a1dae 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.126 2008/10/31 15:05:00 heikki Exp $
+ *       $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.127 2008/11/02 01:45:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1277,8 +1277,8 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats)
                                        k,
                                        n;
                Datum           values[Natts_pg_statistic];
-               char            nulls[Natts_pg_statistic];
-               char            replaces[Natts_pg_statistic];
+               bool            nulls[Natts_pg_statistic];
+               bool            replaces[Natts_pg_statistic];
 
                /* Ignore attr if we weren't able to collect stats */
                if (!stats->stats_valid)
@@ -1289,8 +1289,8 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats)
                 */
                for (i = 0; i < Natts_pg_statistic; ++i)
                {
-                       nulls[i] = ' ';
-                       replaces[i] = 'r';
+                       nulls[i] = false;
+                       replaces[i] = true;
                }
 
                i = 0;
@@ -1326,7 +1326,7 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats)
                        }
                        else
                        {
-                               nulls[i] = 'n';
+                               nulls[i] = true;
                                values[i++] = (Datum) 0;
                        }
                }
@@ -1346,7 +1346,7 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats)
                        }
                        else
                        {
-                               nulls[i] = 'n';
+                               nulls[i] = true;
                                values[i++] = (Datum) 0;
                        }
                }
@@ -1360,7 +1360,7 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats)
                if (HeapTupleIsValid(oldtup))
                {
                        /* Yes, replace it */
-                       stup = heap_modifytuple(oldtup,
+                       stup = heap_modify_tuple(oldtup,
                                                                        RelationGetDescr(sd),
                                                                        values,
                                                                        nulls,
@@ -1371,7 +1371,7 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats)
                else
                {
                        /* No, insert new tuple */
-                       stup = heap_formtuple(RelationGetDescr(sd), values, nulls);
+                       stup = heap_form_tuple(RelationGetDescr(sd), values, nulls);
                        simple_heap_insert(sd, stup);
                }
 
index fabba799c4a50d190aad342c01875b65c938a33e..195159f305359593529b6f1d56cb4830958a7af9 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.141 2008/08/30 01:39:13 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.142 2008/11/02 01:45:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -446,7 +446,7 @@ Exec_Listen(Relation lRel, const char *relname)
        HeapScanDesc scan;
        HeapTuple       tuple;
        Datum           values[Natts_pg_listener];
-       char            nulls[Natts_pg_listener];
+       bool            nulls[Natts_pg_listener];
        NameData        condname;
        bool            alreadyListener = false;
 
@@ -475,14 +475,14 @@ Exec_Listen(Relation lRel, const char *relname)
        /*
         * OK to insert a new tuple
         */
-       memset(nulls, ' ', sizeof(nulls));
+       memset(nulls, false, sizeof(nulls));
 
        namestrcpy(&condname, relname);
        values[Anum_pg_listener_relname - 1] = NameGetDatum(&condname);
        values[Anum_pg_listener_pid - 1] = Int32GetDatum(MyProcPid);
        values[Anum_pg_listener_notify - 1] = Int32GetDatum(0); /* no notifies pending */
 
-       tuple = heap_formtuple(RelationGetDescr(lRel), values, nulls);
+       tuple = heap_form_tuple(RelationGetDescr(lRel), values, nulls);
 
        simple_heap_insert(lRel, tuple);
 
@@ -585,14 +585,14 @@ Send_Notify(Relation lRel)
        HeapTuple       lTuple,
                                rTuple;
        Datum           value[Natts_pg_listener];
-       char            repl[Natts_pg_listener],
+       bool            repl[Natts_pg_listener],
                                nulls[Natts_pg_listener];
 
        /* preset data to update notify column to MyProcPid */
-       nulls[0] = nulls[1] = nulls[2] = ' ';
-       repl[0] = repl[1] = repl[2] = ' ';
-       repl[Anum_pg_listener_notify - 1] = 'r';
-       value[0] = value[1] = value[2] = (Datum) 0;
+       memset(nulls, false, sizeof(nulls));
+       memset(repl, false, sizeof(repl));
+       repl[Anum_pg_listener_notify - 1] = true;
+       memset(value, 0, sizeof(value));
        value[Anum_pg_listener_notify - 1] = Int32GetDatum(MyProcPid);
 
        scan = heap_beginscan(lRel, SnapshotNow, 0, NULL);
@@ -647,7 +647,7 @@ Send_Notify(Relation lRel)
                        else if (listener->notification == 0)
                        {
                                /* Rewrite the tuple with my PID in notification column */
-                               rTuple = heap_modifytuple(lTuple, tdesc, value, nulls, repl);
+                               rTuple = heap_modify_tuple(lTuple, tdesc, value, nulls, repl);
                                simple_heap_update(lRel, &lTuple->t_self, rTuple);
 
 #ifdef NOT_USED                                        /* currently there are no indexes */
@@ -950,7 +950,7 @@ ProcessIncomingNotify(void)
        HeapTuple       lTuple,
                                rTuple;
        Datum           value[Natts_pg_listener];
-       char            repl[Natts_pg_listener],
+       bool            repl[Natts_pg_listener],
                                nulls[Natts_pg_listener];
        bool            catchup_enabled;
 
@@ -977,10 +977,10 @@ ProcessIncomingNotify(void)
        scan = heap_beginscan(lRel, SnapshotNow, 1, key);
 
        /* Prepare data for rewriting 0 into notification field */
-       nulls[0] = nulls[1] = nulls[2] = ' ';
-       repl[0] = repl[1] = repl[2] = ' ';
-       repl[Anum_pg_listener_notify - 1] = 'r';
-       value[0] = value[1] = value[2] = (Datum) 0;
+       memset(nulls, false, sizeof(nulls));
+       memset(repl, false, sizeof(repl));
+       repl[Anum_pg_listener_notify - 1] = true;
+       memset(value, 0, sizeof(value));
        value[Anum_pg_listener_notify - 1] = Int32GetDatum(0);
 
        while ((lTuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
@@ -1002,7 +1002,7 @@ ProcessIncomingNotify(void)
                        /*
                         * Rewrite the tuple with 0 in notification column.
                         */
-                       rTuple = heap_modifytuple(lTuple, tdesc, value, nulls, repl);
+                       rTuple = heap_modify_tuple(lTuple, tdesc, value, nulls, repl);
                        simple_heap_update(lRel, &lTuple->t_self, rTuple);
 
 #ifdef NOT_USED                                        /* currently there are no indexes */
index 7172b8638c1c9a4752c39b156a66b8f4a365e755..4f3e5c82c4036a7e83c3924272ba9413e471a624 100644 (file)
@@ -7,7 +7,7 @@
  * Copyright (c) 1996-2008, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.104 2008/10/21 10:38:51 petere Exp $
+ *       $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.105 2008/11/02 01:45:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -197,8 +197,8 @@ CreateComments(Oid oid, Oid classoid, int32 subid, char *comment)
        HeapTuple       oldtuple;
        HeapTuple       newtuple = NULL;
        Datum           values[Natts_pg_description];
-       char            nulls[Natts_pg_description];
-       char            replaces[Natts_pg_description];
+       bool            nulls[Natts_pg_description];
+       bool            replaces[Natts_pg_description];
        int                     i;
 
        /* Reduce empty-string to NULL case */
@@ -210,8 +210,8 @@ CreateComments(Oid oid, Oid classoid, int32 subid, char *comment)
        {
                for (i = 0; i < Natts_pg_description; i++)
                {
-                       nulls[i] = ' ';
-                       replaces[i] = 'r';
+                       nulls[i] = false;
+                       replaces[i] = true;
                }
                i = 0;
                values[i++] = ObjectIdGetDatum(oid);
@@ -248,7 +248,7 @@ CreateComments(Oid oid, Oid classoid, int32 subid, char *comment)
                        simple_heap_delete(description, &oldtuple->t_self);
                else
                {
-                       newtuple = heap_modifytuple(oldtuple, RelationGetDescr(description), values,
+                       newtuple = heap_modify_tuple(oldtuple, RelationGetDescr(description), values,
                                                                                nulls, replaces);
                        simple_heap_update(description, &oldtuple->t_self, newtuple);
                }
@@ -262,7 +262,7 @@ CreateComments(Oid oid, Oid classoid, int32 subid, char *comment)
 
        if (newtuple == NULL && comment != NULL)
        {
-               newtuple = heap_formtuple(RelationGetDescr(description),
+               newtuple = heap_form_tuple(RelationGetDescr(description),
                                                                  values, nulls);
                simple_heap_insert(description, newtuple);
        }
@@ -297,8 +297,8 @@ CreateSharedComments(Oid oid, Oid classoid, char *comment)
        HeapTuple       oldtuple;
        HeapTuple       newtuple = NULL;
        Datum           values[Natts_pg_shdescription];
-       char            nulls[Natts_pg_shdescription];
-       char            replaces[Natts_pg_shdescription];
+       bool            nulls[Natts_pg_shdescription];
+       bool            replaces[Natts_pg_shdescription];
        int                     i;
 
        /* Reduce empty-string to NULL case */
@@ -310,8 +310,8 @@ CreateSharedComments(Oid oid, Oid classoid, char *comment)
        {
                for (i = 0; i < Natts_pg_shdescription; i++)
                {
-                       nulls[i] = ' ';
-                       replaces[i] = 'r';
+                       nulls[i] = false;
+                       replaces[i] = true;
                }
                i = 0;
                values[i++] = ObjectIdGetDatum(oid);
@@ -343,7 +343,7 @@ CreateSharedComments(Oid oid, Oid classoid, char *comment)
                        simple_heap_delete(shdescription, &oldtuple->t_self);
                else
                {
-                       newtuple = heap_modifytuple(oldtuple, RelationGetDescr(shdescription),
+                       newtuple = heap_modify_tuple(oldtuple, RelationGetDescr(shdescription),
                                                                                values, nulls, replaces);
                        simple_heap_update(shdescription, &oldtuple->t_self, newtuple);
                }
@@ -357,7 +357,7 @@ CreateSharedComments(Oid oid, Oid classoid, char *comment)
 
        if (newtuple == NULL && comment != NULL)
        {
-               newtuple = heap_formtuple(RelationGetDescr(shdescription),
+               newtuple = heap_form_tuple(RelationGetDescr(shdescription),
                                                                  values, nulls);
                simple_heap_insert(shdescription, newtuple);
        }
index 69a059631bc10738366030979d78a2c8eac5c1b0..4d6fd988d77a90390ee47d5894d98d2576d43682 100644 (file)
@@ -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);
index 1efe0c3777b9c9314a976f4407486360bd863c81..7eb6e1bda00c4288ac77ad8453a63069ab9f66d5 100644 (file)
@@ -13,7 +13,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.214 2008/10/09 10:34:06 heikki Exp $
+ *       $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.215 2008/11/02 01:45:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -98,7 +98,7 @@ createdb(const CreatedbStmt *stmt)
        Relation        pg_database_rel;
        HeapTuple       tuple;
        Datum           new_record[Natts_pg_database];
-       char            new_record_nulls[Natts_pg_database];
+       bool            new_record_nulls[Natts_pg_database];
        Oid                     dboid;
        Oid                     datdba;
        ListCell   *option;
@@ -492,7 +492,7 @@ createdb(const CreatedbStmt *stmt)
 
        /* Form tuple */
        MemSet(new_record, 0, sizeof(new_record));
-       MemSet(new_record_nulls, ' ', sizeof(new_record_nulls));
+       MemSet(new_record_nulls, false, sizeof(new_record_nulls));
 
        new_record[Anum_pg_database_datname - 1] =
                DirectFunctionCall1(namein, CStringGetDatum(dbname));
@@ -515,10 +515,10 @@ createdb(const CreatedbStmt *stmt)
         * a bad idea when the owner is not the same as the template's owner. It's
         * more debatable whether datconfig should be copied.
         */
-       new_record_nulls[Anum_pg_database_datconfig - 1] = 'n';
-       new_record_nulls[Anum_pg_database_datacl - 1] = 'n';
+       new_record_nulls[Anum_pg_database_datconfig - 1] = true;
+       new_record_nulls[Anum_pg_database_datacl - 1] = true;
 
-       tuple = heap_formtuple(RelationGetDescr(pg_database_rel),
+       tuple = heap_form_tuple(RelationGetDescr(pg_database_rel),
                                                   new_record, new_record_nulls);
 
        HeapTupleSetOid(tuple, dboid);
@@ -949,8 +949,8 @@ AlterDatabase(AlterDatabaseStmt *stmt)
        int                     connlimit = -1;
        DefElem    *dconnlimit = NULL;
        Datum           new_record[Natts_pg_database];
-       char            new_record_nulls[Natts_pg_database];
-       char            new_record_repl[Natts_pg_database];
+       bool            new_record_nulls[Natts_pg_database];
+       bool            new_record_repl[Natts_pg_database];
 
        /* Extract options from the statement node tree */
        foreach(option, stmt->options)
@@ -999,16 +999,16 @@ AlterDatabase(AlterDatabaseStmt *stmt)
         * Build an updated tuple, perusing the information just obtained
         */
        MemSet(new_record, 0, sizeof(new_record));
-       MemSet(new_record_nulls, ' ', sizeof(new_record_nulls));
-       MemSet(new_record_repl, ' ', sizeof(new_record_repl));
+       MemSet(new_record_nulls, false, sizeof(new_record_nulls));
+       MemSet(new_record_repl, false, sizeof(new_record_repl));
 
        if (dconnlimit)
        {
                new_record[Anum_pg_database_datconnlimit - 1] = Int32GetDatum(connlimit);
-               new_record_repl[Anum_pg_database_datconnlimit - 1] = 'r';
+               new_record_repl[Anum_pg_database_datconnlimit - 1] = true;
        }
 
-       newtuple = heap_modifytuple(tuple, RelationGetDescr(rel), new_record,
+       newtuple = heap_modify_tuple(tuple, RelationGetDescr(rel), new_record,
                                                                new_record_nulls, new_record_repl);
        simple_heap_update(rel, &tuple->t_self, newtuple);
 
@@ -1040,8 +1040,8 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
        ScanKeyData scankey;
        SysScanDesc scan;
        Datum        &n