JNSimba opened a new pull request, #63402:
URL: https://github.com/apache/doris/pull/63402

   ### What problem does this PR solve?
   
   Issue Number: close #xxx
   
   Related PR: #xxx
   
   Problem Summary:
   
   `JdbcPostgreSQLClient.getJdbcColumnsInfo` calls 
`DatabaseMetaData.getColumns(catalog, schemaPattern, tableNamePattern, 
columnNamePattern)`. Per the JDBC spec the 3rd argument is a **SQL LIKE 
pattern**, so literal `_` / `%` characters in the requested table name are 
interpreted as wildcards by the Postgres driver. When a streaming job is 
created with `include_tables = "user_info_pg_normal1"` and a neighbour table 
like `userXinfo_pg_normal1` happens to coexist in the same schema, the metadata 
query returns columns from **both** tables. The combined result then trips 
`CREATE TABLE` on the Doris side with errors such as `errCode = 2, 
detailMessage = Duplicate column name 'name'`, or pollutes the auto-created 
table schema with stray columns.
   
   The repro is trivial: in the same Postgres schema create
   
   - `user_info_pg_normal1(name varchar, age int2)` — the table we want to 
capture
   - `userXinfo_pg_normal1(name varchar, weight float8)` — a decoy whose name 
only differs from the target by a single character that `_` matches
   
   then run `CREATE JOB ... include_tables = "user_info_pg_normal1"`. Without 
the fix the schema fetched for the target leaks `weight` (or `Duplicate column 
name 'name'`, depending on column order).
   
   Fix: after fetching the `ResultSet`, drop rows whose `TABLE_NAME` does not 
exactly equal the requested `remoteTableName`. This mirrors 
[apache/flink-cdc#4239 
(FLINK-38965)](https://github.com/apache/flink-cdc/pull/4239), which solved the 
same class of issue in the Postgres CDC source. We deliberately do **not** 
escape `_` / `%` at the source: relying on 
`DatabaseMetaData.getSearchStringEscape()` is driver-version dependent (older 
Oracle drivers don't honour escape sequences in `getTables`), while filtering 
on the consumer side is deterministic and driver-agnostic.
   
   Scope:
   
   - Only `JdbcPostgreSQLClient` is patched. This is the path used by Postgres 
streaming jobs (the failing case). MySQL streaming jobs were checked against 
the same decoy pattern and do not reproduce the bug because MySQL Connector/J 
doesn't pull neighbour rows here in practice — so `JdbcMySQLClient` is left 
untouched in this PR.
   - The JDBC catalog path lives in a separate module 
(`fe-connector-jdbc/.../JdbcConnectorClient`) and is **not** part of this PR. 
It already does partial escape but intentionally skips `_` / `%` for 
driver-compatibility reasons; a follow-up can apply the same after-the-fact 
filter there.
   
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Test
       - [x] Regression test
       - [ ] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason
   
   A decoy table `userXinfo_pg_normal1` (with a different column shape: `weight 
float8`) is added to `test_streaming_postgres_job.groovy`, plus an `assert 
!createTalInfo.contains(\`weight\`)` guard. Without the fix the case fails 
(either `Duplicate column name` during `CREATE TABLE`, or the `weight` assert 
trips). The same decoy is mirrored into `test_streaming_mysql_job.groovy` as a 
baseline so any future regression in MySQL Connector/J's behaviour is caught 
immediately.
   
   - Behavior changed:
       - [x] No.
       - [ ] Yes.
   
   - Does this need documentation?
       - [x] No.
       - [ ] Yes.
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to