diff --git a/src/common/backend/utils/adt/varchar.cpp b/src/common/backend/utils/adt/varchar.cpp index 9b68d9355cd16b9e535dc70c84a9569f467c7c59..55a72d62c7d28895b5c53482f86fc96b8d067611 100644 --- a/src/common/backend/utils/adt/varchar.cpp +++ b/src/common/backend/utils/adt/varchar.cpp @@ -317,7 +317,7 @@ Datum bpchar(PG_FUNCTION_ARGS) * * Now, only explicit cast char type data should pad blank space. */ - if (!isExplicit) + if (!isExplicit || DB_IS_CMPT(PG_FORMAT | B_FORMAT)) maxlen = len; } diff --git a/src/test/regress/expected/b_compatibility.out b/src/test/regress/expected/b_compatibility.out index df93b5cff7a2aa87b1d09081009fd787d5d4826f..9bd82f4881f6f68280e2bc9b29c8fcdbbd03241a 100644 --- a/src/test/regress/expected/b_compatibility.out +++ b/src/test/regress/expected/b_compatibility.out @@ -785,6 +785,12 @@ select bit_length(a),bit_length(b) from char_test; 8 | 8 (8 rows) +select 'ni啊shaeskeeee'::char(3); + bpchar +-------- + ni啊 +(1 row) + create index a on char_test(a); create index b on char_test(b); set enable_seqscan to off; diff --git a/src/test/regress/expected/pg_compatibility.out b/src/test/regress/expected/pg_compatibility.out index 5c1cc24d9812235b41fee5b48997454b3f74172a..03d0f26370b68f03d5df99ff264d8a60174d8685 100644 --- a/src/test/regress/expected/pg_compatibility.out +++ b/src/test/regress/expected/pg_compatibility.out @@ -82,6 +82,12 @@ select bit_length(a),bit_length(b) from char_test; 8 | 8 (6 rows) +select 'ni啊shaeskeeee'::char(3); + bpchar +-------- + ni啊 +(1 row) + create index a on char_test(a); create index b on char_test(b); set enable_seqscan to off; diff --git a/src/test/regress/sql/b_compatibility.sql b/src/test/regress/sql/b_compatibility.sql index c2e94ac866549fd1ba3425ddd35aff229e5e4936..8249d6db0dd73835d1161097c71b7429bb6666b9 100644 --- a/src/test/regress/sql/b_compatibility.sql +++ b/src/test/regress/sql/b_compatibility.sql @@ -204,6 +204,7 @@ insert into char_test values('0','0'); select length(a),length(b) from char_test; select lengthb(a),lengthb(b) from char_test; select bit_length(a),bit_length(b) from char_test; +select 'ni啊shaeskeeee'::char(3); create index a on char_test(a); create index b on char_test(b); diff --git a/src/test/regress/sql/pg_compatibility.sql b/src/test/regress/sql/pg_compatibility.sql index 4d720643a083b1e5e7d7c69a1da1216309bd4128..6bd029d6909f4e7be47ffcd495d862fbb7ea3657 100644 --- a/src/test/regress/sql/pg_compatibility.sql +++ b/src/test/regress/sql/pg_compatibility.sql @@ -32,6 +32,7 @@ insert into char_test values('0','0'); select length(a),length(b) from char_test; select lengthb(a),lengthb(b) from char_test; select bit_length(a),bit_length(b) from char_test; +select 'ni啊shaeskeeee'::char(3); create index a on char_test(a); create index b on char_test(b);