1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +03:00

Code review for FILLFACTOR patch. Change WITH grammar as per earlier

discussion (including making def_arg allow reserved words), add missed
opt_definition for UNIQUE case.  Put the reloptions support code in a less
random place (I chose to make a new file access/common/reloptions.c).
Eliminate header inclusion creep.  Make the index options functions safely
user-callable (seems like client apps might like to be able to test validity
of options before trying to make an index).  Reduce overhead for normal case
with no options by allowing rd_options to be NULL.  Fix some unmaintainably
klugy code, including getting rid of Natts_pg_class_fixed at long last.
Some stylistic cleanup too, and pay attention to keeping comments in sync
with code.

Documentation still needs work, though I did fix the omissions in
catalogs.sgml and indexam.sgml.
This commit is contained in:
Tom Lane
2006-07-03 22:45:41 +00:00
parent feed07350b
commit b7b78d24f7
57 changed files with 1128 additions and 1088 deletions

View File

@ -16,7 +16,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.108 2006/07/02 02:23:18 momjian Exp $
* $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.109 2006/07/03 22:45:36 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -1694,9 +1694,8 @@ minimal_tuple_from_heap_tuple(HeapTuple htup)
* presumed to contain no null fields and no varlena fields.
*
* This routine is really only useful for certain system tables that are
* known to be fixed-width and null-free. It is used in some places for
* pg_class, but that is a gross hack (it only works because relacl can
* be omitted from the tuple entirely in those places).
* known to be fixed-width and null-free. Currently it is only used for
* pg_attribute tuples.
* ----------------
*/
HeapTuple
@ -1738,54 +1737,3 @@ heap_addheader(int natts, /* max domain index */
return tuple;
}
/*
* build_class_tuple
*
* XXX Natts_pg_class_fixed is a hack - see pg_class.h
*/
HeapTuple
build_class_tuple(Form_pg_class pgclass, ArrayType *options)
{
HeapTuple tuple;
HeapTupleHeader td;
Form_pg_class data; /* contents of tuple */
Size len;
Size size;
int hoff;
/* size of pg_class tuple with options */
if (options)
size = offsetof(FormData_pg_class, reloptions) + VARATT_SIZE(options);
else
size = CLASS_TUPLE_SIZE;
/* header needs no null bitmap */
hoff = offsetof(HeapTupleHeaderData, t_bits);
hoff += sizeof(Oid);
hoff = MAXALIGN(hoff);
len = hoff + size;
tuple = (HeapTuple) palloc0(HEAPTUPLESIZE + len);
tuple->t_data = td = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE);
tuple->t_len = len;
ItemPointerSetInvalid(&(tuple->t_self));
tuple->t_tableOid = InvalidOid;
/* we don't bother to fill the Datum fields */
td->t_natts = Natts_pg_class_fixed;
td->t_hoff = hoff;
td->t_infomask = HEAP_HASOID;
data = (Form_pg_class) ((char *) td + hoff);
memcpy(data, pgclass, CLASS_TUPLE_SIZE);
if (options)
{
td->t_natts++;
memcpy(data->reloptions, options, VARATT_SIZE(options));
}
return tuple;
}