dongjoon-hyun opened a new pull request, #56508:
URL: https://github.com/apache/spark/pull/56508

   ### What changes were proposed in this pull request?
   
   `indexExists` in `H2Dialect`, `MySQLDialect`, and `PostgresDialect` embeds 
the
   index name as a SQL string literal in its lookup query. This PR wraps the 
index
   name with the existing `JdbcDialect.escapeSql` helper so that single quotes 
are
   properly escaped.
   
   ### Why are the changes needed?
   
   If an index name contains a single quote, the lookup query becomes malformed
   (e.g. `... INDEX_NAME = 'a'b'`). `JdbcUtils.checkIfIndexExists` swallows the
   resulting exception and returns `false`, so an existing index whose name
   contains a single quote is incorrectly reported as not existing.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Added a unit test in `JDBCSuite` that captures the lookup SQL generated by
   `indexExists` for the H2, MySQL, and PostgreSQL dialects via a mocked
   `Connection`, and asserts that a single quote in the index name is escaped. 
The
   test fails for each dialect when the escaping is reverted.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code


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