Ban ROWNUM when creating index.
This commit is contained in:
@ -3265,6 +3265,7 @@ IndexStmt* transformIndexStmt(Oid relid, IndexStmt* stmt, const char* queryStrin
|
||||
* consistency with what transformWhereClause() checks for the
|
||||
* predicate. DefineIndex() will make more checks.
|
||||
*/
|
||||
ExcludeRownumExpr(pstate, (Node*)ielem->expr);
|
||||
if (expression_returns_set(ielem->expr))
|
||||
ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("index expression cannot return a set")));
|
||||
}
|
||||
|
@ -2721,6 +2721,18 @@ explain (costs off) select /*+ rows(t_rep_table #100000) */ * from t_hash_tabl
|
||||
Index Cond: (a = t_hash_table.a)
|
||||
(4 rows)
|
||||
|
||||
create index test0 on t_rep_table(rownum);
|
||||
ERROR: specified ROWNUM is not allowed here.
|
||||
LINE 1: create index test0 on t_rep_table(rownum);
|
||||
^
|
||||
create index test0 on t_rep_table(sin(a), sin(rownum));
|
||||
ERROR: specified ROWNUM is not allowed here.
|
||||
LINE 1: create index test0 on t_rep_table(sin(a), sin(rownum));
|
||||
^
|
||||
create index test0 on t_rep_table(sin(a), sin(rownum+1));
|
||||
ERROR: specified ROWNUM is not allowed here.
|
||||
LINE 1: create index test0 on t_rep_table(sin(a), sin(rownum+1));
|
||||
^
|
||||
drop index idx_rep_table;
|
||||
drop table t_hash_table;
|
||||
drop table t_rep_table;
|
||||
|
@ -956,6 +956,10 @@ create index idx_rep_table on t_rep_table(a);
|
||||
explain (costs off) select /*+ rows(t_rep_table #100000) */ * from t_hash_table where t_hash_table.a in (select a from t_rep_table);
|
||||
explain (costs off) select /*+ rows(t_rep_table #100000) */ * from t_hash_table where '1' = '0' or t_hash_table.a in (select a from t_rep_table);
|
||||
|
||||
create index test0 on t_rep_table(rownum);
|
||||
create index test0 on t_rep_table(sin(a), sin(rownum));
|
||||
create index test0 on t_rep_table(sin(a), sin(rownum+1));
|
||||
|
||||
drop index idx_rep_table;
|
||||
drop table t_hash_table;
|
||||
drop table t_rep_table;
|
||||
|
Reference in New Issue
Block a user