diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/access/genam.h | 12 | ||||
-rw-r--r-- | src/include/access/gin.h | 4 | ||||
-rw-r--r-- | src/include/access/gist_private.h | 8 | ||||
-rw-r--r-- | src/include/access/hash.h | 7 | ||||
-rw-r--r-- | src/include/access/heapam.h | 31 | ||||
-rw-r--r-- | src/include/access/nbtree.h | 11 | ||||
-rw-r--r-- | src/include/access/reloptions.h | 38 | ||||
-rw-r--r-- | src/include/catalog/catversion.h | 4 | ||||
-rw-r--r-- | src/include/catalog/heap.h | 12 | ||||
-rw-r--r-- | src/include/catalog/index.h | 7 | ||||
-rw-r--r-- | src/include/catalog/pg_am.h | 14 | ||||
-rw-r--r-- | src/include/catalog/pg_attribute.h | 10 | ||||
-rw-r--r-- | src/include/catalog/pg_class.h | 35 | ||||
-rw-r--r-- | src/include/catalog/pg_proc.h | 10 | ||||
-rw-r--r-- | src/include/commands/defrem.h | 3 | ||||
-rw-r--r-- | src/include/nodes/parsenodes.h | 21 | ||||
-rw-r--r-- | src/include/parser/parse_clause.h | 9 | ||||
-rw-r--r-- | src/include/utils/rel.h | 56 |
18 files changed, 164 insertions, 128 deletions
diff --git a/src/include/access/genam.h b/src/include/access/genam.h index c7ebae99315..9a8828a33ac 100644 --- a/src/include/access/genam.h +++ b/src/include/access/genam.h @@ -7,14 +7,13 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/genam.h,v 1.61 2006/07/02 02:23:22 momjian Exp $ + * $PostgreSQL: pgsql/src/include/access/genam.h,v 1.62 2006/07/03 22:45:39 tgl Exp $ * *------------------------------------------------------------------------- */ #ifndef GENAM_H #define GENAM_H -#include "access/heapam.h" #include "access/itup.h" #include "access/relscan.h" #include "access/sdir.h" @@ -145,13 +144,4 @@ extern SysScanDesc systable_beginscan(Relation heapRelation, extern HeapTuple systable_getnext(SysScanDesc sysscan); extern void systable_endscan(SysScanDesc sysscan); - -typedef HeapOption IndexOption; - -extern bytea *genam_option(ArrayType *options, - int minFillfactor, int defaultFillfactor); - -#define IndexGetFillFactor(relation) HeapGetFillFactor(relation) -#define IndexGetPageFreeSpace(relation) HeapGetPageFreeSpace(relation) - #endif /* GENAM_H */ diff --git a/src/include/access/gin.h b/src/include/access/gin.h index 4749eca192a..de3100c4cae 100644 --- a/src/include/access/gin.h +++ b/src/include/access/gin.h @@ -3,7 +3,7 @@ * header file for postgres inverted index access method implementation. * * Copyright (c) 2006, PostgreSQL Global Development Group - * $PostgreSQL: pgsql/src/include/access/gin.h,v 1.2 2006/07/02 02:23:22 momjian Exp $ + * $PostgreSQL: pgsql/src/include/access/gin.h,v 1.3 2006/07/03 22:45:39 tgl Exp $ *-------------------------------------------------------------------------- */ @@ -213,7 +213,7 @@ typedef struct ginxlogDeletePage { } ginxlogDeletePage; /* ginutil.c */ -extern Datum ginoption(PG_FUNCTION_ARGS); +extern Datum ginoptions(PG_FUNCTION_ARGS); extern void initGinState( GinState *state, Relation index ); extern Buffer GinNewBuffer(Relation index); extern void GinInitBuffer(Buffer b, uint32 f); diff --git a/src/include/access/gist_private.h b/src/include/access/gist_private.h index 5be99712b00..bf9dd11e215 100644 --- a/src/include/access/gist_private.h +++ b/src/include/access/gist_private.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/gist_private.h,v 1.19 2006/07/02 02:23:22 momjian Exp $ + * $PostgreSQL: pgsql/src/include/access/gist_private.h,v 1.20 2006/07/03 22:45:39 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -272,7 +272,10 @@ extern Datum gistgetmulti(PG_FUNCTION_ARGS); #define GiSTPageSize \ ( BLCKSZ - SizeOfPageHeaderData - MAXALIGN(sizeof(GISTPageOpaqueData)) ) -extern Datum gistoption(PG_FUNCTION_ARGS); +#define GIST_MIN_FILLFACTOR 50 +#define GIST_DEFAULT_FILLFACTOR 90 + +extern Datum gistoptions(PG_FUNCTION_ARGS); extern bool gistfitpage(IndexTuple *itvec, int len); extern bool gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size freespace); extern void gistcheckpage(Relation rel, Buffer buf); @@ -330,4 +333,5 @@ extern void gistSplitByKey(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *giststate, GistSplitVector *v, GistEntryVector *entryvec, int attno); + #endif /* GIST_PRIVATE_H */ diff --git a/src/include/access/hash.h b/src/include/access/hash.h index 59cf5c9961a..10646522d93 100644 --- a/src/include/access/hash.h +++ b/src/include/access/hash.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/hash.h,v 1.70 2006/07/02 02:23:22 momjian Exp $ + * $PostgreSQL: pgsql/src/include/access/hash.h,v 1.71 2006/07/03 22:45:39 tgl Exp $ * * NOTES * modeled after Margo Seltzer's hash implementation for unix. @@ -167,6 +167,9 @@ typedef HashMetaPageData *HashMetaPage; MAXALIGN(sizeof(HashPageOpaqueData)) - \ sizeof(ItemIdData)) +#define HASH_MIN_FILLFACTOR 50 +#define HASH_DEFAULT_FILLFACTOR 75 + /* * Constants */ @@ -234,7 +237,7 @@ extern Datum hashmarkpos(PG_FUNCTION_ARGS); extern Datum hashrestrpos(PG_FUNCTION_ARGS); extern Datum hashbulkdelete(PG_FUNCTION_ARGS); extern Datum hashvacuumcleanup(PG_FUNCTION_ARGS); -extern Datum hashoption(PG_FUNCTION_ARGS); +extern Datum hashoptions(PG_FUNCTION_ARGS); /* * Datatype-specific hash functions in hashfunc.c. diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index 085501be7d2..a2ca20bddd9 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.113 2006/07/02 02:23:22 momjian Exp $ + * $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.114 2006/07/03 22:45:39 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -22,7 +22,6 @@ #include "nodes/primnodes.h" #include "storage/block.h" #include "storage/lmgr.h" -#include "utils/array.h" #include "utils/rel.h" #include "utils/tqual.h" @@ -228,32 +227,4 @@ extern MinimalTuple minimal_tuple_from_heap_tuple(HeapTuple htup); extern HeapTuple heap_addheader(int natts, bool withoid, Size structlen, void *structure); -extern HeapTuple build_class_tuple(Form_pg_class pgclass, ArrayType *options); - -/* - * HeapOption - * Internal data of heaps. - */ -typedef struct HeapOption -{ - int32 vl_len; - int fillfactor; -} HeapOption; - -extern bytea *heap_option(char relkind, ArrayType *options); - -/* - * HeapGetFillFactor - * Returns the heap's fillfactor. - */ -#define HeapGetFillFactor(relation) \ - (((HeapOption*)(relation)->rd_options)->fillfactor) - -/* - * HeapGetPageFreeSpace - * Returns the heap's freespace per page in bytes. - */ -#define HeapGetPageFreeSpace(relation) \ - (BLCKSZ * (100 - HeapGetFillFactor(relation)) / 100) - #endif /* HEAPAM_H */ diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h index e5981d092c0..43bd49a7bb5 100644 --- a/src/include/access/nbtree.h +++ b/src/include/access/nbtree.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.99 2006/07/02 02:23:22 momjian Exp $ + * $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.100 2006/07/03 22:45:39 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -107,6 +107,13 @@ typedef struct BTMetaPageData MAXALIGN(sizeof(BTPageOpaqueData))) / 3 - sizeof(ItemIdData)) /* + * Because of above, min fillfactor can't be less than 2/3rds; see notes in + * nbtsort.c before you change these! + */ +#define BTREE_MIN_FILLFACTOR 70 +#define BTREE_DEFAULT_FILLFACTOR 90 + +/* * Test whether two btree entries are "the same". * * Old comments: @@ -453,7 +460,7 @@ extern Datum btmarkpos(PG_FUNCTION_ARGS); extern Datum btrestrpos(PG_FUNCTION_ARGS); extern Datum btbulkdelete(PG_FUNCTION_ARGS); extern Datum btvacuumcleanup(PG_FUNCTION_ARGS); -extern Datum btoption(PG_FUNCTION_ARGS); +extern Datum btoptions(PG_FUNCTION_ARGS); /* * prototypes for functions in nbtinsert.c diff --git a/src/include/access/reloptions.h b/src/include/access/reloptions.h new file mode 100644 index 00000000000..82474f4707a --- /dev/null +++ b/src/include/access/reloptions.h @@ -0,0 +1,38 @@ +/*------------------------------------------------------------------------- + * + * reloptions.h + * Core support for relation options (pg_class.reloptions) + * + * Note: the functions dealing with text-array reloptions values declare + * them as Datum, not ArrayType *, to avoid needing to include array.h + * into a lot of low-level code. + * + * + * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL: pgsql/src/include/access/reloptions.h,v 1.1 2006/07/03 22:45:40 tgl Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef RELOPTIONS_H +#define RELOPTIONS_H + +#include "nodes/pg_list.h" + +extern Datum transformRelOptions(Datum oldOptions, List *defList, + bool ignoreOids, bool isReset); + +extern void parseRelOptions(Datum options, int numkeywords, + const char * const *keywords, + char **values, bool validate); + +extern bytea *default_reloptions(Datum reloptions, bool validate, + int minFillfactor, int defaultFillfactor); + +extern bytea *heap_reloptions(char relkind, Datum reloptions, bool validate); + +extern bytea *index_reloptions(RegProcedure amoptions, Datum reloptions, + bool validate); + +#endif /* RELOPTIONS_H */ diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 10e71559bc1..59dea36fe42 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.335 2006/07/02 02:23:22 momjian Exp $ + * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.336 2006/07/03 22:45:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200607011 +#define CATALOG_VERSION_NO 200607021 #endif diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h index 23604ec2ee1..09aa05f44c2 100644 --- a/src/include/catalog/heap.h +++ b/src/include/catalog/heap.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.83 2006/07/02 02:23:22 momjian Exp $ + * $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.84 2006/07/03 22:45:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -17,7 +17,6 @@ #include "catalog/pg_attribute.h" #include "nodes/parsenodes.h" #include "parser/parse_node.h" -#include "utils/array.h" #include "utils/rel.h" @@ -55,8 +54,8 @@ extern Oid heap_create_with_catalog(const char *relname, bool oidislocal, int oidinhcount, OnCommitAction oncommit, - bool allow_system_table_mods, - ArrayType *options); + Datum reloptions, + bool allow_system_table_mods); extern void heap_drop_with_catalog(Oid relid); @@ -66,6 +65,11 @@ extern void heap_truncate_check_FKs(List *relations, bool tempTables); extern List *heap_truncate_find_FKs(List *relationIds); +extern void InsertPgClassTuple(Relation pg_class_desc, + Relation new_rel_desc, + Oid new_rel_oid, + Datum reloptions); + extern List *AddRelationRawConstraints(Relation rel, List *rawColDefaults, List *rawConstraints); diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h index f4b1bc98304..c1af45da8d1 100644 --- a/src/include/catalog/index.h +++ b/src/include/catalog/index.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/index.h,v 1.67 2006/07/02 02:23:22 momjian Exp $ + * $PostgreSQL: pgsql/src/include/catalog/index.h,v 1.68 2006/07/03 22:45:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -17,7 +17,6 @@ #include "access/itup.h" #include "catalog/pg_index.h" #include "nodes/execnodes.h" -#include "utils/array.h" #define DEFAULT_INDEX_TYPE "btree" @@ -38,7 +37,7 @@ extern Oid index_create(Oid heapRelationId, Oid accessMethodObjectId, Oid tableSpaceId, Oid *classObjectId, - List *options, + Datum reloptions, bool isprimary, bool istoast, bool isconstraint, @@ -72,6 +71,4 @@ extern double IndexBuildHeapScan(Relation heapRelation, extern void reindex_index(Oid indexId); extern bool reindex_relation(Oid relid, bool toast_too); -extern bytea *index_option(RegProcedure amoption, ArrayType *options); - #endif /* INDEX_H */ diff --git a/src/include/catalog/pg_am.h b/src/include/catalog/pg_am.h index 5e0d1cf4b6e..048e3e97f7a 100644 --- a/src/include/catalog/pg_am.h +++ b/src/include/catalog/pg_am.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_am.h,v 1.44 2006/07/02 02:23:22 momjian Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_am.h,v 1.45 2006/07/03 22:45:40 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -65,7 +65,7 @@ CATALOG(pg_am,2601) regproc ambulkdelete; /* bulk-delete function */ regproc amvacuumcleanup; /* post-VACUUM cleanup function */ regproc amcostestimate; /* estimate cost of an indexscan */ - regproc amoption; /* parse AM-specific parameters */ + regproc amoptions; /* parse AM-specific parameters */ } FormData_pg_am; /* ---------------- @@ -103,23 +103,23 @@ typedef FormData_pg_am *Form_pg_am; #define Anum_pg_am_ambulkdelete 21 #define Anum_pg_am_amvacuumcleanup 22 #define Anum_pg_am_amcostestimate 23 -#define Anum_pg_am_amoption 24 +#define Anum_pg_am_amoptions 24 /* ---------------- * initial contents of pg_am * ---------------- */ -DATA(insert OID = 403 ( btree 5 1 1 t t t t f t t btinsert btbeginscan btgettuple btgetmulti btrescan btendscan btmarkpos btrestrpos btbuild btbulkdelete btvacuumcleanup btcostestimate btoption )); +DATA(insert OID = 403 ( btree 5 1 1 t t t t f t t btinsert btbeginscan btgettuple btgetmulti btrescan btendscan btmarkpos btrestrpos btbuild btbulkdelete btvacuumcleanup btcostestimate btoptions )); DESCR("b-tree index access method"); #define BTREE_AM_OID 403 -DATA(insert OID = 405 ( hash 1 1 0 f f f f f t f hashinsert hashbeginscan hashgettuple hashgetmulti hashrescan hashendscan hashmarkpos hashrestrpos hashbuild hashbulkdelete hashvacuumcleanup hashcostestimate hashoption )); +DATA(insert OID = 405 ( hash 1 1 0 f f f f f t f hashinsert hashbeginscan hashgettuple hashgetmulti hashrescan hashendscan hashmarkpos hashrestrpos hashbuild hashbulkdelete hashvacuumcleanup hashcostestimate hashoptions )); DESCR("hash index access method"); #define HASH_AM_OID 405 -DATA(insert OID = 783 ( gist 100 7 0 f t t t t t t gistinsert gistbeginscan gistgettuple gistgetmulti gistrescan gistendscan gistmarkpos gistrestrpos gistbuild gistbulkdelete gistvacuumcleanup gistcostestimate gistoption )); +DATA(insert OID = 783 ( gist 100 7 0 f t t t t t t gistinsert gistbeginscan gistgettuple gistgetmulti gistrescan gistendscan gistmarkpos gistrestrpos gistbuild gistbulkdelete gistvacuumcleanup gistcostestimate gistoptions )); DESCR("GiST index access method"); #define GIST_AM_OID 783 -DATA(insert OID = 2742 ( gin 100 4 0 f f f f t t f gininsert ginbeginscan gingettuple gingetmulti ginrescan ginendscan ginmarkpos ginrestrpos ginbuild ginbulkdelete ginvacuumcleanup gincostestimate ginoption )); +DATA(insert OID = 2742 ( gin 100 4 0 f f f f t t f gininsert ginbeginscan gingettuple gingetmulti ginrescan ginendscan ginmarkpos ginrestrpos ginbuild ginbulkdelete ginvacuumcleanup gincostestimate ginoptions )); DESCR("GIN index access method"); #define GIN_AM_OID 2742 diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h index c0be03ac4d3..fe4a7189bae 100644 --- a/src/include/catalog/pg_attribute.h +++ b/src/include/catalog/pg_attribute.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_attribute.h,v 1.121 2006/07/02 02:23:22 momjian Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_attribute.h,v 1.122 2006/07/03 22:45:40 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -404,8 +404,8 @@ DATA(insert ( 1249 tableoid 26 0 4 -7 0 -1 -1 t p i t f f t 0)); { 1259, {"relhaspkey"}, 16, -1, 1, 22, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ { 1259, {"relhasrules"}, 16, -1, 1, 23, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ { 1259, {"relhassubclass"},16, -1, 1, 24, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ -{ 1259, {"reloptions"}, 1009, -1, -1, 25, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \ -{ 1259, {"relacl"}, 1034, -1, -1, 26, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 } +{ 1259, {"relacl"}, 1034, -1, -1, 25, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \ +{ 1259, {"reloptions"}, 1009, -1, -1, 26, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 } DATA(insert ( 1259 relname 19 -1 NAMEDATALEN 1 0 -1 -1 f p i t f f t 0)); DATA(insert ( 1259 relnamespace 26 -1 4 2 0 -1 -1 t p i t f f t 0)); @@ -431,8 +431,8 @@ DATA(insert ( 1259 relhasoids 16 -1 1 21 0 -1 -1 t p c t f f t 0)); DATA(insert ( 1259 relhaspkey 16 -1 1 22 0 -1 -1 t p c t f f t 0)); DATA(insert ( 1259 relhasrules 16 -1 1 23 0 -1 -1 t p c t f f t 0)); DATA(insert ( 1259 relhassubclass 16 -1 1 24 0 -1 -1 t p c t f f t 0)); -DATA(insert ( 1259 reloptions 1009 -1 -1 25 1 -1 -1 f x i f f f t 0)); -DATA(insert ( 1259 relacl 1034 -1 -1 26 1 -1 -1 f x i f f f t 0)); +DATA(insert ( 1259 relacl 1034 -1 -1 25 1 -1 -1 f x i f f f t 0)); +DATA(insert ( 1259 reloptions 1009 -1 -1 26 1 -1 -1 f x i f f f t 0)); DATA(insert ( 1259 ctid 27 0 6 -1 0 -1 -1 f p s t f f t 0)); DATA(insert ( 1259 oid 26 0 4 -2 0 -1 -1 t p i t f f t 0)); DATA(insert ( 1259 xmin 28 0 4 -3 0 -1 -1 t p i t f f t 0)); diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h index 32b3406aa87..6d303b1cd66 100644 --- a/src/include/catalog/pg_class.h +++ b/src/include/catalog/pg_class.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.93 2006/07/02 02:23:22 momjian Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.94 2006/07/03 22:45:40 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -31,15 +31,6 @@ * typedef struct FormData_pg_class * ---------------- */ - -/* ---------------- - * This structure is actually variable-length (the last attribute is - * a POSTGRES array). Hence, sizeof(FormData_pg_class) does not - * necessarily match the actual length of the structure. Furthermore - * relacl may be a NULL field. Hence, you MUST use heap_getattr() - * to get the relacl field ... and don't forget to check isNull. - * ---------------- - */ #define RelationRelationId 1259 CATALOG(pg_class,1259) BKI_BOOTSTRAP @@ -75,12 +66,17 @@ CATALOG(pg_class,1259) BKI_BOOTSTRAP bool relhasrules; /* has associated rules */ bool relhassubclass; /* has derived classes */ - /* following fields may or may not be present, see note above! */ - text reloptions[1]; /* access method specific data */ - aclitem relacl[1]; /* we declare this just for the catalog */ + /* + * VARIABLE LENGTH FIELDS start here. These fields may be NULL, too. + * + * NOTE: these fields are not present in a relcache entry's rd_rel field. + */ + + aclitem relacl[1]; /* access permissions */ + text reloptions[1]; /* access-method-specific options */ } FormData_pg_class; -/* Size of fixed part of pg_class tuples, not counting relacl or padding */ +/* Size of fixed part of pg_class tuples, not counting var-length fields */ #define CLASS_TUPLE_SIZE \ (offsetof(FormData_pg_class,relhassubclass) + sizeof(bool)) @@ -96,13 +92,6 @@ typedef FormData_pg_class *Form_pg_class; * ---------------- */ -/* ---------------- - * Natts_pg_class_fixed is used to tell routines that insert new - * pg_class tuples (as opposed to replacing old ones) that there's no - * relacl field. This is a kluge. - * ---------------- - */ -#define Natts_pg_class_fixed 24 #define Natts_pg_class 26 #define Anum_pg_class_relname 1 #define Anum_pg_class_relnamespace 2 @@ -128,8 +117,8 @@ typedef FormData_pg_class *Form_pg_class; #define Anum_pg_class_relhaspkey 22 #define Anum_pg_class_relhasrules 23 #define Anum_pg_class_relhassubclass 24 -#define Anum_pg_class_reloptions 25 -#define Anum_pg_class_relacl 26 +#define Anum_pg_class_relacl 25 +#define Anum_pg_class_reloptions 26 /* ---------------- * initial contents of pg_class diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index aba5eee5fef..efa54141536 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.414 2006/07/02 02:23:22 momjian Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.415 2006/07/03 22:45:40 tgl Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -680,7 +680,7 @@ DATA(insert OID = 972 ( btvacuumcleanup PGNSP PGUID 12 f f t f v 2 2281 "2281 DESCR("btree(internal)"); DATA(insert OID = 1268 ( btcostestimate PGNSP PGUID 12 f f t f v 8 2278 "2281 2281 2281 2281 2281 2281 2281 2281" _null_ _null_ _null_ btcostestimate - _null_ )); DESCR("btree(internal)"); -DATA(insert OID = 2785 ( btoption PGNSP PGUID 12 f f t f v 1 2281 "2281" _null_ _null_ _null_ btoption - _null_ )); +DATA(insert OID = 2785 ( btoptions PGNSP PGUID 12 f f t f s 2 17 "1009 16" _null_ _null_ _null_ btoptions - _null_ )); DESCR("btree(internal)"); DATA(insert OID = 339 ( poly_same PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_same - _null_ )); @@ -799,7 +799,7 @@ DATA(insert OID = 425 ( hashvacuumcleanup PGNSP PGUID 12 f f t f v 2 2281 "2281 DESCR("hash(internal)"); DATA(insert OID = 438 ( hashcostestimate PGNSP PGUID 12 f f t f v 8 2278 "2281 2281 2281 2281 2281 2281 2281 2281" _null_ _null_ _null_ hashcostestimate - _null_ )); DESCR("hash(internal)"); -DATA(insert OID = 2786 ( hashoption PGNSP PGUID 12 f f t f v 1 2281 "2281" _null_ _null_ _null_ hashoption - _null_ )); +DATA(insert OID = 2786 ( hashoptions PGNSP PGUID 12 f f t f s 2 17 "1009 16" _null_ _null_ _null_ hashoptions - _null_ )); DESCR("hash(internal)"); DATA(insert OID = 449 ( hashint2 PGNSP PGUID 12 f f t f i 1 23 "21" _null_ _null_ _null_ hashint2 - _null_ )); @@ -1067,7 +1067,7 @@ DATA(insert OID = 2561 ( gistvacuumcleanup PGNSP PGUID 12 f f t f v 2 2281 "2 DESCR("gist(internal)"); DATA(insert OID = 772 ( gistcostestimate PGNSP PGUID 12 f f t f v 8 2278 "2281 2281 2281 2281 2281 2281 2281 2281" _null_ _null_ _null_ gistcostestimate - _null_ )); DESCR("gist(internal)"); -DATA(insert OID = 2787 ( gistoption PGNSP PGUID 12 f f t f v 1 2281 "2281" _null_ _null_ _null_ gistoption - _null_ )); +DATA(insert OID = 2787 ( gistoptions PGNSP PGUID 12 f f t f s 2 17 "1009 16" _null_ _null_ _null_ gistoptions - _null_ )); DESCR("gist(internal)"); DATA(insert OID = 784 ( tintervaleq PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervaleq - _null_ )); @@ -3855,7 +3855,7 @@ DATA(insert OID = 2740 ( ginvacuumcleanup PGNSP PGUID 12 f f t f v 2 2281 "2281 DESCR("gin(internal)"); DATA(insert OID = 2741 ( gincostestimate PGNSP PGUID 12 f f t f v 8 2278 "2281 2281 2281 2281 2281 2281 2281 2281" _null_ _null_ _null_ gincostestimate - _null_ )); DESCR("gin(internal)"); -DATA(insert OID = 2788 ( ginoption PGNSP PGUID 12 f f t f v 1 2281 "2281" _null_ _null_ _null_ ginoption - _null_ )); +DATA(insert OID = 2788 ( ginoptions PGNSP PGUID 12 f f t f s 2 17 "1009 16" _null_ _null_ _null_ ginoptions - _null_ )); DESCR("gin(internal)"); /* GIN array support */ diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h index e0678db4cf1..ac4b2a3a501 100644 --- a/src/include/commands/defrem.h +++ b/src/include/commands/defrem.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.73 2006/07/02 02:23:23 momjian Exp $ + * $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.74 2006/07/03 22:45:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -95,7 +95,6 @@ extern int64 defGetInt64(DefElem *def); extern List *defGetQualifiedName(DefElem *def); extern TypeName *defGetTypeName(DefElem *def); extern int defGetTypeLength(DefElem *def); - extern DefElem *defWithOids(bool value); #endif /* DEFREM_H */ diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 6cda429d3e6..fa63ca185bb 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.314 2006/07/02 02:23:23 momjian Exp $ + * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.315 2006/07/03 22:45:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -92,9 +92,8 @@ typedef struct Query int resultRelation; /* target relation (index into rtable) */ RangeVar *into; /* target relation for SELECT INTO */ - bool intoHasOids; /* should target relation contain OIDs? */ - List *intoOptions; /* options passed by WITH */ - OnCommitAction intoOnCommit; /* what do we do at COMMIT? */ + List *intoOptions; /* options from WITH clause */ + OnCommitAction intoOnCommit; /* what do we do at COMMIT? */ char *intoTableSpaceName; /* table space to use, or NULL */ bool hasAggs; /* has aggregates in tlist or havingQual */ @@ -708,7 +707,7 @@ typedef struct SelectStmt * lcons(NIL,NIL) for all (SELECT DISTINCT) */ RangeVar *into; /* target table (for select into table) */ List *intoColNames; /* column names for into table */ - List *intoOptions; /* options passed by WITH */ + List *intoOptions; /* options from WITH clause */ OnCommitAction intoOnCommit; /* what do we do at COMMIT? */ char *intoTableSpaceName; /* table space to use, or NULL */ List *targetList; /* the target list (of ResTarget) */ @@ -861,7 +860,8 @@ typedef enum AlterTableType AT_DropCluster, /* SET WITHOUT CLUSTER */ AT_DropOids, /* SET WITHOUT OIDS */ AT_SetTableSpace, /* SET TABLESPACE */ - AT_SetOptions, /* SET (...) -- AM specific parameters */ + AT_SetRelOptions, /* SET (...) -- AM specific parameters */ + AT_ResetRelOptions, /* RESET (...) -- AM specific parameters */ AT_EnableTrig, /* ENABLE TRIGGER name */ AT_DisableTrig, /* DISABLE TRIGGER name */ AT_EnableTrigAll, /* ENABLE TRIGGER ALL */ @@ -1017,7 +1017,7 @@ typedef struct CreateStmt List *inhRelations; /* relations to inherit from (list of * inhRelation) */ List *constraints; /* constraints (list of Constraint nodes) */ - List *options; /* options passed by WITH */ + List *options; /* options from WITH clause */ OnCommitAction oncommit; /* what do we do at COMMIT? */ char *tablespacename; /* table space to use, or NULL */ } CreateStmt; @@ -1075,7 +1075,7 @@ typedef struct Constraint Node *raw_expr; /* expr, as untransformed parse tree */ char *cooked_expr; /* expr, as nodeToString representation */ List *keys; /* String nodes naming referenced column(s) */ - List *options; /* options passed by WITH */ + List *options; /* options from WITH clause */ char *indexspace; /* index tablespace for PKEY/UNIQUE * constraints; NULL for default */ } Constraint; @@ -1429,7 +1429,7 @@ typedef struct IndexStmt char *accessMethod; /* name of access method (eg. btree) */ char *tableSpace; /* tablespace, or NULL to use parent's */ List *indexParams; /* a list of IndexElem */ - List *options; /* options passed by WITH */ + List *options; /* options from WITH clause */ Node *whereClause; /* qualification (partial-index predicate) */ List *rangetable; /* range table for qual and/or expressions, * filled in by transformStmt() */ @@ -1886,8 +1886,7 @@ typedef struct ExecuteStmt NodeTag type; char *name; /* The name of the plan to execute */ RangeVar *into; /* Optional table to store results in */ - bool into_has_oids; /* Merge GUC info with user input */ - List *intoOptions; /* options passed by WITH */ + List *intoOptions; /* Options from WITH clause */ OnCommitAction into_on_commit; /* What do we do at COMMIT? */ char *into_tbl_space; /* Tablespace to use, or NULL */ List *params; /* Values to assign to parameters */ diff --git a/src/include/parser/parse_clause.h b/src/include/parser/parse_clause.h index dc04bcb0bb8..c328a1bd5aa 100644 --- a/src/include/parser/parse_clause.h +++ b/src/include/parser/parse_clause.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/parser/parse_clause.h,v 1.45 2006/07/02 02:23:23 momjian Exp $ + * $PostgreSQL: pgsql/src/include/parser/parse_clause.h,v 1.46 2006/07/03 22:45:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -15,17 +15,12 @@ #define PARSE_CLAUSE_H #include "parser/parse_node.h" -#include "utils/array.h" extern void transformFromClause(ParseState *pstate, List *frmList); extern int setTargetTable(ParseState *pstate, RangeVar *relation, bool inh, bool alsoSource, AclMode requiredPerms); extern bool interpretInhOption(InhOption inhOpt); -extern bool interpretOidsOption(List *options); - -extern ArrayType *OptionBuild(ArrayType *array, List *list); -extern void OptionParse(ArrayType *options, Size num, DefElem kwds[], - bool strict); +extern bool interpretOidsOption(List *defList); extern Node *transformWhereClause(ParseState *pstate, Node *clause, const char *constructName); diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 9d2e4a8bee8..7bb1b270a49 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.90 2006/07/02 02:23:23 momjian Exp $ + * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.91 2006/07/03 22:45:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -115,7 +115,7 @@ typedef struct RelationAmInfo FmgrInfo ambulkdelete; FmgrInfo amvacuumcleanup; FmgrInfo amcostestimate; - FmgrInfo amoption; + FmgrInfo amoptions; } RelationAmInfo; @@ -143,14 +143,8 @@ typedef struct RelationData * survived into; or zero if the rel was not created in the current top * transaction. This should be relied on only for optimization purposes; * it is possible for new-ness to be "forgotten" (eg, after CLUSTER). - * - * rd_options and rd_amcache are alike, but different in terms of - * lifetime. Invalidation of rd_options is at the change of pg_class - * and of rd_amcache is at the change of AM's metapages. Also, rd_options - * is serialized in the relcache init file, but rd_amcache is not. */ Form_pg_class rd_rel; /* RELATION tuple */ - bytea *rd_options; /* parsed rd_rel->reloptions */ TupleDesc rd_att; /* tuple descriptor */ Oid rd_id; /* relation's object id */ List *rd_indexlist; /* list of OIDs of indexes on relation */ @@ -160,6 +154,13 @@ typedef struct RelationData MemoryContext rd_rulescxt; /* private memory cxt for rd_rules, if any */ TriggerDesc *trigdesc; /* Trigger info, or NULL if rel has none */ + /* + * rd_options is set whenever rd_rel is loaded into the relcache entry. + * Note that you can NOT look into rd_rel for this data. NULL means + * "use defaults". + */ + bytea *rd_options; /* parsed pg_class.reloptions */ + /* These are non-NULL only for an index relation: */ Form_pg_index rd_index; /* pg_index tuple describing this index */ struct HeapTupleData *rd_indextuple; /* all of pg_index tuple */ @@ -208,6 +209,45 @@ typedef Relation *RelationPtr; /* + * StdRdOptions + * Standard contents of rd_options for heaps and generic indexes. + * + * RelationGetFillFactor() and RelationGetTargetPageFreeSpace() can only + * be applied to relations that use this format or a superset for + * private options data. + */ +typedef struct StdRdOptions +{ + int32 vl_len; /* required to be a bytea */ + int fillfactor; /* page fill factor in percent (0..100) */ +} StdRdOptions; + +#define HEAP_MIN_FILLFACTOR 10 +#define HEAP_DEFAULT_FILLFACTOR 100 + +/* + * RelationGetFillFactor + * Returns the relation's fillfactor. Note multiple eval of argument! + */ +#define RelationGetFillFactor(relation, defaultff) \ + ((relation)->rd_options ? \ + ((StdRdOptions *) (relation)->rd_options)->fillfactor : (defaultff)) + +/* + * RelationGetTargetPageUsage + * Returns the relation's desired space usage per page in bytes. + */ +#define RelationGetTargetPageUsage(relation, defaultff) \ + (BLCKSZ * RelationGetFillFactor(relation, defaultff) / 100) + +/* + * RelationGetTargetPageFreeSpace + * Returns the relation's desired freespace per page in bytes. + */ +#define RelationGetTargetPageFreeSpace(relation, defaultff) \ + (BLCKSZ * (100 - RelationGetFillFactor(relation, defaultff)) / 100) + +/* * RelationIsValid * True iff relation descriptor is valid. */ |