diff --git a/src/common/backend/utils/adt/ruleutils.cpp b/src/common/backend/utils/adt/ruleutils.cpp index 2fea73042af313df76497750d72efc0046cb5abb..b6b666c6f7acc4ede57c304dc81de6f0d8d6a574 100644 --- a/src/common/backend/utils/adt/ruleutils.cpp +++ b/src/common/backend/utils/adt/ruleutils.cpp @@ -2426,7 +2426,8 @@ static char* pg_get_tabledef_worker(Oid tableoid) { StringInfoData buf; StringInfoData query; - const char* reltypename = NULL; + const char* reltypename = NULL; // pg_class reltype + char* relOfTypeName = NULL; // pg_class reloftype int actual_atts = 0; bool isnull = false; char* srvname = NULL; @@ -2610,47 +2611,53 @@ static char* pg_get_tabledef_worker(Oid tableoid) reltypename, relname); - // get attribute info - actual_atts = get_table_attribute(tableoid, &buf, formatter, ft_frmt_clmn, cnt_ft_frmt_clmns); + if (classForm->reloftype != 0) { + relOfTypeName = get_typename(classForm->reloftype); + appendStringInfo(&buf, " of %s", relOfTypeName); + } + else { + // get attribute info + actual_atts = get_table_attribute(tableoid, &buf, formatter, ft_frmt_clmn, cnt_ft_frmt_clmns); - /* - * Fetch the constraint tuple from pg_constraint. There may be more than - * one match, because constraints are not required to have unique names; - * if so, error out. - */ - pg_constraint = heap_open(ConstraintRelationId, AccessShareLock); + /* + * Fetch the constraint tuple from pg_constraint. There may be more than + * one match, because constraints are not required to have unique names; + * if so, error out. + */ + pg_constraint = heap_open(ConstraintRelationId, AccessShareLock); - ScanKeyInit(&skey[0], Anum_pg_constraint_conrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(tableoid)); + ScanKeyInit(&skey[0], Anum_pg_constraint_conrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(tableoid)); - scan = systable_beginscan(pg_constraint, ConstraintRelidIndexId, true, NULL, 1, skey); + scan = systable_beginscan(pg_constraint, ConstraintRelidIndexId, true, NULL, 1, skey); - while (HeapTupleIsValid(tuple = systable_getnext(scan))) { - Form_pg_constraint con = (Form_pg_constraint)GETSTRUCT(tuple); + while (HeapTupleIsValid(tuple = systable_getnext(scan))) { + Form_pg_constraint con = (Form_pg_constraint)GETSTRUCT(tuple); - if (con->contype == 'c' || con->contype == 'f') { - if (!con->convalidated) { - has_not_valid_check = true; - continue; - } + if (con->contype == 'c' || con->contype == 'f') { + if (!con->convalidated) { + has_not_valid_check = true; + continue; + } - if (actual_atts == 0) - appendStringInfo(&buf, " (\n "); - else - appendStringInfo(&buf, ",\n "); + if (actual_atts == 0) + appendStringInfo(&buf, " (\n "); + else + appendStringInfo(&buf, ",\n "); - appendStringInfo(&buf, "CONSTRAINT %s ", quote_identifier(NameStr(con->conname))); - Oid conOid = HeapTupleGetOid(tuple); - appendStringInfo(&buf, "%s", pg_get_constraintdef_worker(conOid, false, 0)); + appendStringInfo(&buf, "CONSTRAINT %s ", quote_identifier(NameStr(con->conname))); + Oid conOid = HeapTupleGetOid(tuple); + appendStringInfo(&buf, "%s", pg_get_constraintdef_worker(conOid, false, 0)); - actual_atts++; + actual_atts++; + } } - } - systable_endscan(scan); - heap_close(pg_constraint, AccessShareLock); + systable_endscan(scan); + heap_close(pg_constraint, AccessShareLock); - if (actual_atts) { - appendStringInfo(&buf, "\n)"); + if (actual_atts) { + appendStringInfo(&buf, "\n)"); + } } /* append table info to buf */ diff --git a/src/gausskernel/storage/replication/logical/reorderbuffer.cpp b/src/gausskernel/storage/replication/logical/reorderbuffer.cpp index a9996909171855fe8c48ed11db4ddd7dcaa93ad5..f13e093a3be393a9e2df87c9450b4e5b1c541a50 100644 --- a/src/gausskernel/storage/replication/logical/reorderbuffer.cpp +++ b/src/gausskernel/storage/replication/logical/reorderbuffer.cpp @@ -1251,7 +1251,6 @@ void ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid, XLogRecPtr commit volatile Snapshot snapshot_now = NULL; volatile bool txn_started = false; volatile bool subtxn_started = false; - u_sess->attr.attr_common.extra_float_digits = LOGICAL_DECODE_EXTRA_FLOAT_DIGITS; txn = ReorderBufferTXNByXid(rb, xid, false, NULL, InvalidXLogRecPtr, false); /* unknown transaction, nothing to replay */ diff --git a/src/test/regress/expected/function_get_table_def.out b/src/test/regress/expected/function_get_table_def.out index 7359f05a1083fe70d3c8faaa6a3e860aeb981fb0..413e0009eb39c8e07ecb8efca176d846f35f802b 100644 --- a/src/test/regress/expected/function_get_table_def.out +++ b/src/test/regress/expected/function_get_table_def.out @@ -589,5 +589,18 @@ select * from pg_get_tabledef('generated_test'); (1 row) drop table generated_test; +--type table +create type test_type_table is(a varchar2, b int); +create table test_type_table_t of test_type_table; +select pg_get_tabledef('test_type_table_t'); + pg_get_tabledef +--------------------------------------------------- + SET search_path = test_get_table_def; + + CREATE TABLE test_type_table_t of test_type_table+ + WITH (orientation=row, compression=no); +(1 row) + +drop table test_type_table_t; +drop type test_type_table; reset current_schema; drop schema test_get_table_def cascade; diff --git a/src/test/regress/sql/function_get_table_def.sql b/src/test/regress/sql/function_get_table_def.sql index 644b0c787e7c5afc38b959f30ae0093fab1cc09d..d5f98aaee5a75b1b6a040b12a8a61d07fb092c91 100644 --- a/src/test/regress/sql/function_get_table_def.sql +++ b/src/test/regress/sql/function_get_table_def.sql @@ -214,5 +214,12 @@ create table generated_test(a int, b int generated always as (length((a)::text)) select * from pg_get_tabledef('generated_test'); drop table generated_test; +--type table +create type test_type_table is(a varchar2, b int); +create table test_type_table_t of test_type_table; +select pg_get_tabledef('test_type_table_t'); +drop table test_type_table_t; +drop type test_type_table; + reset current_schema; drop schema test_get_table_def cascade;