From 4b189910c8f50c2a9c4a767e602266e510a0eaf7 Mon Sep 17 00:00:00 2001 From: Yongtao Huang Date: Fri, 4 Aug 2023 13:30:42 +0800 Subject: [PATCH] Fix incompatible logerrors type in pg_exttable This commit is directly cherry-picked from Greenplum#14123. "logerrors" type in pg_foreign_table has been changed from bool to char *by design* in GPDB7 to support log error persistence for external tables, and originally the "logerrors" of extension gp_exttable_fdw was changed accordingly. This PR changes the type back to preserve backward compatability. Because the factual data are stored in pg_foreign_table and this PR only changes the display of the data, it should have no compatability implication. See: Issue#21 See: https://github.com/greenplum-db/gpdb/pull/14123 --- gpcontrib/gp_exttable_fdw/gp_exttable_fdw--1.0.sql | 2 +- gpcontrib/gp_exttable_fdw/gp_exttable_fdw.c | 13 ++++++++++--- src/test/regress/output/external_table.source | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gpcontrib/gp_exttable_fdw/gp_exttable_fdw--1.0.sql b/gpcontrib/gp_exttable_fdw/gp_exttable_fdw--1.0.sql index 9e5b77f06df..bab63e84ba5 100644 --- a/gpcontrib/gp_exttable_fdw/gp_exttable_fdw--1.0.sql +++ b/gpcontrib/gp_exttable_fdw/gp_exttable_fdw--1.0.sql @@ -29,7 +29,7 @@ CREATE FUNCTION pg_exttable(OUT reloid oid, OUT command text, OUT rejectlimit int4, OUT rejectlimittype "char", - OUT logerrors "char", + OUT logerrors bool, OUT encoding int4, OUT writable bool) RETURNS SETOF record diff --git a/gpcontrib/gp_exttable_fdw/gp_exttable_fdw.c b/gpcontrib/gp_exttable_fdw/gp_exttable_fdw.c index c6d87f9cb90..9831fed4bd1 100644 --- a/gpcontrib/gp_exttable_fdw/gp_exttable_fdw.c +++ b/gpcontrib/gp_exttable_fdw/gp_exttable_fdw.c @@ -232,7 +232,7 @@ Datum pg_exttable(PG_FUNCTION_ARGS) TupleDescInitEntry(tupdesc, (AttrNumber) 7, "command", TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 8, "rejectlimit", INT4OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 9, "rejectlimittype", CHAROID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 10, "logerrors", CHAROID, -1, 0); + TupleDescInitEntry(tupdesc, (AttrNumber) 10, "logerrors", BOOLOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 11, "encoding", INT4OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 12, "writable", BOOLOID, -1, 0); @@ -345,8 +345,15 @@ Datum pg_exttable(PG_FUNCTION_ARGS) nulls[8] = true; /* logerrors */ - values[9] = CharGetDatum(extentry->logerrors); - + if IS_LOG_TO_FILE(extentry->logerrors) + { + values[9] = BoolGetDatum(true); + } + else + { + values[9] = BoolGetDatum(false); + } + /* encoding */ values[10] = Int32GetDatum(extentry->encoding); diff --git a/src/test/regress/output/external_table.source b/src/test/regress/output/external_table.source index 6bf7b1554b6..61ea2c938af 100644 --- a/src/test/regress/output/external_table.source +++ b/src/test/regress/output/external_table.source @@ -4974,7 +4974,7 @@ SELECT logerrors from pg_exttable a, pg_class b where a.reloid = b.oid and b.rel SELECT logerrors from pg_exttable a, pg_class b where a.reloid = b.oid and b.relname = 'ext_persistently'; logerrors ----------- - p + t (1 row) -- drop tables