peter-toth opened a new pull request, #57038: URL: https://github.com/apache/spark/pull/57038
### What changes were proposed in this pull request? `PostgresDialect.indexExists` and `H2Dialect.indexExists`/`listIndexes` embed the table (and, for H2, schema) name into a SQL string literal in the `pg_indexes` / `INFORMATION_SCHEMA` lookup query without escaping. A table or schema name containing a single quote therefore produces a malformed query that fails with a syntax error. This is inconsistent with the index name in the same methods, which is already escaped via `escapeSql` (SPARK-57446 / SPARK-57447). This change applies `escapeSql` to the table/schema identifiers at these sites so quote-containing identifiers work correctly. `MySQLDialect.indexExists` places the table in identifier position via `quoteIdentifier` and is already correct. ### Why are the changes needed? To correctly handle table and schema names that contain a single quote, consistent with the existing index-name handling. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? New unit test in `JDBCSuite` asserting the generated lookup SQL escapes single quotes in the table/schema name for the H2 and Postgres dialects. ### Was this patch authored or co-authored using generative AI tooling? No. -- 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]
