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

Commitfcf4b14

Browse files
committed
Simplify pg_am representation of ordering-capable access methods:
provide just a boolean 'amcanorder', instead of fields that specify thesort operator strategy numbers. We have decided to require ordering-capableAMs to use btree-compatible strategy numbers, so the old fields areoverkill (and indeed misleading about what's allowed).
1 parentc82cc60 commitfcf4b14

File tree

8 files changed

+58
-80
lines changed

8 files changed

+58
-80
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.141 2007/01/09 02:14:09 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.142 2007/01/20 23:13:01 tgl Exp $ -->
22
<!--
33
Documentation of the system catalogs, directed toward PostgreSQL developers
44
-->
@@ -365,21 +365,10 @@
365365
</row>
366366

367367
<row>
368-
<entry><structfield>amorderstrategy</structfield></entry>
369-
<entry><type>int2</type></entry>
370-
<entry></entry>
371-
<entry>Zero if the index offers no sort order, otherwise the strategy
372-
number of the strategy operator that describes the default
373-
(<literal>ASC</>) sort order</entry>
374-
</row>
375-
376-
<row>
377-
<entry><structfield>amdescorder</structfield></entry>
378-
<entry><type>int2</type></entry>
368+
<entry><structfield>amcanorder</structfield></entry>
369+
<entry><type>bool</type></entry>
379370
<entry></entry>
380-
<entry>Zero if the index offers no sort order, otherwise the strategy
381-
number of the strategy operator that describes the <literal>DESC</>
382-
sort order</entry>
371+
<entry>Does the access method support ordered scans?</entry>
383372
</row>
384373

385374
<row>

‎doc/src/sgml/indexam.sgml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/indexam.sgml,v 2.19 2006/12/23 00:43:08 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/indexam.sgml,v 2.20 2007/01/20 23:13:01 tgl Exp $ -->
22

33
<chapter id="indexam">
44
<title>Index Access Method Interface Definition</title>
@@ -442,6 +442,15 @@ amrestrpos (IndexScanDesc scan);
442442
the scan keys to a <quote>normalized</> form.
443443
</para>
444444

445+
<para>
446+
Some access methods return index entries in a well-defined order, others
447+
do not. If entries are returned in sorted order, the access method should
448+
set <structname>pg_am</>.<structfield>amcanorder</> true to indicate that
449+
it supports ordered scans.
450+
All such access methods must use btree-compatible strategy numbers for
451+
their equality and ordering operators.
452+
</para>
453+
445454
<para>
446455
The <function>amgettuple</> function has a <literal>direction</> argument,
447456
which can be either <literal>ForwardScanDirection</> (the normal case)
@@ -451,8 +460,7 @@ amrestrpos (IndexScanDesc scan);
451460
the normal front-to-back direction, so <function>amgettuple</> must return
452461
the last matching tuple in the index, rather than the first one as it
453462
normally would. (This will only occur for access
454-
methods that advertise they support ordered scans by setting
455-
<structname>pg_am</>.<structfield>amorderstrategy</> nonzero.) After the
463+
methods that advertise they support ordered scans.) After the
456464
first call, <function>amgettuple</> must be prepared to advance the scan in
457465
either direction from the most recently returned entry.
458466
</para>

‎doc/src/sgml/xindex.sgml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/xindex.sgml,v 1.54 2007/01/09 02:14:10 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/xindex.sgml,v 1.55 2007/01/20 23:13:01 tgl Exp $ -->
22

33
<sect1 id="xindex">
44
<title>Interfacing Extensions To Indexes</title>
@@ -287,20 +287,6 @@
287287
return type <type>boolean</type>, since they must appear at the top
288288
level of a <literal>WHERE</> clause to be used with an index.
289289
</para>
290-
291-
<para>
292-
By the way, the <structfield>amorderstrategy</structfield> and
293-
<structfield>amdescorder</structfield> columns in <classname>pg_am</> tell
294-
whether the index method supports ordered scans. Zeroes mean it doesn't;
295-
if it does, <structfield>amorderstrategy</structfield> is the strategy
296-
number that corresponds to the default ordering operator, and
297-
<structfield>amdescorder</structfield> is the strategy number for the
298-
ordering operator of an index column that has the <literal>DESC</> option.
299-
For example, B-tree has <structfield>amorderstrategy</structfield> = 1,
300-
which is its <quote>less than</quote> strategy number, and
301-
<structfield>amdescorder</structfield> = 5, which is its
302-
<quote>greater than</quote> strategy number.
303-
</para>
304290
</sect2>
305291

306292
<sect2 id="xindex-support">

‎src/backend/commands/indexcmds.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.152 2007/01/09 02:14:11 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.153 2007/01/20 23:13:01 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -295,8 +295,7 @@ DefineIndex(RangeVar *heapRelation,
295295
errmsg("access method \"%s\" does not support multicolumn indexes",
296296
accessMethodName)));
297297

298-
amcanorder= (accessMethodForm->amorderstrategy>0);
299-
298+
amcanorder=accessMethodForm->amcanorder;
300299
amoptions=accessMethodForm->amoptions;
301300

302301
ReleaseSysCache(tuple);

‎src/backend/optimizer/util/plancat.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.131 2007/01/09 02:14:13 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.132 2007/01/20 23:13:01 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -190,8 +190,10 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
190190

191191
/*
192192
* Fetch the ordering operators associated with the index, if any.
193+
* We expect that all ordering-capable indexes use btree's
194+
* strategy numbers for the ordering operators.
193195
*/
194-
if (indexRelation->rd_am->amorderstrategy>0)
196+
if (indexRelation->rd_am->amcanorder)
195197
{
196198
intnstrat=indexRelation->rd_am->amstrategies;
197199

@@ -203,17 +205,17 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
203205

204206
if (opt&INDOPTION_DESC)
205207
{
206-
fwdstrat=indexRelation->rd_am->amdescorder;
207-
revstrat=indexRelation->rd_am->amorderstrategy;
208+
fwdstrat=BTGreaterStrategyNumber;
209+
revstrat=BTLessStrategyNumber;
208210
}
209211
else
210212
{
211-
fwdstrat=indexRelation->rd_am->amorderstrategy;
212-
revstrat=indexRelation->rd_am->amdescorder;
213+
fwdstrat=BTLessStrategyNumber;
214+
revstrat=BTGreaterStrategyNumber;
213215
}
214216
/*
215217
* Index AM must have a fixed set of strategies for it
216-
* to make sense to specifyamorderstrategy, so we
218+
* to make sense to specifyamcanorder, so we
217219
* need not allow the case amstrategies == 0.
218220
*/
219221
if (fwdstrat>0)

‎src/backend/utils/adt/ruleutils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.244 2007/01/2001:08:42 neilc Exp $
12+
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.245 2007/01/2023:13:01 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -767,7 +767,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, int prettyFlags)
767767
&buf);
768768

769769
/* Add options if relevant */
770-
if (amrec->amorderstrategy>0)
770+
if (amrec->amcanorder)
771771
{
772772
/* if it supports sort ordering, report DESC and NULLS opts */
773773
if (opt&INDOPTION_DESC)

‎src/include/catalog/catversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.374 2007/01/2021:47:10 neilc Exp $
40+
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.375 2007/01/2023:13:01 tgl Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO200701202
56+
#defineCATALOG_VERSION_NO200701203
5757

5858
#endif

‎src/include/catalog/pg_am.h

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $PostgreSQL: pgsql/src/include/catalog/pg_am.h,v 1.49 2007/01/09 02:14:15 tgl Exp $
11+
* $PostgreSQL: pgsql/src/include/catalog/pg_am.h,v 1.50 2007/01/20 23:13:01 tgl Exp $
1212
*
1313
* NOTES
1414
*the genbki.sh script reads this file and generates .bki
@@ -45,12 +45,7 @@ CATALOG(pg_am,2601)
4545
* strategy assignments. */
4646
int2amsupport;/* total number of support functions that this
4747
* AM uses */
48-
int2amorderstrategy;/* if this AM has a sort order, the strategy
49-
* number of the default (ASC) sort operator.
50-
* Zero if AM is not ordered. */
51-
int2amdescorder;/* if this AM has a sort order, the strategy
52-
* number of the DESC sort operator.
53-
* Zero if AM is not ordered. */
48+
boolamcanorder;/* does AM support ordered scan results? */
5449
boolamcanunique;/* does AM support UNIQUE indexes? */
5550
boolamcanmulticol;/* does AM support multi-column indexes? */
5651
boolamoptionalkey;/* can query omit key for the first column? */
@@ -83,47 +78,46 @@ typedef FormData_pg_am *Form_pg_am;
8378
*compiler constants for pg_am
8479
* ----------------
8580
*/
86-
#defineNatts_pg_am24
81+
#defineNatts_pg_am23
8782
#defineAnum_pg_am_amname1
8883
#defineAnum_pg_am_amstrategies2
8984
#defineAnum_pg_am_amsupport3
90-
#defineAnum_pg_am_amorderstrategy4
91-
#defineAnum_pg_am_amdescorder5
92-
#defineAnum_pg_am_amcanunique6
93-
#defineAnum_pg_am_amcanmulticol7
94-
#defineAnum_pg_am_amoptionalkey8
95-
#defineAnum_pg_am_amindexnulls9
96-
#defineAnum_pg_am_amstorage10
97-
#defineAnum_pg_am_amclusterable11
98-
#defineAnum_pg_am_aminsert12
99-
#defineAnum_pg_am_ambeginscan13
100-
#defineAnum_pg_am_amgettuple14
101-
#defineAnum_pg_am_amgetmulti15
102-
#defineAnum_pg_am_amrescan16
103-
#defineAnum_pg_am_amendscan17
104-
#defineAnum_pg_am_ammarkpos18
105-
#defineAnum_pg_am_amrestrpos19
106-
#defineAnum_pg_am_ambuild20
107-
#defineAnum_pg_am_ambulkdelete21
108-
#defineAnum_pg_am_amvacuumcleanup22
109-
#defineAnum_pg_am_amcostestimate23
110-
#defineAnum_pg_am_amoptions24
85+
#defineAnum_pg_am_amcanorder4
86+
#defineAnum_pg_am_amcanunique5
87+
#defineAnum_pg_am_amcanmulticol6
88+
#defineAnum_pg_am_amoptionalkey7
89+
#defineAnum_pg_am_amindexnulls8
90+
#defineAnum_pg_am_amstorage9
91+
#defineAnum_pg_am_amclusterable10
92+
#defineAnum_pg_am_aminsert11
93+
#defineAnum_pg_am_ambeginscan12
94+
#defineAnum_pg_am_amgettuple13
95+
#defineAnum_pg_am_amgetmulti14
96+
#defineAnum_pg_am_amrescan15
97+
#defineAnum_pg_am_amendscan16
98+
#defineAnum_pg_am_ammarkpos17
99+
#defineAnum_pg_am_amrestrpos18
100+
#defineAnum_pg_am_ambuild19
101+
#defineAnum_pg_am_ambulkdelete20
102+
#defineAnum_pg_am_amvacuumcleanup21
103+
#defineAnum_pg_am_amcostestimate22
104+
#defineAnum_pg_am_amoptions23
111105

112106
/* ----------------
113107
*initial contents of pg_am
114108
* ----------------
115109
*/
116110

117-
DATA(insertOID=403 (btree5115ttttftbtinsertbtbeginscanbtgettuplebtgetmultibtrescanbtendscanbtmarkposbtrestrposbtbuildbtbulkdeletebtvacuumcleanupbtcostestimatebtoptions ));
111+
DATA(insertOID=403 (btree51tttttftbtinsertbtbeginscanbtgettuplebtgetmultibtrescanbtendscanbtmarkposbtrestrposbtbuildbtbulkdeletebtvacuumcleanupbtcostestimatebtoptions ));
118112
DESCR("b-tree index access method");
119113
#defineBTREE_AM_OID 403
120-
DATA(insertOID=405 (hash1100ffffffhashinserthashbeginscanhashgettuplehashgetmultihashrescanhashendscanhashmarkposhashrestrposhashbuildhashbulkdeletehashvacuumcleanuphashcostestimatehashoptions ));
114+
DATA(insertOID=405 (hash11fffffffhashinserthashbeginscanhashgettuplehashgetmultihashrescanhashendscanhashmarkposhashrestrposhashbuildhashbulkdeletehashvacuumcleanuphashcostestimatehashoptions ));
121115
DESCR("hash index access method");
122116
#defineHASH_AM_OID 405
123-
DATA(insertOID=783 (gist0700ftttttgistinsertgistbeginscangistgettuplegistgetmultigistrescangistendscangistmarkposgistrestrposgistbuildgistbulkdeletegistvacuumcleanupgistcostestimategistoptions ));
117+
DATA(insertOID=783 (gist07fftttttgistinsertgistbeginscangistgettuplegistgetmultigistrescangistendscangistmarkposgistrestrposgistbuildgistbulkdeletegistvacuumcleanupgistcostestimategistoptions ));
124118
DESCR("GiST index access method");
125119
#defineGIST_AM_OID 783
126-
DATA(insertOID=2742 (gin0400fffftfgininsertginbeginscangingettuplegingetmultiginrescanginendscanginmarkposginrestrposginbuildginbulkdeleteginvacuumcleanupgincostestimateginoptions ));
120+
DATA(insertOID=2742 (gin04ffffftfgininsertginbeginscangingettuplegingetmultiginrescanginendscanginmarkposginrestrposginbuildginbulkdeleteginvacuumcleanupgincostestimateginoptions ));
127121
DESCR("GIN index access method");
128122
#defineGIN_AM_OID 2742
129123

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp