Skip to content

Commit 26c48b5

Browse files
committed
Final stage of psort reconstruction work: replace psort.c with
a generalized module 'tuplesort.c' that can sort either HeapTuples or IndexTuples, and is not tied to execution of a Sort node. Clean up memory leakages in sorting, and replace nbtsort.c's private implementation of mergesorting with calls to tuplesort.c.
1 parent 59ed74e commit 26c48b5

File tree

10 files changed

+1747
-1018
lines changed

10 files changed

+1747
-1018
lines changed

src/backend/access/nbtree/nbtree.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/*-------------------------------------------------------------------------
22
*
3-
* btree.c
3+
* nbtree.c
44
* Implementation of Lehman and Yao's btree management algorithm for
55
* Postgres.
66
*
7-
* Copyright (c) 1994, Regents of the University of California
7+
* NOTES
8+
* This file contains only the public interface routines.
89
*
910
*
10-
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.46 1999/09/18 19:06:10 tgl Exp $
11+
* Copyright (c) 1994, Regents of the University of California
1212
*
13-
* NOTES
14-
* This file contains only the public interface routines.
13+
* IDENTIFICATION
14+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.47 1999/10/17 22:15:03 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -76,7 +76,7 @@ btbuild(Relation heap,
7676
#endif
7777
Node *pred,
7878
*oldPred;
79-
void *spool = (void *) NULL;
79+
BTSpool *spool = NULL;
8080
bool isunique;
8181
bool usefast;
8282

@@ -147,7 +147,7 @@ btbuild(Relation heap,
147147

148148
if (usefast)
149149
{
150-
spool = _bt_spoolinit(index, 7, isunique);
150+
spool = _bt_spoolinit(index, isunique);
151151
res = (InsertIndexResult) NULL;
152152
}
153153

@@ -249,11 +249,11 @@ btbuild(Relation heap,
249249

250250
/*
251251
* if we are doing bottom-up btree build, we insert the index into
252-
* a spool page for subsequent processing. otherwise, we insert
252+
* a spool file for subsequent processing. otherwise, we insert
253253
* into the btree.
254254
*/
255255
if (usefast)
256-
_bt_spool(index, btitem, spool);
256+
_bt_spool(btitem, spool);
257257
else
258258
res = _bt_doinsert(index, btitem, isunique, heap);
259259

@@ -275,15 +275,13 @@ btbuild(Relation heap,
275275
}
276276

277277
/*
278-
* if we are doing bottom-up btree build, we now have a bunch of
279-
* sorted runs in the spool pages. finish the build by (1) merging
280-
* the runs, (2) inserting the sorted tuples into btree pages and (3)
281-
* building the upper levels.
278+
* if we are doing bottom-up btree build, finish the build by
279+
* (1) completing the sort of the spool file, (2) inserting the
280+
* sorted tuples into btree pages and (3) building the upper levels.
282281
*/
283282
if (usefast)
284283
{
285-
_bt_spool(index, (BTItem) NULL, spool); /* flush the spool */
286-
_bt_leafbuild(index, spool);
284+
_bt_leafbuild(spool);
287285
_bt_spooldestroy(spool);
288286
}
289287

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy