From afcd18e3570704e56e3cb604f7f7cf05bd8edaa3 Mon Sep 17 00:00:00 2001 From: wuyuechuan Date: Mon, 23 Oct 2023 19:56:07 +0800 Subject: [PATCH] tableof: pljson_list_data support --- src/common/backend/parser/parse_utilcmd.cpp | 2 +- .../regress/expected/tableof_unsupported.out | 23 +++++++++++++++++++ src/test/regress/parallel_schedule0 | 2 +- src/test/regress/sql/tableof_unsupported.sql | 16 ++++++++++++- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/common/backend/parser/parse_utilcmd.cpp b/src/common/backend/parser/parse_utilcmd.cpp index ab7aa98a6..730772954 100644 --- a/src/common/backend/parser/parse_utilcmd.cpp +++ b/src/common/backend/parser/parse_utilcmd.cpp @@ -5302,7 +5302,7 @@ static void CheckColumnTableOfType(Type ctype) errmsg("type %u cannot get tupledesc", HeapTupleGetOid(ctype)))); } for (int i = 0; i < tupleDesc->natts; i++) { - if (tupleDesc->attrs[i].attisdropped) { + if (tupleDesc->attrs[i].attisdropped || strcmp(NameStr(tupleDesc->attrs[i].attname), "pljson_list_data") == 0) { continue; } HeapTuple typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(tupleDesc->attrs[i].atttypid)); diff --git a/src/test/regress/expected/tableof_unsupported.out b/src/test/regress/expected/tableof_unsupported.out index 9cfc8a93e..2f33fa99a 100644 --- a/src/test/regress/expected/tableof_unsupported.out +++ b/src/test/regress/expected/tableof_unsupported.out @@ -1,3 +1,5 @@ +create schema tableof_unsupported; +set search_path to tableof_unsupported; ------ Prepare ------ -- create type of TYPTYPE_TABLEOF create type r0 is (c1 int1, c2 int2); @@ -14,3 +16,24 @@ DETAIL: "t0" is a nest table type create table tableof_unsupported(id t2); ERROR: type "t2" is not supported as column type DETAIL: "t2" is a nest table type +-- composite type cannot be made a member of itself +create type test as (a int); +create type test_arr as(a test[]); +alter type test add attribute b test_arr; +ERROR: composite type test cannot be made a member of itself +-- pljson_list_data is an exception +create type pljson as (a int); +create type pljson_list_data as (pljson_list_data pljson[]); +alter type pljson add attribute b pljson_list_data; +reset search_path; +drop schema tableof_unsupported cascade; +NOTICE: drop cascades to 9 other objects +DETAIL: drop cascades to type tableof_unsupported.r0 +drop cascades to type _int4[] +drop cascades to type tableof_unsupported.t1 +drop cascades to type tableof_unsupported._r0[] +drop cascades to type tableof_unsupported.test +drop cascades to type tableof_unsupported.test_arr +drop cascades to type tableof_unsupported.pljson +drop cascades to type tableof_unsupported.pljson_list_data +drop cascades to composite type tableof_unsupported.pljson column b \ No newline at end of file diff --git a/src/test/regress/parallel_schedule0 b/src/test/regress/parallel_schedule0 index bdb4208fc..b686321de 100644 --- a/src/test/regress/parallel_schedule0 +++ b/src/test/regress/parallel_schedule0 @@ -1011,7 +1011,7 @@ test: gtt_trunc_pre test: gtt_trunc_parallel_dml1 gtt_trunc_parallel_dml2 gtt_trunc_parallel_ddl1 gtt_trunc_parallel_ddl2 #test: gtt_trunc_clean -test: toomanyparams +test: toomanyparams tableof_unsupported test: test_astore_multixact test: row_compression/pg_table_size row_compression/unsupported_feature row_compression/normal_test row_compression/alter_compress_params diff --git a/src/test/regress/sql/tableof_unsupported.sql b/src/test/regress/sql/tableof_unsupported.sql index f574c6a66..3307c7153 100644 --- a/src/test/regress/sql/tableof_unsupported.sql +++ b/src/test/regress/sql/tableof_unsupported.sql @@ -1,3 +1,5 @@ +create schema tableof_unsupported; +set search_path to tableof_unsupported; ------ Prepare ------ -- create type of TYPTYPE_TABLEOF create type r0 is (c1 int1, c2 int2); @@ -9,4 +11,16 @@ create type t2 is table of r0; -- create table create table tableof_unsupported(id t0); create table tableof_unsupported(id t1); -create table tableof_unsupported(id t2); \ No newline at end of file +create table tableof_unsupported(id t2); + +-- composite type cannot be made a member of itself +create type test as (a int); +create type test_arr as(a test[]); +alter type test add attribute b test_arr; + +-- pljson_list_data is an exception +create type pljson as (a int); +create type pljson_list_data as (pljson_list_data pljson[]); +alter type pljson add attribute b pljson_list_data; +reset search_path; +drop schema tableof_unsupported cascade; \ No newline at end of file