diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/access/tuptoaster.h | 12 | ||||
-rw-r--r-- | src/include/catalog/catversion.h | 4 | ||||
-rw-r--r-- | src/include/catalog/heap.h | 5 | ||||
-rw-r--r-- | src/include/catalog/index.h | 4 | ||||
-rw-r--r-- | src/include/catalog/indexing.h | 4 | ||||
-rw-r--r-- | src/include/catalog/pg_attribute.h | 254 | ||||
-rw-r--r-- | src/include/catalog/pg_class.h | 4 | ||||
-rw-r--r-- | src/include/catalog/pg_statistic.h | 177 | ||||
-rw-r--r-- | src/include/commands/command.h | 12 | ||||
-rw-r--r-- | src/include/commands/vacuum.h | 120 | ||||
-rw-r--r-- | src/include/config.h.in | 7 | ||||
-rw-r--r-- | src/include/nodes/execnodes.h | 4 | ||||
-rw-r--r-- | src/include/nodes/parsenodes.h | 21 | ||||
-rw-r--r-- | src/include/nodes/primnodes.h | 8 | ||||
-rw-r--r-- | src/include/nodes/relation.h | 6 | ||||
-rw-r--r-- | src/include/optimizer/cost.h | 5 | ||||
-rw-r--r-- | src/include/optimizer/pathnode.h | 4 | ||||
-rw-r--r-- | src/include/utils/lsyscache.h | 12 | ||||
-rw-r--r-- | src/include/utils/syscache.h | 4 | ||||
-rw-r--r-- | src/include/utils/tuplesort.h | 22 |
20 files changed, 367 insertions, 322 deletions
diff --git a/src/include/access/tuptoaster.h b/src/include/access/tuptoaster.h index 759ab3d39e2..6e38529204d 100644 --- a/src/include/access/tuptoaster.h +++ b/src/include/access/tuptoaster.h @@ -6,15 +6,13 @@ * * Copyright (c) 2000, PostgreSQL Development Team * - * $Id: tuptoaster.h,v 1.10 2001/03/22 04:00:32 momjian Exp $ + * $Id: tuptoaster.h,v 1.11 2001/05/07 00:43:24 tgl Exp $ * *------------------------------------------------------------------------- */ #ifndef TUPTOASTER_H #define TUPTOASTER_H -#ifdef TUPLE_TOASTER_ACTIVE - #include "access/heapam.h" #include "access/htup.h" #include "access/tupmacs.h" @@ -109,7 +107,13 @@ extern varattrib *heap_tuple_untoast_attr(varattrib *attr); */ extern Datum toast_compress_datum(Datum value); -#endif /* TUPLE_TOASTER_ACTIVE */ +/* ---------- + * toast_raw_datum_size - + * + * Return the raw (detoasted) size of a varlena datum + * ---------- + */ +extern Size toast_raw_datum_size(Datum value); #endif /* TUPTOASTER_H */ diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 963b11c1d38..832f91fb09f 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: catversion.h,v 1.70 2001/03/22 04:00:35 momjian Exp $ + * $Id: catversion.h,v 1.71 2001/05/07 00:43:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200101061 +#define CATALOG_VERSION_NO 200105051 #endif diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h index a7248f6c6dc..7ab04b05fb2 100644 --- a/src/include/catalog/heap.h +++ b/src/include/catalog/heap.h @@ -7,13 +7,14 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: heap.h,v 1.34 2001/03/22 04:00:35 momjian Exp $ + * $Id: heap.h,v 1.35 2001/05/07 00:43:24 tgl Exp $ * *------------------------------------------------------------------------- */ #ifndef HEAP_H #define HEAP_H +#include "catalog/pg_attribute.h" #include "utils/rel.h" typedef struct RawColumnDefault @@ -44,4 +45,6 @@ extern void AddRelationRawConstraints(Relation rel, List *rawColDefaults, List *rawConstraints); +extern Form_pg_attribute SystemAttributeDefinition(AttrNumber attno); + #endif /* HEAP_H */ diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h index 1dac0bb1c31..07aaad61c79 100644 --- a/src/include/catalog/index.h +++ b/src/include/catalog/index.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: index.h,v 1.33 2001/03/22 04:00:35 momjian Exp $ + * $Id: index.h,v 1.34 2001/05/07 00:43:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,7 @@ extern void FormIndexDatum(IndexInfo *indexInfo, Datum *datum, char *nullv); -extern void UpdateStats(Oid relid, long reltuples); +extern void UpdateStats(Oid relid, double reltuples); extern bool IndexesAreActive(Oid relid, bool comfirmCommitted); extern void setRelhasindex(Oid relid, bool hasindex); diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h index 41a580a3777..cc155cf1bbb 100644 --- a/src/include/catalog/indexing.h +++ b/src/include/catalog/indexing.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: indexing.h,v 1.48 2001/03/22 04:00:36 momjian Exp $ + * $Id: indexing.h,v 1.49 2001/05/07 00:43:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -171,7 +171,7 @@ DECLARE_UNIQUE_INDEX(pg_rewrite_rulename_index on pg_rewrite using btree(rulenam xDECLARE_UNIQUE_INDEX(pg_shadow_name_index on pg_shadow using btree(usename name_ops)); xDECLARE_UNIQUE_INDEX(pg_shadow_sysid_index on pg_shadow using btree(usesysid int4_ops)); */ -DECLARE_INDEX(pg_statistic_relid_att_index on pg_statistic using btree(starelid oid_ops, staattnum int2_ops)); +DECLARE_UNIQUE_INDEX(pg_statistic_relid_att_index on pg_statistic using btree(starelid oid_ops, staattnum int2_ops)); DECLARE_INDEX(pg_trigger_tgconstrname_index on pg_trigger using btree(tgconstrname name_ops)); DECLARE_INDEX(pg_trigger_tgconstrrelid_index on pg_trigger using btree(tgconstrrelid oid_ops)); DECLARE_INDEX(pg_trigger_tgrelid_index on pg_trigger using btree(tgrelid oid_ops)); diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h index 58724e94dc9..6e11aa6d530 100644 --- a/src/include/catalog/pg_attribute.h +++ b/src/include/catalog/pg_attribute.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_attribute.h,v 1.70 2001/03/22 04:00:37 momjian Exp $ + * $Id: pg_attribute.h,v 1.71 2001/05/07 00:43:24 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -36,15 +36,14 @@ * typedef struct FormData_pg_attribute * * If you change the following, make sure you change the structs for - * system attributes in heap.c and index.c also. + * system attributes in catalog/heap.c also. * ---------------- */ CATALOG(pg_attribute) BOOTSTRAP { Oid attrelid; /* OID of relation containing this * attribute */ - NameData attname; - Oid atttypid; + NameData attname; /* name of attribute */ /* * atttypid is the OID of the instance in Catalog Class pg_type that @@ -53,30 +52,20 @@ CATALOG(pg_attribute) BOOTSTRAP * attalign attributes of this instance, so they had better match or * Postgres will fail. */ - - float4 attdispersion; + Oid atttypid; /* - * attdispersion is the dispersion statistic of the column (0.0 to - * 1.0), or zero if the statistic has not been calculated, or -1.0 if - * VACUUM found that the column contains no duplicate entries (in - * which case the dispersion should be taken as 1.0/numberOfRows for - * the current table size). The -1.0 hack is useful because the - * number of rows may be updated more often than attdispersion is. We - * assume that the column will retain its no-duplicate-entry property. - * (Perhaps this should be driven off the existence of a UNIQUE index - * for the column, instead of being a statistical guess?) + * attstattarget is the target number of statistics datapoints to collect + * during VACUUM ANALYZE of this column. A zero here indicates that we + * do not wish to collect any stats about this column. */ - - int2 attlen; + int4 attstattarget; /* * attlen is a copy of the typlen field from pg_type for this - * attribute. See atttypid above. See struct Form_pg_type for - * definition. + * attribute. See atttypid comments above. */ - - int2 attnum; + int2 attlen; /* * attnum is the "attribute number" for the attribute: A value that @@ -91,10 +80,13 @@ CATALOG(pg_attribute) BOOTSTRAP * * Note that (attnum - 1) is often used as the index to an array. */ + int2 attnum; - int4 attnelems; /* number of dimensions, if an array type */ - - int4 attcacheoff; + /* + * attndims is the declared number of dimensions, if an array type, + * otherwise zero. + */ + int4 attndims; /* * fastgetattr() uses attcacheoff to cache byte offsets of attributes @@ -103,8 +95,7 @@ CATALOG(pg_attribute) BOOTSTRAP * tuple descriptor, we may then update attcacheoff in the copies. * This speeds up the attribute walking process. */ - - int4 atttypmod; + int4 attcacheoff; /* * atttypmod records type-specific data supplied at table creation @@ -113,16 +104,13 @@ CATALOG(pg_attribute) BOOTSTRAP * argument. The value will generally be -1 for types that do not need * typmod. */ - - bool attbyval; + int4 atttypmod; /* * attbyval is a copy of the typbyval field from pg_type for this - * attribute. See atttypid above. See struct Form_pg_type for - * definition. + * attribute. See atttypid comments above. */ - - char attstorage; + bool attbyval; /*---------- * attstorage tells for VARLENA attributes, what the heap access @@ -137,30 +125,31 @@ CATALOG(pg_attribute) BOOTSTRAP * but only as a last resort ('e' and 'x' fields are moved first). *---------- */ + char attstorage; + /* This flag indicates that the attribute is really a set */ bool attisset; - char attalign; /* * attalign is a copy of the typalign field from pg_type for this - * attribute. See atttypid above. See struct Form_pg_type for - * definition. + * attribute. See atttypid comments above. */ - - bool attnotnull; + char attalign; /* This flag represents the "NOT NULL" constraint */ - bool atthasdef; + bool attnotnull; /* Has DEFAULT value or not */ + bool atthasdef; } FormData_pg_attribute; /* * someone should figure out how to do this properly. (The problem is - * the size of the C struct is not the same as the size of the tuple.) + * the size of the C struct is not the same as the size of the tuple + * because of alignment padding at the end of the struct.) */ #define ATTRIBUTE_TUPLE_SIZE \ - (offsetof(FormData_pg_attribute,atthasdef) + sizeof(char)) + (offsetof(FormData_pg_attribute,atthasdef) + sizeof(bool)) /* ---------------- * Form_pg_attribute corresponds to a pointer to a tuple with @@ -178,10 +167,10 @@ typedef FormData_pg_attribute *Form_pg_attribute; #define Anum_pg_attribute_attrelid 1 #define Anum_pg_attribute_attname 2 #define Anum_pg_attribute_atttypid 3 -#define Anum_pg_attribute_attdispersion 4 +#define Anum_pg_attribute_attstattarget 4 #define Anum_pg_attribute_attlen 5 #define Anum_pg_attribute_attnum 6 -#define Anum_pg_attribute_attnelems 7 +#define Anum_pg_attribute_attndims 7 #define Anum_pg_attribute_attcacheoff 8 #define Anum_pg_attribute_atttypmod 9 #define Anum_pg_attribute_attbyval 10 @@ -206,6 +195,7 @@ typedef FormData_pg_attribute *Form_pg_attribute; (attribute)->attnotnull = false; \ (attribute)->atthasdef = false; #endif /* _DROP_COLUMN_HACK__ */ + /* ---------------- * SCHEMA_ macros for declaring hardcoded tuple descriptors. * these are used in utils/cache/relcache.c @@ -231,25 +221,25 @@ typedef FormData_pg_attribute *Form_pg_attribute; * ---------------- */ #define Schema_pg_type \ -{ 1247, {"typname"}, 19, 0, NAMEDATALEN, 1, 0, -1, -1, '\0', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1247, {"typowner"}, 23, 0, 4, 2, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1247, {"typlen"}, 21, 0, 2, 3, 0, -1, -1, '\001', 'p', '\0', 's', '\0', '\0' }, \ -{ 1247, {"typprtlen"}, 21, 0, 2, 4, 0, -1, -1, '\001', 'p', '\0', 's', '\0', '\0' }, \ -{ 1247, {"typbyval"}, 16, 0, 1, 5, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1247, {"typtype"}, 18, 0, 1, 6, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1247, {"typisdefined"}, 16, 0, 1, 7, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1247, {"typdelim"}, 18, 0, 1, 8, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1247, {"typrelid"}, 26, 0, 4, 9, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1247, {"typelem"}, 26, 0, 4, 10, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1247, {"typinput"}, 24, 0, 4, 11, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1247, {"typoutput"}, 24, 0, 4, 12, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1247, {"typreceive"}, 24, 0, 4, 13, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1247, {"typsend"}, 24, 0, 4, 14, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1247, {"typalign"}, 18, 0, 1, 15, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1247, {"typstorage"}, 18, 0, 1, 16, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1247, {"typdefault"}, 25, 0, -1, 17, 0, -1, -1, '\0' , 'x', '\0', 'i', '\0', '\0' } - -DATA(insert OID = 0 ( 1247 typname 19 0 NAMEDATALEN 1 0 -1 -1 f p f i f f)); +{ 1247, {"typname"}, 19, DEFAULT_ATTSTATTARGET, NAMEDATALEN, 1, 0, -1, -1, false, 'p', false, 'i', false, false }, \ +{ 1247, {"typowner"}, 23, 0, 4, 2, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1247, {"typlen"}, 21, 0, 2, 3, 0, -1, -1, true, 'p', false, 's', false, false }, \ +{ 1247, {"typprtlen"}, 21, 0, 2, 4, 0, -1, -1, true, 'p', false, 's', false, false }, \ +{ 1247, {"typbyval"}, 16, 0, 1, 5, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1247, {"typtype"}, 18, 0, 1, 6, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1247, {"typisdefined"}, 16, 0, 1, 7, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1247, {"typdelim"}, 18, 0, 1, 8, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1247, {"typrelid"}, 26, 0, 4, 9, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1247, {"typelem"}, 26, 0, 4, 10, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1247, {"typinput"}, 24, 0, 4, 11, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1247, {"typoutput"}, 24, 0, 4, 12, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1247, {"typreceive"}, 24, 0, 4, 13, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1247, {"typsend"}, 24, 0, 4, 14, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1247, {"typalign"}, 18, 0, 1, 15, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1247, {"typstorage"}, 18, 0, 1, 16, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1247, {"typdefault"}, 25, 0, -1, 17, 0, -1, -1, false , 'x', false, 'i', false, false } + +DATA(insert OID = 0 ( 1247 typname 19 DEFAULT_ATTSTATTARGET NAMEDATALEN 1 0 -1 -1 f p f i f f)); DATA(insert OID = 0 ( 1247 typowner 23 0 4 2 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1247 typlen 21 0 2 3 0 -1 -1 t p f s f f)); DATA(insert OID = 0 ( 1247 typprtlen 21 0 2 4 0 -1 -1 t p f s f f)); @@ -299,25 +289,25 @@ DATA(insert OID = 0 ( 1262 tableoid 26 0 4 -7 0 -1 -1 t p f i f f)); * ---------------- */ #define Schema_pg_proc \ -{ 1255, {"proname"}, 19, 0, NAMEDATALEN, 1, 0, -1, -1, '\0', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1255, {"proowner"}, 23, 0, 4, 2, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1255, {"prolang"}, 26, 0, 4, 3, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1255, {"proisinh"}, 16, 0, 1, 4, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1255, {"proistrusted"}, 16, 0, 1, 5, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1255, {"proiscachable"}, 16, 0, 1, 6, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1255, {"proisstrict"}, 16, 0, 1, 7, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1255, {"pronargs"}, 21, 0, 2, 8, 0, -1, -1, '\001', 'p', '\0', 's', '\0', '\0' }, \ -{ 1255, {"proretset"}, 16, 0, 1, 9, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1255, {"prorettype"}, 26, 0, 4, 10, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1255, {"proargtypes"}, 30, 0, INDEX_MAX_KEYS*4, 11, 0, -1, -1, '\0', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1255, {"probyte_pct"}, 23, 0, 4, 12, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1255, {"properbyte_cpu"}, 23, 0, 4, 13, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1255, {"propercall_cpu"}, 23, 0, 4, 14, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1255, {"prooutin_ratio"}, 23, 0, 4, 15, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1255, {"prosrc"}, 25, 0, -1, 16, 0, -1, -1, '\0', 'x', '\0', 'i', '\0', '\0' }, \ -{ 1255, {"probin"}, 17, 0, -1, 17, 0, -1, -1, '\0', 'x', '\0', 'i', '\0', '\0' } - -DATA(insert OID = 0 ( 1255 proname 19 0 NAMEDATALEN 1 0 -1 -1 f p f i f f)); +{ 1255, {"proname"}, 19, DEFAULT_ATTSTATTARGET, NAMEDATALEN, 1, 0, -1, -1, false, 'p', false, 'i', false, false }, \ +{ 1255, {"proowner"}, 23, 0, 4, 2, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1255, {"prolang"}, 26, 0, 4, 3, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1255, {"proisinh"}, 16, 0, 1, 4, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1255, {"proistrusted"}, 16, 0, 1, 5, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1255, {"proiscachable"}, 16, 0, 1, 6, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1255, {"proisstrict"}, 16, 0, 1, 7, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1255, {"pronargs"}, 21, 0, 2, 8, 0, -1, -1, true, 'p', false, 's', false, false }, \ +{ 1255, {"proretset"}, 16, 0, 1, 9, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1255, {"prorettype"}, 26, 0, 4, 10, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1255, {"proargtypes"}, 30, 0, INDEX_MAX_KEYS*4, 11, 0, -1, -1, false, 'p', false, 'i', false, false }, \ +{ 1255, {"probyte_pct"}, 23, 0, 4, 12, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1255, {"properbyte_cpu"}, 23, 0, 4, 13, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1255, {"propercall_cpu"}, 23, 0, 4, 14, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1255, {"prooutin_ratio"}, 23, 0, 4, 15, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1255, {"prosrc"}, 25, 0, -1, 16, 0, -1, -1, false, 'x', false, 'i', false, false }, \ +{ 1255, {"probin"}, 17, 0, -1, 17, 0, -1, -1, false, 'x', false, 'i', false, false } + +DATA(insert OID = 0 ( 1255 proname 19 DEFAULT_ATTSTATTARGET NAMEDATALEN 1 0 -1 -1 f p f i f f)); DATA(insert OID = 0 ( 1255 proowner 23 0 4 2 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1255 prolang 26 0 4 3 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1255 proisinh 16 0 1 4 0 -1 -1 t p f c f f)); @@ -346,8 +336,8 @@ DATA(insert OID = 0 ( 1255 tableoid 26 0 4 -7 0 -1 -1 t p f i f f)); * pg_shadow * ---------------- */ -DATA(insert OID = 0 ( 1260 usename 19 0 NAMEDATALEN 1 0 -1 -1 f p f i f f)); -DATA(insert OID = 0 ( 1260 usesysid 23 0 4 2 0 -1 -1 t p f i f f)); +DATA(insert OID = 0 ( 1260 usename 19 DEFAULT_ATTSTATTARGET NAMEDATALEN 1 0 -1 -1 f p f i f f)); +DATA(insert OID = 0 ( 1260 usesysid 23 DEFAULT_ATTSTATTARGET 4 2 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1260 usecreatedb 16 0 1 3 0 -1 -1 t p f c f f)); DATA(insert OID = 0 ( 1260 usetrace 16 0 1 4 0 -1 -1 t p f c f f)); DATA(insert OID = 0 ( 1260 usesuper 16 0 1 5 0 -1 -1 t p f c f f)); @@ -366,8 +356,8 @@ DATA(insert OID = 0 ( 1260 tableoid 26 0 4 -7 0 -1 -1 t p f i f f)); * pg_group * ---------------- */ -DATA(insert OID = 0 ( 1261 groname 19 0 NAMEDATALEN 1 0 -1 -1 f p f i f f)); -DATA(insert OID = 0 ( 1261 grosysid 23 0 4 2 0 -1 -1 t p f i f f)); +DATA(insert OID = 0 ( 1261 groname 19 DEFAULT_ATTSTATTARGET NAMEDATALEN 1 0 -1 -1 f p f i f f)); +DATA(insert OID = 0 ( 1261 grosysid 23 DEFAULT_ATTSTATTARGET 4 2 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1261 grolist 1007 0 -1 3 0 -1 -1 f x f i f f)); DATA(insert OID = 0 ( 1261 ctid 27 0 6 -1 0 -1 -1 f p f i f f)); DATA(insert OID = 0 ( 1261 oid 26 0 4 -2 0 -1 -1 t p f i f f)); @@ -382,29 +372,29 @@ DATA(insert OID = 0 ( 1261 tableoid 26 0 4 -7 0 -1 -1 t p f i f f)); * ---------------- */ #define Schema_pg_attribute \ -{ 1249, {"attrelid"}, 26, 0, 4, 1, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1249, {"attname"}, 19, 0, NAMEDATALEN, 2, 0, -1, -1, '\0', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1249, {"atttypid"}, 26, 0, 4, 3, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1249, {"attdispersion"}, 700, 0, 4, 4, 0, -1, -1, '\0', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1249, {"attlen"}, 21, 0, 2, 5, 0, -1, -1, '\001', 'p', '\0', 's', '\0', '\0' }, \ -{ 1249, {"attnum"}, 21, 0, 2, 6, 0, -1, -1, '\001', 'p', '\0', 's', '\0', '\0' }, \ -{ 1249, {"attnelems"}, 23, 0, 4, 7, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1249, {"attcacheoff"}, 23, 0, 4, 8, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1249, {"atttypmod"}, 23, 0, 4, 9, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1249, {"attbyval"}, 16, 0, 1, 10, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1249, {"attstorage"}, 18, 0, 1, 11, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1249, {"attisset"}, 16, 0, 1, 12, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1249, {"attalign"}, 18, 0, 1, 13, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1249, {"attnotnull"}, 16, 0, 1, 14, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1249, {"atthasdef"}, 16, 0, 1, 15, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' } - -DATA(insert OID = 0 ( 1249 attrelid 26 0 4 1 0 -1 -1 t p f i f f)); -DATA(insert OID = 0 ( 1249 attname 19 0 NAMEDATALEN 2 0 -1 -1 f p f i f f)); +{ 1249, {"attrelid"}, 26, DEFAULT_ATTSTATTARGET, 4, 1, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1249, {"attname"}, 19, DEFAULT_ATTSTATTARGET, NAMEDATALEN, 2, 0, -1, -1, false, 'p', false, 'i', false, false }, \ +{ 1249, {"atttypid"}, 26, 0, 4, 3, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1249, {"attstattarget"}, 23, 0, 4, 4, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1249, {"attlen"}, 21, 0, 2, 5, 0, -1, -1, true, 'p', false, 's', false, false }, \ +{ 1249, {"attnum"}, 21, 0, 2, 6, 0, -1, -1, true, 'p', false, 's', false, false }, \ +{ 1249, {"attndims"}, 23, 0, 4, 7, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1249, {"attcacheoff"}, 23, 0, 4, 8, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1249, {"atttypmod"}, 23, 0, 4, 9, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1249, {"attbyval"}, 16, 0, 1, 10, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1249, {"attstorage"}, 18, 0, 1, 11, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1249, {"attisset"}, 16, 0, 1, 12, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1249, {"attalign"}, 18, 0, 1, 13, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1249, {"attnotnull"}, 16, 0, 1, 14, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1249, {"atthasdef"}, 16, 0, 1, 15, 0, -1, -1, true, 'p', false, 'c', false, false } + +DATA(insert OID = 0 ( 1249 attrelid 26 DEFAULT_ATTSTATTARGET 4 1 0 -1 -1 t p f i f f)); +DATA(insert OID = 0 ( 1249 attname 19 DEFAULT_ATTSTATTARGET NAMEDATALEN 2 0 -1 -1 f p f i f f)); DATA(insert OID = 0 ( 1249 atttypid 26 0 4 3 0 -1 -1 t p f i f f)); -DATA(insert OID = 0 ( 1249 attdispersion 700 0 4 4 0 -1 -1 f p f i f f)); +DATA(insert OID = 0 ( 1249 attstattarget 23 0 4 4 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1249 attlen 21 0 2 5 0 -1 -1 t p f s f f)); DATA(insert OID = 0 ( 1249 attnum 21 0 2 6 0 -1 -1 t p f s f f)); -DATA(insert OID = 0 ( 1249 attnelems 23 0 4 7 0 -1 -1 t p f i f f)); +DATA(insert OID = 0 ( 1249 attndims 23 0 4 7 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1249 attcacheoff 23 0 4 8 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1249 atttypmod 23 0 4 9 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1249 attbyval 16 0 1 10 0 -1 -1 t p f c f f)); @@ -426,36 +416,36 @@ DATA(insert OID = 0 ( 1249 tableoid 26 0 4 -7 0 -1 -1 t p f i f f)); * ---------------- */ #define Schema_pg_class \ -{ 1259, {"relname"}, 19, 0, NAMEDATALEN, 1, 0, -1, -1, '\0', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1259, {"reltype"}, 26, 0, 4, 2, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1259, {"relowner"}, 23, 0, 4, 3, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1259, {"relam"}, 26, 0, 4, 4, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1259, {"relfilenode"}, 26, 0, 4, 5, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1259, {"relpages"}, 23, 0, 4, 6, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1259, {"reltuples"}, 23, 0, 4, 7, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1259, {"reltoastrelid"}, 26, 0, 4, 8, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1259, {"reltoastidxid"}, 26, 0, 4, 9, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' }, \ -{ 1259, {"relhasindex"}, 16, 0, 1, 10, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1259, {"relisshared"}, 16, 0, 1, 11, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1259, {"relkind"}, 18, 0, 1, 12, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1259, {"relnatts"}, 21, 0, 2, 13, 0, -1, -1, '\001', 'p', '\0', 's', '\0', '\0' }, \ -{ 1259, {"relchecks"}, 21, 0, 2, 14, 0, -1, -1, '\001', 'p', '\0', 's', '\0', '\0' }, \ -{ 1259, {"reltriggers"}, 21, 0, 2, 15, 0, -1, -1, '\001', 'p', '\0', 's', '\0', '\0' }, \ -{ 1259, {"relukeys"}, 21, 0, 2, 16, 0, -1, -1, '\001', 'p', '\0', 's', '\0', '\0' }, \ -{ 1259, {"relfkeys"}, 21, 0, 2, 17, 0, -1, -1, '\001', 'p', '\0', 's', '\0', '\0' }, \ -{ 1259, {"relrefs"}, 21, 0, 2, 18, 0, -1, -1, '\001', 'p', '\0', 's', '\0', '\0' }, \ -{ 1259, {"relhaspkey"}, 16, 0, 1, 19, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1259, {"relhasrules"}, 16, 0, 1, 20, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1259, {"relhassubclass"},16, 0, 1, 21, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ -{ 1259, {"relacl"}, 1034, 0, -1, 22, 0, -1, -1, '\0', 'x', '\0', 'i', '\0', '\0' } - -DATA(insert OID = 0 ( 1259 relname 19 0 NAMEDATALEN 1 0 -1 -1 f p f i f f)); +{ 1259, {"relname"}, 19, DEFAULT_ATTSTATTARGET, NAMEDATALEN, 1, 0, -1, -1, false, 'p', false, 'i', false, false }, \ +{ 1259, {"reltype"}, 26, 0, 4, 2, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1259, {"relowner"}, 23, 0, 4, 3, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1259, {"relam"}, 26, 0, 4, 4, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1259, {"relfilenode"}, 26, 0, 4, 5, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1259, {"relpages"}, 23, 0, 4, 6, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1259, {"reltuples"}, 700, 0, 4, 7, 0, -1, -1, false, 'p', false, 'i', false, false }, \ +{ 1259, {"reltoastrelid"}, 26, 0, 4, 8, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1259, {"reltoastidxid"}, 26, 0, 4, 9, 0, -1, -1, true, 'p', false, 'i', false, false }, \ +{ 1259, {"relhasindex"}, 16, 0, 1, 10, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1259, {"relisshared"}, 16, 0, 1, 11, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1259, {"relkind"}, 18, 0, 1, 12, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1259, {"relnatts"}, 21, 0, 2, 13, 0, -1, -1, true, 'p', false, 's', false, false }, \ +{ 1259, {"relchecks"}, 21, 0, 2, 14, 0, -1, -1, true, 'p', false, 's', false, false }, \ +{ 1259, {"reltriggers"}, 21, 0, 2, 15, 0, -1, -1, true, 'p', false, 's', false, false }, \ +{ 1259, {"relukeys"}, 21, 0, 2, 16, 0, -1, -1, true, 'p', false, 's', false, false }, \ +{ 1259, {"relfkeys"}, 21, 0, 2, 17, 0, -1, -1, true, 'p', false, 's', false, false }, \ +{ 1259, {"relrefs"}, 21, 0, 2, 18, 0, -1, -1, true, 'p', false, 's', false, false }, \ +{ 1259, {"relhaspkey"}, 16, 0, 1, 19, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1259, {"relhasrules"}, 16, 0, 1, 20, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1259, {"relhassubclass"},16, 0, 1, 21, 0, -1, -1, true, 'p', false, 'c', false, false }, \ +{ 1259, {"relacl"}, 1034, 0, -1, 22, 0, -1, -1, false, 'x', false, 'i', false, false } + +DATA(insert OID = 0 ( 1259 relname 19 DEFAULT_ATTSTATTARGET NAMEDATALEN 1 0 -1 -1 f p f i f f)); DATA(insert OID = 0 ( 1259 reltype 26 0 4 2 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1259 relowner 23 0 4 3 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1259 relam 26 0 4 4 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1259 relfilenode 26 0 4 5 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1259 relpages 23 0 4 6 0 -1 -1 t p f i f f)); -DATA(insert OID = 0 ( 1259 reltuples 23 0 4 7 0 -1 -1 t p f i f f)); +DATA(insert OID = 0 ( 1259 reltuples 700 0 4 7 0 -1 -1 f p f i f f)); DATA(insert OID = 0 ( 1259 reltoastrelid 26 0 4 8 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1259 reltoastidxid 26 0 4 9 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1259 relhasindex 16 0 1 10 0 -1 -1 t p f c f f)); @@ -544,7 +534,7 @@ DATA(insert OID = 0 ( 1219 tableoid 26 0 4 -7 0 -1 -1 t p f i f f)); * ---------------- */ #define Schema_pg_variable \ -{ 1264, {"varfoo"}, 26, 0, 4, 1, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' } +{ 1264, {"varfoo"}, 26, 0, 4, 1, 0, -1, -1, true, 'p', false, 'i', false, false } DATA(insert OID = 0 ( 1264 varfoo 26 0 4 1 0 -1 -1 t p f i f f)); @@ -555,7 +545,7 @@ DATA(insert OID = 0 ( 1264 varfoo 26 0 4 1 0 -1 -1 t p f i f f)); * ---------------- */ #define Schema_pg_log \ -{ 1269, {"logfoo"}, 26, 0, 4, 1, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' } +{ 1269, {"logfoo"}, 26, 0, 4, 1, 0, -1, -1, true, 'p', false, 'i', false, false } DATA(insert OID = 0 ( 1269 logfoo 26 0 4 1 0 -1 -1 t p f i f f)); @@ -566,7 +556,7 @@ DATA(insert OID = 0 ( 1269 logfoo 26 0 4 1 0 -1 -1 t p f i f f)); * ---------------- */ #define Schema_pg_xactlock \ -{ 376, {"xactlockfoo"}, 26, 0, 4, 1, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0' } +{ 376, {"xactlockfoo"}, 26, 0, 4, 1, 0, -1, -1, true, 'p', false, 'i', false, false } DATA(insert OID = 0 ( 376 xactlockfoo 26 0 4 1 0 -1 -1 t p f i f f)); diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h index 81e75e14b6a..86de88cc9b6 100644 --- a/src/include/catalog/pg_class.h +++ b/src/include/catalog/pg_class.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_class.h,v 1.47 2001/03/22 04:00:38 momjian Exp $ + * $Id: pg_class.h,v 1.48 2001/05/07 00:43:25 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -52,7 +52,7 @@ CATALOG(pg_class) BOOTSTRAP Oid relam; Oid relfilenode; int4 relpages; - int4 reltuples; + float4 reltuples; Oid reltoastrelid; Oid reltoastidxid; bool relhasindex; diff --git a/src/include/catalog/pg_statistic.h b/src/include/catalog/pg_statistic.h index 2f39bea3245..8d6a6b37c16 100644 --- a/src/include/catalog/pg_statistic.h +++ b/src/include/catalog/pg_statistic.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_statistic.h,v 1.10 2001/01/24 19:43:22 momjian Exp $ + * $Id: pg_statistic.h,v 1.11 2001/05/07 00:43:25 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -36,40 +36,91 @@ CATALOG(pg_statistic) /* These fields form the unique key for the entry: */ Oid starelid; /* relation containing attribute */ int2 staattnum; /* attribute (column) stats are for */ - Oid staop; /* '<' comparison op used for lo/hi vals */ + + /* the fraction of the column's entries that are NULL: */ + float4 stanullfrac; /* - * Note: the current VACUUM code will never produce more than one - * entry per column, but in theory there could be multiple entries if - * a datatype has more than one useful ordering operator. Also, the - * current code will not write an entry unless it found at least one - * non-NULL value in the column; so the remaining fields will never be - * NULL. + * stawidth is the average width in bytes of non-null entries. For + * fixed-width datatypes this is of course the same as the typlen, but + * for varlena types it is more useful. Note that this is the average + * width of the data as actually stored, post-TOASTing (eg, for a + * moved-out-of-line value, only the size of the pointer object is + * counted). This is the appropriate definition for the primary use of + * the statistic, which is to estimate sizes of in-memory hash tables of + * tuples. + */ + int4 stawidth; + + /* ---------------- + * stadistinct indicates the (approximate) number of distinct non-null + * data values in the column. The interpretation is: + * 0 unknown or not computed + * > 0 actual number of distinct values + * < 0 negative of multiplier for number of rows + * The special negative case allows us to cope with columns that are + * unique (stadistinct = -1) or nearly so (for example, a column in + * which values appear about twice on the average could be represented + * by stadistinct = -0.5). Because the number-of-rows statistic in + * pg_class may be updated more frequently than pg_statistic is, it's + * important to be able to describe such situations as a multiple of + * the number of rows, rather than a fixed number of distinct values. + * But in other cases a fixed number is correct (eg, a boolean column). + * ---------------- + */ + float4 stadistinct; + + /* ---------------- + * To allow keeping statistics on different kinds of datatypes, + * we do not hard-wire any particular meaning for the remaining + * statistical fields. Instead, we provide several "slots" in which + * statistical data can be placed. Each slot includes: + * kind integer code identifying kind of data + * op OID of associated operator, if needed + * numbers float4 array (for statistical values) + * values text array (for representations of data values) + * The ID and operator fields are never NULL; they are zeroes in an + * unused slot. The numbers and values fields are NULL in an unused + * slot, and might also be NULL in a used slot if the slot kind has + * no need for one or the other. + * ---------------- */ + int2 stakind1; + int2 stakind2; + int2 stakind3; + int2 stakind4; + + Oid staop1; + Oid staop2; + Oid staop3; + Oid staop4; + /* - * These fields contain the stats about the column indicated by the - * key + * THE REST OF THESE ARE VARIABLE LENGTH FIELDS, and may even be absent + * (NULL). They cannot be accessed as C struct entries; you have to use + * the full field access machinery (heap_getattr) for them. We declare + * them here for the catalog machinery. */ - float4 stanullfrac; /* the fraction of the entries that are - * NULL */ - float4 stacommonfrac; /* the fraction that are the most common - * val */ + + float4 stanumbers1[1]; + float4 stanumbers2[1]; + float4 stanumbers3[1]; + float4 stanumbers4[1]; /* - * THE REST OF THESE ARE VARIABLE LENGTH FIELDS. They cannot be - * accessed as C struct entries; you have to use the full field access - * machinery (heap_getattr) for them. - * - * All three of these are text representations of data values of the - * column's data type. To re-create the actual Datum, do - * datatypein(textout(givenvalue)). + * Values in these text arrays are external representations of values + * of the column's data type. To re-create the actual Datum, do + * datatypein(textout(arrayelement)). */ - text stacommonval; /* most common non-null value in column */ - text staloval; /* smallest non-null value in column */ - text stahival; /* largest non-null value in column */ + text stavalues1[1]; + text stavalues2[1]; + text stavalues3[1]; + text stavalues4[1]; } FormData_pg_statistic; +#define STATISTIC_NUM_SLOTS 4 + /* ---------------- * Form_pg_statistic corresponds to a pointer to a tuple with * the format of pg_statistic relation. @@ -81,14 +132,78 @@ typedef FormData_pg_statistic *Form_pg_statistic; * compiler constants for pg_statistic * ---------------- */ -#define Natts_pg_statistic 8 +#define Natts_pg_statistic 21 #define Anum_pg_statistic_starelid 1 #define Anum_pg_statistic_staattnum 2 -#define Anum_pg_statistic_staop 3 -#define Anum_pg_statistic_stanullfrac 4 -#define Anum_pg_statistic_stacommonfrac 5 -#define Anum_pg_statistic_stacommonval 6 -#define Anum_pg_statistic_staloval 7 -#define Anum_pg_statistic_stahival 8 +#define Anum_pg_statistic_stanullfrac 3 +#define Anum_pg_statistic_stawidth 4 +#define Anum_pg_statistic_stadistinct 5 +#define Anum_pg_statistic_stakind1 6 +#define Anum_pg_statistic_stakind2 7 +#define Anum_pg_statistic_stakind3 8 +#define Anum_pg_statistic_stakind4 9 +#define Anum_pg_statistic_staop1 10 +#define Anum_pg_statistic_staop2 11 +#define Anum_pg_statistic_staop3 12 +#define Anum_pg_statistic_staop4 13 +#define Anum_pg_statistic_stanumbers1 14 +#define Anum_pg_statistic_stanumbers2 15 +#define Anum_pg_statistic_stanumbers3 16 +#define Anum_pg_statistic_stanumbers4 17 +#define Anum_pg_statistic_stavalues1 18 +#define Anum_pg_statistic_stavalues2 19 +#define Anum_pg_statistic_stavalues3 20 +#define Anum_pg_statistic_stavalues4 21 + +/* + * Currently, three statistical slot "kinds" are defined: most common values, + * histogram, and correlation. Additional "kinds" will probably appear in + * future to help cope with non-scalar datatypes. + * + * Code reading the pg_statistic relation should not assume that a particular + * data "kind" will appear in any particular slot. Instead, search the + * stakind fields to see if the desired data is available. + */ + +/* + * In a "most common values" slot, staop is the OID of the "=" operator + * used to decide whether values are the same or not. stavalues contains + * the K most common non-null values appearing in the column, and stanumbers + * contains their frequencies (fractions of total row count). The values + * shall be ordered in decreasing frequency. Note that since the arrays are + * variable-size, K may be chosen by the statistics collector. Values should + * not appear in MCV unless they have been observed to occur more than once; + * a unique column will have no MCV slot. + */ +#define STATISTIC_KIND_MCV 1 + +/* + * A "histogram" slot describes the distribution of scalar data. staop is + * the OID of the "<" operator that describes the sort ordering. (In theory, + * more than one histogram could appear, if a datatype has more than one + * useful sort operator.) stavalues contains M (>=2) non-null values that + * divide the non-null column data values into M-1 bins of approximately equal + * population. The first stavalues item is the MIN and the last is the MAX. + * stanumbers is not used and should be NULL. IMPORTANT POINT: if an MCV + * slot is also provided, then the histogram describes the data distribution + * *after removing the values listed in MCV* (thus, it's a "compressed + * histogram" in the technical parlance). This allows a more accurate + * representation of the distribution of a column with some very-common + * values. In a column with only a few distinct values, it's possible that + * the MCV list describes the entire data population; in this case the + * histogram reduces to empty and should be omitted. + */ +#define STATISTIC_KIND_HISTOGRAM 2 + +/* + * A "correlation" slot describes the correlation between the physical order + * of table tuples and the ordering of data values of this column, as seen + * by the "<" operator identified by staop. (As with the histogram, more + * than one entry could theoretically appear.) stavalues is not used and + * should be NULL. stanumbers contains a single entry, the correlation + * coefficient between the sequence of data values and the sequence of + * their actual tuple positions. The coefficient ranges from +1 to -1. + */ +#define STATISTIC_KIND_CORRELATION 3 #endif /* PG_STATISTIC_H */ diff --git a/src/include/commands/command.h b/src/include/commands/command.h index 8b108451d2a..7eb1a4fab84 100644 --- a/src/include/commands/command.h +++ b/src/include/commands/command.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: command.h,v 1.26 2001/03/22 04:00:41 momjian Exp $ + * $Id: command.h,v 1.27 2001/05/07 00:43:25 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -43,9 +43,13 @@ extern void PortalCleanup(Portal portal); extern void AlterTableAddColumn(const char *relationName, bool inh, ColumnDef *colDef); -extern void AlterTableAlterColumn(const char *relationName, - bool inh, const char *colName, - Node *newDefault); +extern void AlterTableAlterColumnDefault(const char *relationName, + bool inh, const char *colName, + Node *newDefault); + +extern void AlterTableAlterColumnStatistics(const char *relationName, + bool inh, const char *colName, + Node *statsTarget); extern void AlterTableDropColumn(const char *relationName, bool inh, const char *colName, diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h index d82d22fcdfc..87bb0007aa0 100644 --- a/src/include/commands/vacuum.h +++ b/src/include/commands/vacuum.h @@ -1,129 +1,27 @@ /*------------------------------------------------------------------------- * * vacuum.h - * header file for postgres vacuum cleaner + * header file for postgres vacuum cleaner and statistics analyzer * * * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: vacuum.h,v 1.34 2001/03/22 04:00:43 momjian Exp $ + * $Id: vacuum.h,v 1.35 2001/05/07 00:43:25 tgl Exp $ * *------------------------------------------------------------------------- */ #ifndef VACUUM_H #define VACUUM_H -#include "catalog/pg_attribute.h" -#include "catalog/pg_index.h" -#include "fmgr.h" -#include "nodes/pg_list.h" -#include "storage/itemptr.h" +#include "nodes/parsenodes.h" -typedef struct VAttListData -{ - int val_dummy; - struct VAttListData *val_next; -} VAttListData; - -typedef VAttListData *VAttList; - -typedef struct VacPageData -{ - BlockNumber blkno; /* BlockNumber of this Page */ - Size free; /* FreeSpace on this Page */ - uint16 offsets_used; /* Number of OffNums used by vacuum */ - uint16 offsets_free; /* Number of OffNums free or to be free */ - OffsetNumber offsets[1]; /* Array of its OffNums */ -} VacPageData; - -typedef VacPageData *VacPage; - -typedef struct VacPageListData -{ - int empty_end_pages;/* Number of "empty" end-pages */ - int num_pages; /* Number of pages in pagedesc */ - int num_allocated_pages; /* Number of allocated pages in - * pagedesc */ - VacPage *pagedesc; /* Descriptions of pages */ -} VacPageListData; - -typedef VacPageListData *VacPageList; - -typedef struct -{ - Form_pg_attribute attr; - Datum best, - guess1, - guess2, - max, - min; - int best_len, - guess1_len, - guess2_len, - max_len, - min_len; - long best_cnt, - guess1_cnt, - guess1_hits, - guess2_hits, - null_cnt, - nonnull_cnt, - max_cnt, - min_cnt; - FmgrInfo f_cmpeq, - f_cmplt, - f_cmpgt; - Oid op_cmplt; - regproc outfunc; - Oid typelem; - bool initialized; -} VacAttrStats; - -typedef struct VRelListData -{ - Oid vrl_relid; - struct VRelListData *vrl_next; -} VRelListData; - -typedef VRelListData *VRelList; - -typedef struct VTupleLinkData -{ - ItemPointerData new_tid; - ItemPointerData this_tid; -} VTupleLinkData; - -typedef VTupleLinkData *VTupleLink; - -typedef struct VTupleMoveData -{ - ItemPointerData tid; /* tuple ID */ - VacPage vacpage; /* where to move */ - bool cleanVpd; /* clean vacpage before using */ -} VTupleMoveData; - -typedef VTupleMoveData *VTupleMove; - -typedef struct VRelStats -{ - Oid relid; - int num_tuples; - int num_pages; - Size min_tlen; - Size max_tlen; - bool hasindex; - int num_vtlinks; - VTupleLink vtlinks; -} VRelStats; - -extern bool VacuumRunning; - -extern void vc_abort(void); -extern void vacuum(char *vacrel, bool verbose, bool analyze, List *anal_cols); -extern void analyze_rel(Oid relid, List *anal_cols2, int MESSAGE_LEVEL); - -#define ATTNVALS_SCALE 1000000000 /* XXX so it can act as a float4 */ +/* in commands/vacuum.c */ +extern void vacuum(VacuumStmt *vacstmt); +extern void vac_update_relstats(Oid relid, long num_pages, double num_tuples, + bool hasindex); +/* in commands/analyze.c */ +extern void analyze_rel(Oid relid, VacuumStmt *vacstmt); #endif /* VACUUM_H */ diff --git a/src/include/config.h.in b/src/include/config.h.in index 0d989dbbb31..01593a4ce96 100644 --- a/src/include/config.h.in +++ b/src/include/config.h.in @@ -8,7 +8,7 @@ * or in config.h afterwards. Of course, if you edit config.h, then your * changes will be overwritten the next time you run configure. * - * $Id: config.h.in,v 1.162 2001/04/14 22:55:02 petere Exp $ + * $Id: config.h.in,v 1.163 2001/05/07 00:43:25 tgl Exp $ */ #ifndef CONFIG_H @@ -157,6 +157,11 @@ #define FUNC_MAX_ARGS INDEX_MAX_KEYS /* + * System default value for pg_attribute.attstattarget + */ +#define DEFAULT_ATTSTATTARGET 10 + +/* * Define this to make libpgtcl's "pg_result -assign" command process C-style * backslash sequences in returned tuple data and convert Postgres array * attributes into Tcl lists. CAUTION: this conversion is *wrong* unless diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 2cf9378cf11..0967bef24ba 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: execnodes.h,v 1.57 2001/03/22 04:00:50 momjian Exp $ + * $Id: execnodes.h,v 1.58 2001/05/07 00:43:25 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -628,7 +628,6 @@ typedef struct GroupState * SortState information * * sort_Done indicates whether sort has been performed yet - * sort_Keys scan key structures describing the sort keys * tuplesortstate private state of tuplesort.c * ---------------- */ @@ -636,7 +635,6 @@ typedef struct SortState { CommonScanState csstate; /* its first field is NodeTag */ bool sort_Done; - ScanKey sort_Keys; void *tuplesortstate; } SortState; diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 1614d787bcb..63b1b1046a8 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parsenodes.h,v 1.126 2001/03/23 04:49:56 momjian Exp $ + * $Id: parsenodes.h,v 1.127 2001/05/07 00:43:25 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -118,11 +118,12 @@ typedef struct AlterTableStmt NodeTag type; char subtype; /*------------ * A = add column - * T = alter column + * T = alter column default + * S = alter column statistics * D = drop column * C = add constraint * X = drop constraint - * E = add toast table, + * E = create toast table * U = change owner *------------ */ @@ -690,16 +691,20 @@ typedef struct ClusterStmt } ClusterStmt; /* ---------------------- - * Vacuum Statement + * Vacuum and Analyze Statements + * + * Even though these are nominally two statements, it's convenient to use + * just one node type for both. * ---------------------- */ typedef struct VacuumStmt { NodeTag type; - bool verbose; /* print status info */ - bool analyze; /* analyze data */ - char *vacrel; /* table to vacuum */ - List *va_spec; /* columns to analyse */ + bool vacuum; /* do VACUUM step */ + bool analyze; /* do ANALYZE step */ + bool verbose; /* print progress info */ + char *vacrel; /* name of single table to process, or NULL */ + List *va_cols; /* list of column names, or NIL for all */ } VacuumStmt; /* ---------------------- diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h index 3ae8e09f57a..9e69ed60992 100644 --- a/src/include/nodes/primnodes.h +++ b/src/include/nodes/primnodes.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: primnodes.h,v 1.53 2001/03/22 04:00:52 momjian Exp $ + * $Id: primnodes.h,v 1.54 2001/05/07 00:43:25 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -45,8 +45,8 @@ typedef struct FunctionCache *FunctionCachePtr; * reskey and reskeyop are the execution-time representation of sorting. * reskey must be zero in any non-sort-key item. The reskey of sort key * targetlist items for a sort plan node is 1,2,...,n for the n sort keys. - * The reskeyop of each such targetlist item is the sort operator's - * regproc OID. reskeyop will be zero in non-sort-key items. + * The reskeyop of each such targetlist item is the sort operator's OID. + * reskeyop will be zero in non-sort-key items. * * Both reskey and reskeyop are typically zero during parse/plan stages. * The executor does not pay any attention to ressortgroupref. @@ -62,7 +62,7 @@ typedef struct Resdom Index ressortgroupref; /* nonzero if referenced by a sort/group clause */ Index reskey; /* order of key in a sort (for those > 0) */ - Oid reskeyop; /* sort operator's regproc Oid */ + Oid reskeyop; /* sort operator's Oid */ bool resjunk; /* set to true to eliminate the attribute * from final target list */ } Resdom; diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index f643ef87968..c76d9b4af71 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: relation.h,v 1.54 2001/03/22 04:00:53 momjian Exp $ + * $Id: relation.h,v 1.55 2001/05/07 00:43:26 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -512,8 +512,8 @@ typedef struct RestrictInfo Oid hashjoinoperator; /* copy of clause operator */ /* cache space for hashclause processing; -1 if not yet set */ - Selectivity left_dispersion;/* dispersion of left side */ - Selectivity right_dispersion; /* dispersion of right side */ + Selectivity left_bucketsize; /* avg bucketsize of left side */ + Selectivity right_bucketsize; /* avg bucketsize of right side */ } RestrictInfo; /* diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h index 5caa576f0c0..cbf6df063a3 100644 --- a/src/include/optimizer/cost.h +++ b/src/include/optimizer/cost.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: cost.h,v 1.38 2001/02/16 00:03:05 tgl Exp $ + * $Id: cost.h,v 1.39 2001/05/07 00:43:26 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -64,7 +64,8 @@ extern void cost_mergejoin(Path *path, Path *outer_path, Path *inner_path, List *restrictlist, List *outersortkeys, List *innersortkeys); extern void cost_hashjoin(Path *path, Path *outer_path, Path *inner_path, - List *restrictlist, Selectivity innerdispersion); + List *restrictlist, Selectivity innerbucketsize); +extern Selectivity estimate_hash_bucketsize(Query *root, Var *var); extern Cost cost_qual_eval(List *quals); extern void set_baserel_size_estimates(Query *root, RelOptInfo *rel); extern void set_joinrel_size_estimates(Query *root, RelOptInfo *rel, diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h index 5b71eded86f..0839feb4b2f 100644 --- a/src/include/optimizer/pathnode.h +++ b/src/include/optimizer/pathnode.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pathnode.h,v 1.35 2001/03/22 04:00:54 momjian Exp $ + * $Id: pathnode.h,v 1.36 2001/05/07 00:43:26 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -59,7 +59,7 @@ extern HashPath *create_hashjoin_path(RelOptInfo *joinrel, Path *inner_path, List *restrict_clauses, List *hashclauses, - Selectivity innerdispersion); + Selectivity innerbucketsize); /* * prototypes for relnode.c diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h index f1c4aff1c80..6b35deed286 100644 --- a/src/include/utils/lsyscache.h +++ b/src/include/utils/lsyscache.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: lsyscache.h,v 1.30 2001/03/22 04:01:13 momjian Exp $ + * $Id: lsyscache.h,v 1.31 2001/05/07 00:43:26 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -21,8 +21,6 @@ extern AttrNumber get_attnum(Oid relid, char *attname); extern Oid get_atttype(Oid relid, AttrNumber attnum); extern bool get_attisset(Oid relid, char *attname); extern int32 get_atttypmod(Oid relid, AttrNumber attnum); -extern double get_attdispersion(Oid relid, AttrNumber attnum, - double min_estimate); extern RegProcedure get_opcode(Oid opno); extern char *get_opname(Oid opno); extern bool op_mergejoinable(Oid opno, Oid ltype, Oid rtype, @@ -41,6 +39,14 @@ extern bool get_typbyval(Oid typid); extern void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval); extern char get_typstorage(Oid typid); extern Datum get_typdefault(Oid typid); +extern bool get_attstatsslot(HeapTuple statstuple, + Oid atttype, int32 atttypmod, + int reqkind, Oid reqop, + Datum **values, int *nvalues, + float4 **numbers, int *nnumbers); +extern void free_attstatsslot(Oid atttype, + Datum *values, int nvalues, + float4 *numbers, int nnumbers); #define TypeIsToastable(typid) (get_typstorage(typid) != 'p') diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h index 8d4e2ae62c4..342f7bf8a56 100644 --- a/src/include/utils/syscache.h +++ b/src/include/utils/syscache.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: syscache.h,v 1.29 2001/03/22 04:01:14 momjian Exp $ + * $Id: syscache.h,v 1.30 2001/05/07 00:43:26 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,7 +53,7 @@ #define RULEOID 22 #define SHADOWNAME 23 #define SHADOWSYSID 24 -#define STATRELID 25 +#define STATRELATT 25 #define TYPENAME 26 #define TYPEOID 27 diff --git a/src/include/utils/tuplesort.h b/src/include/utils/tuplesort.h index 7f273776c36..001761796e2 100644 --- a/src/include/utils/tuplesort.h +++ b/src/include/utils/tuplesort.h @@ -13,7 +13,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: tuplesort.h,v 1.6 2001/01/24 19:43:29 momjian Exp $ + * $Id: tuplesort.h,v 1.7 2001/05/07 00:43:26 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -36,8 +36,9 @@ typedef struct Tuplesortstate Tuplesortstate; */ extern Tuplesortstate *tuplesort_begin_heap(TupleDesc tupDesc, - int nkeys, ScanKey keys, - bool randomAccess); + int nkeys, + Oid *sortOperators, AttrNumber *attNums, + bool randomAccess); extern Tuplesortstate *tuplesort_begin_index(Relation indexRel, bool enforceUnique, bool randomAccess); @@ -75,4 +76,19 @@ extern void tuplesort_rescan(Tuplesortstate *state); extern void tuplesort_markpos(Tuplesortstate *state); extern void tuplesort_restorepos(Tuplesortstate *state); +/* + * This routine selects an appropriate sorting function to implement + * a sort operator as efficiently as possible. + */ +typedef enum +{ + SORTFUNC_LT, /* raw "<" operator */ + SORTFUNC_CMP, /* -1 / 0 / 1 three-way comparator */ + SORTFUNC_REVCMP /* 1 / 0 / -1 (reversed) 3-way comparator */ +} SortFunctionKind; + +extern void SelectSortFunction(Oid sortOperator, + RegProcedure *sortFunction, + SortFunctionKind *kind); + #endif /* TUPLESORT_H */ |