diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-03-29 00:17:27 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-03-29 00:17:27 +0000 |
commit | 70c9763d4815ac847f0f7694f43eb6a59a236868 (patch) | |
tree | 7d8aa05f668f1ef7809ff521b6c1e12d31125fd7 /src/backend/bootstrap | |
parent | 119191609c507528b20d74c59be69f2129127575 (diff) | |
download | postgresql-70c9763d4815ac847f0f7694f43eb6a59a236868.tar.gz |
Convert oidvector and int2vector into variable-length arrays. This
change saves a great deal of space in pg_proc and its primary index,
and it eliminates the former requirement that INDEX_MAX_KEYS and
FUNC_MAX_ARGS have the same value. INDEX_MAX_KEYS is still embedded
in the on-disk representation (because it affects index tuple header
size), but FUNC_MAX_ARGS is not. I believe it would now be possible
to increase FUNC_MAX_ARGS at little cost, but haven't experimented yet.
There are still a lot of vestigial references to FUNC_MAX_ARGS, which
I will clean up in a separate pass. However, getting rid of it
altogether would require changing the FunctionCallInfoData struct,
and I'm not sure I want to buy into that.
Diffstat (limited to 'src/backend/bootstrap')
-rw-r--r-- | src/backend/bootstrap/bootstrap.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index 279ceba48e..05d73e2709 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.199 2005/02/20 02:21:31 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.200 2005/03/29 00:16:54 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -139,9 +139,9 @@ static const struct typinfo TypInfo[] = { F_XIDIN, F_XIDOUT}, {"cid", CIDOID, 0, 4, true, 'i', 'p', F_CIDIN, F_CIDOUT}, - {"int2vector", INT2VECTOROID, INT2OID, INDEX_MAX_KEYS * 2, false, 's', 'p', + {"int2vector", INT2VECTOROID, INT2OID, -1, false, 'i', 'p', F_INT2VECTORIN, F_INT2VECTOROUT}, - {"oidvector", OIDVECTOROID, OIDOID, INDEX_MAX_KEYS * 4, false, 'i', 'p', + {"oidvector", OIDVECTOROID, OIDOID, -1, false, 'i', 'p', F_OIDVECTORIN, F_OIDVECTOROUT}, {"_int4", INT4ARRAYOID, INT4OID, -1, false, 'i', 'x', F_ARRAY_IN, F_ARRAY_OUT}, @@ -667,7 +667,6 @@ closerel(char *name) void DefineAttr(char *name, char *type, int attnum) { - int attlen; Oid typeoid; if (boot_reldesc != NULL) @@ -689,7 +688,7 @@ DefineAttr(char *name, char *type, int attnum) if (Typ != NULL) { attrtypes[attnum]->atttypid = Ap->am_oid; - attlen = attrtypes[attnum]->attlen = Ap->am_typ.typlen; + attrtypes[attnum]->attlen = Ap->am_typ.typlen; attrtypes[attnum]->attbyval = Ap->am_typ.typbyval; attrtypes[attnum]->attstorage = Ap->am_typ.typstorage; attrtypes[attnum]->attalign = Ap->am_typ.typalign; @@ -702,12 +701,13 @@ DefineAttr(char *name, char *type, int attnum) else { attrtypes[attnum]->atttypid = TypInfo[typeoid].oid; - attlen = attrtypes[attnum]->attlen = TypInfo[typeoid].len; + attrtypes[attnum]->attlen = TypInfo[typeoid].len; attrtypes[attnum]->attbyval = TypInfo[typeoid].byval; attrtypes[attnum]->attstorage = TypInfo[typeoid].storage; attrtypes[attnum]->attalign = TypInfo[typeoid].align; /* if an array type, assume 1-dimensional attribute */ - if (TypInfo[typeoid].elem != InvalidOid && attlen < 0) + if (TypInfo[typeoid].elem != InvalidOid && + attrtypes[attnum]->attlen < 0) attrtypes[attnum]->attndims = 1; else attrtypes[attnum]->attndims = 0; @@ -722,14 +722,22 @@ DefineAttr(char *name, char *type, int attnum) * Mark as "not null" if type is fixed-width and prior columns are * too. This corresponds to case where column can be accessed directly * via C struct declaration. + * + * oidvector and int2vector are also treated as not-nullable, even + * though they are no longer fixed-width. */ - if (attlen > 0) +#define MARKNOTNULL(att) \ + ((att)->attlen > 0 || \ + (att)->atttypid == OIDVECTOROID || \ + (att)->atttypid == INT2VECTOROID) + + if (MARKNOTNULL(attrtypes[attnum])) { int i; for (i = 0; i < attnum; i++) { - if (attrtypes[i]->attlen <= 0) + if (!MARKNOTNULL(attrtypes[i])) break; } if (i == attnum) |