1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

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.
This commit is contained in:
Tom Lane
2005-03-29 00:17:27 +00:00
parent 119191609c
commit 70c9763d48
61 changed files with 819 additions and 581 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.42 2004/12/31 21:59:13 pgsql Exp $
* $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.43 2005/03/29 00:16:50 tgl Exp $
*
* NOTES
* These functions are stored in pg_amproc. For each operator class
@@ -107,17 +107,17 @@ hashfloat8(PG_FUNCTION_ARGS)
Datum
hashoidvector(PG_FUNCTION_ARGS)
{
Oid *key = (Oid *) PG_GETARG_POINTER(0);
oidvector *key = (oidvector *) PG_GETARG_POINTER(0);
return hash_any((unsigned char *) key, INDEX_MAX_KEYS * sizeof(Oid));
return hash_any((unsigned char *) key->values, key->dim1 * sizeof(Oid));
}
Datum
hashint2vector(PG_FUNCTION_ARGS)
{
int16 *key = (int16 *) PG_GETARG_POINTER(0);
int2vector *key = (int2vector *) PG_GETARG_POINTER(0);
return hash_any((unsigned char *) key, INDEX_MAX_KEYS * sizeof(int16));
return hash_any((unsigned char *) key->values, key->dim1 * sizeof(int2));
}
Datum

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.45 2005/03/27 23:52:59 tgl Exp $
* $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.46 2005/03/29 00:16:51 tgl Exp $
*
* NOTES
* many of the old access method routines have been turned into
@@ -219,7 +219,7 @@ systable_beginscan(Relation heapRelation,
*/
for (i = 0; i < nkeys; i++)
{
Assert(key[i].sk_attno == irel->rd_index->indkey[i]);
Assert(key[i].sk_attno == irel->rd_index->indkey.values[i]);
key[i].sk_attno = i + 1;
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.50 2004/12/31 21:59:22 pgsql Exp $
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.51 2005/03/29 00:16:52 tgl Exp $
*
* NOTES
*
@@ -198,15 +198,19 @@ btoidcmp(PG_FUNCTION_ARGS)
Datum
btoidvectorcmp(PG_FUNCTION_ARGS)
{
Oid *a = (Oid *) PG_GETARG_POINTER(0);
Oid *b = (Oid *) PG_GETARG_POINTER(1);
oidvector *a = (oidvector *) PG_GETARG_POINTER(0);
oidvector *b = (oidvector *) PG_GETARG_POINTER(1);
int i;
for (i = 0; i < INDEX_MAX_KEYS; i++)
/* We arbitrarily choose to sort first by vector length */
if (a->dim1 != b->dim1)
PG_RETURN_INT32(a->dim1 - b->dim1);
for (i = 0; i < a->dim1; i++)
{
if (a[i] != b[i])
if (a->values[i] != b->values[i])
{
if (a[i] > b[i])
if (a->values[i] > b->values[i])
PG_RETURN_INT32(1);
else
PG_RETURN_INT32(-1);

View File

@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.90 2004/12/31 21:59:22 pgsql Exp $
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.91 2005/03/29 00:16:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -684,7 +684,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
{
RegProcedure cmp_proc;
cmp_proc = get_opclass_proc(rel->rd_index->indclass[i],
cmp_proc = get_opclass_proc(rel->rd_indclass->values[i],
cur->sk_subtype,
BTORDER_PROC);
ScanKeyEntryInitialize(scankeys + i,

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/rtree/rtscan.c,v 1.57 2005/01/18 23:25:48 neilc Exp $
* $PostgreSQL: pgsql/src/backend/access/rtree/rtscan.c,v 1.58 2005/03/29 00:16:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -135,7 +135,7 @@ rtrescan(PG_FUNCTION_ARGS)
Oid int_oper;
RegProcedure int_proc;
opclass = s->indexRelation->rd_index->indclass[attno - 1];
opclass = s->indexRelation->rd_indclass->values[attno - 1];
int_strategy = RTMapToInternalOperator(s->keyData[i].sk_strategy);
int_oper = get_opclass_member(opclass,
s->keyData[i].sk_subtype,