12
12
* Portions Copyright (c) 1994, Regents of the University of California
13
13
*
14
14
* IDENTIFICATION
15
- * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.143 2006/03/31 23:32:05 tgl Exp $
15
+ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.144 2006/04/01 03:03:37 tgl Exp $
16
16
*
17
17
*-------------------------------------------------------------------------
18
18
*/
32
32
/* Working state for btbuild and its callback */
33
33
typedef struct
34
34
{
35
- bool usefast ;
36
35
bool isUnique ;
37
36
bool haveDead ;
38
37
Relation heapRel ;
@@ -48,8 +47,6 @@ typedef struct
48
47
} BTBuildState ;
49
48
50
49
51
- bool FastBuild = true; /* use SORT instead of insertion build */
52
-
53
50
static void _bt_restscan (IndexScanDesc scan );
54
51
static void btbuildCallback (Relation index ,
55
52
HeapTuple htup ,
@@ -71,13 +68,6 @@ btbuild(PG_FUNCTION_ARGS)
71
68
double reltuples ;
72
69
BTBuildState buildstate ;
73
70
74
- /*
75
- * bootstrap processing does something strange, so don't use sort/build
76
- * for initial catalog indices. at some point i need to look harder at
77
- * this. (there is some kind of incremental processing going on there.)
78
- * -- pma 08/29/95
79
- */
80
- buildstate .usefast = (FastBuild && IsNormalProcessingMode ());
81
71
buildstate .isUnique = indexInfo -> ii_Unique ;
82
72
buildstate .haveDead = false;
83
73
buildstate .heapRel = heap ;
@@ -98,22 +88,14 @@ btbuild(PG_FUNCTION_ARGS)
98
88
elog (ERROR , "index \"%s\" already contains data" ,
99
89
RelationGetRelationName (index ));
100
90
101
- if (buildstate .usefast )
102
- {
103
- buildstate .spool = _bt_spoolinit (index , indexInfo -> ii_Unique , false);
91
+ buildstate .spool = _bt_spoolinit (index , indexInfo -> ii_Unique , false);
104
92
105
- /*
106
- * If building a unique index, put dead tuples in a second spool to
107
- * keep them out of the uniqueness check.
108
- */
109
- if (indexInfo -> ii_Unique )
110
- buildstate .spool2 = _bt_spoolinit (index , false, true);
111
- }
112
- else
113
- {
114
- /* if using slow build, initialize the btree index metadata page */
115
- _bt_metapinit (index );
116
- }
93
+ /*
94
+ * If building a unique index, put dead tuples in a second spool to
95
+ * keep them out of the uniqueness check.
96
+ */
97
+ if (indexInfo -> ii_Unique )
98
+ buildstate .spool2 = _bt_spoolinit (index , false, true);
117
99
118
100
/* do the heap scan */
119
101
reltuples = IndexBuildHeapScan (heap , index , indexInfo ,
@@ -128,17 +110,14 @@ btbuild(PG_FUNCTION_ARGS)
128
110
}
129
111
130
112
/*
131
- * if we are doing bottom-up btree build, finish the build by (1 )
132
- * completing the sort of the spool file, (2) inserting the sorted tuples
133
- * into btree pages and (3) building the upper levels.
113
+ * Finish the build by (1) completing the sort of the spool file, (2 )
114
+ * inserting the sorted tuples into btree pages and (3) building the upper
115
+ * levels.
134
116
*/
135
- if (buildstate .usefast )
136
- {
137
- _bt_leafbuild (buildstate .spool , buildstate .spool2 );
138
- _bt_spooldestroy (buildstate .spool );
139
- if (buildstate .spool2 )
140
- _bt_spooldestroy (buildstate .spool2 );
141
- }
117
+ _bt_leafbuild (buildstate .spool , buildstate .spool2 );
118
+ _bt_spooldestroy (buildstate .spool );
119
+ if (buildstate .spool2 )
120
+ _bt_spooldestroy (buildstate .spool2 );
142
121
143
122
#ifdef BTREE_BUILD_STATS
144
123
if (log_btree_build_stats )
@@ -173,24 +152,16 @@ btbuildCallback(Relation index,
173
152
itup -> t_tid = htup -> t_self ;
174
153
175
154
/*
176
- * if we are doing bottom-up btree build, we insert the index into a spool
177
- * file for subsequent processing. otherwise, we insert into the btree.
155
+ * insert the index tuple into the appropriate spool file for subsequent
156
+ * processing
178
157
*/
179
- if (buildstate -> usefast )
180
- {
181
- if (tupleIsAlive || buildstate -> spool2 == NULL )
182
- _bt_spool (itup , buildstate -> spool );
183
- else
184
- {
185
- /* dead tuples are put into spool2 */
186
- buildstate -> haveDead = true;
187
- _bt_spool (itup , buildstate -> spool2 );
188
- }
189
- }
158
+ if (tupleIsAlive || buildstate -> spool2 == NULL )
159
+ _bt_spool (itup , buildstate -> spool );
190
160
else
191
161
{
192
- _bt_doinsert (index , itup ,
193
- buildstate -> isUnique , buildstate -> heapRel );
162
+ /* dead tuples are put into spool2 */
163
+ buildstate -> haveDead = true;
164
+ _bt_spool (itup , buildstate -> spool2 );
194
165
}
195
166
196
167
buildstate -> indtuples += 1 ;
0 commit comments