stoty commented on code in PR #1586:
URL: https://github.com/apache/phoenix/pull/1586#discussion_r1163998991
##########
phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java:
##########
@@ -500,18 +522,44 @@ else if (!clean){
}
}
}
+
+
private void forcefullyDropView(PhoenixConnection phoenixConnection,
Key key) throws Exception {
- String deleteRowsFromCatalog = "DELETE FROM " + SYSTEM_CATALOG_NAME +
- " WHERE " + TENANT_ID + (key.getTenantId() == null ? " IS
NULL" : " = '" + key.getTenantId() + "'") + " AND " +
- TABLE_SCHEM + (key.getSchemaName() == null ? " IS NULL " : " =
'" + key.getSchemaName() + "'") + " AND " +
- TABLE_NAME + " = '" + key.getTableName() + "'";
- String deleteRowsFromChildLink = "DELETE FROM " +
SYSTEM_CHILD_LINK_NAME +
- " WHERE " + COLUMN_NAME + (key.getTenantId() == null ? " IS
NULL" : " = '" + key.getTenantId() + "'") + " AND " +
- COLUMN_FAMILY + " = '" + (key.getSchemaName() == null ?
key.getTableName() : key.getSchemaName() + "." + key.getTableName()) + "'";
+ String deleteRowsFromCatalog = String.format("DELETE FROM " +
SYSTEM_CATALOG_NAME
+ + " WHERE " + TENANT_ID + " %s AND " + TABLE_SCHEM + " %s
AND "
+ + TABLE_NAME + " = ? ",
+ key.getTenantId() == null ? " IS NULL" : " = ? ",
+ key.getSchemaName() == null ? " IS NULL " : " = ? ");
+ String deleteRowsFromChildLink = String.format("DELETE FROM " +
SYSTEM_CHILD_LINK_NAME
+ + " WHERE " + COLUMN_NAME + " %s AND " + COLUMN_FAMILY + " =
? ",
+ key.getTenantId() == null ? " IS NULL" : " = ? ");
try {
- phoenixConnection.createStatement().execute(deleteRowsFromCatalog);
-
phoenixConnection.createStatement().execute(deleteRowsFromChildLink);
+ try (PreparedStatement delSysCat =
+ phoenixConnection.prepareStatement(deleteRowsFromCatalog)) {
+ int param = 0;
+ if (key.getTenantId() != null) {
+ delSysCat.setString(++param, key.getTenantId());
+ }
+ if (key.getSchemaName() != null) {
+ delSysCat.setString(++param, key.getSchemaName());
+ }
+ delSysCat.setString(++param, key.getTableName());
+ delSysCat.execute();
+ }
+ try (PreparedStatement delChLink =
+ phoenixConnection.prepareStatement(deleteRowsFromChildLink)) {
+ int param = 0;
+ if (key.getTenantId() != null) {
Review Comment:
My bad, it's OK.
--
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]