Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit77db9d9

Browse files
committed
Remove mark/restore support in GIN and GiST indexes.
Per Tom's comment.Also revome useless GISTScanOpaque->flags field.
1 parent7f6bc33 commit77db9d9

File tree

6 files changed

+20
-250
lines changed

6 files changed

+20
-250
lines changed

‎src/backend/access/gin/ginget.c

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
*$PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.19 2008/09/04 11:47:05 teodor Exp $
11+
*$PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.20 2008/10/20 13:39:44 teodor Exp $
1212
*-------------------------------------------------------------------------
1313
*/
1414

@@ -582,54 +582,6 @@ entryGetItem(Relation index, GinScanEntry entry)
582582
returnentry->isFinished;
583583
}
584584

585-
/*
586-
* restart from saved position. Actually it's needed only for
587-
* partial match. function is called only by ginrestpos()
588-
*/
589-
void
590-
ginrestartentry(GinScanEntryentry)
591-
{
592-
ItemPointerDatastopItem=entry->curItem;
593-
boolsavedReduceResult;
594-
595-
if (entry->master||entry->partialMatch==NULL )
596-
return;/* entry is slave or not a partial match type*/
597-
598-
if (entry->isFinished )
599-
return;/* entry was finished before ginmarkpos() call */
600-
601-
if (ItemPointerGetBlockNumber(&stopItem)==InvalidBlockNumber )
602-
return;/* entry wasn't began before ginmarkpos() call */
603-
604-
/*
605-
* Reset iterator
606-
*/
607-
tbm_begin_iterate(entry->partialMatch );
608-
entry->partialMatchResult=NULL;
609-
entry->offset=0;
610-
611-
/*
612-
* Temporary reset reduceResult flag to guarantee refinding
613-
* of curItem
614-
*/
615-
savedReduceResult=entry->reduceResult;
616-
entry->reduceResult= FALSE;
617-
618-
do
619-
{
620-
/*
621-
* We can use null instead of index because
622-
* partial match doesn't use it
623-
*/
624-
if (entryGetItem(NULL,entry )== false )
625-
elog(ERROR,"cannot refind scan position");/* must not be here! */
626-
}while(compareItemPointers(&stopItem,&entry->curItem )!=0 );
627-
628-
Assert(entry->isFinished== FALSE );
629-
630-
entry->reduceResult=savedReduceResult;
631-
}
632-
633585
/*
634586
* Sets key->curItem to new found heap item pointer for one scan key
635587
* Returns isFinished, ie TRUE means we did NOT get a new item pointer!

‎src/backend/access/gin/ginscan.c

Lines changed: 10 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
*$PostgreSQL: pgsql/src/backend/access/gin/ginscan.c,v 1.18 2008/09/04 11:47:05 teodor Exp $
11+
*$PostgreSQL: pgsql/src/backend/access/gin/ginscan.c,v 1.19 2008/10/20 13:39:44 teodor Exp $
1212
*-------------------------------------------------------------------------
1313
*/
1414

@@ -114,7 +114,7 @@ resetScanKeys(GinScanKey keys, uint32 nkeys)
114114
#endif
115115

116116
staticvoid
117-
freeScanKeys(GinScanKeykeys,uint32nkeys,boolremoveRes)
117+
freeScanKeys(GinScanKeykeys,uint32nkeys)
118118
{
119119
uint32i,
120120
j;
@@ -130,14 +130,13 @@ freeScanKeys(GinScanKey keys, uint32 nkeys, bool removeRes)
130130
{
131131
if (key->scanEntry[j].buffer!=InvalidBuffer)
132132
ReleaseBuffer(key->scanEntry[j].buffer);
133-
if (removeRes&&key->scanEntry[j].list)
133+
if (key->scanEntry[j].list)
134134
pfree(key->scanEntry[j].list);
135-
if (removeRes&&key->scanEntry[j].partialMatch)
135+
if (key->scanEntry[j].partialMatch)
136136
tbm_free(key->scanEntry[j].partialMatch);
137137
}
138138

139-
if (removeRes)
140-
pfree(key->entryRes);
139+
pfree(key->entryRes);
141140
pfree(key->scanEntry);
142141
}
143142

@@ -233,11 +232,10 @@ ginrescan(PG_FUNCTION_ARGS)
233232
}
234233
else
235234
{
236-
freeScanKeys(so->keys,so->nkeys, TRUE);
237-
freeScanKeys(so->markPos,so->nkeys, FALSE);
235+
freeScanKeys(so->keys,so->nkeys);
238236
}
239237

240-
so->markPos=so->keys=NULL;
238+
so->keys=NULL;
241239

242240
if (scankey&&scan->numberOfKeys>0)
243241
{
@@ -257,8 +255,7 @@ ginendscan(PG_FUNCTION_ARGS)
257255

258256
if (so!=NULL)
259257
{
260-
freeScanKeys(so->keys,so->nkeys, TRUE);
261-
freeScanKeys(so->markPos,so->nkeys, FALSE);
258+
freeScanKeys(so->keys,so->nkeys);
262259

263260
MemoryContextDelete(so->tempCtx);
264261

@@ -268,60 +265,16 @@ ginendscan(PG_FUNCTION_ARGS)
268265
PG_RETURN_VOID();
269266
}
270267

271-
staticGinScanKey
272-
copyScanKeys(GinScanKeykeys,uint32nkeys,boolrestart)
273-
{
274-
GinScanKeynewkeys;
275-
uint32i,
276-
j;
277-
278-
newkeys= (GinScanKey)palloc(sizeof(GinScanKeyData)*nkeys);
279-
memcpy(newkeys,keys,sizeof(GinScanKeyData)*nkeys);
280-
281-
for (i=0;i<nkeys;i++)
282-
{
283-
newkeys[i].scanEntry= (GinScanEntry)palloc(sizeof(GinScanEntryData)*keys[i].nentries);
284-
memcpy(newkeys[i].scanEntry,keys[i].scanEntry,sizeof(GinScanEntryData)*keys[i].nentries);
285-
286-
for (j=0;j<keys[i].nentries;j++)
287-
{
288-
if (keys[i].scanEntry[j].buffer!=InvalidBuffer)
289-
IncrBufferRefCount(keys[i].scanEntry[j].buffer);
290-
if (keys[i].scanEntry[j].master)
291-
{
292-
intmasterN=keys[i].scanEntry[j].master-keys[i].scanEntry;
293-
294-
newkeys[i].scanEntry[j].master=newkeys[i].scanEntry+masterN;
295-
}
296-
297-
if (restart )
298-
ginrestartentry(&keys[i].scanEntry[j] );
299-
}
300-
}
301-
302-
returnnewkeys;
303-
}
304-
305268
Datum
306269
ginmarkpos(PG_FUNCTION_ARGS)
307270
{
308-
IndexScanDescscan= (IndexScanDesc)PG_GETARG_POINTER(0);
309-
GinScanOpaqueso= (GinScanOpaque)scan->opaque;
310-
311-
freeScanKeys(so->markPos,so->nkeys, FALSE);
312-
so->markPos=copyScanKeys(so->keys,so->nkeys, FALSE);
313-
271+
elog(ERROR,"GIN does not support mark/restore");
314272
PG_RETURN_VOID();
315273
}
316274

317275
Datum
318276
ginrestrpos(PG_FUNCTION_ARGS)
319277
{
320-
IndexScanDescscan= (IndexScanDesc)PG_GETARG_POINTER(0);
321-
GinScanOpaqueso= (GinScanOpaque)scan->opaque;
322-
323-
freeScanKeys(so->keys,so->nkeys, FALSE);
324-
so->keys=copyScanKeys(so->markPos,so->nkeys, TRUE);
325-
278+
elog(ERROR,"GIN does not support mark/restore");
326279
PG_RETURN_VOID();
327280
}

‎src/backend/access/gist/gistget.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.76 2008/10/17 17:02:21 teodor Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.77 2008/10/20 13:39:44 teodor Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -494,16 +494,6 @@ gistfindnext(IndexScanDesc scan, OffsetNumber n, ScanDirection dir)
494494
*/
495495
oldcxt=MemoryContextSwitchTo(so->tempCxt);
496496

497-
/*
498-
* If we modified the index during the scan, we may have a pointer to a
499-
* ghost tuple, before the scan. If this is the case, back up one.
500-
*/
501-
if (so->flags&GS_CURBEFORE)
502-
{
503-
so->flags &= ~GS_CURBEFORE;
504-
n=OffsetNumberPrev(n);
505-
}
506-
507497
while (n >=FirstOffsetNumber&&n <=maxoff)
508498
{
509499
it= (IndexTuple)PageGetItem(p,PageGetItemId(p,n));

‎src/backend/access/gist/gistscan.c

Lines changed: 6 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.72 2008/10/17 17:02:21 teodor Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.73 2008/10/20 13:39:44 teodor Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -49,30 +49,21 @@ gistrescan(PG_FUNCTION_ARGS)
4949
{
5050
/* rescan an existing indexscan --- reset state */
5151
gistfreestack(so->stack);
52-
gistfreestack(so->markstk);
53-
so->stack=so->markstk=NULL;
54-
so->flags=0x0;
52+
so->stack=NULL;
5553
/* drop pins on buffers -- no locks held */
5654
if (BufferIsValid(so->curbuf))
5755
{
5856
ReleaseBuffer(so->curbuf);
5957
so->curbuf=InvalidBuffer;
6058
}
61-
if (BufferIsValid(so->markbuf))
62-
{
63-
ReleaseBuffer(so->markbuf);
64-
so->markbuf=InvalidBuffer;
65-
}
66-
6759
}
6860
else
6961
{
7062
/* initialize opaque data */
7163
so= (GISTScanOpaque)palloc(sizeof(GISTScanOpaqueData));
72-
so->stack=so->markstk=NULL;
73-
so->flags=0x0;
64+
so->stack=NULL;
7465
so->tempCxt=createTempGistContext();
75-
so->curbuf=so->markbuf=InvalidBuffer;
66+
so->curbuf=InvalidBuffer;
7667
so->giststate= (GISTSTATE*)palloc(sizeof(GISTSTATE));
7768
initGISTstate(so->giststate,scan->indexRelation);
7869

@@ -83,7 +74,6 @@ gistrescan(PG_FUNCTION_ARGS)
8374
* Clear all the pointers.
8475
*/
8576
ItemPointerSetInvalid(&so->curpos);
86-
ItemPointerSetInvalid(&so->markpos);
8777
so->nPageData=so->curPageData=0;
8878

8979
/* Update scan key, if a new one is given */
@@ -119,108 +109,14 @@ gistrescan(PG_FUNCTION_ARGS)
119109
Datum
120110
gistmarkpos(PG_FUNCTION_ARGS)
121111
{
122-
IndexScanDescscan= (IndexScanDesc)PG_GETARG_POINTER(0);
123-
GISTScanOpaqueso;
124-
GISTSearchStack*o,
125-
*n,
126-
*tmp;
127-
128-
so= (GISTScanOpaque)scan->opaque;
129-
so->markpos=so->curpos;
130-
if (so->flags&GS_CURBEFORE)
131-
so->flags |=GS_MRKBEFORE;
132-
else
133-
so->flags &= ~GS_MRKBEFORE;
134-
135-
o=NULL;
136-
n=so->stack;
137-
138-
/* copy the parent stack from the current item data */
139-
while (n!=NULL)
140-
{
141-
tmp= (GISTSearchStack*)palloc(sizeof(GISTSearchStack));
142-
tmp->lsn=n->lsn;
143-
tmp->parentlsn=n->parentlsn;
144-
tmp->block=n->block;
145-
tmp->next=o;
146-
o=tmp;
147-
n=n->next;
148-
}
149-
150-
gistfreestack(so->markstk);
151-
so->markstk=o;
152-
153-
/* Update markbuf: make sure to bump ref count on curbuf */
154-
if (BufferIsValid(so->markbuf))
155-
{
156-
ReleaseBuffer(so->markbuf);
157-
so->markbuf=InvalidBuffer;
158-
}
159-
if (BufferIsValid(so->curbuf))
160-
{
161-
IncrBufferRefCount(so->curbuf);
162-
so->markbuf=so->curbuf;
163-
}
164-
165-
so->markNPageData=so->nPageData;
166-
so->markCurPageData=so->curPageData;
167-
if (so->markNPageData>0 )
168-
memcpy(so->markPageData,so->pageData,sizeof(ItemResult)*so->markNPageData );
169-
112+
elog(ERROR,"GiST does not support mark/restore");
170113
PG_RETURN_VOID();
171114
}
172115

173116
Datum
174117
gistrestrpos(PG_FUNCTION_ARGS)
175118
{
176-
IndexScanDescscan= (IndexScanDesc)PG_GETARG_POINTER(0);
177-
GISTScanOpaqueso;
178-
GISTSearchStack*o,
179-
*n,
180-
*tmp;
181-
182-
so= (GISTScanOpaque)scan->opaque;
183-
so->curpos=so->markpos;
184-
if (so->flags&GS_MRKBEFORE)
185-
so->flags |=GS_CURBEFORE;
186-
else
187-
so->flags &= ~GS_CURBEFORE;
188-
189-
o=NULL;
190-
n=so->markstk;
191-
192-
/* copy the parent stack from the current item data */
193-
while (n!=NULL)
194-
{
195-
tmp= (GISTSearchStack*)palloc(sizeof(GISTSearchStack));
196-
tmp->lsn=n->lsn;
197-
tmp->parentlsn=n->parentlsn;
198-
tmp->block=n->block;
199-
tmp->next=o;
200-
o=tmp;
201-
n=n->next;
202-
}
203-
204-
gistfreestack(so->stack);
205-
so->stack=o;
206-
207-
/* Update curbuf: be sure to bump ref count on markbuf */
208-
if (BufferIsValid(so->curbuf))
209-
{
210-
ReleaseBuffer(so->curbuf);
211-
so->curbuf=InvalidBuffer;
212-
}
213-
if (BufferIsValid(so->markbuf))
214-
{
215-
IncrBufferRefCount(so->markbuf);
216-
so->curbuf=so->markbuf;
217-
}
218-
219-
so->nPageData=so->markNPageData;
220-
so->curPageData=so->markNPageData;
221-
if (so->markNPageData>0 )
222-
memcpy(so->pageData,so->markPageData,sizeof(ItemResult)*so->markNPageData );
223-
119+
elog(ERROR,"GiST does not support mark/restore");
224120
PG_RETURN_VOID();
225121
}
226122

@@ -235,14 +131,11 @@ gistendscan(PG_FUNCTION_ARGS)
235131
if (so!=NULL)
236132
{
237133
gistfreestack(so->stack);
238-
gistfreestack(so->markstk);
239134
if (so->giststate!=NULL)
240135
freeGISTstate(so->giststate);
241136
/* drop pins on buffers -- we aren't holding any locks */
242137
if (BufferIsValid(so->curbuf))
243138
ReleaseBuffer(so->curbuf);
244-
if (BufferIsValid(so->markbuf))
245-
ReleaseBuffer(so->markbuf);
246139
MemoryContextDelete(so->tempCxt);
247140
pfree(scan->opaque);
248141
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp