From 1e2e3c91eba5a0ed99b28ce2cc30a3651a534803 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Tue, 22 Sep 2026 09:07:31 +0000
Subject: [PATCH] [#902] Name the table to the index guard of the JDBC backend the way the database stores it (#1001)

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/jdbc/JDBCStorage.java |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/jdbc/JDBCStorage.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/jdbc/JDBCStorage.java
index 4f56aa4..d2f2c61 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/jdbc/JDBCStorage.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/jdbc/JDBCStorage.java
@@ -4622,8 +4622,10 @@
 					}
 				}else if (dialect==Dialect.ORACLE) {
 					try {
-						// oracle has no "create index if not exists"; unquoted identifiers are stored in uppercase
-						if (!isExistsIndex(tableName.toUpperCase(Locale.ROOT),"k_"+tableName.substring("opendj_".length()))) {
+						// oracle has no "create index if not exists"; the lookup spells the table the way this
+						// database stores it - unquoted identifiers go in folded there - and is told so by the
+						// driver rather than by this branch
+						if (!isExistsIndex(tableName,"k_"+tableName.substring("opendj_".length()))) {
 							commitStatement("create index k_"+tableName.substring("opendj_".length())+" on "+tableName+" (k)", true);
 						}
 					}catch (SQLException e) {
@@ -5006,8 +5008,15 @@
 			// class: it asks a data dictionary rather than the data, so a wait here is the metadata lock
 			// of another session - and it is narrowed to the scope every table lookup here is narrowed to
 			return bounded(con, StatementBound.OPERATION, () -> {
+				final DatabaseMetaData metaData=con.getMetaData();
+				// the table named the way this database stores it, asked of the driver rather than folded
+				// per engine: getIndexInfo() takes a name and matches it against the stored form, and an
+				// unquoted identifier is stored folded. isExistsTable() asks storedIdentifier() the same
+				// question, and an engine wired in later inherits the answer here instead of the upper case
+				// the oracle branch of the caller used to carry for itself (#902)
 				// approximate=true: with false the oracle driver runs ANALYZE on every call
-				try (final ResultSet rs = con.getMetaData().getIndexInfo(scope.catalog, null, tableName, false, true)) {
+				try (final ResultSet rs = metaData.getIndexInfo(scope.catalog, null,
+						storedIdentifier(metaData, tableName), false, true)) {
 					while (rs.next()) {
 						if (indexName.equalsIgnoreCase(rs.getString("INDEX_NAME")) && scope.covers(rs)) {
 							return true;

--
Gitblit v1.10.0