Message-ID: From: "Chitrae92 (@Chitrae92)" To: "pgjdbc/pgjdbc" Date: Fri, 18 Jul 2025 01:31:15 +0000 Subject: [pgjdbc/pgjdbc] issue #3729: PgDatabaseMetaData.getColumns returns duplicate columnNames List-Id: X-GitHub-Author-Id: 28798779 X-GitHub-Author-Login: Chitrae92 X-GitHub-Issue: 3729 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-State: closed X-GitHub-Type: issue X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3729 Content-Type: text/plain; charset=utf-8 Postgres jdbc version - **42.6.1** Java version - 17 When we execute code to retrieve column names for a table with schema name having _ in them and there exists similar table in another schema, we currently get duplicate columns due to the like clause used in getColumns Example: **Schema Name:** test_ **Table Name:** tableA *Column Names* c1, c2 **Schema Name:** test1 **Table Name:** tableA *Column Names* c1, c2 PgDatabaseMetaData.getColumns function ends up returning c1, c2, c1, c2 when getting the column Names for test_.tableA since the LIKE clause satisfies for both the schema names. Is this expected by design? Should we not escape _ in schema or table names instead of treating them as wild characters. if (schemaPattern != null && !schemaPattern.isEmpty()) { sql += " AND n.nspname LIKE " + escapeQuotes(schemaPattern); } if (tableNamePattern != null && !tableNamePattern.isEmpty()) { sql += " AND c.relname LIKE " + escapeQuotes(tableNamePattern); }