yuqi1129 opened a new issue, #13973:
URL: https://github.com/apache/gravitino/issues/13973
### Version
main branch
### Describe what's wrong
`JdbcColumnDefaultValueConverter.fromGravitino` renders every non-numeric
default literal as `String.format("'%s'", literal.value())` without escaping.
Numeric defaults are written verbatim from the request value without checking
that they are numbers.
MySQL, PostgreSQL, StarRocks, OceanBase and Hologres use this converter for
create table, add column and update column default. Doris uses it for CREATE
TABLE.
A default value that contains a quote produces invalid DDL. A value carrying
quotes and SQL text changes the generated statement itself.
### Error message and/or stacktrace
The database rejects the generated statement with a syntax error.
### How to reproduce
1. Create a table through a MySQL catalog with a `VARCHAR(64)` column whose
default is `Literals.varcharLiteral(64, "O'Brien")`.
2. The generated DDL contains `DEFAULT 'O'Brien'` and MySQL rejects it.
### Additional context
Dialects differ in how a string literal must be escaped:
- MySQL, StarRocks and OceanBase: backslash escapes plus doubled apostrophes.
- PostgreSQL and Hologres: doubled apostrophes only, since backslashes are
ordinary characters with `standard_conforming_strings` on.
- Doris 2.1 and later: the string default text is kept unchanged at CREATE
TABLE and parsed again as a double-quoted literal when a row takes the default.
Doris 1.2 decodes the literal at CREATE TABLE instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]