Fix simulate query count#18583
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## QA_5_2 #18583 +/- ##
============================================
- Coverage 48.20% 47.27% -0.94%
- Complexity 17010 17011 +1
============================================
Files 607 607
Lines 72335 72342 +7
============================================
- Hits 34870 34200 -670
- Misses 37465 38142 +677
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
6edfdfe to
7706ad6
Compare
|
@MoonE Could you please rebase the PR? |
7706ad6 to
fbaeff2
Compare
Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
fbaeff2 to
93a8f20
Compare
| return 'SELECT COUNT(*)' . | ||
| ' FROM (SELECT ' . implode(',', $newValues) . ') AS `pma_new`' . | ||
| ' JOIN (' . | ||
| 'SELECT ' . implode(', ', $oldValues) . ' FROM ' . $tableReferences[0] . $where . $order . $limit . | ||
| ') AS `pma_old`' . | ||
| ' WHERE NOT (' . implode(', ', $newColumns) . ') <=> (' . implode(', ', $oldColumns) . ')'; |
There was a problem hiding this comment.
I'd love if there was some comment explaining how this works because I can't comprehend it myself. :)
There was a problem hiding this comment.
pma_new selects the set values into a single row which is then joined with the current table as pma_old. No ON condition needed, as pma_new is always just a single row.
In the WHERE condition a tuple comparison is made that checks if the old data tuple is different to the new data tuple.
The outer select counts all rows that are different.
UPDATE `table_1` SET `id` = 1, `name` = 'asdf' WHERE `id` = 10SELECT COUNT(*)
FROM (SELECT 1 AS `n0`, 'asdf' AS `n1`) AS `pma_new`
JOIN (SELECT `id` AS `o0`, `name` AS `o1` FROM `table_1` WHERE `id` = 1) AS `pma_old`
WHERE NOT (`n0`, `n1`) <=> (`o0`, `o1`)Thinking about it ... this should be equivalent to this, placing the values directly in the WHERE condition:
SELECT COUNT(*)
FROM (SELECT `id` AS `o0`, `name` AS `o1` FROM `table_1` WHERE `id` = 1) AS `pma_old`
WHERE NOT (1, 'asdf') <=> (`o0`, `o1`)There was a problem hiding this comment.
@MoonE I'm not sure about COUNT(*). Previously, when the number was clicked it would have shown the rows that will be updated, but now is only the count number.
There was a problem hiding this comment.
The count is the number of updated/affected rows. The pma_old subquery will give the matched rows, and the where condition reduces this to the affected rows
There was a problem hiding this comment.
I did not know about that ...
Though I'm not sure how useful this feature is. Just listing the updated values without a full row context?
It does make sense when deleting rows ...
There was a problem hiding this comment.
I did not know about that ...
Though I'm not sure how useful this feature is. Just listing the updated values without a full row context?
Well, the feature was there and probably someone might use this.

Fixes #18533, closes #18536