clintropolis commented on code in PR #12709:
URL: https://github.com/apache/druid/pull/12709#discussion_r931575463


##########
sql/src/main/java/org/apache/druid/sql/avatica/DruidConnection.java:
##########
@@ -89,36 +107,85 @@ public DruidStatement createStatement(SqlLifecycleFactory 
sqlLifecycleFactory)
       }
 
       if (statements.size() >= maxStatements) {
-        throw DruidMeta.logFailure(new ISE("Too many open statements, limit 
is[%,d]", maxStatements));
+        throw DruidMeta.logFailure(new ISE("Too many open statements, limit is 
[%,d]", maxStatements));
       }
 
       @SuppressWarnings("GuardedBy")
-      final DruidStatement statement = new DruidStatement(
-          connectionId,
+      final DruidJdbcStatement statement = new DruidJdbcStatement(
+          this,
           statementId,
-          context,
-          sqlLifecycleFactory.factorize(),
-          () -> {
-            // onClose function for the statement
-            LOG.debug("Connection[%s] closed statement[%s].", connectionId, 
statementId);
-            // statements will be accessed unsynchronized to avoid deadlock
-            statements.remove(statementId);
-          }
+          sqlLifecycleFactory
       );
 
       statements.put(statementId, statement);
-      LOG.debug("Connection[%s] opened statement[%s].", connectionId, 
statementId);
+      LOG.debug("Connection [%s] opened statement [%s].", connectionId, 
statementId);
       return statement;
     }
   }
 
-  public DruidStatement getStatement(final int statementId)
+  public DruidJdbcPreparedStatement createPreparedStatement(
+      SqlLifecycleFactory sqlLifecycleFactory,
+      SqlQueryPlus queryPlus,
+      final long maxRowCount)
+  {
+    final int statementId = statementCounter.incrementAndGet();
+
+    synchronized (connectionLock) {
+      if (statements.containsKey(statementId)) {
+        // Will only happen if statementCounter rolls over before old 
statements are cleaned up. If this
+        // ever happens then something fishy is going on, because we shouldn't 
have billions of statements.
+        throw DruidMeta.logFailure(new ISE("Uh oh, too many statements"));
+      }
+
+      if (statements.size() >= maxStatements) {
+        throw DruidMeta.logFailure(new ISE("Too many open statements, limit is 
[%,d]", maxStatements));
+      }
+
+      @SuppressWarnings("GuardedBy")

Review Comment:
   does this still need suppressed?



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