summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2000-07-14 22:18:02 +0000
committerTom Lane2000-07-14 22:18:02 +0000
commit6bfe64032efd043f80a495a495331dcfc2d9f05c (patch)
treed0cc092d38bdea690a79e4aebfa4629e1db54e96 /src/include
parenta30bc7c75a54910a78d1939bd32f5d91164ba8a4 (diff)
Cleanup of code for creating index entries. Functional indexes with
pass-by-ref data types --- eg, an index on lower(textfield) --- no longer leak memory during index creation or update. Clean up a lot of redundant code ... did you know that copy, vacuum, truncate, reindex, extend index, and bootstrap each basically duplicated the main executor's logic for extracting information about an index and preparing index entries? Functional indexes should be a little faster now too, due to removal of repeated function lookups. CREATE INDEX 'opt_type' clause is deimplemented by these changes, but I haven't removed it from the parser yet (need to merge with Thomas' latest change set first).
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/funcindex.h43
-rw-r--r--src/include/access/genam.h6
-rw-r--r--src/include/access/gist.h1
-rw-r--r--src/include/access/hash.h3
-rw-r--r--src/include/access/istrat.h13
-rw-r--r--src/include/access/itup.h14
-rw-r--r--src/include/bootstrap/bootstrap.h14
-rw-r--r--src/include/catalog/index.h39
-rw-r--r--src/include/catalog/pg_proc.h10
-rw-r--r--src/include/commands/vacuum.h15
-rw-r--r--src/include/nodes/execnodes.h32
-rw-r--r--src/include/utils/rel.h3
12 files changed, 66 insertions, 127 deletions
diff --git a/src/include/access/funcindex.h b/src/include/access/funcindex.h
deleted file mode 100644
index 0555755aaab..00000000000
--- a/src/include/access/funcindex.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * funcindex.h
- *
- *
- *
- * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * $Id: funcindex.h,v 1.9 2000/01/26 05:57:50 momjian Exp $
- *
- *-------------------------------------------------------------------------
- */
-#ifndef _FUNC_INDEX_INCLUDED_
-#define _FUNC_INDEX_INCLUDED_
-
-typedef struct
-{
- int nargs;
- Oid arglist[FUNC_MAX_ARGS];
- Oid procOid;
- NameData funcName;
-} FuncIndexInfo;
-
-typedef FuncIndexInfo *FuncIndexInfoPtr;
-
-/*
- * some marginally useful macro definitions
- */
-/* #define FIgetname(FINFO) (&((FINFO)->funcName.data[0]))*/
-#define FIgetname(FINFO) (FINFO)->funcName.data
-#define FIgetnArgs(FINFO) (FINFO)->nargs
-#define FIgetProcOid(FINFO) (FINFO)->procOid
-#define FIgetArg(FINFO, argnum) (FINFO)->arglist[argnum]
-#define FIgetArglist(FINFO) (FINFO)->arglist
-
-#define FIsetnArgs(FINFO, numargs) ((FINFO)->nargs = numargs)
-#define FIsetProcOid(FINFO, id) ((FINFO)->procOid = id)
-#define FIsetArg(FINFO, argnum, argtype) ((FINFO)->arglist[argnum] = argtype)
-
-#define FIisFunctionalIndex(FINFO) (FINFO->procOid != InvalidOid)
-
-#endif /* FUNCINDEX_H */
diff --git a/src/include/access/genam.h b/src/include/access/genam.h
index c7e0c5021b4..b62a979f051 100644
--- a/src/include/access/genam.h
+++ b/src/include/access/genam.h
@@ -7,14 +7,13 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: genam.h,v 1.23 2000/01/26 05:57:50 momjian Exp $
+ * $Id: genam.h,v 1.24 2000/07/14 22:17:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef GENAM_H
#define GENAM_H
-#include "access/funcindex.h"
#include "access/itup.h"
#include "access/relscan.h"
#include "access/sdir.h"
@@ -42,9 +41,6 @@ extern RetrieveIndexResult index_getnext(IndexScanDesc scan,
extern RegProcedure index_cost_estimator(Relation relation);
extern RegProcedure index_getprocid(Relation irel, AttrNumber attnum,
uint16 procnum);
-extern Datum GetIndexValue(HeapTuple tuple, TupleDesc hTupDesc,
- int attOff, AttrNumber *attrNums, FuncIndexInfo *fInfo,
- bool *attNull);
/* in genam.c */
extern IndexScanDesc RelationGetIndexScan(Relation relation, bool scanFromEnd,
diff --git a/src/include/access/gist.h b/src/include/access/gist.h
index dd8f557e9ba..1297b02ff01 100644
--- a/src/include/access/gist.h
+++ b/src/include/access/gist.h
@@ -12,7 +12,6 @@
#ifndef GIST_H
#define GIST_H
-#include "access/funcindex.h"
#include "access/itup.h"
#include "access/relscan.h"
#include "access/sdir.h"
diff --git a/src/include/access/hash.h b/src/include/access/hash.h
index aa461a75e2b..17d3496dee0 100644
--- a/src/include/access/hash.h
+++ b/src/include/access/hash.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: hash.h,v 1.34 2000/06/19 03:54:35 tgl Exp $
+ * $Id: hash.h,v 1.35 2000/07/14 22:17:53 tgl Exp $
*
* NOTES
* modeled after Margo Seltzer's hash implementation for unix.
@@ -17,7 +17,6 @@
#ifndef HASH_H
#define HASH_H
-#include "access/funcindex.h"
#include "access/itup.h"
#include "access/relscan.h"
#include "access/sdir.h"
diff --git a/src/include/access/istrat.h b/src/include/access/istrat.h
index 99d4901bcdc..9178f8c410e 100644
--- a/src/include/access/istrat.h
+++ b/src/include/access/istrat.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: istrat.h,v 1.17 2000/06/08 22:37:36 momjian Exp $
+ * $Id: istrat.h,v 1.18 2000/07/14 22:17:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -56,9 +56,12 @@ extern StrategyNumber RelationGetStrategy(Relation relation,
AttrNumber attributeNumber, StrategyEvaluation evaluation,
RegProcedure procedure);
extern void IndexSupportInitialize(IndexStrategy indexStrategy,
- RegProcedure *indexSupport, Oid indexObjectId,
- Oid accessMethodObjectId, StrategyNumber maxStrategyNumber,
- StrategyNumber maxSupportNumber, AttrNumber maxAttributeNumber);
-
+ RegProcedure *indexSupport,
+ bool *isUnique,
+ Oid indexObjectId,
+ Oid accessMethodObjectId,
+ StrategyNumber maxStrategyNumber,
+ StrategyNumber maxSupportNumber,
+ AttrNumber maxAttributeNumber);
#endif /* ISTRAT_H */
diff --git a/src/include/access/itup.h b/src/include/access/itup.h
index e01cb7a31b6..a5047729616 100644
--- a/src/include/access/itup.h
+++ b/src/include/access/itup.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: itup.h,v 1.24 2000/03/17 02:36:37 tgl Exp $
+ * $Id: itup.h,v 1.25 2000/07/14 22:17:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -61,18 +61,6 @@ typedef struct RetrieveIndexResultData
typedef RetrieveIndexResultData *RetrieveIndexResult;
-/*-----------------
- * PredInfo -
- * used for partial indices
- *-----------------
- */
-typedef struct PredInfo
-{
- Node *pred;
- Node *oldPred;
-} PredInfo;
-
-
/* ----------------
* externs
* ----------------
diff --git a/src/include/bootstrap/bootstrap.h b/src/include/bootstrap/bootstrap.h
index b3ddea19d50..882ac3c7d1c 100644
--- a/src/include/bootstrap/bootstrap.h
+++ b/src/include/bootstrap/bootstrap.h
@@ -7,18 +7,21 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: bootstrap.h,v 1.18 2000/06/17 23:41:49 tgl Exp $
+ * $Id: bootstrap.h,v 1.19 2000/07/14 22:17:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef BOOTSTRAP_H
#define BOOTSTRAP_H
-#include "access/funcindex.h"
#include "access/itup.h"
+#include "nodes/execnodes.h"
#include "utils/rel.h"
-#define MAXATTR 40 /* max. number of attributes in a relation */
+/* MAXATTR is the maximum number of attributes in a relation supported
+ * at bootstrap time (ie, the max possible in a system table).
+ */
+#define MAXATTR 40
typedef struct hashnode
{
@@ -35,10 +38,7 @@ extern int DebugMode;
extern int BootstrapMain(int ac, char *av[]);
-extern void index_register(char *heap, char *ind,
- int natts, AttrNumber *attnos,
- FuncIndexInfo *finfo, PredInfo *predInfo,
- bool unique);
+extern void index_register(char *heap, char *ind, IndexInfo *indexInfo);
extern void err_out(void);
extern void InsertOneTuple(Oid objectid);
diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index 66b4f601be3..e00b25e6f07 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: index.h,v 1.28 2000/07/12 02:37:27 tgl Exp $
+ * $Id: index.h,v 1.29 2000/07/14 22:17:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,25 +27,24 @@ extern void InitIndexStrategy(int numatts,
Oid accessMethodObjectId);
extern void index_create(char *heapRelationName,
- char *indexRelationName,
- FuncIndexInfo *funcInfo,
- List *attributeList,
- Oid accessMethodObjectId,
- int numatts,
- AttrNumber *attNums,
- Oid *classObjectId,
- Node *predicate,
- bool islossy,
- bool unique,
- bool primary,
- bool allow_system_table_mods);
+ char *indexRelationName,
+ IndexInfo *indexInfo,
+ Oid accessMethodObjectId,
+ Oid *classObjectId,
+ bool islossy,
+ bool primary,
+ bool allow_system_table_mods);
extern void index_drop(Oid indexId);
-extern void FormIndexDatum(int numberOfAttributes,
- AttrNumber *attributeNumber, HeapTuple heapTuple,
- TupleDesc heapDescriptor, Datum *datum,
- char *nullv, FuncIndexInfoPtr fInfo);
+extern IndexInfo *BuildIndexInfo(HeapTuple indexTuple);
+
+extern void FormIndexDatum(IndexInfo *indexInfo,
+ HeapTuple heapTuple,
+ TupleDesc heapDescriptor,
+ MemoryContext resultCxt,
+ Datum *datum,
+ char *nullv);
extern void UpdateStats(Oid relid, long reltuples, bool inplace);
extern bool IndexesAreActive(Oid relid, bool comfirmCommitted);
@@ -54,11 +53,7 @@ extern bool SetReindexProcessing(bool processing);
extern bool IsReindexProcessing(void);
extern void index_build(Relation heapRelation, Relation indexRelation,
- int numberOfAttributes, AttrNumber *attributeNumber,
- FuncIndexInfo *funcInfo, PredInfo *predInfo,
- bool unique);
-
-extern bool IndexIsUnique(Oid indexId);
+ IndexInfo *indexInfo, Node *oldPred);
extern bool reindex_index(Oid indexId, bool force);
extern bool activate_indexes_of_a_table(Oid relid, bool activate);
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index bd260a827b4..538299773d9 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_proc.h,v 1.146 2000/07/08 03:04:21 tgl Exp $
+ * $Id: pg_proc.h,v 1.147 2000/07/14 22:17:56 tgl Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
@@ -677,7 +677,7 @@ DATA(insert OID = 321 ( rtdelete PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100
DESCR("r-tree(internal)");
DATA(insert OID = 322 ( rtgettuple PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 rtgettuple - ));
DESCR("r-tree(internal)");
-DATA(insert OID = 323 ( rtbuild PGUID 12 f t f t 8 f 23 "0 0 0 0 0 0 0 0" 100 0 0 100 rtbuild - ));
+DATA(insert OID = 323 ( rtbuild PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 rtbuild - ));
DESCR("r-tree(internal)");
DATA(insert OID = 324 ( rtbeginscan PGUID 12 f t f t 4 f 23 "0 0 0 0" 100 0 0 100 rtbeginscan - ));
DESCR("r-tree(internal)");
@@ -706,7 +706,7 @@ DATA(insert OID = 336 ( btmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100
DESCR("btree(internal)");
DATA(insert OID = 337 ( btrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btrestrpos - ));
DESCR("btree(internal)");
-DATA(insert OID = 338 ( btbuild PGUID 12 f t f t 8 f 23 "0 0 0 0 0 0 0 0" 100 0 0 100 btbuild - ));
+DATA(insert OID = 338 ( btbuild PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 btbuild - ));
DESCR("btree(internal)");
DATA(insert OID = 339 ( poly_same PGUID 11 f t t t 2 f 16 "604 604" 100 0 1 0 poly_same - ));
@@ -810,7 +810,7 @@ DATA(insert OID = 446 ( hashmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100
DESCR("hash(internal)");
DATA(insert OID = 447 ( hashrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashrestrpos - ));
DESCR("hash(internal)");
-DATA(insert OID = 448 ( hashbuild PGUID 12 f t f t 8 f 23 "0 0 0 0 0 0 0 0" 100 0 0 100 hashbuild - ));
+DATA(insert OID = 448 ( hashbuild PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 hashbuild - ));
DESCR("hash(internal)");
DATA(insert OID = 449 ( hashint2 PGUID 12 f t t t 1 f 23 "21" 100 0 0 100 hashint2 - ));
DESCR("hash");
@@ -1033,7 +1033,7 @@ DATA(insert OID = 780 ( gistmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100
DESCR("gist(internal)");
DATA(insert OID = 781 ( gistrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistrestrpos - ));
DESCR("gist(internal)");
-DATA(insert OID = 782 ( gistbuild PGUID 12 f t f t 8 f 23 "0 0 0 0 0 0 0 0" 100 0 0 100 gistbuild - ));
+DATA(insert OID = 782 ( gistbuild PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 gistbuild - ));
DESCR("gist(internal)");
DATA(insert OID = 784 ( tintervaleq PGUID 12 f t f t 2 f 16 "704 704" 100 0 0 100 tintervaleq - ));
diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h
index fed4c6a9a16..b42a8e6a17f 100644
--- a/src/include/commands/vacuum.h
+++ b/src/include/commands/vacuum.h
@@ -7,17 +7,16 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: vacuum.h,v 1.31 2000/05/29 17:40:44 momjian Exp $
+ * $Id: vacuum.h,v 1.32 2000/07/14 22:17:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef VACUUM_H
#define VACUUM_H
-#include "fmgr.h"
-#include "access/funcindex.h"
-#include "catalog/pg_index.h"
#include "catalog/pg_attribute.h"
+#include "catalog/pg_index.h"
+#include "fmgr.h"
#include "nodes/pg_list.h"
#include "storage/itemptr.h"
@@ -56,14 +55,6 @@ typedef VacPageListData *VacPageList;
typedef struct
{
- FuncIndexInfo finfo;
- FuncIndexInfo *finfoP;
- Form_pg_index tform;
- int natts;
-} IndDesc;
-
-typedef struct
-{
Form_pg_attribute attr;
Datum best,
guess1,
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 2c21dba9c23..62a887d754b 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -7,39 +7,49 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: execnodes.h,v 1.43 2000/07/12 02:37:32 tgl Exp $
+ * $Id: execnodes.h,v 1.44 2000/07/14 22:17:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef EXECNODES_H
#define EXECNODES_H
-#include "access/funcindex.h"
#include "access/relscan.h"
#include "access/sdir.h"
#include "executor/hashjoin.h"
#include "executor/tuptable.h"
+#include "fmgr.h"
#include "nodes/params.h"
#include "nodes/primnodes.h"
/* ----------------
* IndexInfo information
*
- * this class holds the information saying what attributes
- * are the key attributes for this index. -cim 10/15/89
- *
- * NumKeyAttributes number of key attributes for this index
- * KeyAttributeNumbers array of attribute numbers used as keys
- * Predicate partial-index predicate for this index
+ * this class holds the information needed to construct new index
+ * entries for a particular index. Used for both index_build and
+ * retail creation of index entries.
+ *
+ * NumIndexAttrs number of columns in this index
+ * (1 if a func. index, else same as NumKeyAttrs)
+ * NumKeyAttrs number of key attributes for this index
+ * (ie, number of attrs from underlying relation)
+ * KeyAttrNumbers underlying-rel attribute numbers used as keys
+ * Predicate partial-index predicate, or NULL if none
+ * FuncOid OID of function, or InvalidOid if not f. index
+ * FuncInfo fmgr lookup data for function, if FuncOid valid
+ * Unique is it a unique index?
* ----------------
*/
typedef struct IndexInfo
{
NodeTag type;
- int ii_NumKeyAttributes;
- AttrNumber *ii_KeyAttributeNumbers;
- FuncIndexInfoPtr ii_FuncIndexInfo;
+ int ii_NumIndexAttrs;
+ int ii_NumKeyAttrs;
+ AttrNumber ii_KeyAttrNumbers[INDEX_MAX_KEYS];
Node *ii_Predicate;
+ Oid ii_FuncOid;
+ FmgrInfo ii_FuncInfo;
+ bool ii_Unique;
} IndexInfo;
/* ----------------
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 121012d7fd4..c90ba3c5ee0 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: rel.h,v 1.39 2000/06/30 07:04:03 tgl Exp $
+ * $Id: rel.h,v 1.40 2000/07/14 22:18:02 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -92,6 +92,7 @@ typedef struct RelationData
bool rd_isnailed; /* rel is nailed in cache */
bool rd_unlinked; /* rel already unlinked or not created yet */
bool rd_indexfound; /* true if rd_indexlist is valid */
+ bool rd_uniqueindex; /* true if rel is a UNIQUE index */
Form_pg_am rd_am; /* AM tuple */
Form_pg_class rd_rel; /* RELATION tuple */
Oid rd_id; /* relation's object id */