mirror of
https://github.com/HypoPG/hypopg
synced 2026-05-24 01:28:51 +00:00
Fix compatibility for pg12.
This commit is contained in:
parent
82db543aff
commit
4e6fce31c7
4 changed files with 47 additions and 6 deletions
|
|
@ -44,10 +44,17 @@
|
|||
#include "catalog/pg_opclass.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "commands/defrem.h"
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
#include "nodes/makefuncs.h"
|
||||
#endif
|
||||
#include "optimizer/clauses.h"
|
||||
#include "optimizer/cost.h"
|
||||
#include "optimizer/pathnode.h"
|
||||
#if PG_VERSION_NUM < 120000
|
||||
#include "optimizer/var.h"
|
||||
#else
|
||||
#include "optimizer/optimizer.h"
|
||||
#endif
|
||||
#include "parser/parse_utilcmd.h"
|
||||
#include "parser/parser.h"
|
||||
#include "storage/bufmgr.h"
|
||||
|
|
@ -112,6 +119,7 @@ hypo_newIndex(Oid relid, char *accessMethod, int nkeycolumns, int ninccolumns,
|
|||
hypoIndex *volatile entry;
|
||||
MemoryContext oldcontext;
|
||||
HeapTuple tuple;
|
||||
Oid oid;
|
||||
|
||||
#if PG_VERSION_NUM >= 90600
|
||||
IndexAmRoutine *amroutine;
|
||||
|
|
@ -130,13 +138,19 @@ hypo_newIndex(Oid relid, char *accessMethod, int nkeycolumns, int ninccolumns,
|
|||
accessMethod)));
|
||||
}
|
||||
|
||||
hypo_discover_am(accessMethod, HeapTupleGetOid(tuple));
|
||||
#if PG_VERSION_NUM < 120000
|
||||
oid = HeapTupleGetOid(tuple);
|
||||
#else
|
||||
oid = ((Form_pg_am) GETSTRUCT(tuple))->oid;
|
||||
#endif
|
||||
|
||||
hypo_discover_am(accessMethod, oid);
|
||||
|
||||
oldcontext = MemoryContextSwitchTo(HypoMemoryContext);
|
||||
|
||||
entry = palloc0(sizeof(hypoIndex));
|
||||
|
||||
entry->relam = HeapTupleGetOid(tuple);
|
||||
entry->relam = oid;
|
||||
|
||||
#if PG_VERSION_NUM >= 90600
|
||||
|
||||
|
|
@ -544,10 +558,17 @@ hypo_index_store_parsetree(IndexStmt *node, const char *queryString)
|
|||
}
|
||||
|
||||
/* get the opclass */
|
||||
#if PG_VERSION_NUM < 100000
|
||||
opclass = GetIndexOpClass(attribute->opclass,
|
||||
atttype,
|
||||
node->accessMethod,
|
||||
entry->relam);
|
||||
#else
|
||||
opclass = ResolveOpClass(attribute->opclass,
|
||||
atttype,
|
||||
node->accessMethod,
|
||||
entry->relam);
|
||||
#endif
|
||||
entry->opclass[attn] = opclass;
|
||||
/* setup the opfamily */
|
||||
entry->opfamily[attn] = get_opclass_family(opclass);
|
||||
|
|
@ -606,7 +627,11 @@ hypo_index_store_parsetree(IndexStmt *node, const char *queryString)
|
|||
{
|
||||
AttrNumber attno = entry->indexkeys[attn];
|
||||
|
||||
if (attno < 0 && attno != ObjectIdAttributeNumber)
|
||||
if (attno < 0
|
||||
#if PG_VERSION_NUM < 120000
|
||||
&& attno != ObjectIdAttributeNumber
|
||||
#endif
|
||||
)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("hypopg: index creation on system columns is not supported")));
|
||||
|
|
@ -696,7 +721,10 @@ hypo_index_store_parsetree(IndexStmt *node, const char *queryString)
|
|||
|
||||
for (i = FirstLowInvalidHeapAttributeNumber + 1; i < 0; i++)
|
||||
{
|
||||
if (i != ObjectIdAttributeNumber &&
|
||||
if (
|
||||
#if PG_VERSION_NUM < 120000
|
||||
i != ObjectIdAttributeNumber &&
|
||||
#endif
|
||||
bms_is_member(i - FirstLowInvalidHeapAttributeNumber,
|
||||
indexattrs))
|
||||
ereport(ERROR,
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@
|
|||
#include "nodes/makefuncs.h"
|
||||
#include "nodes/pg_list.h"
|
||||
#include "optimizer/clauses.h"
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
#include "optimizer/optimizer.h"
|
||||
#endif
|
||||
#include "optimizer/planner.h"
|
||||
#include "optimizer/pathnode.h"
|
||||
#if PG_VERSION_NUM >= 110000
|
||||
|
|
@ -63,8 +66,11 @@ build_index_tlist(PlannerInfo *root, IndexOptInfo *index,
|
|||
const FormData_pg_attribute *att_tup;
|
||||
|
||||
if (indexkey < 0)
|
||||
att_tup = SystemAttributeDefinition(indexkey,
|
||||
heapRelation->rd_rel->relhasoids);
|
||||
att_tup = SystemAttributeDefinition(indexkey
|
||||
#if PG_VERSION_NUM < 120000
|
||||
, heapRelation->rd_rel->relhasoids
|
||||
#endif
|
||||
);
|
||||
else
|
||||
#if PG_VERSION_NUM >= 110000
|
||||
att_tup = TupleDescAttr(heapRelation->rd_att, indexkey - 1);
|
||||
|
|
@ -100,6 +106,7 @@ build_index_tlist(PlannerInfo *root, IndexOptInfo *index,
|
|||
return tlist;
|
||||
}
|
||||
|
||||
#if PG_VERSION_NUM < 100000
|
||||
/*
|
||||
* Copied from src/backend/commands/indexcmds.c, not exported.
|
||||
* Resolve possibly-defaulted operator class specification
|
||||
|
|
@ -214,6 +221,7 @@ GetIndexOpClass(List *opclass, Oid attrType,
|
|||
|
||||
return opClassId;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copied from src/backend/commands/indexcmds.c, not exported.
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@
|
|||
#ifndef _HYPOPG_H_
|
||||
#define _HYPOPG_H_
|
||||
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
#include "access/table.h"
|
||||
#endif
|
||||
#include "catalog/catalog.h"
|
||||
#include "commands/explain.h"
|
||||
#include "nodes/nodeFuncs.h"
|
||||
|
|
|
|||
|
|
@ -21,8 +21,10 @@
|
|||
|
||||
extern List *build_index_tlist(PlannerInfo *root, IndexOptInfo *index,
|
||||
Relation heapRelation);
|
||||
#if PG_VERSION_NUM < 100000
|
||||
extern Oid GetIndexOpClass(List *opclass, Oid attrType,
|
||||
char *accessMethodName, Oid accessMethodId);
|
||||
#endif
|
||||
|
||||
extern void CheckPredicate(Expr *predicate);
|
||||
extern bool CheckMutability(Expr *expr);
|
||||
|
|
|
|||
Loading…
Reference in a new issue