diff options
Diffstat (limited to 'src/include')
30 files changed, 402 insertions, 231 deletions
diff --git a/src/include/access/hash.h b/src/include/access/hash.h index 821f8348e8e..dad59823409 100644 --- a/src/include/access/hash.h +++ b/src/include/access/hash.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: hash.h,v 1.49 2003/08/04 02:40:10 momjian Exp $ + * $Id: hash.h,v 1.49.2.1 2003/09/07 04:37:05 momjian Exp $ * * NOTES * modeled after Margo Seltzer's hash implementation for unix. @@ -24,43 +24,17 @@ #include "fmgr.h" /* - * An overflow page is a spare page allocated for storing data whose - * bucket doesn't have room to store it. We use overflow pages rather - * than just splitting the bucket because there is a linear order in - * the way we split buckets. In other words, if there isn't enough space - * in the bucket itself, put it in an overflow page. - * - * Overflow page addresses are stored in form: (Splitnumber, Page offset). - * - * A splitnumber is the number of the generation where the table doubles - * in size. The ovflpage's offset within the splitnumber; offsets start - * at 1. - * - * We convert the stored bitmap address into a page address with the - * macro OADDR_OF(S, O) where S is the splitnumber and O is the page - * offset. + * Mapping from hash bucket number to physical block number of bucket's + * starting page. Beware of multiple evaluations of argument! */ typedef uint32 Bucket; -typedef bits16 OverflowPageAddress; -typedef uint32 SplitNumber; -typedef uint32 PageOffset; - -/* A valid overflow address will always have a page offset >= 1 */ -#define InvalidOvflAddress 0 - -#define SPLITSHIFT 11 -#define SPLITMASK 0x7FF -#define SPLITNUM(N) ((SplitNumber)(((uint32)(N)) >> SPLITSHIFT)) -#define OPAGENUM(N) ((PageOffset)((N) & SPLITMASK)) -#define OADDR_OF(S,O) ((OverflowPageAddress)((uint32)((uint32)(S) << SPLITSHIFT) + (O))) -#define BUCKET_TO_BLKNO(B) \ - ((Bucket) ((B) + ((B) ? metap->hashm_spares[_hash_log2((B)+1)-1] : 0)) + 1) -#define OADDR_TO_BLKNO(B) \ - ((BlockNumber) \ - (BUCKET_TO_BLKNO ( (1 << SPLITNUM((B))) -1 ) + OPAGENUM((B)))); +#define BUCKET_TO_BLKNO(metap,B) \ + ((BlockNumber) ((B) + ((B) ? (metap)->hashm_spares[_hash_log2((B)+1)-1] : 0)) + 1) /* + * Special space for hash index pages. + * * hasho_flag tells us which type of page we're looking at. For * example, knowing overflow pages from bucket pages is necessary * information when you're deleting tuples from a page. If all the @@ -69,7 +43,6 @@ typedef uint32 PageOffset; * the tuples are deleted from a bucket page, no additional action is * necessary. */ - #define LH_UNUSED_PAGE (0) #define LH_OVERFLOW_PAGE (1 << 0) #define LH_BUCKET_PAGE (1 << 1) @@ -78,25 +51,46 @@ typedef uint32 PageOffset; typedef struct HashPageOpaqueData { - bits16 hasho_flag; /* is this page a bucket or ovfl */ - Bucket hasho_bucket; /* bucket number this pg belongs to */ - OverflowPageAddress hasho_oaddr; /* ovfl address of this ovfl pg */ - BlockNumber hasho_nextblkno; /* next ovfl blkno */ BlockNumber hasho_prevblkno; /* previous ovfl (or bucket) blkno */ + BlockNumber hasho_nextblkno; /* next ovfl blkno */ + Bucket hasho_bucket; /* bucket number this pg belongs to */ + uint16 hasho_flag; /* page type code, see above */ + uint16 hasho_filler; /* available for future use */ + /* + * We presently set hasho_filler to HASHO_FILL (0x1234); this is for + * the convenience of pg_filedump, which otherwise would have a hard + * time telling HashPageOpaqueData from BTPageOpaqueData. If we ever + * need that space for some other purpose, pg_filedump will have to + * find another way. + */ } HashPageOpaqueData; typedef HashPageOpaqueData *HashPageOpaque; +#define HASHO_FILL 0x1234 + /* - * ScanOpaqueData is used to remember which buffers we're currently - * examining in the scan. We keep these buffers locked and pinned and - * recorded in the opaque entry of the scan in order to avoid doing a - * ReadBuffer() for every tuple in the index. This avoids semop() calls, - * which are expensive. + * HashScanOpaqueData is private state for a hash index scan. */ - typedef struct HashScanOpaqueData { + /* + * By definition, a hash scan should be examining only one bucket. + * We record the bucket number here as soon as it is known. + */ + Bucket hashso_bucket; + bool hashso_bucket_valid; + /* + * If we have a share lock on the bucket, we record it here. When + * hashso_bucket_blkno is zero, we have no such lock. + */ + BlockNumber hashso_bucket_blkno; + /* + * We also want to remember which buffers we're currently examining in the + * scan. We keep these buffers pinned (but not locked) across hashgettuple + * calls, in order to avoid doing a ReadBuffer() for every tuple in the + * index. + */ Buffer hashso_curbuf; Buffer hashso_mrkbuf; } HashScanOpaqueData; @@ -110,63 +104,57 @@ typedef HashScanOpaqueData *HashScanOpaque; #define HASH_METAPAGE 0 /* metapage is always block 0 */ #define HASH_MAGIC 0x6440640 -#define HASH_VERSION 0 +#define HASH_VERSION 1 /* new for Pg 7.4 */ /* - * NCACHED is used to set the array sizeof spares[] & bitmaps[]. + * Spares[] holds the number of overflow pages currently allocated at or + * before a certain splitpoint. For example, if spares[3] = 7 then there are + * 7 ovflpages before splitpoint 3 (compare BUCKET_TO_BLKNO macro). The + * value in spares[ovflpoint] increases as overflow pages are added at the + * end of the index. Once ovflpoint increases (ie, we have actually allocated + * the bucket pages belonging to that splitpoint) the number of spares at the + * prior splitpoint cannot change anymore. * - * Spares[] is used to hold the number overflow pages currently - * allocated at a certain splitpoint. For example, if spares[3] = 7 - * then there are a maximum of 7 ovflpages available at splitpoint 3. - * The value in spares[] will change as ovflpages are added within - * a splitpoint. + * ovflpages that have been recycled for reuse can be found by looking at + * bitmaps that are stored within ovflpages dedicated for the purpose. + * The blknos of these bitmap pages are kept in bitmaps[]; nmaps is the + * number of currently existing bitmaps. * - * Within a splitpoint, one can find which ovflpages are available and - * which are used by looking at a bitmaps that are stored on the ovfl - * pages themselves. There is at least one bitmap for every splitpoint's - * ovflpages. Bitmaps[] contains the ovflpage addresses of the ovflpages - * that hold the ovflpage bitmaps. - * - * The reason that the size is restricted to NCACHED (32) is because - * the bitmaps are 16 bits: upper 5 represent the splitpoint, lower 11 - * indicate the page number within the splitpoint. Since there are - * only 5 bits to store the splitpoint, there can only be 32 splitpoints. - * Both spares[] and bitmaps[] use splitpoints as there indices, so there - * can only be 32 of them. + * The limitation on the size of spares[] comes from the fact that there's + * no point in having more than 2^32 buckets with only uint32 hashcodes. + * There is no particular upper limit on the size of mapp[], other than + * needing to fit into the metapage. (With 8K block size, 128 bitmaps + * limit us to 64 Gb of overflow space...) */ - -#define NCACHED 32 - +#define HASH_MAX_SPLITPOINTS 32 +#define HASH_MAX_BITMAPS 128 typedef struct HashMetaPageData { PageHeaderData hashm_phdr; /* pad for page header (do not use) */ uint32 hashm_magic; /* magic no. for hash tables */ uint32 hashm_version; /* version ID */ - uint32 hashm_nkeys; /* number of keys stored in the table */ - uint16 hashm_ffactor; /* fill factor */ - uint16 hashm_bsize; /* bucket size (bytes) - must be a power - * of 2 */ - uint16 hashm_bshift; /* bucket shift */ + double hashm_ntuples; /* number of tuples stored in the table */ + uint16 hashm_ffactor; /* target fill factor (tuples/bucket) */ + uint16 hashm_bsize; /* index page size (bytes) */ uint16 hashm_bmsize; /* bitmap array size (bytes) - must be a * power of 2 */ + uint16 hashm_bmshift; /* log2(bitmap array size in BITS) */ uint32 hashm_maxbucket; /* ID of maximum bucket in use */ uint32 hashm_highmask; /* mask to modulo into entire table */ uint32 hashm_lowmask; /* mask to modulo into lower half of table */ - uint32 hashm_ovflpoint;/* pageno. from which ovflpgs being + uint32 hashm_ovflpoint;/* splitpoint from which ovflpgs being * allocated */ - uint32 hashm_lastfreed; /* last ovflpage freed */ - uint32 hashm_nmaps; /* Initial number of bitmaps */ - uint32 hashm_spares[NCACHED]; /* spare pages available at - * splitpoints */ - BlockNumber hashm_mapp[NCACHED]; /* blknumbers of ovfl page maps */ + uint32 hashm_firstfree; /* lowest-number free ovflpage (bit#) */ + uint32 hashm_nmaps; /* number of bitmap pages */ RegProcedure hashm_procid; /* hash procedure id from pg_proc */ + uint32 hashm_spares[HASH_MAX_SPLITPOINTS]; /* spare pages before + * each splitpoint */ + BlockNumber hashm_mapp[HASH_MAX_BITMAPS]; /* blknos of ovfl bitmaps */ } HashMetaPageData; typedef HashMetaPageData *HashMetaPage; -extern bool BuildingHash; - typedef struct HashItemData { IndexTupleData hash_itup; @@ -175,56 +163,57 @@ typedef struct HashItemData typedef HashItemData *HashItem; /* + * Maximum size of a hash index item (it's okay to have only one per page) + */ +#define HashMaxItemSize(page) \ + (PageGetPageSize(page) - \ + sizeof(PageHeaderData) - \ + MAXALIGN(sizeof(HashPageOpaqueData)) - \ + sizeof(ItemIdData)) + +/* * Constants */ -#define DEFAULT_FFACTOR 300 -#define SPLITMAX 8 #define BYTE_TO_BIT 3 /* 2^3 bits/byte */ -#define INT_TO_BYTE 2 /* 2^2 bytes/int */ -#define INT_TO_BIT 5 /* 2^5 bits/int */ #define ALL_SET ((uint32) ~0) /* - * bitmap pages do not contain tuples. they do contain the standard + * Bitmap pages do not contain tuples. They do contain the standard * page headers and trailers; however, everything in between is a - * giant bit array. the number of bits that fit on a page obviously - * depends on the page size and the header/trailer overhead. + * giant bit array. The number of bits that fit on a page obviously + * depends on the page size and the header/trailer overhead. We require + * the number of bits per page to be a power of 2. */ #define BMPGSZ_BYTE(metap) ((metap)->hashm_bmsize) #define BMPGSZ_BIT(metap) ((metap)->hashm_bmsize << BYTE_TO_BIT) +#define BMPG_SHIFT(metap) ((metap)->hashm_bmshift) +#define BMPG_MASK(metap) (BMPGSZ_BIT(metap) - 1) #define HashPageGetBitmap(pg) \ ((uint32 *) (((char *) (pg)) + MAXALIGN(sizeof(PageHeaderData)))) /* - * The number of bits in an ovflpage bitmap which - * tells which ovflpages are empty versus in use (NOT the number of - * bits in an overflow page *address* bitmap). + * The number of bits in an ovflpage bitmap word. */ -#define BITS_PER_MAP 32 /* Number of bits in ovflpage bitmap */ +#define BITS_PER_MAP 32 /* Number of bits in uint32 */ -/* Given the address of the beginning of a big map, clear/set the nth bit */ +/* Given the address of the beginning of a bit map, clear/set the nth bit */ #define CLRBIT(A, N) ((A)[(N)/BITS_PER_MAP] &= ~(1<<((N)%BITS_PER_MAP))) #define SETBIT(A, N) ((A)[(N)/BITS_PER_MAP] |= (1<<((N)%BITS_PER_MAP))) #define ISSET(A, N) ((A)[(N)/BITS_PER_MAP] & (1<<((N)%BITS_PER_MAP))) /* - * page locking modes + * page-level and high-level locking modes (see README) */ -#define HASH_READ 0 -#define HASH_WRITE 1 +#define HASH_READ BUFFER_LOCK_SHARE +#define HASH_WRITE BUFFER_LOCK_EXCLUSIVE +#define HASH_NOLOCK (-1) -/* - * In general, the hash code tries to localize its knowledge about page - * layout to a couple of routines. However, we need a special value to - * indicate "no page number" in those places where we expect page numbers. - */ - -#define P_NONE 0 +#define HASH_SHARE ShareLock +#define HASH_EXCLUSIVE ExclusiveLock /* * Strategy number. There's only one valid strategy for hashing: equality. */ - #define HTEqualStrategyNumber 1 #define HTMaxStrategyNumber 1 @@ -233,9 +222,9 @@ typedef HashItemData *HashItem; * us with an amproc procudure for hashing a key of the new type. * Since we only have one such proc in amproc, it's number 1. */ - #define HASHPROC 1 + /* public routines */ extern Datum hashbuild(PG_FUNCTION_ARGS); @@ -276,54 +265,48 @@ extern Datum hash_any(register const unsigned char *k, register int keylen); /* hashinsert.c */ extern InsertIndexResult _hash_doinsert(Relation rel, HashItem hitem); - /* hashovfl.c */ -extern Buffer _hash_addovflpage(Relation rel, Buffer *metabufp, Buffer buf); -extern Buffer _hash_freeovflpage(Relation rel, Buffer ovflbuf); -extern int32 _hash_initbitmap(Relation rel, HashMetaPage metap, int32 pnum, - int32 nbits, int32 ndx); -extern void _hash_squeezebucket(Relation rel, HashMetaPage metap, - Bucket bucket); - +extern Buffer _hash_addovflpage(Relation rel, Buffer metabuf, Buffer buf); +extern BlockNumber _hash_freeovflpage(Relation rel, Buffer ovflbuf); +extern void _hash_initbitmap(Relation rel, HashMetaPage metap, + BlockNumber blkno); +extern void _hash_squeezebucket(Relation rel, + Bucket bucket, BlockNumber bucket_blkno); /* hashpage.c */ -extern void _hash_metapinit(Relation rel); +extern void _hash_getlock(Relation rel, BlockNumber whichlock, int access); +extern bool _hash_try_getlock(Relation rel, BlockNumber whichlock, int access); +extern void _hash_droplock(Relation rel, BlockNumber whichlock, int access); extern Buffer _hash_getbuf(Relation rel, BlockNumber blkno, int access); -extern void _hash_relbuf(Relation rel, Buffer buf, int access); +extern void _hash_relbuf(Relation rel, Buffer buf); +extern void _hash_dropbuf(Relation rel, Buffer buf); extern void _hash_wrtbuf(Relation rel, Buffer buf); -extern void _hash_wrtnorelbuf(Buffer buf); -extern Page _hash_chgbufaccess(Relation rel, Buffer *bufp, int from_access, +extern void _hash_wrtnorelbuf(Relation rel, Buffer buf); +extern void _hash_chgbufaccess(Relation rel, Buffer buf, int from_access, int to_access); +extern void _hash_metapinit(Relation rel); extern void _hash_pageinit(Page page, Size size); -extern void _hash_pagedel(Relation rel, ItemPointer tid); extern void _hash_expandtable(Relation rel, Buffer metabuf); - /* hashscan.c */ extern void _hash_regscan(IndexScanDesc scan); extern void _hash_dropscan(IndexScanDesc scan); -extern void _hash_adjscans(Relation rel, ItemPointer tid); +extern bool _hash_has_active_scan(Relation rel, Bucket bucket); extern void AtEOXact_hash(void); - /* hashsearch.c */ -extern void _hash_search(Relation rel, int keysz, ScanKey scankey, - Buffer *bufP, HashMetaPage metap); extern bool _hash_next(IndexScanDesc scan, ScanDirection dir); extern bool _hash_first(IndexScanDesc scan, ScanDirection dir); -extern bool _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir, - Buffer metabuf); - +extern bool _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir); /* hashutil.c */ -extern ScanKey _hash_mkscankey(Relation rel, IndexTuple itup); -extern void _hash_freeskey(ScanKey skey); extern bool _hash_checkqual(IndexScanDesc scan, IndexTuple itup); extern HashItem _hash_formitem(IndexTuple itup); -extern Bucket _hash_call(Relation rel, HashMetaPage metap, Datum key); +extern uint32 _hash_datum2hashkey(Relation rel, Datum key); +extern Bucket _hash_hashkey2bucket(uint32 hashkey, uint32 maxbucket, + uint32 highmask, uint32 lowmask); extern uint32 _hash_log2(uint32 num); -extern void _hash_checkpage(Page page, int flags); - +extern void _hash_checkpage(Relation rel, Page page, int flags); /* hash.c */ extern void hash_redo(XLogRecPtr lsn, XLogRecord *record); diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 48723471a26..552b42f36e7 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: catversion.h,v 1.206 2003/08/04 02:40:10 momjian Exp $ + * $Id: catversion.h,v 1.206.2.1 2003/09/07 04:37:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200307301 +#define CATALOG_VERSION_NO 200308172 #endif diff --git a/src/include/catalog/pg_amop.h b/src/include/catalog/pg_amop.h index fcf162eb98f..9e2e2e19ca9 100644 --- a/src/include/catalog/pg_amop.h +++ b/src/include/catalog/pg_amop.h @@ -16,7 +16,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_amop.h,v 1.54 2003/08/04 02:40:10 momjian Exp $ + * $Id: pg_amop.h,v 1.54.2.1 2003/09/07 04:37:05 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -419,6 +419,36 @@ DATA(insert ( 2098 4 f 2335 )); DATA(insert ( 2098 5 f 2336 )); /* + * btree money_ops + */ + +DATA(insert ( 2099 1 f 902 )); +DATA(insert ( 2099 2 f 904 )); +DATA(insert ( 2099 3 f 900 )); +DATA(insert ( 2099 4 f 905 )); +DATA(insert ( 2099 5 f 903 )); + +/* + * btree reltime_ops + */ + +DATA(insert ( 2233 1 f 568 )); +DATA(insert ( 2233 2 f 570 )); +DATA(insert ( 2233 3 f 566 )); +DATA(insert ( 2233 4 f 569 )); +DATA(insert ( 2233 5 f 571 )); + +/* + * btree tinterval_ops + */ + +DATA(insert ( 2234 1 f 813 )); +DATA(insert ( 2234 2 f 815 )); +DATA(insert ( 2234 3 f 811 )); +DATA(insert ( 2234 4 f 814 )); +DATA(insert ( 2234 5 f 816 )); + +/* * btree array_ops */ @@ -496,5 +526,7 @@ DATA(insert ( 2230 1 f 2316 )); DATA(insert ( 2231 1 f 2328 )); /* name_pattern_ops */ DATA(insert ( 2232 1 f 2334 )); +/* aclitem_ops */ +DATA(insert ( 2235 1 f 974 )); #endif /* PG_AMOP_H */ diff --git a/src/include/catalog/pg_amproc.h b/src/include/catalog/pg_amproc.h index 24c1fa416fe..0e40ef537d1 100644 --- a/src/include/catalog/pg_amproc.h +++ b/src/include/catalog/pg_amproc.h @@ -14,7 +14,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_amproc.h,v 1.43 2003/08/04 02:40:11 momjian Exp $ + * $Id: pg_amproc.h,v 1.43.2.1 2003/09/07 04:37:05 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -110,6 +110,9 @@ DATA(insert ( 2095 1 2166 )); DATA(insert ( 2096 1 2166 )); DATA(insert ( 2097 1 2180 )); DATA(insert ( 2098 1 2187 )); +DATA(insert ( 2099 1 377 )); +DATA(insert ( 2233 1 380 )); +DATA(insert ( 2234 1 381 )); /* hash */ @@ -145,5 +148,6 @@ DATA(insert ( 2229 1 456 )); DATA(insert ( 2230 1 456 )); DATA(insert ( 2231 1 456 )); DATA(insert ( 2232 1 455 )); +DATA(insert ( 2235 1 329 )); #endif /* PG_AMPROC_H */ diff --git a/src/include/catalog/pg_opclass.h b/src/include/catalog/pg_opclass.h index bbd69dca5b6..9f6133718c8 100644 --- a/src/include/catalog/pg_opclass.h +++ b/src/include/catalog/pg_opclass.h @@ -26,7 +26,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_opclass.h,v 1.56 2003/08/04 02:40:12 momjian Exp $ + * $Id: pg_opclass.h,v 1.56.2.1 2003/09/07 04:37:05 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -157,6 +157,7 @@ DATA(insert OID = 2097 ( 403 bpchar_pattern_ops PGNSP PGUID 1042 f 0 )); #define BPCHAR_PATTERN_BTREE_OPS_OID 2097 DATA(insert OID = 2098 ( 403 name_pattern_ops PGNSP PGUID 19 f 0 )); #define NAME_PATTERN_BTREE_OPS_OID 2098 +DATA(insert OID = 2099 ( 403 money_ops PGNSP PGUID 790 t 0 )); DATA(insert OID = 2222 ( 405 bool_ops PGNSP PGUID 16 t 0 )); DATA(insert OID = 2223 ( 405 bytea_ops PGNSP PGUID 17 t 0 )); DATA(insert OID = 2224 ( 405 int2vector_ops PGNSP PGUID 22 t 0 )); @@ -168,5 +169,8 @@ DATA(insert OID = 2229 ( 405 text_pattern_ops PGNSP PGUID 25 f 0 )); DATA(insert OID = 2230 ( 405 varchar_pattern_ops PGNSP PGUID 1043 f 0 )); DATA(insert OID = 2231 ( 405 bpchar_pattern_ops PGNSP PGUID 1042 f 0 )); DATA(insert OID = 2232 ( 405 name_pattern_ops PGNSP PGUID 19 f 0 )); +DATA(insert OID = 2233 ( 403 reltime_ops PGNSP PGUID 703 t 0 )); +DATA(insert OID = 2234 ( 403 tinterval_ops PGNSP PGUID 704 t 0 )); +DATA(insert OID = 2235 ( 405 aclitem_ops PGNSP PGUID 1033 t 0 )); #endif /* PG_OPCLASS_H */ diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h index 176cd1eaaf6..df8931259b0 100644 --- a/src/include/catalog/pg_operator.h +++ b/src/include/catalog/pg_operator.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_operator.h,v 1.120 2003/08/04 02:40:12 momjian Exp $ + * $Id: pg_operator.h,v 1.120.2.1 2003/09/07 04:37:05 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -424,7 +424,7 @@ DATA(insert OID = 965 ( "^" PGNSP PGUID b f 701 701 701 0 0 0 0 0 0 dpow - DATA(insert OID = 966 ( "+" PGNSP PGUID b f 1034 1033 1034 0 0 0 0 0 0 aclinsert - - )); DATA(insert OID = 967 ( "-" PGNSP PGUID b f 1034 1033 1034 0 0 0 0 0 0 aclremove - - )); DATA(insert OID = 968 ( "~" PGNSP PGUID b f 1034 1033 16 0 0 0 0 0 0 aclcontains - - )); -DATA(insert OID = 974 ( "=" PGNSP PGUID b f 1033 1033 16 974 0 0 0 0 0 aclitemeq eqsel eqjoinsel )); +DATA(insert OID = 974 ( "=" PGNSP PGUID b t 1033 1033 16 974 0 0 0 0 0 aclitemeq eqsel eqjoinsel )); /* additional geometric operators - thomas 1997-07-09 */ DATA(insert OID = 969 ( "@@" PGNSP PGUID l f 0 601 600 0 0 0 0 0 0 lseg_center - - )); @@ -448,6 +448,7 @@ DATA(insert OID = 1071 ( "<>" PGNSP PGUID b f 2277 2277 16 1071 1070 0 0 0 DATA(insert OID = 1072 ( "<" PGNSP PGUID b f 2277 2277 16 1073 1075 0 0 0 0 array_lt scalarltsel scalarltjoinsel )); #define ARRAY_LT_OP 1072 DATA(insert OID = 1073 ( ">" PGNSP PGUID b f 2277 2277 16 1072 1074 0 0 0 0 array_gt scalargtsel scalargtjoinsel )); +#define ARRAY_GT_OP 1073 DATA(insert OID = 1074 ( "<=" PGNSP PGUID b f 2277 2277 16 1075 1073 0 0 0 0 array_le scalarltsel scalarltjoinsel )); DATA(insert OID = 1075 ( ">=" PGNSP PGUID b f 2277 2277 16 1074 1072 0 0 0 0 array_ge scalargtsel scalargtjoinsel )); diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 1fe3812d709..fa61ff22f7a 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_proc.h,v 1.312 2003/08/04 02:40:12 momjian Exp $ + * $Id: pg_proc.h,v 1.312.2.1 2003/09/07 04:37:05 momjian Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -758,6 +758,12 @@ DATA(insert OID = 359 ( btnamecmp PGNSP PGUID 12 f f t f i 2 23 "19 19" btn DESCR("btree less-equal-greater"); DATA(insert OID = 360 ( bttextcmp PGNSP PGUID 12 f f t f i 2 23 "25 25" bttextcmp - _null_ )); DESCR("btree less-equal-greater"); +DATA(insert OID = 377 ( cash_cmp PGNSP PGUID 12 f f t f i 2 23 "790 790" cash_cmp - _null_ )); +DESCR("btree less-equal-greater"); +DATA(insert OID = 380 ( btreltimecmp PGNSP PGUID 12 f f t f i 2 23 "703 703" btreltimecmp - _null_ )); +DESCR("btree less-equal-greater"); +DATA(insert OID = 381 ( bttintervalcmp PGNSP PGUID 12 f f t f i 2 23 "704 704" bttintervalcmp - _null_ )); +DESCR("btree less-equal-greater"); DATA(insert OID = 382 ( btarraycmp PGNSP PGUID 12 f f t f i 2 23 "2277 2277" btarraycmp - _null_ )); DESCR("btree less-equal-greater"); @@ -844,6 +850,8 @@ DATA(insert OID = 456 ( hashvarlena PGNSP PGUID 12 f f t f i 1 23 "2281" has DESCR("hash any varlena type"); DATA(insert OID = 457 ( hashoidvector PGNSP PGUID 12 f f t f i 1 23 "30" hashoidvector - _null_ )); DESCR("hash"); +DATA(insert OID = 329 ( hash_aclitem PGNSP PGUID 12 f f t f i 1 23 "1033" hash_aclitem - _null_ )); +DESCR("hash"); DATA(insert OID = 398 ( hashint2vector PGNSP PGUID 12 f f t f i 1 23 "22" hashint2vector - _null_ )); DESCR("hash"); DATA(insert OID = 399 ( hashmacaddr PGNSP PGUID 12 f f t f i 1 23 "829" hashmacaddr - _null_ )); diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index af2f123d2d6..adaf9666167 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: executor.h,v 1.99 2003/08/08 21:42:44 momjian Exp $ + * $Id: executor.h,v 1.99.2.1 2003/09/07 04:37:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -71,8 +71,6 @@ extern TupleHashTable BuildTupleHashTable(int numCols, AttrNumber *keyColIdx, extern TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot, bool *isnew); -extern TupleHashEntry ScanTupleHashTable(TupleHashTable hashtable, - TupleHashIterator *state); /* * prototypes from functions in execJunk.c diff --git a/src/include/libpq/ip.h b/src/include/libpq/ip.h index c60030ccf50..b5fbc02082d 100644 --- a/src/include/libpq/ip.h +++ b/src/include/libpq/ip.h @@ -5,7 +5,7 @@ * * Copyright (c) 2003, PostgreSQL Global Development Group * - * $Id: ip.h,v 1.10 2003/08/04 00:43:31 momjian Exp $ + * $Id: ip.h,v 1.10.2.1 2003/09/07 04:37:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,9 +30,14 @@ extern int rangeSockAddr(const struct sockaddr_storage * addr, const struct sockaddr_storage * netaddr, const struct sockaddr_storage * netmask); -extern int SockAddr_cidr_mask(struct sockaddr_storage ** mask, +extern int SockAddr_cidr_mask(struct sockaddr_storage * mask, char *numbits, int family); +#ifdef HAVE_IPV6 +extern void promote_v4_to_v6_addr(struct sockaddr_storage * addr); +extern void promote_v4_to_v6_mask(struct sockaddr_storage * addr); +#endif + #ifdef HAVE_UNIX_SOCKETS #define IS_AF_UNIX(fam) ((fam) == AF_UNIX) #else diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index 3093de0f888..6c9b2bd3af3 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: miscadmin.h,v 1.132 2003/08/04 04:03:10 tgl Exp $ + * $Id: miscadmin.h,v 1.132.2.1 2003/09/07 04:37:05 momjian Exp $ * * NOTES * some of the information in this file should be moved to @@ -191,17 +191,12 @@ extern int VacuumMem; * A few postmaster startup options are exported here so the * configuration file processor can access them. */ - extern bool NetServer; extern bool EnableSSL; extern bool SilentMode; extern int MaxBackends; - -#define DEF_MAXBACKENDS 32 extern int ReservedBackends; extern DLLIMPORT int NBuffers; - -#define DEF_NBUFFERS (DEF_MAXBACKENDS > 8 ? DEF_MAXBACKENDS * 2 : 16) extern int PostPortNumber; extern int Unix_socket_permissions; extern char *Unix_socket_group; diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 3f163b8fdaa..b1993f31ac1 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: execnodes.h,v 1.103 2003/08/08 21:42:47 momjian Exp $ + * $Id: execnodes.h,v 1.103.2.1 2003/09/07 04:37:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,6 +21,7 @@ #include "nodes/bitmapset.h" #include "nodes/params.h" #include "nodes/plannodes.h" +#include "utils/hsearch.h" #include "utils/tuplestore.h" @@ -344,14 +345,14 @@ typedef struct TupleHashTableData *TupleHashTable; typedef struct TupleHashEntryData { - TupleHashEntry next; /* next entry in same hash bucket */ - uint32 hashkey; /* exact hash key of this entry */ + /* firstTuple must be the first field in this struct! */ HeapTuple firstTuple; /* copy of first tuple in this group */ /* there may be additional data beyond the end of this struct */ } TupleHashEntryData; /* VARIABLE LENGTH STRUCT */ typedef struct TupleHashTableData { + HTAB *hashtab; /* underlying dynahash table */ int numCols; /* number of columns in lookup key */ AttrNumber *keyColIdx; /* attr numbers of key columns */ FmgrInfo *eqfunctions; /* lookup data for comparison functions */ @@ -359,19 +360,15 @@ typedef struct TupleHashTableData MemoryContext tablecxt; /* memory context containing table */ MemoryContext tempcxt; /* context for function evaluations */ Size entrysize; /* actual size to make each hash entry */ - int nbuckets; /* number of buckets in hash table */ - TupleHashEntry buckets[1]; /* VARIABLE LENGTH ARRAY */ -} TupleHashTableData; /* VARIABLE LENGTH STRUCT */ + TupleDesc tupdesc; /* tuple descriptor */ +} TupleHashTableData; -typedef struct -{ - TupleHashEntry next_entry; /* next entry in current chain */ - int next_bucket; /* next chain */ -} TupleHashIterator; +typedef HASH_SEQ_STATUS TupleHashIterator; -#define ResetTupleHashIterator(iter) \ - ((iter)->next_entry = NULL, \ - (iter)->next_bucket = 0) +#define ResetTupleHashIterator(htable, iter) \ + hash_seq_init(iter, (htable)->hashtab) +#define ScanTupleHashTable(iter) \ + ((TupleHashEntry) hash_seq_search(iter)) /* ---------------------------------------------------------------- @@ -771,6 +768,8 @@ typedef ScanState SeqScanState; * RuntimeKeysReady true if runtime Skeys have been computed * RelationDescs ptr to array of relation descriptors * ScanDescs ptr to array of scan descriptors + * DupHash hashtable for recognizing dups in multiple scan + * MaxHash max # entries we will allow in hashtable * ---------------- */ typedef struct IndexScanState @@ -788,6 +787,8 @@ typedef struct IndexScanState bool iss_RuntimeKeysReady; RelationPtr iss_RelationDescs; IndexScanDescPtr iss_ScanDescs; + HTAB *iss_DupHash; + long iss_MaxHash; } IndexScanState; /* ---------------- diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index 9c80a9ebc74..12d079bdeae 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodes.h,v 1.146 2003/08/04 02:40:13 momjian Exp $ + * $Id: nodes.h,v 1.146.2.1 2003/09/07 04:37:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -265,7 +265,7 @@ typedef enum NodeTag T_ExprFieldSelect, T_ResTarget, T_TypeCast, - T_SortGroupBy, + T_SortBy, T_RangeSubselect, T_RangeFunction, T_TypeName, diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 497ba3b6247..994575b55a2 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parsenodes.h,v 1.246 2003/08/08 21:42:48 momjian Exp $ + * $Id: parsenodes.h,v 1.246.2.1 2003/09/07 04:37:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -279,14 +279,19 @@ typedef struct ResTarget } ResTarget; /* - * SortGroupBy - for ORDER BY clause + * SortBy - for ORDER BY clause */ -typedef struct SortGroupBy +#define SORTBY_ASC 1 +#define SORTBY_DESC 2 +#define SORTBY_USING 3 + +typedef struct SortBy { NodeTag type; - List *useOp; /* operator to use */ - Node *node; /* Expression */ -} SortGroupBy; + int sortby_kind; /* see codes above */ + List *useOp; /* name of op to use, if SORTBY_USING */ + Node *node; /* expression to sort on */ +} SortBy; /* * RangeSubselect - subquery appearing in a FROM clause @@ -614,7 +619,7 @@ typedef struct SelectStmt * These fields are used in both "leaf" SelectStmts and upper-level * SelectStmts. */ - List *sortClause; /* sort clause (a list of SortGroupBy's) */ + List *sortClause; /* sort clause (a list of SortBy's) */ Node *limitOffset; /* # of result tuples to skip */ Node *limitCount; /* # of result tuples to return */ List *forUpdate; /* FOR UPDATE clause */ diff --git a/src/include/nodes/pg_list.h b/src/include/nodes/pg_list.h index 4d9ce8304b1..4db5ac6297d 100644 --- a/src/include/nodes/pg_list.h +++ b/src/include/nodes/pg_list.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_list.h,v 1.40 2003/08/08 21:42:48 momjian Exp $ + * $Id: pg_list.h,v 1.40.2.1 2003/09/07 04:37:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -132,6 +132,9 @@ typedef struct List * FastList is an optimization for building large lists. The conventional * way to build a list is repeated lappend() operations, but that is O(N^2) * in the number of list items, which gets tedious for large lists. + * + * Note: there are some hacks in gram.y that rely on the head pointer (the + * value-as-list) being the first field. */ typedef struct FastList { @@ -144,6 +147,9 @@ typedef struct FastList ( (fl)->head = (l), (fl)->tail = llastnode((fl)->head) ) #define FastListValue(fl) ( (fl)->head ) +#define makeFastList1(fl, x1) \ + ( (fl)->head = (fl)->tail = makeList1(x1) ) + /* * function prototypes in nodes/list.c diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h index f6e4436d950..771e962fec6 100644 --- a/src/include/nodes/primnodes.h +++ b/src/include/nodes/primnodes.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: primnodes.h,v 1.91 2003/08/11 23:04:50 tgl Exp $ + * $Id: primnodes.h,v 1.91.2.1 2003/09/07 04:37:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -587,16 +587,18 @@ typedef struct CaseWhen /* * ArrayExpr - an ARRAY[] expression * - * Note: if ndims > 1, then the array elements are all ArrayExprs of the - * same type and ndims one less. + * Note: if multidims is false, the constituent expressions all yield the + * scalar type identified by element_typeid. If multidims is true, the + * constituent expressions all yield arrays of element_typeid (ie, the same + * type as array_typeid); at runtime we must check for compatible subscripts. */ typedef struct ArrayExpr { Expr xpr; Oid array_typeid; /* type of expression result */ - Oid element_typeid; /* common type of expression elements */ - List *elements; /* the array elements */ - int ndims; /* number of array dimensions */ + Oid element_typeid; /* common type of array elements */ + List *elements; /* the array elements or sub-arrays */ + bool multidims; /* true if elements are sub-arrays */ } ArrayExpr; /* diff --git a/src/include/parser/parse_clause.h b/src/include/parser/parse_clause.h index 670b72cfbac..b6c9e4511cb 100644 --- a/src/include/parser/parse_clause.h +++ b/src/include/parser/parse_clause.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parse_clause.h,v 1.36 2003/08/07 19:20:23 tgl Exp $ + * $Id: parse_clause.h,v 1.36.2.1 2003/09/07 04:37:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,8 @@ extern List *addAllTargetsToSortList(ParseState *pstate, bool resolveUnknown); extern List *addTargetToSortList(ParseState *pstate, TargetEntry *tle, List *sortlist, List *targetlist, - List *opname, bool resolveUnknown); + int sortby_kind, List *sortby_opname, + bool resolveUnknown); extern Index assignSortGroupRef(TargetEntry *tle, List *tlist); extern bool targetIsInSortList(TargetEntry *tle, List *sortList); diff --git a/src/include/parser/parse_oper.h b/src/include/parser/parse_oper.h index 1167997706a..281d82cbd69 100644 --- a/src/include/parser/parse_oper.h +++ b/src/include/parser/parse_oper.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parse_oper.h,v 1.32 2003/08/04 02:40:14 momjian Exp $ + * $Id: parse_oper.h,v 1.32.2.1 2003/09/07 04:37:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,15 +38,16 @@ extern Operator compatible_oper(List *op, Oid arg1, Oid arg2, bool noError); /* currently no need for compatible_left_oper/compatible_right_oper */ -/* Routines for identifying "=" and "<" operators for a type */ +/* Routines for identifying "=", "<", ">" operators for a type */ extern Operator equality_oper(Oid argtype, bool noError); extern Operator ordering_oper(Oid argtype, bool noError); +extern Operator reverse_ordering_oper(Oid argtype, bool noError); /* Convenience routines for common calls on the above */ extern Oid compatible_oper_opid(List *op, Oid arg1, Oid arg2, bool noError); extern Oid equality_oper_funcid(Oid argtype); extern Oid ordering_oper_opid(Oid argtype); -extern Oid ordering_oper_funcid(Oid argtype); +extern Oid reverse_ordering_oper_opid(Oid argtype); /* Extract operator OID or underlying-function OID from an Operator tuple */ extern Oid oprid(Operator op); diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index acb140b856b..03874772cd0 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -9,6 +9,9 @@ /* Define to the type of arg 3 of 'accept' */ #undef ACCEPT_TYPE_ARG3 +/* Define to the return type of 'accept' */ +#undef ACCEPT_TYPE_RETURN + /* The alignment requirement of a `double'. */ #undef ALIGNOF_DOUBLE @@ -118,9 +121,6 @@ /* Define to 1 if you have the `getaddrinfo' function. */ #undef HAVE_GETADDRINFO -/* Define to 1 if you have the `gethostbyname_r' function. */ -#undef HAVE_GETHOSTBYNAME_R - /* Define to 1 if you have the `gethostname' function. */ #undef HAVE_GETHOSTNAME @@ -136,9 +136,6 @@ /* Define to 1 if you have the `getpeereid' function. */ #undef HAVE_GETPEEREID -/* Define to 1 if you have the `getpwuid_r' function. */ -#undef HAVE_GETPWUID_R - /* Define to 1 if you have the `getrusage' function. */ #undef HAVE_GETRUSAGE @@ -378,9 +375,6 @@ /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR -/* Define to 1 if you have the `strerror_r' function. */ -#undef HAVE_STRERROR_R - /* Define to 1 if cpp supports the ANSI # stringizing operator. */ #undef HAVE_STRINGIZE diff --git a/src/include/port.h b/src/include/port.h index 4ff6710c302..359631190fb 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: port.h,v 1.12 2003/08/08 21:42:31 momjian Exp $ + * $Id: port.h,v 1.12.2.1 2003/09/07 04:37:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -112,8 +112,10 @@ extern void srandom(unsigned int seed); /* thread.h */ extern char *pqStrerror(int errnum, char *strerrbuf, size_t buflen); +#ifndef WIN32 extern int pqGetpwuid(uid_t uid, struct passwd * resultbuf, char *buffer, size_t buflen, struct passwd ** result); +#endif extern int pqGethostbyname(const char *name, struct hostent * resbuf, diff --git a/src/include/postgres_ext.h b/src/include/postgres_ext.h index b252453bbff..91c1daf830b 100644 --- a/src/include/postgres_ext.h +++ b/src/include/postgres_ext.h @@ -15,7 +15,7 @@ * use header files that are otherwise internal to Postgres to interface * with the backend. * - * $Id: postgres_ext.h,v 1.12 2003/03/18 17:21:07 momjian Exp $ + * $Id: postgres_ext.h,v 1.12.2.1 2003/09/07 04:37:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,4 +47,21 @@ typedef unsigned int Oid; */ #define NAMEDATALEN 64 + +/* + * Identifiers of error message fields. Kept here to keep common + * between frontend and backend, and also to export them to libpq + * applications. + */ +#define PG_DIAG_SEVERITY 'S' +#define PG_DIAG_SQLSTATE 'C' +#define PG_DIAG_MESSAGE_PRIMARY 'M' +#define PG_DIAG_MESSAGE_DETAIL 'D' +#define PG_DIAG_MESSAGE_HINT 'H' +#define PG_DIAG_STATEMENT_POSITION 'P' +#define PG_DIAG_CONTEXT 'W' +#define PG_DIAG_SOURCE_FILE 'F' +#define PG_DIAG_SOURCE_LINE 'L' +#define PG_DIAG_SOURCE_FUNCTION 'R' + #endif diff --git a/src/include/storage/lmgr.h b/src/include/storage/lmgr.h index d7a557d2b57..8940f333fc8 100644 --- a/src/include/storage/lmgr.h +++ b/src/include/storage/lmgr.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: lmgr.h,v 1.39 2003/08/04 02:40:14 momjian Exp $ + * $Id: lmgr.h,v 1.39.2.1 2003/09/07 04:37:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,8 +54,9 @@ extern void UnlockRelation(Relation relation, LOCKMODE lockmode); extern void LockRelationForSession(LockRelId *relid, LOCKMODE lockmode); extern void UnlockRelationForSession(LockRelId *relid, LOCKMODE lockmode); -/* Lock a page (mainly used for indices) */ +/* Lock a page (mainly used for indexes) */ extern void LockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode); +extern bool ConditionalLockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode); extern void UnlockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode); /* Lock an XID (used to wait for a transaction to finish) */ diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h index 59b5d106fa6..af854a12509 100644 --- a/src/include/utils/acl.h +++ b/src/include/utils/acl.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: acl.h,v 1.61 2003/08/08 21:42:55 momjian Exp $ + * $Id: acl.h,v 1.61.2.1 2003/09/07 04:37:09 momjian Exp $ * * NOTES * For backward-compatibility purposes we have to allow there @@ -209,6 +209,7 @@ extern Datum aclremove(PG_FUNCTION_ARGS); extern Datum aclcontains(PG_FUNCTION_ARGS); extern Datum makeaclitem(PG_FUNCTION_ARGS); extern Datum aclitem_eq(PG_FUNCTION_ARGS); +extern Datum hash_aclitem(PG_FUNCTION_ARGS); /* * prototypes for functions in aclchk.c diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index a84f8512256..d998520ed31 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: builtins.h,v 1.227 2003/08/08 21:42:55 momjian Exp $ + * $Id: builtins.h,v 1.227.2.1 2003/09/07 04:37:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -222,6 +222,8 @@ extern Datum btfloat8cmp(PG_FUNCTION_ARGS); extern Datum btoidcmp(PG_FUNCTION_ARGS); extern Datum btoidvectorcmp(PG_FUNCTION_ARGS); extern Datum btabstimecmp(PG_FUNCTION_ARGS); +extern Datum btreltimecmp(PG_FUNCTION_ARGS); +extern Datum bttintervalcmp(PG_FUNCTION_ARGS); extern Datum btcharcmp(PG_FUNCTION_ARGS); extern Datum btnamecmp(PG_FUNCTION_ARGS); extern Datum bttextcmp(PG_FUNCTION_ARGS); diff --git a/src/include/utils/cash.h b/src/include/utils/cash.h index 305304c20d2..b78da25edd1 100644 --- a/src/include/utils/cash.h +++ b/src/include/utils/cash.h @@ -23,6 +23,7 @@ extern Datum cash_lt(PG_FUNCTION_ARGS); extern Datum cash_le(PG_FUNCTION_ARGS); extern Datum cash_gt(PG_FUNCTION_ARGS); extern Datum cash_ge(PG_FUNCTION_ARGS); +extern Datum cash_cmp(PG_FUNCTION_ARGS); extern Datum cash_pl(PG_FUNCTION_ARGS); extern Datum cash_mi(PG_FUNCTION_ARGS); diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h index d5facdd8e00..f221cab080e 100644 --- a/src/include/utils/datetime.h +++ b/src/include/utils/datetime.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: datetime.h,v 1.44 2003/08/05 18:30:21 tgl Exp $ + * $Id: datetime.h,v 1.44.2.1 2003/09/07 04:37:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -204,7 +204,7 @@ typedef struct */ #define FMODULO(t,q,u) \ do { \ - q = ((t < 0) ? ceil(t / u): floor(t / u)); \ + q = ((t < 0) ? ceil(t / u) : floor(t / u)); \ if (q != 0) t -= rint(q * u); \ } while(0) @@ -222,7 +222,7 @@ do { \ #else #define TMODULO(t,q,u) \ do { \ - q = ((t < 0) ? ceil(t / u): floor(t / u)); \ + q = ((t < 0) ? ceil(t / u) : floor(t / u)); \ if (q != 0) t -= rint(q * u); \ } while(0) #endif @@ -253,6 +253,15 @@ extern int day_tab[2][13]; || (((m) == JULIAN_MINMONTH) && ((d) >= JULIAN_MINDAY))))) \ && ((y) < JULIAN_MAXYEAR)) +/* Julian-date equivalents of Day 0 in Unix and Postgres reckoning */ +#define UNIX_EPOCH_JDATE 2440588 /* == date2j(1970, 1, 1) */ +#define POSTGRES_EPOCH_JDATE 2451545 /* == date2j(2000, 1, 1) */ + +/* + * Info about limits of the Unix time_t data type. We assume that time_t + * is a signed int32 with origin 1970-01-01. Note this is only relevant + * when we use the C library's time routines for timezone processing. + */ #define UTIME_MINYEAR (1901) #define UTIME_MINMONTH (12) #define UTIME_MINDAY (14) @@ -267,9 +276,17 @@ extern int day_tab[2][13]; || (((y) == UTIME_MAXYEAR) && (((m) < UTIME_MAXMONTH) \ || (((m) == UTIME_MAXMONTH) && ((d) <= UTIME_MAXDAY)))))) -/* Julian-date equivalents of Day 0 in Unix and Postgres reckoning */ -#define UNIX_EPOCH_JDATE 2440588 /* == date2j(1970, 1, 1) */ -#define POSTGRES_EPOCH_JDATE 2451545 /* == date2j(2000, 1, 1) */ +/* + * Datetime input parsing routines (ParseDateTime, DecodeDateTime, etc) + * return zero or a positive value on success. On failure, they return + * one of these negative code values. DateTimeParseError may be used to + * produce a correct ereport. + */ +#define DTERR_BAD_FORMAT (-1) +#define DTERR_FIELD_OVERFLOW (-2) +#define DTERR_MD_FIELD_OVERFLOW (-3) /* triggers hint about DateStyle */ +#define DTERR_INTERVAL_OVERFLOW (-4) +#define DTERR_TZDISP_OVERFLOW (-5) extern void GetCurrentDateTime(struct tm * tm); @@ -283,14 +300,14 @@ extern int ParseDateTime(const char *timestr, char *lowstr, extern int DecodeDateTime(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fsec_t *fsec, int *tzp); - extern int DecodeTimeOnly(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fsec_t *fsec, int *tzp); - extern int DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fsec_t *fsec); +extern void DateTimeParseError(int dterr, const char *str, + const char *datatype); extern int DetermineLocalTimeZone(struct tm * tm); diff --git a/src/include/utils/errcodes.h b/src/include/utils/errcodes.h index 8db8e52320c..c4340923dc9 100644 --- a/src/include/utils/errcodes.h +++ b/src/include/utils/errcodes.h @@ -11,7 +11,7 @@ * * Copyright (c) 2003, PostgreSQL Global Development Group * - * $Id: errcodes.h,v 1.4 2003/08/04 00:43:32 momjian Exp $ + * $Id: errcodes.h,v 1.4.2.1 2003/09/07 04:37:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -294,6 +294,8 @@ /* Class 58 - System Error (class borrowed from DB2) */ /* (we define this as errors external to PostgreSQL itself) */ #define ERRCODE_IO_ERROR MAKE_SQLSTATE('5','8', '0','3','0') +#define ERRCODE_UNDEFINED_FILE MAKE_SQLSTATE('5','8', 'P','0','1') +#define ERRCODE_DUPLICATE_FILE MAKE_SQLSTATE('5','8', 'P','0','2') /* Class F0 - Configuration File Error (PostgreSQL-specific error class) */ #define ERRCODE_CONFIG_FILE_ERROR MAKE_SQLSTATE('F','0', '0','0','0') diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index 80ad3b3aa66..75859159833 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -7,7 +7,7 @@ * Copyright (c) 2000-2003, PostgreSQL Global Development Group * Written by Peter Eisentraut <peter_e@gmx.net>. * - * $Id: guc.h,v 1.40 2003/08/04 23:59:41 tgl Exp $ + * $Id: guc.h,v 1.40.2.1 2003/09/07 04:37:09 momjian Exp $ *-------------------------------------------------------------------- */ #ifndef GUC_H @@ -127,7 +127,7 @@ extern void BeginReportingGUCOptions(void); extern void ParseLongOption(const char *string, char **name, char **value); extern bool set_config_option(const char *name, const char *value, GucContext context, GucSource source, - bool isLocal, bool DoIt); + bool isLocal, bool changeVal); extern void ShowGUCConfigOption(const char *name, DestReceiver *dest); extern void ShowAllGUCConfig(DestReceiver *dest); extern char *GetConfigOptionByName(const char *name, const char **varname); diff --git a/src/include/utils/hsearch.h b/src/include/utils/hsearch.h index 905268badc6..fec224bfe12 100644 --- a/src/include/utils/hsearch.h +++ b/src/include/utils/hsearch.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: hsearch.h,v 1.28 2003/08/04 02:40:15 momjian Exp $ + * $Id: hsearch.h,v 1.28.2.1 2003/09/07 04:37:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,6 +16,23 @@ /* + * Hash and comparison functions must have these signatures. Comparison + * functions return zero for match, nonzero for no match. (The comparison + * function definition is designed to allow memcmp() and strncmp() to be + * used directly as key comparison functions.) + */ +typedef uint32 (*HashValueFunc) (const void *key, Size keysize); +typedef int (*HashCompareFunc) (const void *key1, const void *key2, + Size keysize); + +/* + * Space allocation function for a hashtable --- designed to match malloc(). + * Note: there is no free function API; can't destroy a hashtable unless you + * use the default allocator. + */ +typedef void *(*HashAllocFunc) (Size request); + +/* * Constants * * A hash table has a top-level "directory", each of whose entries points @@ -44,6 +61,7 @@ typedef struct HASHELEMENT { struct HASHELEMENT *link; /* link to next entry in same bucket */ + uint32 hashvalue; /* hash function result for this entry */ } HASHELEMENT; /* A hash bucket is a linked list of HASHELEMENTs */ @@ -64,8 +82,8 @@ typedef struct HASHHDR long ffactor; /* Fill factor */ long nentries; /* Number of entries in hash table */ long nsegs; /* Number of allocated segments */ - long keysize; /* hash key length in bytes */ - long entrysize; /* total user element size in bytes */ + Size keysize; /* hash key length in bytes */ + Size entrysize; /* total user element size in bytes */ long max_dsize; /* 'dsize' limit if directory is fixed * size */ HASHELEMENT *freeList; /* linked list of free elements */ @@ -83,8 +101,9 @@ typedef struct HTAB { HASHHDR *hctl; /* shared control information */ HASHSEGMENT *dir; /* directory of segment starts */ - uint32 (*hash) (void *key, int keysize); /* Hash Function */ - void *(*alloc) (Size); /* memory allocator */ + HashValueFunc hash; /* hash function */ + HashCompareFunc match; /* key comparison function */ + HashAllocFunc alloc; /* memory allocator */ MemoryContext hcxt; /* memory context if default allocator * used */ char *tabname; /* table name (for error messages) */ @@ -97,28 +116,30 @@ typedef struct HASHCTL { long ssize; /* Segment Size */ long dsize; /* (initial) Directory Size */ - long ffactor; /* Fill factor */ - uint32 (*hash) (void *key, int keysize); /* Hash Function */ - long keysize; /* hash key length in bytes */ - long entrysize; /* total user element size in bytes */ long max_dsize; /* limit to dsize if directory size is * limited */ - void *(*alloc) (Size); /* memory allocation function */ + long ffactor; /* Fill factor */ + Size keysize; /* hash key length in bytes */ + Size entrysize; /* total user element size in bytes */ + HashValueFunc hash; /* hash function */ + HashCompareFunc match; /* key comparison function */ + HashAllocFunc alloc; /* memory allocator */ HASHSEGMENT *dir; /* directory of segment starts */ HASHHDR *hctl; /* location of header in shared mem */ MemoryContext hcxt; /* memory context to use for allocations */ } HASHCTL; /* Flags to indicate which parameters are supplied */ -#define HASH_SEGMENT 0x002 /* Setting segment size */ -#define HASH_DIRSIZE 0x004 /* Setting directory size */ -#define HASH_FFACTOR 0x008 /* Setting fill factor */ +#define HASH_SEGMENT 0x002 /* Set segment size */ +#define HASH_DIRSIZE 0x004 /* Set directory size */ +#define HASH_FFACTOR 0x008 /* Set fill factor */ #define HASH_FUNCTION 0x010 /* Set user defined hash function */ -#define HASH_ELEM 0x020 /* Setting key/entry size */ -#define HASH_SHARED_MEM 0x040 /* Setting shared mem const */ +#define HASH_ELEM 0x020 /* Set key/entry size */ +#define HASH_SHARED_MEM 0x040 /* Set shared mem const */ #define HASH_ATTACH 0x080 /* Do not initialize hctl */ -#define HASH_ALLOC 0x100 /* Setting memory allocator */ -#define HASH_CONTEXT 0x200 /* Setting explicit memory context */ +#define HASH_ALLOC 0x100 /* Set memory allocator */ +#define HASH_CONTEXT 0x200 /* Set explicit memory context */ +#define HASH_COMPARE 0x400 /* Set user defined comparison function */ /* max_dsize value to indicate expansible directory */ @@ -151,17 +172,17 @@ extern HTAB *hash_create(const char *tabname, long nelem, HASHCTL *info, int flags); extern void hash_destroy(HTAB *hashp); extern void hash_stats(const char *where, HTAB *hashp); -extern void *hash_search(HTAB *hashp, void *keyPtr, HASHACTION action, +extern void *hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr); extern void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp); extern void *hash_seq_search(HASH_SEQ_STATUS *status); -extern long hash_estimate_size(long num_entries, long entrysize); +extern long hash_estimate_size(long num_entries, Size entrysize); extern long hash_select_dirsize(long num_entries); /* * prototypes for functions in hashfn.c */ -extern uint32 string_hash(void *key, int keysize); -extern uint32 tag_hash(void *key, int keysize); +extern uint32 string_hash(const void *key, Size keysize); +extern uint32 tag_hash(const void *key, Size keysize); #endif /* HSEARCH_H */ diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h index 4c9c073adea..36bfc8b2b1f 100644 --- a/src/include/utils/lsyscache.h +++ b/src/include/utils/lsyscache.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: lsyscache.h,v 1.80 2003/08/11 23:04:50 tgl Exp $ + * $Id: lsyscache.h,v 1.80.2.1 2003/09/07 04:37:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,6 +28,7 @@ extern bool op_in_opclass(Oid opno, Oid opclass); extern bool op_requires_recheck(Oid opno, Oid opclass); extern Oid get_opclass_member(Oid opclass, int16 strategy); extern Oid get_op_hash_function(Oid opno); +extern Oid get_opclass_proc(Oid opclass, int16 procnum); extern char *get_attname(Oid relid, AttrNumber attnum); extern char *get_relid_attribute_name(Oid relid, AttrNumber attnum); extern AttrNumber get_attnum(Oid relid, const char *attname); diff --git a/src/include/utils/typcache.h b/src/include/utils/typcache.h new file mode 100644 index 00000000000..38e9d4c4df8 --- /dev/null +++ b/src/include/utils/typcache.h @@ -0,0 +1,66 @@ +/*------------------------------------------------------------------------- + * + * typcache.h + * Type cache definitions. + * + * The type cache exists to speed lookup of certain information about data + * types that is not directly available from a type's pg_type row. + * + * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $Id: typcache.h,v 1.1.2.1 2003/09/07 04:37:09 momjian Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef TYPCACHE_H +#define TYPCACHE_H + +#include "fmgr.h" + + +typedef struct TypeCacheEntry +{ + /* typeId is the hash lookup key and MUST BE FIRST */ + Oid type_id; /* OID of the data type */ + + /* some subsidiary information copied from the pg_type row */ + int16 typlen; + bool typbyval; + char typalign; + + /* + * Information obtained from opclass entries + * + * These will be InvalidOid if no match could be found, or if the + * information hasn't yet been requested. + */ + Oid btree_opc; /* OID of the default btree opclass */ + Oid hash_opc; /* OID of the default hash opclass */ + Oid eq_opr; /* OID of the equality operator */ + Oid lt_opr; /* OID of the less-than operator */ + Oid gt_opr; /* OID of the greater-than operator */ + Oid cmp_proc; /* OID of the btree comparison function */ + + /* + * Pre-set-up fmgr call info for the equality operator and the btree + * comparison function. These are kept in the type cache to avoid + * problems with memory leaks in repeated calls to array_eq and array_cmp. + * There is not currently a need to maintain call info for the lt_opr + * or gt_opr. + */ + FmgrInfo eq_opr_finfo; + FmgrInfo cmp_proc_finfo; +} TypeCacheEntry; + +/* Bit flags to indicate which fields a given caller needs to have set */ +#define TYPECACHE_EQ_OPR 0x0001 +#define TYPECACHE_LT_OPR 0x0002 +#define TYPECACHE_GT_OPR 0x0004 +#define TYPECACHE_CMP_PROC 0x0008 +#define TYPECACHE_EQ_OPR_FINFO 0x0010 +#define TYPECACHE_CMP_PROC_FINFO 0x0020 + +extern TypeCacheEntry *lookup_type_cache(Oid type_id, int flags); + +#endif /* TYPCACHE_H */ |
