Move INDEX_MAX_KEYS to postgres.h, and make it configurable for users.

This commit is contained in:
Bruce Momjian 2000-01-10 04:36:37 +00:00
parent 8cc9d8454b
commit b99f300675
3 changed files with 26 additions and 30 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.28 1999/07/17 20:17:58 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.29 2000/01/10 04:36:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -30,26 +30,23 @@ Oid *
oid8in(char *oidString)
{
Oid *result;
int nums;
int slot;
if (oidString == NULL)
return NULL;
result = (Oid *) palloc(sizeof(Oid[8]));
if ((nums = sscanf(oidString, "%u%u%u%u%u%u%u%u",
&result[0],
&result[1],
&result[2],
&result[3],
&result[4],
&result[5],
&result[6],
&result[7])) != 8)
result = (Oid *) palloc(sizeof(Oid[INDEX_MAX_KEYS]));
for (slot=0; *oidString && slot < INDEX_MAX_KEYS; slot++)
{
do
result[nums++] = 0;
while (nums < 8);
if (sscanf(oidString, "%u", &result[slot]) != 1)
break;
while (*oidString && *oidString != ' ')
oidString++;
}
while (slot < INDEX_MAX_KEYS)
result[slot++] = 0;
return result;
}
@ -73,9 +70,9 @@ oid8out(Oid *oidArray)
}
/* assumes sign, 10 digits, ' ' */
rp = result = (char *) palloc(8 * 12);
rp = result = (char *) palloc(INDEX_MAX_KEYS * 12);
sp = oidArray;
for (num = 8; num != 0; num--)
for (num = INDEX_MAX_KEYS; num != 0; num--)
{
ltoa(*sp++, rp);
while (*++rp != '\0')
@ -121,13 +118,13 @@ oidne(Oid arg1, Oid arg2)
bool
oid8eq(Oid *arg1, Oid *arg2)
{
return (bool) (memcmp(arg1, arg2, 8 * sizeof(Oid)) == 0);
return (bool) (memcmp(arg1, arg2, INDEX_MAX_KEYS * sizeof(Oid)) == 0);
}
bool
oid8ne(Oid *arg1, Oid *arg2)
{
return (bool) (memcmp(arg1, arg2, 8 * sizeof(Oid)) != 0);
return (bool) (memcmp(arg1, arg2, INDEX_MAX_KEYS * sizeof(Oid)) != 0);
}
bool
@ -135,7 +132,7 @@ oid8lt(Oid *arg1, Oid *arg2)
{
int i;
for (i = 0; i < 8; i++)
for (i = 0; i < INDEX_MAX_KEYS; i++)
if (!int4eq(arg1[i], arg2[i]))
return int4lt(arg1[i], arg2[i]);
return false;
@ -146,7 +143,7 @@ oid8le(Oid *arg1, Oid *arg2)
{
int i;
for (i = 0; i < 8; i++)
for (i = 0; i < INDEX_MAX_KEYS; i++)
if (!int4eq(arg1[i], arg2[i]))
return int4le(arg1[i], arg2[i]);
return true;
@ -157,7 +154,7 @@ oid8ge(Oid *arg1, Oid *arg2)
{
int i;
for (i = 0; i < 8; i++)
for (i = 0; i < INDEX_MAX_KEYS; i++)
if (!int4eq(arg1[i], arg2[i]))
return int4ge(arg1[i], arg2[i]);
return true;
@ -168,7 +165,7 @@ oid8gt(Oid *arg1, Oid *arg2)
{
int i;
for (i = 0; i < 8; i++)
for (i = 0; i < INDEX_MAX_KEYS; i++)
if (!int4eq(arg1[i], arg2[i]))
return int4gt(arg1[i], arg2[i]);
return false;

View File

@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_index.h,v 1.12 1999/05/25 16:13:45 momjian Exp $
* $Id: pg_index.h,v 1.13 2000/01/10 04:36:37 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@ -58,9 +58,6 @@ CATALOG(pg_index)
text indpred; /* query plan for partial index predicate */
} FormData_pg_index;
#define INDEX_MAX_KEYS 8 /* maximum number of keys in an index
* definition */
/* ----------------
* Form_pg_index corresponds to a pointer to a tuple with
* the format of pg_index relation.

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1995, Regents of the University of California
*
* $Id: postgres.h,v 1.31 1999/12/21 00:06:41 wieck Exp $
* $Id: postgres.h,v 1.32 2000/01/10 04:36:36 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -101,8 +101,10 @@ struct varlena
typedef struct varlena bytea;
typedef struct varlena text;
typedef int2 int28[8];
typedef Oid oid8[8];
#define INDEX_MAX_KEYS 8 /* maximum number of keys in an index
* definition */
typedef int2 int28[INDEX_MAX_KEYS];
typedef Oid oid8[INDEX_MAX_KEYS];
/*