tchivs created FLINK-38188:
------------------------------
Summary: PostgreSQL connector database name validation logic is
inverted in getValidateDatabaseName method
Key: FLINK-38188
URL: https://issues.apache.org/jira/browse/FLINK-38188
Project: Flink
Issue Type: Bug
Components: Connectors / JDBC
Affects Versions: cdc-3.4.0
Environment: 1. Configure a PostgreSQL CDC source with multiple tables
from the same database
2. Use table format like: `database.schema.table1,database.schema.table2`
3. Observe the IllegalStateException being thrown during validation
Reporter: tchivs
*Problem Description:*
The `getValidateDatabaseName` method in `PostgresDataSourceFactory` has
incorrect validation logic that causes it to throw an exception when all tables
have the same database name, which is the opposite of the intended behavior.
*Current Behavior:*
When configuring multiple PostgreSQL tables with the same database name (e.g.,
`aia_test.public.table1,aia_test.public.table2`), the validation fails with:
{code}
java.lang.IllegalStateException: The value of option tables all table names
must have the same database name
{code}
*Expected Behavior:*
The validation should pass when all tables have the same database name and only
fail when database names are inconsistent.
*Root Cause:*
In line 424 of `PostgresDataSourceFactory.java`, the condition is inverted:
{code:java}
checkState(
!dbName.equals(currentDbName), // Should be dbName.equals(currentDbName)
String.format(
"The value of option %s all table names must have the same database
name",
TABLES.key()));
{code}
*Impact:*
This prevents users from using multiple tables from the same PostgreSQL
database in their CDC pipelines.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)