support concurrent index and range type in openGauss

This commit is contained in:
xiongxiaojun 2020-08-04 09:47:33 +08:00
parent 22f8541cc3
commit 05c7ae30fb
10 changed files with 204 additions and 196 deletions

View File

@ -1007,6 +1007,13 @@ Oid DefineIndex(Oid relationId, IndexStmt* stmt, Oid indexRelationId, bool is_al
return indexRelationId;
}
// cstore relation doesn't support concurrent INDEX now.
if (OidIsValid(rel->rd_rel->relcudescrelid)) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("column store table does not support concurrent INDEX yet"),
errdetail("The feature is not currently supported")));
}
/* save lockrelid and locktag for below, then close rel */
heaprelid = rel->rd_lockInfo.lockRelId;
SET_LOCKTAG_RELATION(heaplocktag, heaprelid.dbId, heaprelid.relId);

View File

@ -2505,6 +2505,13 @@ void RemoveRelations(DropStmt* drop, StringInfo tmp_queryString, RemoteQueryExec
errmsg("%s is redistributing, please retry later.", delrel->rd_rel->relname.data)));
}
// cstore relation doesn't support concurrent INDEX now.
if (drop->concurrent == true && delrel != NULL && OidIsValid(delrel->rd_rel->relcudescrelid)) {
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("column store table does not support concurrent INDEX yet"),
errdetail("The feature is not currently supported")));
}
if (delrel != NULL) {
relation_close(delrel, NoLock);
}

View File

@ -2779,7 +2779,7 @@ void standard_ProcessUtility(Node* parse_tree, const char* query_string, ParamLi
switch (((DropStmt*)parse_tree)->removeType) {
case OBJECT_INDEX:
#ifdef PGXC
#ifdef ENABLE_MULTIPLE_NODES
if (((DropStmt*)parse_tree)->concurrent) {
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
@ -3928,10 +3928,10 @@ void standard_ProcessUtility(Node* parse_tree, const char* query_string, ParamLi
} break;
case T_CreateRangeStmt: /* CREATE TYPE AS RANGE */
#ifdef PGXC
#ifdef ENABLE_MULTIPLE_NODES
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("user defined range type is not yet supported.")));
#endif /* PGXC */
#endif /* ENABLE_MULTIPLE_NODES */
DefineRange((CreateRangeStmt*)parse_tree);
#ifdef PGXC
if (IS_PGXC_COORDINATOR)
@ -4140,12 +4140,14 @@ void standard_ProcessUtility(Node* parse_tree, const char* query_string, ParamLi
is_first_node = (strcmp(first_exec_node, g_instance.attr.attr_common.PGXCNodeName) == 0);
}
#ifdef ENABLE_MULTIPLE_NODES
if (stmt->concurrent) {
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("PGXC does not support concurrent INDEX yet"),
errdetail("The feature is not currently supported")));
}
#endif
/* INDEX on a temporary table cannot use 2PC at commit */
rel_id = RangeVarGetRelidExtended(stmt->relation, AccessShareLock, true, false, false, true, NULL, NULL);

View File

@ -2203,31 +2203,23 @@ create unique index hash_f8_index_3 on hash_f8_heap(random) where seqno > 1000;
CREATE TABLE concur_heap (f1 text, f2 text);
-- empty table
CREATE INDEX CONCURRENTLY concur_index1 ON concur_heap(f2,f1);
ERROR: PGXC does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
INSERT INTO concur_heap VALUES ('a','b');
INSERT INTO concur_heap VALUES ('b','b');
-- unique index
CREATE UNIQUE INDEX CONCURRENTLY concur_index2 ON concur_heap(f1);
ERROR: PGXC does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
-- check if constraint is set up properly to be enforced
INSERT INTO concur_heap VALUES ('b','x');
ERROR: duplicate key value violates unique constraint "concur_index2"
DETAIL: Key (f1)=(b) already exists.
-- check if constraint is enforced properly at build time
CREATE UNIQUE INDEX CONCURRENTLY concur_index3 ON concur_heap(f2);
ERROR: PGXC does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
ERROR: could not create unique index "concur_index3"
DETAIL: Key (f2)=(b) is duplicated.
-- test that expression indexes and partial indexes work concurrently
CREATE INDEX CONCURRENTLY concur_index4 on concur_heap(f2) WHERE f1='a';
ERROR: PGXC does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
CREATE INDEX CONCURRENTLY concur_index5 on concur_heap(f2) WHERE f1='x';
ERROR: PGXC does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
-- here we also check that you can default the index name
CREATE INDEX CONCURRENTLY on concur_heap((f2||f1));
ERROR: PGXC does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
-- You can't do a concurrent index build in a transaction
START TRANSACTION;
CREATE INDEX CONCURRENTLY concur_index7 ON concur_heap(f1);
@ -2247,42 +2239,33 @@ Table "public.concur_heap"
f1 | text |
f2 | text |
Indexes:
"concur_index2" UNIQUE, btree (f1) TABLESPACE pg_default
"concur_index3" UNIQUE, btree (f2) TABLESPACE pg_default INVALID
"concur_heap_expr_idx" btree ((f2 || f1)) TABLESPACE pg_default
"concur_index1" btree (f2, f1) TABLESPACE pg_default
"concur_index4" btree (f2) TABLESPACE pg_default WHERE f1 = 'a'::text
"concur_index5" btree (f2) TABLESPACE pg_default WHERE f1 = 'x'::text
"std_index" btree (f2) TABLESPACE pg_default
--
-- Try some concurrent index drops
--
DROP INDEX CONCURRENTLY "concur_index2"; -- works
ERROR: PGXC does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
DROP INDEX CONCURRENTLY IF EXISTS "concur_index2"; -- notice
ERROR: PGXC does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
NOTICE: index "concur_index2" does not exist, skipping
-- failures
DROP INDEX CONCURRENTLY "concur_index2", "concur_index3";
ERROR: PGXC does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
ERROR: DROP INDEX CONCURRENTLY does not support dropping multiple objects
START TRANSACTION;
DROP INDEX CONCURRENTLY "concur_index5";
ERROR: PGXC does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
ERROR: DROP INDEX CONCURRENTLY cannot run inside a transaction block
ROLLBACK;
-- successes
DROP INDEX CONCURRENTLY IF EXISTS "concur_index3";
ERROR: PGXC does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
DROP INDEX CONCURRENTLY "concur_index4";
ERROR: PGXC does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
DROP INDEX CONCURRENTLY "concur_index5";
ERROR: PGXC does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
DROP INDEX CONCURRENTLY "concur_index1";
ERROR: PGXC does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
DROP INDEX CONCURRENTLY "concur_heap_expr_idx";
ERROR: PGXC does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
\d concur_heap
Table "public.concur_heap"
Column | Type | Modifiers

View File

@ -44,10 +44,8 @@ select * from gtt6;
---
(0 rows)
-- ERROR
-- SUCCESS
create index CONCURRENTLY idx_gtt1 on gtt1 (b);
ERROR: PGXC does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
-- ERROR
cluster gtt1 using gtt1_pkey;
-- ERROR

View File

@ -2693,7 +2693,7 @@ select count(*) from pg_proc where prokind = 'w';
select count(*) from pg_proc where prokind = 'f';
count
-------
3134
3142
(1 row)
select count(*) from pg_proc where prokind = 'p';

View File

@ -1,167 +1,195 @@
-- Tests for range data types.
create type textrange as range (subtype=text, collation="C");
ERROR: user defined range type is not yet supported.
--
-- test input parser
--
-- negative tests; should fail
select ''::textrange;
ERROR: type "textrange" does not exist
LINE 1: select ''::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
(1 row)
select '-[a,z)'::textrange;
ERROR: type "textrange" does not exist
ERROR: malformed range literal: "-[a,z)"
LINE 1: select '-[a,z)'::textrange;
^
^
DETAIL: Missing left parenthesis or bracket.
CONTEXT: referenced column: textrange
select '[a,z) - '::textrange;
ERROR: type "textrange" does not exist
ERROR: malformed range literal: "[a,z) - "
LINE 1: select '[a,z) - '::textrange;
^
^
DETAIL: Junk after right parenthesis or bracket.
CONTEXT: referenced column: textrange
select '(",a)'::textrange;
ERROR: type "textrange" does not exist
ERROR: malformed range literal: "(",a)"
LINE 1: select '(",a)'::textrange;
^
^
DETAIL: Unexpected end of input.
CONTEXT: referenced column: textrange
select '(,,a)'::textrange;
ERROR: type "textrange" does not exist
ERROR: malformed range literal: "(,,a)"
LINE 1: select '(,,a)'::textrange;
^
^
DETAIL: Too many commas.
CONTEXT: referenced column: textrange
select '(),a)'::textrange;
ERROR: type "textrange" does not exist
ERROR: malformed range literal: "(),a)"
LINE 1: select '(),a)'::textrange;
^
^
DETAIL: Missing comma after lower bound.
CONTEXT: referenced column: textrange
select '(a,))'::textrange;
ERROR: type "textrange" does not exist
ERROR: malformed range literal: "(a,))"
LINE 1: select '(a,))'::textrange;
^
^
DETAIL: Junk after right parenthesis or bracket.
CONTEXT: referenced column: textrange
select '(],a)'::textrange;
ERROR: type "textrange" does not exist
ERROR: malformed range literal: "(],a)"
LINE 1: select '(],a)'::textrange;
^
^
DETAIL: Missing comma after lower bound.
CONTEXT: referenced column: textrange
select '(a,])'::textrange;
ERROR: type "textrange" does not exist
ERROR: malformed range literal: "(a,])"
LINE 1: select '(a,])'::textrange;
^
^
DETAIL: Junk after right parenthesis or bracket.
CONTEXT: referenced column: textrange
select '[z,a]'::textrange;
ERROR: type "textrange" does not exist
ERROR: range lower bound must be less than or equal to range upper bound
LINE 1: select '[z,a]'::textrange;
^
^
CONTEXT: referenced column: textrange
-- should succeed
select ' empty '::textrange;
ERROR: type "textrange" does not exist
LINE 1: select ' empty '::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
empty
(1 row)
select ' ( empty, empty ) '::textrange;
ERROR: type "textrange" does not exist
LINE 1: select ' ( empty, empty ) '::textrange;
^
CONTEXT: referenced column: textrange
textrange
----------------------
(" empty"," empty ")
(1 row)
select ' ( " a " " a ", " z " " z " ) '::textrange;
ERROR: type "textrange" does not exist
LINE 1: select ' ( " a " " a ", " z " " z " ) '::textrange;
^
CONTEXT: referenced column: textrange
textrange
--------------------------
(" a a "," z z ")
(1 row)
select '(,z)'::textrange;
ERROR: type "textrange" does not exist
LINE 1: select '(,z)'::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
(,z)
(1 row)
select '(a,)'::textrange;
ERROR: type "textrange" does not exist
LINE 1: select '(a,)'::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
(a,)
(1 row)
select '[,z]'::textrange;
ERROR: type "textrange" does not exist
LINE 1: select '[,z]'::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
(,z]
(1 row)
select '[a,]'::textrange;
ERROR: type "textrange" does not exist
LINE 1: select '[a,]'::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
[a,)
(1 row)
select '(,)'::textrange;
ERROR: type "textrange" does not exist
LINE 1: select '(,)'::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
(,)
(1 row)
select '[ , ]'::textrange;
ERROR: type "textrange" does not exist
LINE 1: select '[ , ]'::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
[" "," "]
(1 row)
select '["",""]'::textrange;
ERROR: type "textrange" does not exist
ERROR: rangetypes.cpp : 2140 : The parameter destMax is equal to zero or larger than the macro : SECUREC_STRING_MAX_LEN.
LINE 1: select '["",""]'::textrange;
^
^
CONTEXT: referenced column: textrange
select '[",",","]'::textrange;
ERROR: type "textrange" does not exist
LINE 1: select '[",",","]'::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
[",",","]
(1 row)
select '["\\","\\"]'::textrange;
ERROR: type "textrange" does not exist
LINE 1: select '["\\","\\"]'::textrange;
^
CONTEXT: referenced column: textrange
textrange
-------------
["\\","\\"]
(1 row)
select '(\\,a)'::textrange;
ERROR: type "textrange" does not exist
LINE 1: select '(\\,a)'::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
("\\",a)
(1 row)
select '((,z)'::textrange;
ERROR: type "textrange" does not exist
LINE 1: select '((,z)'::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
("(",z)
(1 row)
select '([,z)'::textrange;
ERROR: type "textrange" does not exist
LINE 1: select '([,z)'::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
("[",z)
(1 row)
select '(!,()'::textrange;
ERROR: type "textrange" does not exist
LINE 1: select '(!,()'::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
(!,"(")
(1 row)
select '(!,[)'::textrange;
ERROR: type "textrange" does not exist
LINE 1: select '(!,[)'::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
(!,"[")
(1 row)
select '[a,a]'::textrange;
ERROR: type "textrange" does not exist
LINE 1: select '[a,a]'::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
[a,a]
(1 row)
-- these are allowed but normalize to empty:
select '[a,a)'::textrange;
ERROR: type "textrange" does not exist
LINE 1: select '[a,a)'::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
empty
(1 row)
select '(a,a]'::textrange;
ERROR: type "textrange" does not exist
LINE 1: select '(a,a]'::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
empty
(1 row)
select '(a,a)'::textrange;
ERROR: type "textrange" does not exist
LINE 1: select '(a,a)'::textrange;
^
CONTEXT: referenced column: textrange
textrange
-----------
empty
(1 row)
--
-- create some test data and test the operators
--
@ -871,35 +899,31 @@ set timezone to default;
--
--should fail
create type float8range as range (subtype=float8, subtype_diff=float4mi);
ERROR: user defined range type is not yet supported.
ERROR: function float4mi(double precision, double precision) does not exist
--should succeed
create type float8range as range (subtype=float8, subtype_diff=float8mi);
ERROR: user defined range type is not yet supported.
select '[123.001, 5.e9)'::float8range @> 888.882::float8;
ERROR: type "float8range" does not exist
LINE 1: select '[123.001, 5.e9)'::float8range @> 888.882::float8;
^
?column?
----------
t
(1 row)
create table float8range_test(f8r float8range, i int);
ERROR: type "float8range" does not exist
LINE 1: create table float8range_test(f8r float8range, i int);
^
insert into float8range_test values(float8range(-100.00007, '1.111113e9'), 42);
ERROR: relation "float8range_test" does not exist on datanode1
LINE 1: insert into float8range_test values(float8range(-100.00007, ...
^
select * from float8range_test;
ERROR: relation "float8range_test" does not exist on datanode1
LINE 1: select * from float8range_test;
^
f8r | i
-------------------------+----
[-100.00007,1111113000) | 42
(1 row)
drop table float8range_test;
ERROR: table "float8range_test" does not exist
--
-- Test range types over domains
--
create domain mydomain as int4;
ERROR: domain is not yet supported.
create type mydomainrange as range(subtype=mydomain);
ERROR: user defined range type is not yet supported.
ERROR: type "mydomain" does not exist
select '[4,50)'::mydomainrange @> 7::mydomain;
ERROR: type "mydomainrange" does not exist
LINE 1: select '[4,50)'::mydomainrange @> 7::mydomain;
@ -927,23 +951,17 @@ ERROR: type "restrictedrange" does not exist
-- Test multiple range types over the same subtype
--
create type textrange1 as range(subtype=text, collation="C");
ERROR: user defined range type is not yet supported.
create type textrange2 as range(subtype=text, collation="C");
ERROR: user defined range type is not yet supported.
select textrange1('a','Z') @> 'b'::text;
ERROR: function textrange1(unknown, unknown) does not exist
LINE 1: select textrange1('a','Z') @> 'b'::text;
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
ERROR: range lower bound must be less than or equal to range upper bound
select textrange2('a','z') @> 'b'::text;
ERROR: function textrange2(unknown, unknown) does not exist
LINE 1: select textrange2('a','z') @> 'b'::text;
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
?column?
----------
t
(1 row)
drop type textrange1;
ERROR: type "textrange1" does not exist
drop type textrange2;
ERROR: type "textrange2" does not exist
--
-- Test polymorphic type system
--
@ -1024,40 +1042,34 @@ drop table i8r_array;
-- Ranges of arrays
--
create type arrayrange as range (subtype=int4[]);
ERROR: user defined range type is not yet supported.
select arrayrange(ARRAY[1,2], ARRAY[2,1]);
ERROR: function arrayrange(integer[], integer[]) does not exist
LINE 1: select arrayrange(ARRAY[1,2], ARRAY[2,1]);
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
CONTEXT: referenced column: arrayrange
arrayrange
-------------------
["{1,2}","{2,1}")
(1 row)
select arrayrange(ARRAY[2,1], ARRAY[1,2]); -- fail
ERROR: function arrayrange(integer[], integer[]) does not exist
LINE 1: select arrayrange(ARRAY[2,1], ARRAY[1,2]);
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
ERROR: range lower bound must be less than or equal to range upper bound
CONTEXT: referenced column: arrayrange
select array[1,1] <@ arrayrange(array[1,2], array[2,1]);
ERROR: function arrayrange(integer[], integer[]) does not exist
LINE 1: select array[1,1] <@ arrayrange(array[1,2], array[2,1]);
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
?column?
----------
f
(1 row)
select array[1,3] <@ arrayrange(array[1,2], array[2,1]);
ERROR: function arrayrange(integer[], integer[]) does not exist
LINE 1: select array[1,3] <@ arrayrange(array[1,2], array[2,1]);
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
?column?
----------
t
(1 row)
--
-- Check behavior when subtype lacks a hash function
--
create type cashrange as range (subtype = money);
ERROR: user defined range type is not yet supported.
set enable_sort = off; -- try to make it pick a hash setop implementation
select '(2,5)'::cashrange except select '(5,6)'::cashrange;
ERROR: type "cashrange" does not exist
LINE 1: select '(2,5)'::cashrange except select '(5,6)'::cashrange;
^
CONTEXT: referenced column: cashrange
ERROR: could not identify a hash function for type money
reset enable_sort;
--
-- OUT/INOUT/TABLE functions

View File

@ -3324,7 +3324,6 @@ ERROR: SECURITY LABEL is not yet supported.
CREATE TYPE bigobj (INPUT = lo_filein, OUTPUT = lo_fileout, INTERNALLENGTH = VARIABLE);
ERROR: function lo_filein(cstring) does not exist
CREATE TYPE float8_range AS RANGE (subtype = float8, subtype_diff = float8mi);
ERROR: user defined range type is not yet supported.
ALTER TYPE colors ADD VALUE 'orange' AFTER 'red';
ERROR: type "colors" does not exist
CREATE COLLATION french (LOCALE = 'fr_FR.utf8');

View File

@ -10,7 +10,7 @@ COPY cstore_insert_t1 FROM '@abs_srcdir@/tmp_check/datanode1/pg_copydir/cstore_c
CREATE UNIQUE INDEX unsupport1_idx ON cstore_insert_t1(c1);
ERROR: access method "psort" does not support unique indexes
CREATE INDEX CONCURRENTLY unsupport2_idx ON cstore_insert_t1(c1);
ERROR: PGXC does not support concurrent INDEX yet
ERROR: column store table does not support concurrent INDEX yet
DETAIL: The feature is not currently supported
CREATE INDEX unsupport3_idx ON cstore_insert_t1(lower(c2));
ERROR: access method "psort" does not support index expressions

View File

@ -43,7 +43,7 @@ commit;
-- 0 row
select * from gtt6;
-- ERROR
-- SUCCESS
create index CONCURRENTLY idx_gtt1 on gtt1 (b);
-- ERROR