Title: [274799] trunk/Websites/perf.webkit.org
Revision
274799
Author
[email protected]
Date
2021-03-22 14:23:28 -0700 (Mon, 22 Mar 2021)

Log Message

[perf dashboard] Perf dashboard should be compatible with newer version of postgres.
https://bugs.webkit.org/show_bug.cgi?id=223567

Reviewed by Ryosuke Niwa.

Newer version of postgres requires explicit ROW _expression_ while updating a single column
using multi-column update syntax. However, 'ROW' is not supported in postgres < 10. In order
to keep compatibility, using a separate query when only updating one row.

* public/include/db.php: Use 'column = value' when there is only one column to update.

Modified Paths

Diff

Modified: trunk/Websites/perf.webkit.org/ChangeLog (274798 => 274799)


--- trunk/Websites/perf.webkit.org/ChangeLog	2021-03-22 21:21:48 UTC (rev 274798)
+++ trunk/Websites/perf.webkit.org/ChangeLog	2021-03-22 21:23:28 UTC (rev 274799)
@@ -1,3 +1,16 @@
+2021-03-21  Dewei Zhu  <[email protected]>
+
+        [perf dashboard] Perf dashboard should be compatible with newer version of postgres.
+        https://bugs.webkit.org/show_bug.cgi?id=223567
+
+        Reviewed by Ryosuke Niwa.
+
+        Newer version of postgres requires explicit ROW _expression_ while updating a single column
+        using multi-column update syntax. However, 'ROW' is not supported in postgres < 10. In order
+        to keep compatibility, using a separate query when only updating one row.
+
+        * public/include/db.php: Use 'column = value' when there is only one column to update.
+
 2021-03-06  Ryosuke Niwa  <[email protected]>
 
         [perf dashboard] Use async/await in tests for TimeSeriesChart and InteractiveTimeSeriesChart

Modified: trunk/Websites/perf.webkit.org/public/include/db.php (274798 => 274799)


--- trunk/Websites/perf.webkit.org/public/include/db.php	2021-03-22 21:21:48 UTC (rev 274798)
+++ trunk/Websites/perf.webkit.org/public/include/db.php	2021-03-22 21:23:28 UTC (rev 274799)
@@ -231,8 +231,8 @@
 
         if ($insert_params === NULL)
             $insert_params = $select_params;
-        $insert_placeholders = array();
-        $insert_column_names = $this->prepare_params($insert_params, $insert_placeholders, $values);
+        $insert_placeholder_list = array();
+        $insert_column_name_list = $this->prepare_params($insert_params, $insert_placeholder_list, $values);
 
         assert(!!$returning);
         assert(!$prefix || ctype_alnum_underscore($prefix));
@@ -241,14 +241,19 @@
         $condition = $this->select_conditions_with_null_columns($prefix, $select_column_names, $select_placeholders, $select_null_columns);
         $query = "SELECT $returning_column_name FROM $table WHERE $condition";
 
-        $insert_column_names = $this->prefixed_column_names($insert_column_names, $prefix);
-        $insert_placeholders = join(', ', $insert_placeholders);
+        $insert_column_names = $this->prefixed_column_names($insert_column_name_list, $prefix);
+        $insert_placeholders = join(', ', $insert_placeholder_list);
 
         // http://stackoverflow.com/questions/1109061/insert-on-duplicate-update-in-postgresql
         $rows = NULL;
         if ($should_update) {
-            $rows = $this->query_and_fetch_all("UPDATE $table SET ($insert_column_names) = ($insert_placeholders)
-                WHERE $condition RETURNING $returning_column_name", $values);
+            // FIXME: Remove this special case and use ROW _expression_ when no instance uses Postgres < 10.
+            if (count($insert_placeholder_list) == 1 && count($insert_column_name_list) == 1)
+                $rows = $this->query_and_fetch_all("UPDATE $table SET $insert_column_names = $insert_placeholders
+                    WHERE $condition RETURNING $returning_column_name", $values);
+            else
+                $rows = $this->query_and_fetch_all("UPDATE $table SET ($insert_column_names) = ($insert_placeholders)
+                    WHERE $condition RETURNING $returning_column_name", $values);
         }
         if (!$rows && $should_insert) {
             $rows = $this->query_and_fetch_all("INSERT INTO $table ($insert_column_names) SELECT $insert_placeholders
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to