[ 
https://issues.apache.org/jira/browse/HIVE-24424?focusedWorklogId=517000&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-517000
 ]

ASF GitHub Bot logged work on HIVE-24424:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Nov/20 11:08
            Start Date: 26/Nov/20 11:08
    Worklog Time Spent: 10m 
      Work Description: miklosgergely commented on a change in pull request 
#1704:
URL: https://github.com/apache/hive/pull/1704#discussion_r530951752



##########
File path: 
hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/listener/DbNotificationListener.java
##########
@@ -970,28 +971,44 @@ private static void close(ResultSet rs) {
     }
   }
 
-  private long getNextNLId(Statement stmt, SQLGenerator sqlGenerator, String 
sequence)
+  /**
+   * Get the next notification log ID.
+   *
+   * @return The next ID to use for a notification log message
+   * @throws SQLException if a database access error occurs or this method is
+   *           called on a closed connection
+   * @throws MetaException if the sequence table is not properly initialized
+   */
+  private long getNextNLId(Connection con, SQLGenerator sqlGenerator, String 
sequence)
           throws SQLException, MetaException {
-    String s = sqlGenerator.addForUpdateClause("select \"NEXT_VAL\" from " +
-            "\"SEQUENCE_TABLE\" where \"SEQUENCE_NAME\" = " + 
quoteString(sequence));
-    LOG.debug("Going to execute query <" + s + ">");
-    ResultSet rs = null;
-    try {
-      rs = stmt.executeQuery(s);
-      if (!rs.next()) {
-        throw new MetaException("Transaction database not properly configured, 
can't find next NL id.");
+    final String seq_sql = "select \"NEXT_VAL\" from \"SEQUENCE_TABLE\" where 
\"SEQUENCE_NAME\" = ?";

Review comment:
       These two are constants, please extract them.




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 517000)
    Time Spent: 40m  (was: 0.5h)

> Use PreparedStatements in DbNotificationListener getNextNLId
> ------------------------------------------------------------
>
>                 Key: HIVE-24424
>                 URL: https://issues.apache.org/jira/browse/HIVE-24424
>             Project: Hive
>          Issue Type: Improvement
>            Reporter: David Mollitor
>            Assignee: David Mollitor
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Simplify the code, remove debug logging concatenation, and make it more 
> readable,



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to