Skip to content

Simulate query matched rows wrong count #18533

@liviuconcioiu

Description

@liviuconcioiu

Describe the bug

When simulating a UPDATE query, the matched rows count is wrong sometimes. This happens if the column contains NULL values.

The generated query for count is SELECT `b` FROM `test` WHERE `a` = '2' AND (`b` <> 'test') but it probably should be SELECT `b` FROM `test` WHERE `a` = '2' AND (`b` <> 'test' OR `b` IS NULL)

To Reproduce

Steps to reproduce the behavior:

  1. Create table
CREATE TABLE `test` (
  `id` int(10) UNSIGNED NOT NULL,
  `a` varchar(255) DEFAULT NULL,
  `b` text DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `test` (`id`, `a`, `b`) VALUES
(1, '1', 'test'),
(2, '1', NULL),
(3, '1', NULL),
(4, '1', NULL),
(5, '1', 'test'),
(6, '2', NULL),
(7, '2', NULL),
(8, '2', 'test'),
(9, '2', NULL),
(10, '2', 'test');

ALTER TABLE `test`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `test`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
COMMIT;
  1. Go to SQL tab and simulate this query
    UPDATE `test` SET `b` = 'test' WHERE `a` = '2'
  2. See the count 0 which is wrong. It should be 3.

Expected behavior

The count should be accurate.

Screenshots

16.07.2023_12.36.03_REC.mp4

Server configuration

  • phpMyAdmin version: 5.2.2-dev, 6.0.0-dev

Metadata

Metadata

Assignees

Labels

BugA problem or regression with an existing featureaffects/5.2This issue or pull-request affects 5.2.x releases (and maybe further versions)affects/6.0This issue or pull-request affects 6.0.x releases (and maybe further versions)confirmed/5.2This issue is confirmed to be reproduced on 5.2 at the time this label was setconfirmed/6.0This issue is confirmed to be reproduced on 6.0 at the time this label was sethas-prAn issue that has a pull request pending that may fix this issue. The pull request may be incomplete

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions