Skip to content

Commit 05b8493

Browse files
committed
Fix based on review
1 parent 6d051e2 commit 05b8493

File tree

10 files changed

+17
-26
lines changed

10 files changed

+17
-26
lines changed

core/src/main/java/com/scalar/db/storage/jdbc/JdbcAdmin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,9 +710,10 @@ public Set<String> getNamespaceTableNames(String namespace) throws ExecutionExce
710710

711711
private Set<String> getNamespaceTableNamesInternal(Connection connection, String namespace)
712712
throws SQLException {
713-
String sql = rdbEngine.getTableNamesInNamespaceSql(namespace);
713+
String sql = rdbEngine.getTableNamesInNamespaceSql();
714714
Set<String> tableNames = new HashSet<>();
715715
try (PreparedStatement statement = connection.prepareStatement(sql)) {
716+
statement.setString(1, namespace);
716717
try (ResultSet resultSet = statement.executeQuery()) {
717718
while (resultSet.next()) {
718719
tableNames.add(resultSet.getString(1));

core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineDb2.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,7 @@ public void throwIfCrossPartitionScanOrderingOnBlobColumnNotSupported(
585585
}
586586

587587
@Override
588-
public String getTableNamesInNamespaceSql(String namespace) {
589-
return String.format(
590-
"SELECT TABNAME FROM SYSCAT.TABLES WHERE TABSCHEMA = '%s' AND TYPE = 'T'", namespace);
588+
public String getTableNamesInNamespaceSql() {
589+
return "SELECT TABNAME FROM SYSCAT.TABLES WHERE TABSCHEMA = ? AND TYPE = 'T'";
591590
}
592591
}

core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineMysql.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,7 @@ public void setConnectionToReadOnly(Connection connection, boolean readOnly) thr
506506
}
507507

508508
@Override
509-
public String getTableNamesInNamespaceSql(String namespace) {
510-
return "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '"
511-
+ namespace
512-
+ "'";
509+
public String getTableNamesInNamespaceSql() {
510+
return "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ?";
513511
}
514512
}

core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineOracle.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ public void throwIfAlterColumnTypeNotSupported(DataType from, DataType to) {
453453
}
454454

455455
@Override
456-
public String getTableNamesInNamespaceSql(String namespace) {
457-
return String.format("SELECT TABLE_NAME FROM ALL_TABLES WHERE OWNER = '%s'", namespace);
456+
public String getTableNamesInNamespaceSql() {
457+
return "SELECT TABLE_NAME FROM ALL_TABLES WHERE OWNER = ?";
458458
}
459459
}

core/src/main/java/com/scalar/db/storage/jdbc/RdbEnginePostgresql.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,7 @@ public String tryAddIfNotExistsToCreateIndexSql(String createIndexSql) {
397397
}
398398

399399
@Override
400-
public String getTableNamesInNamespaceSql(String namespace) {
401-
return "SELECT table_name FROM information_schema.tables WHERE table_schema = '"
402-
+ namespace
403-
+ "'";
400+
public String getTableNamesInNamespaceSql() {
401+
return "SELECT table_name FROM information_schema.tables WHERE table_schema = ?";
404402
}
405403
}

core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineSqlServer.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,7 @@ public Map<String, String> getConnectionProperties(JdbcConfig config) {
433433
}
434434

435435
@Override
436-
public String getTableNamesInNamespaceSql(String namespace) {
437-
return "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '"
438-
+ namespace
439-
+ "'";
436+
public String getTableNamesInNamespaceSql() {
437+
return "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ?";
440438
}
441439
}

core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineSqlite.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,7 @@ public void setConnectionToReadOnly(Connection connection, boolean readOnly) {
369369
}
370370

371371
@Override
372-
public String getTableNamesInNamespaceSql(String namespace) {
373-
return "SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '"
374-
+ namespace
375-
+ NAMESPACE_SEPARATOR
376-
+ "%'";
372+
public String getTableNamesInNamespaceSql() {
373+
return "SELECT name FROM sqlite_master WHERE type='table' AND name LIKE ?";
377374
}
378375
}

core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,5 +306,5 @@ default void setConnectionToReadOnly(Connection connection, boolean readOnly)
306306
default void throwIfCrossPartitionScanOrderingOnBlobColumnNotSupported(
307307
ScanAll scanAll, TableMetadata metadata) {}
308308

309-
String getTableNamesInNamespaceSql(String namespace);
309+
String getTableNamesInNamespaceSql();
310310
}

integration-test/src/main/java/com/scalar/db/api/DistributedStorageAdminImportTableIntegrationTestBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public void dropNamespace_ShouldNotDropNonScalarDBTables() throws Exception {
255255
assertThat(admin.namespaceExists(getNamespace())).isTrue();
256256
for (TestData testData : testDataList) {
257257
if (!testData.isImportableTable()) {
258-
adminTestUtils.tableExists(getNamespace(), testData.getTableName());
258+
assertThat(adminTestUtils.tableExists(getNamespace(), testData.getTableName())).isTrue();
259259
}
260260
}
261261
} finally {

integration-test/src/main/java/com/scalar/db/api/DistributedTransactionAdminImportTableIntegrationTestBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public void dropNamespace_ShouldNotDropNonScalarDBTables() throws Exception {
167167
assertThat(admin.namespaceExists(getNamespace())).isTrue();
168168
for (TestData testData : testDataList) {
169169
if (!testData.isImportableTable()) {
170-
adminTestUtils.tableExists(getNamespace(), testData.getTableName());
170+
assertThat(adminTestUtils.tableExists(getNamespace(), testData.getTableName())).isTrue();
171171
}
172172
}
173173
} finally {

0 commit comments

Comments
 (0)