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

Commit0489783

Browse files
committed
Adjust amrescan code so that it's allowed to call index_rescan with a
NULL key pointer, indicating that the existing scan key should be reused.This behavior isn't used yet but will be needed for my planned fix tothe keys_are_unique code.
1 parentcb1672e commit0489783

File tree

5 files changed

+64
-73
lines changed

5 files changed

+64
-73
lines changed

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

Lines changed: 24 additions & 32 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-
* $Header: /cvsroot/pgsql/src/backend/access/gist/gistscan.c,v 1.43 2002/06/20 20:29:24 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/gist/gistscan.c,v 1.44 2003/03/23 23:01:02 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -78,28 +78,14 @@ gistrescan(PG_FUNCTION_ARGS)
7878
ItemPointerSetInvalid(&s->currentItemData);
7979
ItemPointerSetInvalid(&s->currentMarkData);
8080

81-
if (s->numberOfKeys>0)
82-
{
83-
memmove(s->keyData,
84-
key,
85-
s->numberOfKeys*sizeof(ScanKeyData));
86-
}
87-
8881
p= (GISTScanOpaque)s->opaque;
8982
if (p!= (GISTScanOpaque)NULL)
9083
{
84+
/* rescan an existing indexscan --- reset state */
9185
gistfreestack(p->s_stack);
9286
gistfreestack(p->s_markstk);
9387
p->s_stack=p->s_markstk= (GISTSTACK*)NULL;
9488
p->s_flags=0x0;
95-
for (i=0;i<s->numberOfKeys;i++)
96-
{
97-
s->keyData[i].sk_procedure
98-
=RelationGetGISTStrategy(s->indexRelation,
99-
s->keyData[i].sk_attno,
100-
s->keyData[i].sk_procedure);
101-
s->keyData[i].sk_func=p->giststate->consistentFn[s->keyData[i].sk_attno-1];
102-
}
10389
}
10490
else
10591
{
@@ -110,22 +96,28 @@ gistrescan(PG_FUNCTION_ARGS)
11096
s->opaque=p;
11197
p->giststate= (GISTSTATE*)palloc(sizeof(GISTSTATE));
11298
initGISTstate(p->giststate,s->indexRelation);
113-
if (s->numberOfKeys>0)
114-
115-
/*
116-
* * Play games here with the scan key to use the Consistent *
117-
* function for all comparisons: * 1) the sk_procedure field
118-
* will now be used to hold the * strategy number * 2) the
119-
* sk_func field will point to the Consistent function
120-
*/
121-
for (i=0;i<s->numberOfKeys;i++)
122-
{
123-
s->keyData[i].sk_procedure=
124-
RelationGetGISTStrategy(s->indexRelation,
125-
s->keyData[i].sk_attno,
126-
s->keyData[i].sk_procedure);
127-
s->keyData[i].sk_func=p->giststate->consistentFn[s->keyData[i].sk_attno-1];
128-
}
99+
}
100+
101+
/* Update scan key, if a new one is given */
102+
if (key&&s->numberOfKeys>0)
103+
{
104+
memmove(s->keyData,
105+
key,
106+
s->numberOfKeys*sizeof(ScanKeyData));
107+
/*
108+
* Play games here with the scan key to use the Consistent
109+
* function for all comparisons: 1) the sk_procedure field
110+
* will now be used to hold the strategy number 2) the
111+
* sk_func field will point to the Consistent function
112+
*/
113+
for (i=0;i<s->numberOfKeys;i++)
114+
{
115+
s->keyData[i].sk_procedure=
116+
RelationGetGISTStrategy(s->indexRelation,
117+
s->keyData[i].sk_attno,
118+
s->keyData[i].sk_procedure);
119+
s->keyData[i].sk_func=p->giststate->consistentFn[s->keyData[i].sk_attno-1];
120+
}
129121
}
130122

131123
PG_RETURN_VOID();

‎src/backend/access/hash/hash.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.62 2003/02/24 00:57:17 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.63 2003/03/23 23:01:03 tgl Exp $
1212
*
1313
* NOTES
1414
* This file contains only the public interface routines.
@@ -302,10 +302,8 @@ hashrescan(PG_FUNCTION_ARGS)
302302
{
303303
IndexScanDescscan= (IndexScanDesc)PG_GETARG_POINTER(0);
304304
ScanKeyscankey= (ScanKey)PG_GETARG_POINTER(1);
305+
HashScanOpaqueso= (HashScanOpaque)scan->opaque;
305306
ItemPointeriptr;
306-
HashScanOpaqueso;
307-
308-
so= (HashScanOpaque)scan->opaque;
309307

310308
/* we hold a read lock on the current page in the scan */
311309
if (ItemPointerIsValid(iptr=&(scan->currentItemData)))
@@ -321,8 +319,8 @@ hashrescan(PG_FUNCTION_ARGS)
321319
ItemPointerSetInvalid(iptr);
322320
}
323321

324-
/*reset thescan key */
325-
if (scan->numberOfKeys>0)
322+
/*Updatescan key, if a new one is given */
323+
if (scankey&&scan->numberOfKeys>0)
326324
{
327325
memmove(scan->keyData,
328326
scankey,

‎src/backend/access/index/indexam.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.64 2003/02/22 00:45:03 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.65 2003/03/23 23:01:03 tgl Exp $
1212
*
1313
* INTERFACE ROUTINES
1414
*index_open- open an index relation by relation OID
@@ -294,8 +294,12 @@ index_beginscan(Relation heapRelation,
294294
*index_rescan - (re)start a scan of an index
295295
*
296296
* The caller may specify a new set of scankeys (but the number of keys
297-
* cannot change).Note that this is also called when first starting
298-
* an indexscan; see RelationGetIndexScan.
297+
* cannot change). To restart the scan without changing keys, pass NULL
298+
* for the key array.
299+
*
300+
* Note that this is also called when first starting an indexscan;
301+
* see RelationGetIndexScan. Keys *must* be passed in that case,
302+
* unless scan->numberOfKeys is zero.
299303
* ----------------
300304
*/
301305
void

‎src/backend/access/nbtree/nbtree.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
1414
* IDENTIFICATION
15-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.101 2003/03/04 21:51:20 tgl Exp $
15+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.102 2003/03/23 23:01:03 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -396,6 +396,7 @@ btrescan(PG_FUNCTION_ARGS)
396396
so->keyData= (ScanKey)palloc(scan->numberOfKeys*sizeof(ScanKeyData));
397397
else
398398
so->keyData= (ScanKey)NULL;
399+
so->numberOfKeys=scan->numberOfKeys;
399400
scan->opaque=so;
400401
}
401402

@@ -420,12 +421,12 @@ btrescan(PG_FUNCTION_ARGS)
420421
* Reset the scan keys. Note that keys ordering stuff moved to
421422
* _bt_first. - vadim 05/05/97
422423
*/
423-
so->numberOfKeys=scan->numberOfKeys;
424-
if (scan->numberOfKeys>0)
424+
if (scankey&&scan->numberOfKeys>0)
425425
{
426426
memmove(scan->keyData,
427427
scankey,
428428
scan->numberOfKeys*sizeof(ScanKeyData));
429+
so->numberOfKeys=scan->numberOfKeys;
429430
memmove(so->keyData,
430431
scankey,
431432
so->numberOfKeys*sizeof(ScanKeyData));

‎src/backend/access/rtree/rtscan.c

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.42 2002/06/20 20:29:25 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.43 2003/03/23 23:01:03 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -80,22 +80,14 @@ rtrescan(PG_FUNCTION_ARGS)
8080
ItemPointerSetInvalid(&s->currentItemData);
8181
ItemPointerSetInvalid(&s->currentMarkData);
8282

83-
if (s->numberOfKeys>0)
84-
{
85-
memmove(s->keyData,
86-
key,
87-
s->numberOfKeys*sizeof(ScanKeyData));
88-
}
89-
9083
p= (RTreeScanOpaque)s->opaque;
9184
if (p!= (RTreeScanOpaque)NULL)
9285
{
86+
/* rescan an existing indexscan --- reset state */
9387
freestack(p->s_stack);
9488
freestack(p->s_markstk);
9589
p->s_stack=p->s_markstk= (RTSTACK*)NULL;
9690
p->s_flags=0x0;
97-
for (i=0;i<s->numberOfKeys;i++)
98-
p->s_internalKey[i].sk_argument=s->keyData[i].sk_argument;
9991
}
10092
else
10193
{
@@ -106,28 +98,32 @@ rtrescan(PG_FUNCTION_ARGS)
10698
p->s_flags=0x0;
10799
s->opaque=p;
108100
if (s->numberOfKeys>0)
109-
{
110101
p->s_internalKey= (ScanKey)palloc(sizeof(ScanKeyData)*s->numberOfKeys);
102+
}
111103

112-
/*
113-
* Scans on internal pages use different operators than they
114-
* do on leaf pages. For example, if the user wants all boxes
115-
* that exactly match (x1,y1,x2,y2), then on internal pages we
116-
* need to find all boxes that contain (x1,y1,x2,y2).
117-
*/
104+
/* Update scan key, if a new one is given */
105+
if (key&&s->numberOfKeys>0)
106+
{
107+
memmove(s->keyData,
108+
key,
109+
s->numberOfKeys*sizeof(ScanKeyData));
118110

119-
for (i=0;i<s->numberOfKeys;i++)
120-
{
121-
p->s_internalKey[i].sk_argument=s->keyData[i].sk_argument;
122-
internal_proc=RTMapOperator(s->indexRelation,
123-
s->keyData[i].sk_attno,
124-
s->keyData[i].sk_procedure);
125-
ScanKeyEntryInitialize(&(p->s_internalKey[i]),
126-
s->keyData[i].sk_flags,
127-
s->keyData[i].sk_attno,
128-
internal_proc,
129-
s->keyData[i].sk_argument);
130-
}
111+
/*
112+
* Scans on internal pages use different operators than they
113+
* do on leaf pages. For example, if the user wants all boxes
114+
* that exactly match (x1,y1,x2,y2), then on internal pages we
115+
* need to find all boxes that contain (x1,y1,x2,y2).
116+
*/
117+
for (i=0;i<s->numberOfKeys;i++)
118+
{
119+
internal_proc=RTMapOperator(s->indexRelation,
120+
s->keyData[i].sk_attno,
121+
s->keyData[i].sk_procedure);
122+
ScanKeyEntryInitialize(&(p->s_internalKey[i]),
123+
s->keyData[i].sk_flags,
124+
s->keyData[i].sk_attno,
125+
internal_proc,
126+
s->keyData[i].sk_argument);
131127
}
132128
}
133129

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp