Skip to content

Commit 873b106

Browse files
committed
Add support PostgreSQL 11devel
1 parent 0f8c311 commit 873b106

File tree

9 files changed

+221
-195
lines changed

9 files changed

+221
-195
lines changed

src/rum.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,13 @@ typedef struct RumState
391391
Oid supportCollation[INDEX_MAX_KEYS];
392392
} RumState;
393393

394+
/* Accessor for the i'th attribute of tupdesc. */
395+
#if PG_VERSION_NUM > 100000
396+
#define RumTupleDescAttr(tupdesc, i) (TupleDescAttr(tupdesc, i))
397+
#else
398+
#define RumTupleDescAttr(tupdesc, i) ((tupdesc)->attrs[(i)])
399+
#endif
400+
394401
/* rumutil.c */
395402
extern bytea *rumoptions(Datum reloptions, bool validate);
396403
extern Datum rumhandler(PG_FUNCTION_ARGS);
@@ -662,7 +669,7 @@ typedef struct RumScanEntryData
662669
* For a partial-match or full-scan query, we accumulate all TIDs and
663670
* and additional information here
664671
*/
665-
Tuplesortstate *matchSortstate;
672+
RumTuplesortstate *matchSortstate;
666673
RumScanItem collectRumItem;
667674

668675
/* for full-scan query with order-by */
@@ -722,7 +729,7 @@ typedef struct RumScanOpaqueData
722729
uint32 allocentries; /* allocated length of entries[] and
723730
sortedEntries[] */
724731

725-
Tuplesortstate *sortstate;
732+
RumTuplesortstate *sortstate;
726733
int norderbys; /* Number of columns in ordering.
727734
Will be assigned to sortstate->nKeys */
728735

src/rum_arr_utils.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
#define DIST_FROM_SML(sml) \
7373
( (sml == 0.0) ? get_float8_infinity() : ((float8) 1) / ((float8) (sml)) )
7474

75+
#if PG_VERSION_NUM <= 100000
76+
#define HASHSTANDARD_PROC HASHPROC
77+
#endif
78+
7579

7680
typedef struct AnyArrayTypeInfo
7781
{
@@ -583,15 +587,15 @@ getAMProc(Oid amOid, Oid typid)
583587

584588
procOid = get_opfamily_proc(get_opclass_family(opclassOid),
585589
typid, typid,
586-
(amOid == BTREE_AM_OID) ? BTORDER_PROC : HASHPROC);
590+
(amOid == BTREE_AM_OID) ? BTORDER_PROC : HASHSTANDARD_PROC);
587591

588592
if (!OidIsValid(procOid))
589593
{
590594
typid = get_opclass_input_type(opclassOid);
591595

592596
procOid = get_opfamily_proc(get_opclass_family(opclassOid),
593597
typid, typid,
594-
(amOid == BTREE_AM_OID) ? BTORDER_PROC : HASHPROC);
598+
(amOid == BTREE_AM_OID) ? BTORDER_PROC : HASHSTANDARD_PROC);
595599
}
596600

597601
return procOid;

src/rumbulk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ rumInitBA(BuildAccumulator *accum)
123123
static Datum
124124
getDatumCopy(BuildAccumulator *accum, OffsetNumber attnum, Datum value)
125125
{
126-
Form_pg_attribute att = accum->rumstate->origTupdesc->attrs[attnum - 1];
126+
Form_pg_attribute att = RumTupleDescAttr(accum->rumstate->origTupdesc, attnum - 1);
127127
Datum res;
128128

129129
if (att->attbyval)

src/rumget.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ collectMatchBitmap(RumBtreeData * btree, RumBtreeStack * stack,
313313

314314
/* Locate tupdesc entry for key column (for attbyval/attlen data) */
315315
attnum = scanEntry->attnumOrig;
316-
attr = rumstate->origTupdesc->attrs[attnum - 1];
316+
attr = RumTupleDescAttr(rumstate->origTupdesc, attnum - 1);
317317

318318
for (;;)
319319
{

src/ruminsert.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,13 @@ rumHeapTupleBulkInsert(RumBuildState * buildstate, OffsetNumber attnum,
516516
{
517517
/* Check existance of additional information attribute in index */
518518
if (!attr)
519+
{
520+
Form_pg_attribute attr = RumTupleDescAttr(
521+
buildstate->rumstate.origTupdesc, attnum - 1);
522+
519523
elog(ERROR, "additional information attribute \"%s\" is not found in index",
520-
NameStr(buildstate->rumstate.origTupdesc->attrs[attnum - 1]->attname));
524+
NameStr(attr->attname));
525+
}
521526

522527
addInfo[i] = datumCopy(addInfo[i], attr->attbyval, attr->attlen);
523528
}
@@ -775,8 +780,13 @@ rumHeapTupleInsert(RumState * rumstate, OffsetNumber attnum,
775780

776781
/* Check existance of additional information attribute in index */
777782
if (!addInfoIsNull[i] && !rumstate->addAttrs[attnum - 1])
783+
{
784+
Form_pg_attribute attr = RumTupleDescAttr(rumstate->origTupdesc,
785+
attnum - 1);
786+
778787
elog(ERROR, "additional information attribute \"%s\" is not found in index",
779-
NameStr(rumstate->origTupdesc->attrs[attnum - 1]->attname));
788+
NameStr(attr->attname));
789+
}
780790

781791
insert_item.iptr = *item;
782792
insert_item.addInfo = addInfo[i];

src/rumscan.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,12 @@ rumFillScanKey(RumScanOpaque so, OffsetNumber attnum,
182182
/* ...add key to order by index key value */
183183
key->useCurKey)
184184
{
185+
Form_pg_attribute attr = RumTupleDescAttr(rumstate->origTupdesc,
186+
attnum - 1);
187+
185188
if (nQueryValues != 1)
186189
elog(ERROR, "extractQuery should return only one value for ordering");
187-
if (rumstate->origTupdesc->attrs[key->attnum - 1]->attbyval == false)
190+
if (attr->attbyval == false)
188191
elog(ERROR, "doesn't support order by over pass-by-reference column");
189192

190193
if (key->attnum == rumstate->attrnAttachColumn)

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