HEntry *ptr = &(ARRPTR(st->hs)[st->i]);
Datum res,
dvalues[2];
- char nulls[] = {' ', ' '};
+ bool nulls[2] = {false, false};
text *item;
HeapTuple tuple;
if (ptr->valisnull)
{
dvalues[1] = (Datum) 0;
- nulls[1] = 'n';
+ nulls[1] = true;
}
else
{
}
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));
* 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
* 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
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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
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
return tuple;
}
-/* ----------------
+/*
* heap_formtuple
*
* construct a tuple from the given values[] and nulls[] arrays
* 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,
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;
}
return newTuple;
}
-/* ----------------
+/*
* heap_modifytuple
*
* forms a new tuple from an old tuple and a set of replacement values.
*
* 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,
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;
}
/*
}
}
-/* ----------------
+/*
* heap_deformtuple
*
* Given a tuple, extract data into values/nulls arrays; this is
* 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,
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);
}
/*
*
*
* 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
/*
* 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.)
* 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 $
*
*-------------------------------------------------------------------------
*/
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 */
for (i = 0; i < MAXATTR; i++)
{
attrtypes[i] = NULL;
- Blanks[i] = ' ';
+ Nulls[i] = false;
}
for (i = 0; i < STRTABLESIZE; ++i)
strtable[i] = NULL;
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 */
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;
}
/* ----------------
elog(DEBUG4, "inserting column %d NULL", i);
Assert(i >= 0 || i < MAXATTR);
values[i] = PointerGetDatum(NULL);
- Blanks[i] = 'n';
+ Nulls[i] = true;
}
/* ----------------
*
*
* 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.
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;
/* 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);
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;
/* 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);
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;
/* 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);
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;
/* 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);
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;
/* 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);
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;
/* 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);
*
*
* 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
{
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);
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
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;
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);
*
*
* 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
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;
/*
* 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);
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
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
{
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;
/* 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);
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);
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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;
/* initialize nulls and values */
for (i = 0; i < Natts_pg_constraint; i++)
{
- nulls[i] = ' ';
+ nulls[i] = false;
values[i] = (Datum) NULL;
}
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.
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
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);
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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;
/* initialize nulls and values */
for (i = 0; i < Natts_pg_conversion; i++)
{
- nulls[i] = ' ';
+ nulls[i] = false;
values[i] = (Datum) NULL;
}
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);
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
CatalogIndexState indstate;
HeapTuple tup;
int i;
- char nulls[Natts_pg_depend];
+ bool nulls[Natts_pg_depend];
Datum values[Natts_pg_depend];
if (nreferenced <= 0)
/* 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++)
{
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);
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
int i,
n;
Datum values[Natts_pg_enum];
- char nulls[Natts_pg_enum];
+ bool nulls[Natts_pg_enum];
ListCell *lc;
HeapTuple tup;
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)
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);
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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);
for (i = 0; i < Natts_pg_largeobject; i++)
{
values[i] = (Datum) NULL;
- nulls[i] = ' ';
+ nulls[i] = false;
}
i = 0;
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
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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;
/* 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));
*
*
* 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.
int i;
HeapTuple tup;
Datum values[Natts_pg_operator];
- char nulls[Natts_pg_operator];
+ bool nulls[Natts_pg_operator];
NameData oname;
TupleDesc tupDesc;
*/
for (i = 0; i < Natts_pg_operator; ++i)
{
- nulls[i] = ' ';
+ nulls[i] = false;
values[i] = (Datum) NULL; /* redundant, but safe */
}
/*
* create a new operator tuple
*/
- tup = heap_formtuple(tupDesc, values, nulls);
+ tup = heap_form_tuple(tupDesc, values, nulls);
/*
* insert our "shell" operator tuple
{
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;
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;
elog(ERROR, "cache lookup failed for operator %u",
operatorObjectId);
- tup = heap_modifytuple(tup,
+ tup = heap_modify_tuple(tup,
RelationGetDescr(pg_operator_desc),
values,
nulls,
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);
}
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;
}
/*
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,
!(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,
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 */
!(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,
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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;
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);
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);
}
/* 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);
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;
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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);
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
int i;
HeapTuple tup;
Datum values[Natts_pg_type];
- char nulls[Natts_pg_type];
+ bool nulls[Natts_pg_type];
Oid typoid;
NameData name;
*/
for (i = 0; i < Natts_pg_type; ++i)
{
- nulls[i] = ' ';
+ nulls[i] = false;
values[i] = (Datum) NULL; /* redundant, but safe */
}
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.
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;
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;
}
if (defaultTypeBin)
values[i] = CStringGetTextDatum(defaultTypeBin);
else
- nulls[i] = 'n';
+ nulls[i] = true;
i++; /* typdefaultbin */
/*
if (defaultTypeValue)
values[i] = CStringGetTextDatum(defaultTypeValue);
else
- nulls[i] = 'n';
+ nulls[i] = true;
i++; /* typdefault */
/*
/*
* Okay to update existing shell type tuple
*/
- tup = heap_modifytuple(tup,
+ tup = heap_modify_tuple(tup,
RelationGetDescr(pg_type_desc),
values,
nulls,
}
else
{
- tup = heap_formtuple(RelationGetDescr(pg_type_desc),
+ tup = heap_form_tuple(RelationGetDescr(pg_type_desc),
values,
nulls);
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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)
*/
for (i = 0; i < Natts_pg_statistic; ++i)
{
- nulls[i] = ' ';
- replaces[i] = 'r';
+ nulls[i] = false;
+ replaces[i] = true;
}
i = 0;
}
else
{
- nulls[i] = 'n';
+ nulls[i] = true;
values[i++] = (Datum) 0;
}
}
}
else
{
- nulls[i] = 'n';
+ nulls[i] = true;
values[i++] = (Datum) 0;
}
}
if (HeapTupleIsValid(oldtup))
{
/* Yes, replace it */
- stup = heap_modifytuple(oldtup,
+ stup = heap_modify_tuple(oldtup,
RelationGetDescr(sd),
values,
nulls,
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);
}
* 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 $
*
*-------------------------------------------------------------------------
*/
HeapScanDesc scan;
HeapTuple tuple;
Datum values[Natts_pg_listener];
- char nulls[Natts_pg_listener];
+ bool nulls[Natts_pg_listener];
NameData condname;
bool alreadyListener = false;
/*
* 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);
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);
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 */
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;
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)
/*
* 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 */
* 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 $
*
*-------------------------------------------------------------------------
*/
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 */
{
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);
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);
}
if (newtuple == NULL && comment != NULL)
{
- newtuple = heap_formtuple(RelationGetDescr(description),
+ newtuple = heap_form_tuple(RelationGetDescr(description),
values, nulls);
simple_heap_insert(description, newtuple);
}
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 */
{
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);
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);
}
if (newtuple == NULL && comment != NULL)
{
- newtuple = heap_formtuple(RelationGetDescr(shdescription),
+ newtuple = heap_form_tuple(RelationGetDescr(shdescription),
values, nulls);
simple_heap_insert(shdescription, newtuple);
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
int i;
Oid in_func_oid;
Datum *values;
- char *nulls;
+ bool *nulls;
int nfields;
char **field_strings;
bool done = false;
}
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;
/* 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)
{
typioparams[m],
attr[m]->atttypmod);
if (string != NULL)
- nulls[m] = ' ';
+ nulls[m] = false;
cstate->cur_attname = NULL;
cstate->cur_attval = NULL;
}
&in_functions[m],
typioparams[m],
attr[m]->atttypmod,
- &isnull);
- nulls[m] = isnull ? 'n' : ' ';
+ &nulls[m]);
cstate->cur_attname = NULL;
}
}
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);
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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;
/* 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));
* 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);
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)
* 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);
ScanKeyData scankey;
SysScanDesc scan;
Datum &n