This is an automated email from the ASF dual-hosted git repository. yjhjstz pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit 615a5d0c4830d70ddba1dd9c607bfdc7880b4fe1 Author: xiaoxiao <[email protected]> AuthorDate: Tue Aug 9 14:42:26 2022 +0800 if encoding is defaulted when creating external tables, we will use the server encoding (#13885) --- src/backend/commands/exttablecmds.c | 4 ++-- src/test/regress/input/external_table.source | 9 +++++++++ src/test/regress/output/external_table.source | 20 ++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/backend/commands/exttablecmds.c b/src/backend/commands/exttablecmds.c index 4acfc778fc..a839e71ce7 100644 --- a/src/backend/commands/exttablecmds.c +++ b/src/backend/commands/exttablecmds.c @@ -234,9 +234,9 @@ DefineExternalRelation(CreateExternalStmt *createExtStmt) nodeTag(dencoding->arg)); } - /* If encoding is defaulted, use database encoding */ + /* If encoding is defaulted, use database server encoding */ if (encoding < 0) - encoding = pg_get_client_encoding(); + encoding = GetDatabaseEncoding(); /* * If the number of locations (file or http URIs) exceed the number of diff --git a/src/test/regress/input/external_table.source b/src/test/regress/input/external_table.source index 6e668ce7d6..58c2153421 100644 --- a/src/test/regress/input/external_table.source +++ b/src/test/regress/input/external_table.source @@ -270,6 +270,15 @@ DROP OWNED BY test_role_issue_12748; DROP ROLE test_role_issue_12748; DROP PROTOCOL dummy_protocol_issue_12748; +-- Test pg_exttable's encoding: QE's encoding should be consistent with QD +-- GitHub Issue #9727: https://github.com/greenplum-db/gpdb/issues/9727 +SET client_encoding = 'ISO-8859-1'; +CREATE EXTERNAL TABLE issue_9727 (d varchar(20)) location ('gpfdist://9727/d.dat') format 'csv' (DELIMITER '|'); +SELECT encoding from pg_exttable where urilocation='{gpfdist://9727:8080/d.dat}'; +SELECT encoding from gp_dist_random('pg_exttable') where urilocation='{gpfdist://9727:8080/d.dat}'; +DROP FOREIGN TABLE issue_9727; +RESET client_encoding; + -- -- WET tests -- diff --git a/src/test/regress/output/external_table.source b/src/test/regress/output/external_table.source index bcea453311..9d538cf3a0 100644 --- a/src/test/regress/output/external_table.source +++ b/src/test/regress/output/external_table.source @@ -343,6 +343,26 @@ DROP OWNED BY test_role_issue_12748; -- Clean up. DROP ROLE test_role_issue_12748; DROP PROTOCOL dummy_protocol_issue_12748; +-- Test pg_exttable's encoding: QE's encoding should be consistent with QD +-- GitHub Issue #9727: https://github.com/greenplum-db/gpdb/issues/9727 +SET client_encoding = 'ISO-8859-1'; +CREATE EXTERNAL TABLE issue_9727 (d varchar(20)) location ('gpfdist://9727/d.dat') format 'csv' (DELIMITER '|'); +SELECT encoding from pg_exttable where urilocation='{gpfdist://9727:8080/d.dat}'; + encoding +---------- + 6 +(1 row) + +SELECT encoding from gp_dist_random('pg_exttable') where urilocation='{gpfdist://9727:8080/d.dat}'; + encoding +---------- + 6 + 6 + 6 +(3 rows) + +DROP FOREIGN TABLE issue_9727; +RESET client_encoding; -- -- WET tests -- --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
