Fix create/drop domain.

This commit is contained in:
hemny
2020-07-31 13:13:23 +08:00
parent 71197d149c
commit 099e530ea1
12 changed files with 150 additions and 158 deletions

View File

@ -3587,7 +3587,8 @@ void standard_ProcessUtility(Node* parse_tree, const char* query_string, ParamLi
case T_AlterDomainStmt:
#ifdef PGXC
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("domain is not yet supported.")));
/*Single node support domain feature.*/
/* ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("domain is not yet supported.")));*/
#endif /* PGXC */
{
AlterDomainStmt* stmt = (AlterDomainStmt*)parse_tree;
@ -4928,8 +4929,9 @@ void standard_ProcessUtility(Node* parse_tree, const char* query_string, ParamLi
*/
case T_CreateDomainStmt:
#ifdef PGXC
if (!IsInitdb && !u_sess->attr.attr_common.IsInplaceUpgrade)
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("domain is not yet supported.")));
/*Single node support domain feature.*/
/* if (!IsInitdb && !u_sess->attr.attr_common.IsInplaceUpgrade)
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("domain is not yet supported.")));*/
#endif /* PGXC */
DefineDomain((CreateDomainStmt*)parse_tree);
#ifdef PGXC
@ -8564,9 +8566,10 @@ void CheckObjectInBlackList(ObjectType obj_type, const char* query_string)
case OBJECT_LANGUAGE:
tag = "LANGUAGE";
break;
case OBJECT_DOMAIN:
/*Single node support domain feature.*/
/* case OBJECT_DOMAIN:
tag = "DOMAIN";
break;
break;*/
case OBJECT_CONVERSION:
tag = "CONVERSION";
break;

View File

@ -294,56 +294,50 @@ drop table p1 cascade;
-- test that operations with a dropped column do not try to reference
-- its datatype
create domain mytype as text;
ERROR: domain is not yet supported.
create table foo (f1 text, f2 mytype, f3 text);;
ERROR: type "mytype" does not exist
LINE 1: create table foo (f1 text, f2 mytype, f3 text);
^
insert into foo values('bb','cc','dd');
ERROR: relation "foo" does not exist on datanode1
LINE 1: insert into foo values('bb','cc','dd');
^
select * from foo order by f1;
ERROR: relation "foo" does not exist on datanode1
LINE 1: select * from foo order by f1;
^
f1 | f2 | f3
----+----+----
bb | cc | dd
(1 row)
drop domain mytype cascade;
ERROR: type "mytype" does not exist
NOTICE: drop cascades to table foo column f2
select * from foo order by f1;
ERROR: relation "foo" does not exist on datanode1
LINE 1: select * from foo order by f1;
^
f1 | f3
----+----
bb | dd
(1 row)
insert into foo values('qq','rr');
ERROR: relation "foo" does not exist on datanode1
LINE 1: insert into foo values('qq','rr');
^
select * from foo order by f1;
ERROR: relation "foo" does not exist on datanode1
LINE 1: select * from foo order by f1;
^
f1 | f3
----+----
bb | dd
qq | rr
(2 rows)
update foo set f3 = 'zz';
ERROR: relation "foo" does not exist on datanode1
LINE 1: update foo set f3 = 'zz';
^
select * from foo order by f1;
ERROR: relation "foo" does not exist on datanode1
LINE 1: select * from foo order by f1;
^
f1 | f3
----+----
bb | zz
qq | zz
(2 rows)
select f3,max(f1) from foo group by f3;
ERROR: relation "foo" does not exist on datanode1
LINE 1: select f3,max(f1) from foo group by f3;
^
f3 | max
----+-----
zz | qq
(1 row)
-- Simple tests for alter table column type
delete from foo where f1 = 'qq';
ERROR: relation "foo" does not exist on datanode1
LINE 1: delete from foo where f1 = 'qq';
^
alter table foo alter f1 TYPE integer; -- fails
ERROR: relation "foo" does not exist
ERROR: invalid input syntax for integer: "bb"
alter table foo alter f1 TYPE varchar(10);
ERROR: relation "foo" does not exist
drop table foo;
ERROR: table "foo" does not exist
create table anothertab (atcol1 serial8, atcol2 boolean,
constraint anothertab_chk check (atcol1 <= 3));;
NOTICE: CREATE TABLE will create implicit sequence "anothertab_atcol1_seq" for serial column "anothertab.atcol1"
@ -446,11 +440,8 @@ ERROR: composite type recur1 cannot be made a member of itself
alter table recur1 add column f2 recur1[]; -- fails
ERROR: composite type recur1 cannot be made a member of itself
create domain array_of_recur1 as recur1[];
ERROR: domain is not yet supported.
alter table recur1 add column f2 array_of_recur1; -- fails
ERROR: type "array_of_recur1" does not exist
LINE 1: alter table recur1 add column f2 array_of_recur1;
^
ERROR: composite type recur1 cannot be made a member of itself
create table recur2 (f1 int, f2 recur1);
alter table recur1 add column f2 recur2; -- fails
ERROR: composite type recur1 cannot be made a member of itself
@ -649,7 +640,6 @@ NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "t1_pkey" for tab
create view alter1.v1 as select * from alter1.t1;
create function alter1.plus1(int) returns int as 'select $1+1' language sql;
create domain alter1.posint integer check (value > 0);
ERROR: domain is not yet supported.
create type alter1.ctype as (f1 int, f2 text);
create function alter1.same(alter1.ctype, alter1.ctype) returns boolean language sql
as 'select $1.f1 is not distinct from $2.f1 and $1.f2 is not distinct from $2.f2';
@ -675,7 +665,6 @@ ERROR: There's dependent sequence, but ALTER SEQUENCE SET SCHEMA is not yet sup
alter table alter1.v1 set schema alter2;
alter function alter1.plus1(int) set schema alter2;
alter domain alter1.posint set schema alter2;
ERROR: type "alter1.posint" does not exist
alter operator class alter1.ctype_hash_ops using hash set schema alter2;
ERROR: operator class "alter1.ctype_hash_ops" does not exist for access method "hash"
alter operator family alter1.ctype_hash_ops using hash set schema alter2;
@ -727,9 +716,10 @@ select alter2.plus1(41);
-- clean up
drop schema alter2 cascade;
NOTICE: drop cascades to 4 other objects
NOTICE: drop cascades to 5 other objects
DETAIL: drop cascades to view alter2.v1
drop cascades to function alter2.plus1(integer)
drop cascades to type alter2.posint
drop cascades to type alter2.ctype
drop cascades to function alter2.same(alter2.ctype,alter2.ctype)
drop schema alter1 cascade;

View File

@ -8,7 +8,7 @@ select count(*) from pg_node_env;
select count(*) from pg_os_threads;
count
-------
29
10
(1 row)
-- test backtrace output to log

View File

@ -71,39 +71,36 @@ ERROR: collation mismatch between explicit collations "C" and "POSIX"
LINE 1: ...* FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "P...
^
CREATE DOMAIN testdomain_p AS text COLLATE "POSIX";
ERROR: domain is not yet supported.
CREATE DOMAIN testdomain_i AS int COLLATE "POSIX"; -- fail
ERROR: domain is not yet supported.
ERROR: collations are not supported by type integer
CREATE TABLE collate_test4 (
a int,
b testdomain_p
);
ERROR: type "testdomain_p" does not exist
LINE 3: b testdomain_p
^
INSERT INTO collate_test4 SELECT * FROM collate_test1;
ERROR: relation "collate_test4" does not exist on datanode1
LINE 1: INSERT INTO collate_test4 SELECT * FROM collate_test1;
^
SELECT a, b FROM collate_test4 ORDER BY b;
ERROR: relation "collate_test4" does not exist on datanode1
LINE 1: SELECT a, b FROM collate_test4 ORDER BY b;
^
a | b
---+-----
4 | ABD
2 | Abc
1 | abc
3 | bbc
(4 rows)
CREATE TABLE collate_test5 (
a int,
b testdomain_p COLLATE "C"
);
ERROR: type "testdomain_p" does not exist
LINE 3: b testdomain_p COLLATE "C"
^
INSERT INTO collate_test5 SELECT * FROM collate_test1;
ERROR: relation "collate_test5" does not exist on datanode1
LINE 1: INSERT INTO collate_test5 SELECT * FROM collate_test1;
^
SELECT a, b FROM collate_test5 ORDER BY b;
ERROR: relation "collate_test5" does not exist on datanode1
LINE 1: SELECT a, b FROM collate_test5 ORDER BY b;
^
a | b
---+-----
4 | ABD
2 | Abc
1 | abc
3 | bbc
(4 rows)
SELECT a, b FROM collate_test1 ORDER BY b;
a | b
---+-----
@ -299,27 +296,40 @@ SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test2 ORDER BY 2
(4 rows)
CREATE DOMAIN testdomain AS text;
ERROR: domain is not yet supported.
SELECT a, b::testdomain FROM collate_test1 ORDER BY 2;
ERROR: type "testdomain" does not exist
LINE 1: SELECT a, b::testdomain FROM collate_test1 ORDER BY 2;
^
CONTEXT: referenced column: b
a | b
---+-----
4 | ABD
2 | Abc
1 | abc
3 | bbc
(4 rows)
SELECT a, b::testdomain FROM collate_test2 ORDER BY 2;
ERROR: type "testdomain" does not exist
LINE 1: SELECT a, b::testdomain FROM collate_test2 ORDER BY 2;
^
CONTEXT: referenced column: b
a | b
---+-----
4 | ABD
2 | Abc
1 | abc
3 | bbc
(4 rows)
SELECT a, b::testdomain_p FROM collate_test2 ORDER BY 2;
ERROR: type "testdomain_p" does not exist
LINE 1: SELECT a, b::testdomain_p FROM collate_test2 ORDER BY 2;
^
CONTEXT: referenced column: b
a | b
---+-----
4 | ABD
2 | Abc
1 | abc
3 | bbc
(4 rows)
SELECT a, lower(x::testdomain), lower(y::testdomain) FROM collate_test10 ORDER BY 1, 2, 3;
ERROR: type "testdomain" does not exist
LINE 1: SELECT a, lower(x::testdomain), lower(y::testdomain) FROM co...
^
CONTEXT: referenced column: lower
a | lower | lower
---+-------+-------
1 | hij | hij
2 | hij | hij
(2 rows)
SELECT min(b), max(b) FROM collate_test1;
min | max
-----+-----
@ -608,14 +618,18 @@ explain (verbose, costs off, nodes off) SELECT collation for ((SELECT b FROM col
-- must get rid of them.
--
DROP SCHEMA collate_tests CASCADE;
NOTICE: drop cascades to 11 other objects
NOTICE: drop cascades to 15 other objects
DETAIL: drop cascades to table collate_test1
drop cascades to table collate_test_like
drop cascades to table collate_test2
drop cascades to type testdomain_p
drop cascades to table collate_test4
drop cascades to table collate_test5
drop cascades to table collate_test10
drop cascades to view collview1
drop cascades to view collview2
drop cascades to view collview3
drop cascades to type testdomain
drop cascades to function dup(anyelement)
drop cascades to table collate_test20
drop cascades to table collate_test21

View File

@ -58,9 +58,7 @@ ERROR: type "test_domain_exists" does not exist
DROP DOMAIN IF EXISTS test_domain_exists;
NOTICE: type "test_domain_exists" does not exist, skipping
CREATE domain test_domain_exists as int not null check (value > 0);
ERROR: domain is not yet supported.
DROP DOMAIN IF EXISTS test_domain_exists;
NOTICE: type "test_domain_exists" does not exist, skipping
DROP DOMAIN test_domain_exists;
ERROR: type "test_domain_exists" does not exist
---

View File

@ -402,24 +402,19 @@ RESET enable_bitmapscan;
-- Domains over enums
--
CREATE DOMAIN rgb AS rainbow CHECK (VALUE IN ('red', 'green', 'blue'));
ERROR: domain is not yet supported.
SELECT 'red'::rgb;
ERROR: type "rgb" does not exist
LINE 1: SELECT 'red'::rgb;
^
CONTEXT: referenced column: rgb
rgb
-----
red
(1 row)
SELECT 'purple'::rgb;
ERROR: type "rgb" does not exist
LINE 1: SELECT 'purple'::rgb;
^
ERROR: value for domain rgb violates check constraint "rgb_check"
CONTEXT: referenced column: rgb
SELECT 'purple'::rainbow::rgb;
ERROR: type "rgb" does not exist
LINE 1: SELECT 'purple'::rainbow::rgb;
^
ERROR: value for domain rgb violates check constraint "rgb_check"
CONTEXT: referenced column: rgb
DROP DOMAIN rgb;
ERROR: type "rgb" does not exist
--
-- Arrays
--

View File

@ -46,6 +46,8 @@ select * from gtt6;
-- ERROR
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

@ -3230,15 +3230,15 @@ INSERT INTO c VALUES (0), (1);
INSERT INTO d VALUES (1,3), (2,2), (3,1);
-- all three cases should be optimizable into a simple seqscan
explain (verbose on, costs off, nodes off) SELECT a.* FROM a LEFT JOIN b ON a.b_id = b.id;
QUERY PLAN
----------------------------------------
--?.*QUERY PLAN.*
--?----------------------------.*
--? Seq Scan on pg_temp_datanod.*
Output: a.id, a.b_id
(2 rows)
explain (verbose on, costs off, nodes off) SELECT b.* FROM b LEFT JOIN c ON b.c_id = c.id;
QUERY PLAN
----------------------------------------
--?.*QUERY PLAN.*
--?----------------------------.*
--? Seq Scan on pg_temp_datanod.*
Output: b.id, b.c_id
(2 rows)
@ -3246,8 +3246,8 @@ explain (verbose on, costs off, nodes off) SELECT b.* FROM b LEFT JOIN c ON b.c_
explain (verbose on, costs off, nodes off)
SELECT a.* FROM a LEFT JOIN (b left join c on b.c_id = c.id)
ON (a.b_id = b.id);
QUERY PLAN
----------------------------------------
--?QUERY PLAN.*
--?-----------------------------.*
--? Seq Scan on pg_temp_datanod.*
Output: a.id, a.b_id
(2 rows)
@ -3257,8 +3257,8 @@ explain (verbose on, costs off, nodes off)
select id from a where id in (
select b.id from b left join c on b.id = c.id
);
QUERY PLAN
----------------------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Hash Join
Output: a.id
Hash Cond: (a.id = b.id)
@ -3275,8 +3275,8 @@ select id from a where id in (
explain (verbose on, costs off, nodes off)
select d.* from d left join (select * from b group by b.id, b.c_id) s
on d.a = s.id and d.b = s.c_id;
QUERY PLAN
----------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
--? Seq Scan on pg_temp_datanod.*
Output: d.a, d.b
(2 rows)
@ -3285,8 +3285,8 @@ select d.* from d left join (select * from b group by b.id, b.c_id) s
explain (verbose on, costs off, nodes off)
select d.* from d left join (select distinct * from b) s
on d.a = s.id and d.b = s.c_id;
QUERY PLAN
----------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
--? Seq Scan on pg_temp_datanod.*
Output: d.a, d.b
(2 rows)
@ -3296,8 +3296,8 @@ select d.* from d left join (select distinct * from b) s
explain (verbose on, costs off, nodes off)
select d.* from d left join (select * from b group by b.id, b.c_id) s
on d.a = s.id;
QUERY PLAN
----------------------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Hash Right Join
Output: d.a, d.b
Hash Cond: (b.id = d.a)
@ -3316,8 +3316,8 @@ select d.* from d left join (select * from b group by b.id, b.c_id) s
explain (verbose on, costs off, nodes off)
select d.* from d left join (select distinct * from b) s
on d.a = s.id;
QUERY PLAN
----------------------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Hash Right Join
Output: d.a, d.b
Hash Cond: (b.id = d.a)
@ -3337,8 +3337,8 @@ select d.* from d left join (select distinct * from b) s
explain (verbose on, costs off, nodes off)
select d.* from d left join (select id from a union select id from b) s
on d.a = s.id;
QUERY PLAN
----------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
--? Seq Scan on pg_temp_datanod.*
Output: d.a, d.b
(2 rows)
@ -3347,8 +3347,8 @@ select d.* from d left join (select id from a union select id from b) s
explain (verbose on, costs off, nodes off)
select i8.* from int8_tbl i8 left join (select f1 from int4_tbl group by f1) i4
on i8.q1 = i4.f1;
QUERY PLAN
--------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Seq Scan on public.int8_tbl i8
Output: i8.q1, i8.q2
(2 rows)
@ -3371,8 +3371,8 @@ select p.* from parent p left join child c on (p.k = c.k) order by 1,2;
explain (verbose on, costs off, nodes off)
select p.* from parent p left join child c on (p.k = c.k) order by 1,2;
QUERY PLAN
-----------------------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Sort
Output: p.k, p.pd
Sort Key: p.k, p.pd
@ -3395,8 +3395,8 @@ explain (verbose on, costs off, nodes off)
select p.*, linked from parent p
left join (select c.*, true as linked from child c) as ss
on (p.k = ss.k) order by p.k;
QUERY PLAN
-----------------------------------------------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Merge Left Join
Output: p.k, p.pd, (true)
Merge Cond: (p.k = c.k)
@ -3418,8 +3418,8 @@ explain (verbose on, costs off, nodes off)
select p.* from
parent p left join child c on (p.k = c.k)
where p.k = 1 and p.k = 2;
QUERY PLAN
--------------------------
--?QUERY PLAN.*
--?----------------.*
Result
Output: p.k, p.pd
One-Time Filter: false
@ -3519,8 +3519,8 @@ select t1.* from
on (t1.f1 = b1.d1)
left join int4_tbl i4
on (i8.q2 = i4.f1);
QUERY PLAN
----------------------------------------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Hash Left Join
Output: t1.f1
Hash Cond: (i8.q2 = i4.f1)
@ -3586,8 +3586,8 @@ select t1.* from
on (t1.f1 = b1.d1)
left join int4_tbl i4
on (i8.q2 = i4.f1);
QUERY PLAN
----------------------------------------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Hash Left Join
Output: t1.f1
Hash Cond: (i8.q2 = i4.f1)
@ -3652,8 +3652,8 @@ select * from
on t1.f1 = 'doh!'
left join int4_tbl i4
on i8.q1 = i4.f1;
QUERY PLAN
--------------------------------------------------------------
--?QUERY PLAN.*
--?----------------------------.*
Nested Loop Left Join
Output: t1.f1, i8.q1, i8.q2, t2.f1, i4.f1
-> Seq Scan on public.text_tbl t2
@ -3700,8 +3700,8 @@ CREATE TABLE mj_t2 (a int,c char(10));
insert into mj_t2 values(12,'abcde');
insert into mj_t2 values(12,'efghi');
explain (nodes off, costs off) select * from mj_t1 full outer join mj_t2 on 1=1;
QUERY PLAN
-------------------------------
--?QUERY PLAN.*
--?-----------------------.*
Merge Full Join
-> Seq Scan on mj_t1
-> Materialize

View File

@ -71,7 +71,7 @@ SELECT name, setting FROM pg_settings WHERE name LIKE 'enable%' ORDER BY name;
enable_sonic_optspill | on
enable_sort | on
enable_stream_replication | on
enable_thread_pool | on
enable_thread_pool | off
enable_tidscan | on
enable_upgrade_merge_lock_mode | off
enable_user_metric_persistent | on

View File

@ -380,24 +380,19 @@ RESET enable_bitmapscan;
-- Domains over enums
--
CREATE DOMAIN rgb AS rainbow CHECK (VALUE IN ('red', 'green', 'blue'));
ERROR: domain is not yet supported.
SELECT 'red'::rgb;
ERROR: type "rgb" does not exist
LINE 1: SELECT 'red'::rgb;
^
CONTEXT: referenced column: rgb
rgb
-----
red
(1 row)
SELECT 'purple'::rgb;
ERROR: type "rgb" does not exist
LINE 1: SELECT 'purple'::rgb;
^
ERROR: value for domain rgb violates check constraint "rgb_check"
CONTEXT: referenced column: rgb
SELECT 'purple'::rainbow::rgb;
ERROR: type "rgb" does not exist
LINE 1: SELECT 'purple'::rainbow::rgb;
^
ERROR: value for domain rgb violates check constraint "rgb_check"
CONTEXT: referenced column: rgb
DROP DOMAIN rgb;
ERROR: type "rgb" does not exist
--
-- Arrays
--

View File

@ -897,7 +897,6 @@ 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.
select '[4,50)'::mydomainrange @> 7::mydomain;
@ -905,24 +904,21 @@ ERROR: type "mydomainrange" does not exist
LINE 1: select '[4,50)'::mydomainrange @> 7::mydomain;
^
drop domain mydomain; -- fail
ERROR: type "mydomain" does not exist
drop domain mydomain cascade;
ERROR: type "mydomain" does not exist
--
-- Test domains over range types
--
create domain restrictedrange as int4range check (upper(value) < 10);
ERROR: domain is not yet supported.
select '[4,5)'::restrictedrange @> 7;
ERROR: type "restrictedrange" does not exist
LINE 1: select '[4,5)'::restrictedrange @> 7;
^
?column?
----------
f
(1 row)
select '[4,50)'::restrictedrange @> 7; -- should fail
ERROR: type "restrictedrange" does not exist
LINE 1: select '[4,50)'::restrictedrange @> 7;
^
ERROR: value for domain restrictedrange violates check constraint "restrictedrange_check"
drop domain restrictedrange;
ERROR: type "restrictedrange" does not exist
--
-- Test multiple range types over the same subtype
--

View File

@ -3205,7 +3205,6 @@ NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "t1_pkey" for tab
create view alter_llt1.v1 as select * from alter_llt1.t1;
create function alter_llt1.plus1(int) returns int as 'select $1+1' language sql;
create domain alter_llt1.posint integer check (value > 0);
ERROR: domain is not yet supported.
create type alter_llt1.ctype as (f1 int, f2 text);
create function alter_llt1.same(alter_llt1.ctype, alter_llt1.ctype) returns boolean language sql
as 'select $1.f1 is not distinct from $2.f1 and $1.f2 is not distinct from $2.f2';