mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +03:00
Clean up bogosities in pg_opclass, pg_amop, pg_amproc. There are amproc
entries now for int8 and network hash indexes. int24_ops and int42_ops are gone. pg_opclass no longer contains multiple entries claiming to be the default opclass for the same datatype. opr_sanity regress test extended to catch errors like these in the future.
This commit is contained in:
@@ -8,23 +8,27 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.47 2000/06/15 04:10:23 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.48 2000/06/19 03:54:27 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include <limits.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <time.h>
|
||||
#ifdef HAVE_FLOAT_H
|
||||
#include <float.h>
|
||||
#endif
|
||||
|
||||
#include "access/hash.h"
|
||||
#include "miscadmin.h"
|
||||
#include "utils/date.h"
|
||||
#include "utils/nabstime.h"
|
||||
|
||||
static int
|
||||
date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn);
|
||||
|
||||
static int date2tm(DateADT dateVal, int *tzp, struct tm * tm,
|
||||
double *fsec, char **tzn);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -762,6 +766,22 @@ timetz_cmp(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* timetz, being an unusual size, needs a specialized hash function.
|
||||
*/
|
||||
Datum
|
||||
timetz_hash(PG_FUNCTION_ARGS)
|
||||
{
|
||||
TimeTzADT *key = PG_GETARG_TIMETZADT_P(0);
|
||||
|
||||
/*
|
||||
* Specify hash length as sizeof(double) + sizeof(int4), not as
|
||||
* sizeof(TimeTzADT), so that any garbage pad bytes in the structure
|
||||
* won't be included in the hash!
|
||||
*/
|
||||
return hash_any((char *) key, sizeof(double) + sizeof(int4));
|
||||
}
|
||||
|
||||
Datum
|
||||
timetz_larger(PG_FUNCTION_ARGS)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.29 2000/06/09 01:11:09 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.30 2000/06/19 03:54:27 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <sys/timeb.h>
|
||||
#endif
|
||||
|
||||
#include "access/hash.h"
|
||||
#include "access/xact.h"
|
||||
#include "miscadmin.h"
|
||||
#include "utils/builtins.h"
|
||||
@@ -816,6 +817,22 @@ interval_cmp(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32((span1 < span2) ? -1 : (span1 > span2) ? 1 : 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* interval, being an unusual size, needs a specialized hash function.
|
||||
*/
|
||||
Datum
|
||||
interval_hash(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Interval *key = PG_GETARG_INTERVAL_P(0);
|
||||
|
||||
/*
|
||||
* Specify hash length as sizeof(double) + sizeof(int4), not as
|
||||
* sizeof(Interval), so that any garbage pad bytes in the structure
|
||||
* won't be included in the hash!
|
||||
*/
|
||||
return hash_any((char *) key, sizeof(double) + sizeof(int4));
|
||||
}
|
||||
|
||||
/* overlaps_timestamp()
|
||||
* Implements the SQL92 OVERLAPS operator.
|
||||
* Algorithm from Date and Darwen, 1997
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.65 2000/06/15 03:32:29 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.66 2000/06/19 03:54:28 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include "access/hash.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "utils/acl.h"
|
||||
#include "utils/builtins.h"
|
||||
@@ -797,94 +798,19 @@ varcharcmp(char *arg1, char *arg2)
|
||||
return (int32) (cmp);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Hash functions (modified from hashtext in access/hash/hashfunc.c)
|
||||
*****************************************************************************/
|
||||
|
||||
uint32
|
||||
hashbpchar(struct varlena * key)
|
||||
/*
|
||||
* bpchar needs a specialized hash function because we want to ignore
|
||||
* trailing blanks in comparisons. (varchar can use plain hashvarlena.)
|
||||
*/
|
||||
Datum
|
||||
hashbpchar(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int keylen;
|
||||
BpChar *key = PG_GETARG_BPCHAR_P(0);
|
||||
char *keydata;
|
||||
uint32 n;
|
||||
int loop;
|
||||
int keylen;
|
||||
|
||||
keydata = VARDATA(key);
|
||||
keylen = bcTruelen((char *) key);
|
||||
|
||||
#define HASHC n = *keydata++ + 65599 * n
|
||||
|
||||
n = 0;
|
||||
if (keylen > 0)
|
||||
{
|
||||
loop = (keylen + 8 - 1) >> 3;
|
||||
|
||||
switch (keylen & (8 - 1))
|
||||
{
|
||||
case 0:
|
||||
do
|
||||
{ /* All fall throughs */
|
||||
HASHC;
|
||||
case 7:
|
||||
HASHC;
|
||||
case 6:
|
||||
HASHC;
|
||||
case 5:
|
||||
HASHC;
|
||||
case 4:
|
||||
HASHC;
|
||||
case 3:
|
||||
HASHC;
|
||||
case 2:
|
||||
HASHC;
|
||||
case 1:
|
||||
HASHC;
|
||||
} while (--loop);
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
uint32
|
||||
hashvarchar(struct varlena * key)
|
||||
{
|
||||
int keylen;
|
||||
char *keydata;
|
||||
uint32 n;
|
||||
int loop;
|
||||
|
||||
keydata = VARDATA(key);
|
||||
keylen = VARSIZE(key) - VARHDRSZ;
|
||||
|
||||
#define HASHC n = *keydata++ + 65599 * n
|
||||
|
||||
n = 0;
|
||||
if (keylen > 0)
|
||||
{
|
||||
loop = (keylen + 8 - 1) >> 3;
|
||||
|
||||
switch (keylen & (8 - 1))
|
||||
{
|
||||
case 0:
|
||||
do
|
||||
{ /* All fall throughs */
|
||||
HASHC;
|
||||
case 7:
|
||||
HASHC;
|
||||
case 6:
|
||||
HASHC;
|
||||
case 5:
|
||||
HASHC;
|
||||
case 4:
|
||||
HASHC;
|
||||
case 3:
|
||||
HASHC;
|
||||
case 2:
|
||||
HASHC;
|
||||
case 1:
|
||||
HASHC;
|
||||
} while (--loop);
|
||||
}
|
||||
}
|
||||
return n;
|
||||
return hash_any(keydata, keylen);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user