Skip to content

SQLServerDatabaseMetaData getIndexInfo collation error. #2856

@Tinrak

Description

@Tinrak

Driver version

13.2.1.jre11

SQL Server version

Microsoft SQL Azure (RTM) - 12.0.2000.8

Client Operating System

Windows 11

JAVA/JVM version

Java 23

Problem description

We have a SQL Server in Azure where the server collation is SQL_Latin1_General_CP1_CI_AS and the Database collation is in Finnish_Swedish_CI_AS and when running SQLServerDatabaseMetaData.getIndexInfo we now get the error:

'Cannot resolve collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Finnish_Swedish_CI_AS" in UNION ALL operator occurring in ORDER BY statement column 3'

I've extracted the SQL from SQLServerDatabaseMetaData.INDEX_INFO_COMBINED_QUERY and i could reproduce the error by just running that manually.

This might just be expected behavior since the server have a different collation than the database, but version 13.2.0.jre11 did not have this issue.

Error message/stack trace

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot resolve collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Finnish_Swedish_CI_AS" in UNION ALL operator occurring in ORDER BY statement column 3.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:278)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1788)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:688)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:607)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7825)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:4828)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:321)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:253)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:521)
at com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData.getIndexInfo(SQLServerDatabaseMetaData.java:1292)

Any other details that can be helpful

This issue does not exist is version 13.2.0.jre11

Metadata

Metadata

Assignees

Labels

Under ReviewUsed for pull requests under review

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions