Skip to content

branch-4.0: [fix](timestamptz) Report TIMESTAMPTZ as string to MySQL clients #63292#63805

Closed
zclllyybb wants to merge 3 commits into
apache:branch-4.0from
zclllyybb:backport-63292-4.0
Closed

branch-4.0: [fix](timestamptz) Report TIMESTAMPTZ as string to MySQL clients #63292#63805
zclllyybb wants to merge 3 commits into
apache:branch-4.0from
zclllyybb:backport-63292-4.0

Conversation

@zclllyybb
Copy link
Copy Markdown
Contributor

pick #63292

zclllyybb added 2 commits May 28, 2026 14:07
TIMESTAMPTZ result rows are serialized as timezone-aware strings in the MySQL binary protocol. FE metadata used to advertise them as MYSQL_TYPE_DATETIME, so Connector/J decoded the length-encoded string bytes as a MySQL datetime binary payload and failed with Invalid length (32) for type TIMESTAMP when ResultSet.getString read a server-prepared result.

Change PrimitiveType.toMysqlType() to return MYSQL_TYPE_STRING for TIMESTAMPTZ, adjust the field packet length and decimals to string semantics, and make the FE local binary result path write TIMESTAMPTZ through the string fallback instead of the datetime binary layout. BE serialization already uses push_timestamptz -> push_string, so no BE payload change is needed.

Add a field-packet unit test and a regression suite that forces ServerPreparedStatement and compares direct ResultSet.getString(ts) with CAST(ts AS STRING).

Verification:

- ./run-fe-ut.sh --run org.apache.doris.mysql.MysqlSerializerVarbinaryTest

- ./run-regression-test.sh --run -d datatype_p0/timestamptz -s test_timestamptz_jdbc_binary_protocol

(cherry picked from commit ecac996)
The TIMESTAMPTZ MySQL metadata fix now reports TIMESTAMPTZ columns as string fields to JDBC clients. That makes direct TIMESTAMPTZ query results use Doris' timezone-aware textual representation instead of the MySQL driver's previous ISO-style timestamp formatting.

Refresh the affected regression baselines for datatype TIMESTAMPTZ casts, date-function document cases, and the Paimon TIMESTAMPTZ external table case. The Paimon direct scanner outputs are aligned with the TeamCity external-regression real result and the corresponding cast output format.

Verification: ./run-regression-test.sh --conf /tmp/doris-regression-conf-9737.groovy --run -d datatype_p0/timestamptz -s test_timestamptz_cast; ./run-regression-test.sh --conf /tmp/doris-regression-conf-9737.groovy --run -d datatype_p0/timestamptz -s test_cast_timestamptz; ./run-regression-test.sh --conf /tmp/doris-regression-conf-9737.groovy --run -d doc/sql-manual/sql-functions -s doc_date_functions_test. All passed.
(cherry picked from commit 0a39514)
@hello-stephen
Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@zclllyybb
Copy link
Copy Markdown
Contributor Author

run buildall

@zclllyybb
Copy link
Copy Markdown
Contributor Author

run buildall

@yiguolei yiguolei closed this May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants