Skip to content

Commit 4df8c7b

Browse files
author
Artur Zakirov
committed
We need ginsort.h and ginsort.c
1 parent 25e0475 commit 4df8c7b

File tree

3 files changed

+59
-58
lines changed

3 files changed

+59
-58
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# contrib/rum/Makefile
22

33
MODULE_big = rum
4-
OBJS = ginarrayproc.o ginbtree.o ginbulk.o gindatapage.o \
4+
OBJS = ginsort.o \
5+
ginarrayproc.o ginbtree.o ginbulk.o gindatapage.o \
56
ginentrypage.o ginfast.o ginget.o gininsert.o \
67
ginscan.o ginutil.o ginvacuum.o $(WIN32RES)
78

ginget.c

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
#include "postgres.h"
16+
#include "ginsort.h"
1617

1718
#include "access/relscan.h"
1819
#include "miscadmin.h"
@@ -2187,60 +2188,59 @@ insertScanItem(GinScanOpaque so, bool recheck)
21872188
tuplesort_putgin(so->sortstate, item);
21882189
}
21892190

2190-
// Datum
2191-
// gingettuple(PG_FUNCTION_ARGS)
2192-
// {
2193-
// IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
2194-
// bool recheck;
2195-
// GinScanOpaque so = (GinScanOpaque)scan->opaque;
2196-
// GinSortItem *item;
2197-
// bool should_free;
2198-
//
2199-
// if (so->firstCall)
2200-
// {
2201-
// so->norderbys = scan->numberOfOrderBys;
2202-
//
2203-
// /*
2204-
// * Set up the scan keys, and check for unsatisfiable query.
2205-
// */
2206-
// if (GinIsNewKey(scan))
2207-
// ginNewScanKey(scan);
2208-
//
2209-
// if (GinIsVoidRes(scan))
2210-
// PG_RETURN_INT64(0);
2211-
//
2212-
// so->tbm = NULL;
2213-
// so->entriesIncrIndex = -1;
2214-
// so->firstCall = false;
2215-
// so->sortstate = tuplesort_begin_gin(work_mem, so->norderbys, false);
2216-
//
2217-
// scanPendingInsert(scan);
2218-
//
2219-
// /*
2220-
// * Now scan the main index.
2221-
// */
2222-
// startScan(scan);
2223-
//
2224-
// while (scanGetItem(scan, &so->iptr, &so->iptr, &recheck))
2225-
// {
2226-
// insertScanItem(so, recheck);
2227-
// }
2228-
// tuplesort_performsort(so->sortstate);
2229-
// }
2230-
//
2231-
// item = tuplesort_getgin(so->sortstate, true, &should_free);
2232-
// if (item)
2233-
// {
2234-
// scan->xs_ctup.t_self = item->iptr;
2235-
// scan->xs_recheck = item->recheck;
2236-
//
2237-
// if (should_free)
2238-
// pfree(item);
2239-
// PG_RETURN_BOOL(true);
2240-
// }
2241-
// else
2242-
// {
2243-
// PG_RETURN_BOOL(false);
2244-
// }
2245-
// }
2191+
Datum
2192+
gingettuple(PG_FUNCTION_ARGS)
2193+
{
2194+
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
2195+
bool recheck;
2196+
GinScanOpaque so = (GinScanOpaque)scan->opaque;
2197+
GinSortItem *item;
2198+
bool should_free;
2199+
2200+
if (so->firstCall)
2201+
{
2202+
so->norderbys = scan->numberOfOrderBys;
2203+
2204+
/*
2205+
* Set up the scan keys, and check for unsatisfiable query.
2206+
*/
2207+
if (GinIsNewKey(scan))
2208+
ginNewScanKey(scan);
2209+
2210+
if (GinIsVoidRes(scan))
2211+
PG_RETURN_INT64(0);
2212+
2213+
so->tbm = NULL;
2214+
so->entriesIncrIndex = -1;
2215+
so->firstCall = false;
2216+
so->sortstate = tuplesort_begin_gin(work_mem, so->norderbys, false);
2217+
2218+
scanPendingInsert(scan);
2219+
2220+
/*
2221+
* Now scan the main index.
2222+
*/
2223+
startScan(scan);
22462224

2225+
while (scanGetItem(scan, &so->iptr, &so->iptr, &recheck))
2226+
{
2227+
insertScanItem(so, recheck);
2228+
}
2229+
tuplesort_performsort(so->sortstate);
2230+
}
2231+
2232+
item = tuplesort_getgin(so->sortstate, true, &should_free);
2233+
if (item)
2234+
{
2235+
scan->xs_ctup.t_self = item->iptr;
2236+
scan->xs_recheck = item->recheck;
2237+
2238+
if (should_free)
2239+
pfree(item);
2240+
PG_RETURN_BOOL(true);
2241+
}
2242+
else
2243+
{
2244+
PG_RETURN_BOOL(false);
2245+
}
2246+
}

rum.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ extern void ginNewScanKey(IndexScanDesc scan);
794794

795795
/* ginget.c */
796796
extern int64 gingetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
797-
//extern Datum gingettuple(PG_FUNCTION_ARGS);
797+
extern Datum gingettuple(PG_FUNCTION_ARGS);
798798

799799
/* ginvacuum.c */
800800
extern IndexBulkDeleteResult *ginbulkdelete(IndexVacuumInfo *info,

0 commit comments

Comments
 (0)