[FLINK-34088] [hotfix] fix the problems with special table name characters of postgres and oracle and sqlserver.#89
[FLINK-34088] [hotfix] fix the problems with special table name characters of postgres and oracle and sqlserver.#89BlackPigHe wants to merge 4 commits intoapache:mainfrom
Conversation
…res and oracle and sqlserver.
| Thanks for opening this pull request! Please check out our contributing guidelines. (https://flink.apache.org/contributing/how-to-contribute.html) |
…res and oracle and sqlserver. update test case.
| add the commit to update test case |
…in oracle jdbc,Specify the required type explicitly
…roperly in oracle jdbc,Specify the required type explicitly" This reverts commit 7272a79.
| public static String handleDoubleQuotes(String identifier) { | ||
| String[] split = identifier.split("\\."); | ||
| StringBuilder builder = new StringBuilder(); | ||
| for (String s : split) { | ||
| builder.append("\"").append(s).append("\""); | ||
| builder.append("."); | ||
| } | ||
| return builder.deleteCharAt(builder.length() - 1).toString(); | ||
| } |
There was a problem hiding this comment.
I didn't get why we are going to put logic with double quotes into some generic place if for different engines there could be different quotes?
There was a problem hiding this comment.
Because oracle and postgres have the same escape characters, It's all double quotes
There was a problem hiding this comment.
this package is not only for oracle and postgres. E.g. MS SQL Server, MySQL are different
There was a problem hiding this comment.
Do you think that the location of this method is not appropriate, I think it is OK, the specific escape characters of the data source in their own package implementation, there are public features to extract and did not find a better location
| "INSERT INTO \"tbl\"(\"id\", \"name\", \"email\", \"ts\", \"field1\", \"field_2\", \"__field_3__\") " | ||
| + "VALUES (:id, :name, :email, :ts, :field1, :field_2, :__field_3__)"); | ||
| NamedStatementMatcher.parsedSql( | ||
| "INSERT INTO tbl(id, name, email, ts, field1, field_2, __field_3__) " | ||
| "INSERT INTO \"tbl\"(\"id\", \"name\", \"email\", \"ts\", \"field1\", \"field_2\", \"__field_3__\") " |
There was a problem hiding this comment.
In issue description it was only something about table name
why does it impact columns?
There was a problem hiding this comment.
the method ‘quoteIdentifier’ is common,column metadata is also by call the method.Columns should have this problem as well
There was a problem hiding this comment.
can we have a failing test reproducing the problem?
| I guess we can extract information about current quote identifier directly from JDBCDriver |
I get it. If there are no compatibility issues, It's better this way. |
I thought the method |
| yep, may be it is a point to see whether we could adapt it or not btw I haven't found any test reproducing the issue, can you add one? |
| This PR is being marked as stale since it has not had any activity in the last 90 days. If you are having difficulty finding a reviewer, please reach out to the If this PR is no longer valid or desired, please feel free to close it. |
English VersionTitle: PostgresDialect fails to quote reserved keywords (e.g., Body: I encountered an issue when using the Flink JDBC connector to write data into a PostgreSQL table that contains a column named Upon investigation, I found that the generated SQL statement does not wrap the column name Looking at the source code, I noticed that Suggestion: Relevant code location: 中文版本标题:PostgreSQL 方言未正确转义保留关键字字段(如 正文: 我在使用 Flink JDBC connector 写入 PostgreSQL 表时遇到了一个问题:当表中包含名为 经排查,Flink 生成的 SQL 语句未对列名 我查看了源码,发现 建议: --- CREATE TABLE IF NOT EXISTS agent_tool ( `id` STRING, `type` STRING, `shop_id` STRING, `name` STRING, `desc` STRING, `key` STRING, `conf` STRING, `icon` STRING, `enabled` BOOLEAN NOT NULL, `is_deleted` BOOLEAN NOT NULL, `created_at` TIMESTAMP, `updated_at` TIMESTAMP, `deleted_at` TIMESTAMP, `creator` STRING, PRIMARY KEY ( `id` ) NOT ENFORCED ) WITH ( 'connector' = 'jdbc', 'url' = 'jdbc:postgresql://aaaa:5432/bbbb?sslmode=disable&stringtype=unspecified¤tSchema=public', 'username' = 'cccc', 'password'='dddd', 'table-name' = 'agent_tool', 'sink.buffer-flush.max-rows' = '1000', 'sink.buffer-flush.interval' = '2s', 'sink.max-retries' = '3' ); |
| This PR is being marked as stale since it has not had any activity in the last 90 days. If you are having difficulty finding a reviewer, please reach out to the If this PR is no longer valid or desired, please feel free to close it. |

[hotfix] fix the problems with special table name characters of postgres and oracle and sqlserver.