mirror of
https://github.com/HypoPG/hypopg
synced 2026-05-24 09:38:21 +00:00
Disallow hypothetical indexes on system columns
This commit is contained in:
parent
beb223ab41
commit
b6ce86d59d
1 changed files with 38 additions and 0 deletions
38
hypopg.c
38
hypopg.c
|
|
@ -50,6 +50,7 @@
|
|||
#include "optimizer/cost.h"
|
||||
#include "optimizer/pathnode.h"
|
||||
#include "optimizer/plancat.h"
|
||||
#include "optimizer/var.h"
|
||||
#include "parser/parser.h"
|
||||
#include "parser/parse_utilcmd.h"
|
||||
#include "storage/bufmgr.h"
|
||||
|
|
@ -768,6 +769,43 @@ hypo_entry_store_parsetree(IndexStmt *node, const char *queryString)
|
|||
}
|
||||
Assert(attn == ncolumns);
|
||||
|
||||
/*
|
||||
* We disallow indexes on system columns other than OID. They would
|
||||
* not necessarily get updated correctly, and they don't seem useful
|
||||
* anyway.
|
||||
*/
|
||||
for (attn = 0; attn < ncolumns; attn++)
|
||||
{
|
||||
AttrNumber attno = entry->indexkeys[attn];
|
||||
|
||||
if (attno < 0 && attno != ObjectIdAttributeNumber)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("hypopg: index creation on system columns is not supported")));
|
||||
}
|
||||
|
||||
/*
|
||||
* Also check for system columns used in expressions or predicates.
|
||||
*/
|
||||
if (entry->indexprs || entry->indpred)
|
||||
{
|
||||
Bitmapset *indexattrs = NULL;
|
||||
int i;
|
||||
|
||||
pull_varattnos((Node *) entry->indexprs, 1, &indexattrs);
|
||||
pull_varattnos((Node *) entry->indpred, 1, &indexattrs);
|
||||
|
||||
for (i = FirstLowInvalidHeapAttributeNumber + 1; i < 0; i++)
|
||||
{
|
||||
if (i != ObjectIdAttributeNumber &&
|
||||
bms_is_member(i - FirstLowInvalidHeapAttributeNumber,
|
||||
indexattrs))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("hypopg: index creation on system columns is not supported")));
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if the average size fits in a btree index */
|
||||
if (entry->relam == BTREE_AM_OID)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue