summaryrefslogtreecommitdiff
path: root/src/backend/bootstrap
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/backend/bootstrap
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/backend/bootstrap')
-rw-r--r--src/backend/bootstrap/bootparse.y3
-rw-r--r--src/backend/bootstrap/bootscanner.l3
-rw-r--r--src/backend/bootstrap/bootstrap.c67
3 files changed, 16 insertions, 57 deletions
diff --git a/src/backend/bootstrap/bootparse.y b/src/backend/bootstrap/bootparse.y
index 4c13aafc0eb..cf3cd1b280b 100644
--- a/src/backend/bootstrap/bootparse.y
+++ b/src/backend/bootstrap/bootparse.y
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.31 2000/07/04 06:11:22 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.32 2000/07/14 22:17:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -20,7 +20,6 @@
#include "access/attnum.h"
-#include "access/funcindex.h"
#include "access/htup.h"
#include "access/itup.h"
#include "access/skey.h"
diff --git a/src/backend/bootstrap/bootscanner.l b/src/backend/bootstrap/bootscanner.l
index 125ea516f17..ed68c92ac28 100644
--- a/src/backend/bootstrap/bootscanner.l
+++ b/src/backend/bootstrap/bootscanner.l
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootscanner.l,v 1.17 2000/01/26 05:56:07 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootscanner.l,v 1.18 2000/07/14 22:17:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -18,7 +18,6 @@
#include "postgres.h"
#include "access/attnum.h"
-#include "access/funcindex.h"
#include "access/htup.h"
#include "access/itup.h"
#include "access/skey.h"
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 1c52d098a1a..c3cf9371724 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.90 2000/07/03 23:09:23 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.91 2000/07/14 22:17:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -160,20 +160,12 @@ typedef struct _IndexList
{
char *il_heap;
char *il_ind;
- int il_natts;
- AttrNumber *il_attnos;
- FuncIndexInfo *il_finfo;
- PredInfo *il_predInfo;
- bool il_unique;
+ IndexInfo *il_info;
struct _IndexList *il_next;
} IndexList;
static IndexList *ILHead = (IndexList *) NULL;
-typedef void (*sig_func) ();
-
-
-
/* ----------------------------------------------------------------
* misc functions
@@ -334,9 +326,9 @@ BootstrapMain(int argc, char *argv[])
if (!IsUnderPostmaster)
{
- pqsignal(SIGINT, (sig_func) die);
- pqsignal(SIGHUP, (sig_func) die);
- pqsignal(SIGTERM, (sig_func) die);
+ pqsignal(SIGINT, (pqsigfunc) die);
+ pqsignal(SIGHUP, (pqsigfunc) die);
+ pqsignal(SIGTERM, (pqsigfunc) die);
}
/*
@@ -1080,14 +1072,9 @@ AddStr(char *str, int strlength, int mderef)
void
index_register(char *heap,
char *ind,
- int natts,
- AttrNumber *attnos,
- FuncIndexInfo *finfo,
- PredInfo *predInfo,
- bool unique)
+ IndexInfo *indexInfo)
{
IndexList *newind;
- int len;
MemoryContext oldcxt;
/*
@@ -1108,37 +1095,13 @@ index_register(char *heap,
newind = (IndexList *) palloc(sizeof(IndexList));
newind->il_heap = pstrdup(heap);
newind->il_ind = pstrdup(ind);
- newind->il_natts = natts;
-
- if (PointerIsValid(finfo))
- len = FIgetnArgs(finfo) * sizeof(AttrNumber);
- else
- len = natts * sizeof(AttrNumber);
-
- newind->il_attnos = (AttrNumber *) palloc(len);
- memcpy(newind->il_attnos, attnos, len);
-
- if (PointerIsValid(finfo))
- {
- newind->il_finfo = (FuncIndexInfo *) palloc(sizeof(FuncIndexInfo));
- memcpy(newind->il_finfo, finfo, sizeof(FuncIndexInfo));
- }
- else
- newind->il_finfo = (FuncIndexInfo *) NULL;
+ newind->il_info = (IndexInfo *) palloc(sizeof(IndexInfo));
- if (predInfo != NULL)
- {
- newind->il_predInfo = (PredInfo *) palloc(sizeof(PredInfo));
- newind->il_predInfo->pred = predInfo->pred;
- newind->il_predInfo->oldPred = predInfo->oldPred;
- }
- else
- newind->il_predInfo = NULL;
-
- newind->il_unique = unique;
+ memcpy(newind->il_info, indexInfo, sizeof(IndexInfo));
+ /* predicate will likely be null anyway, but may as well copy it */
+ newind->il_info->ii_Predicate = copyObject(indexInfo->ii_Predicate);
newind->il_next = ILHead;
-
ILHead = newind;
MemoryContextSwitchTo(oldcxt);
@@ -1147,18 +1110,16 @@ index_register(char *heap,
void
build_indices()
{
- Relation heap;
- Relation ind;
-
for (; ILHead != (IndexList *) NULL; ILHead = ILHead->il_next)
{
+ Relation heap;
+ Relation ind;
+
heap = heap_openr(ILHead->il_heap, NoLock);
Assert(heap);
ind = index_openr(ILHead->il_ind);
Assert(ind);
- index_build(heap, ind, ILHead->il_natts, ILHead->il_attnos,
- ILHead->il_finfo, ILHead->il_predInfo,
- ILHead->il_unique);
+ index_build(heap, ind, ILHead->il_info, NULL);
/*
* In normal processing mode, index_build would close the heap and