deniskuzZ commented on code in PR #5129:
URL: https://github.com/apache/hive/pull/5129#discussion_r1535459350


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveAlterHandler.java:
##########
@@ -199,10 +193,20 @@ public void alterTable(RawStore msdb, Warehouse wh, 
String catName, String dbnam
             TableName.getQualified(catName, dbname, name) + " doesn't exist");
       }
 
-      if (expectedKey != null && expectedValue != null
-              && !expectedValue.equals(oldt.getParameters().get(expectedKey))) 
{
-        throw new MetaException("The table has been modified. The parameter 
value for key '" + expectedKey + "' is '"
-                + oldt.getParameters().get(expectedKey) + "'. The expected was 
value was '" + expectedValue + "'");
+      if (expectedKey != null && expectedValue != null) {
+        String newValue = newt.getParameters().get(expectedKey);
+        if (newValue == null) {
+          throw new MetaException(String.format("New value for expected key %s 
is not set", expectedKey));
+        }
+        if (!expectedValue.equals(oldt.getParameters().get(expectedKey))) {
+          throw new MetaException("The table has been modified. The parameter 
value for key '" + expectedKey + "' is '"
+              + oldt.getParameters().get(expectedKey) + "'. The expected was 
value was '" + expectedValue + "'");
+        }
+        int affectedRows = msdb.updateParameterWithExpectedValue(oldt, 
expectedKey, expectedValue, newValue);

Review Comment:
   Are we confident that this is a reliable solution? We had `affectedRows` 
issues with some db drivers in the past. 
   Note, Hibernate is using object versioning for optimistic concurrency 
control.



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