Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary dropdown field display bug #16995

Closed
chrisch297 opened this issue Jul 6, 2021 · 6 comments
Closed

Binary dropdown field display bug #16995

chrisch297 opened this issue Jul 6, 2021 · 6 comments
Assignees
Labels
Bug A problem or regression with an existing feature
Projects
Milestone

Comments

@chrisch297
Copy link

chrisch297 commented Jul 6, 2021

Describe the bug

I have two tables A and B. Table A contains UUIDs, stored as BINARY(16). Table B uses the UUIDs from table A as foreign keys.

phpMyAdmin shows me for table B a nice dropdown field, where I can select the UUID from table A. But it seems that on the selected UUID in the dropdown, the number 1 is added to the end of the UUID. See screenshots.

As a result, if I want to save the changes, phpMyAdmin thinks that the UUID has changed and generates an UPDATE statement for the UUID which of course fails with a foreign key constraint failure because the UUID followed by a 1 does not exist.

I guess there must be some errors in the part where the binary value is converted to a human readable format and where the dropdown is populated.

Possibly related to this: #16013 (comment)

Expected behavior

The selected UUID in the dropdown should be shown correctly without the 1 at the end

Screenshots

On the selected UUID, a 1 is added at the end. The correct UUID for Projekt 1 is 0x ... e4a without 1 at the end! The other not-selected UUIDs in the dropdown are correct.

phpmyadmin1

Saving changes gives a SQL error:

phpmyadmin2

Server configuration

  • Apache/2.4.48 (Win64) OpenSSL/1.1.1k PHP/8.0.7
  • Database client version: libmysql - mysqlnd 8.0.7
  • PHP extension: mysqli Documentation curl Documentation mbstring Documentation
  • PHP version: 8.0.7
  • phpMyAdmin version: 5.1.1

Client configuration

  • Browser: Firefox
  • Operating system: Win10
@williamdes williamdes added the Bug A problem or regression with an existing feature label Jul 14, 2021
@williamdes williamdes added this to the 5.1.2 milestone Jul 14, 2021
@williamdes williamdes added this to Needs triage in issues via automation Jul 14, 2021
@williamdes williamdes moved this from Needs triage to to be fixed soon in issues Jul 14, 2021
@williamdes
Copy link
Member

Hi @chrisch297
Thank you for reporting this issue, could you post test tables to allow us to have a quicker and better reproducing of the issue please ?

@chrisch297
Copy link
Author

chrisch297 commented Jul 15, 2021

@williamdes Sure.

Two test tables authors and articles with UUIDs as primary keys:

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";

CREATE TABLE `articles` (
  `uuid` binary(16) NOT NULL,
  `authors_uuid` binary(16) NOT NULL,
  `article` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `articles` (`uuid`, `authors_uuid`, `article`) VALUES
(0x4616c613f014f7ea9611a7141a758300, 0x4616c243c014f7ea9611a7141a758300, 'Some text...');

CREATE TABLE `authors` (
  `uuid` binary(16) NOT NULL,
  `name` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `authors` (`uuid`, `name`) VALUES
(0x4616c243c014f7ea9611a7141a758300, 'John'),
(0x4616c653f014f7ea9611a7121a758299, 'Tina');


ALTER TABLE `articles`
  ADD PRIMARY KEY (`uuid`),
  ADD KEY `fk_articles_authors_idx` (`authors_uuid`);

ALTER TABLE `authors`
  ADD PRIMARY KEY (`uuid`);


ALTER TABLE `articles`
  ADD CONSTRAINT `fk_articles_authors` FOREIGN KEY (`authors_uuid`) REFERENCES `authors` (`uuid`) ON DELETE NO ACTION ON UPDATE NO ACTION;
COMMIT;

On editing an article, phpMyAdmin uses for the authors_uuid dropdown field not the correct UUID for John (which is 0x4616c243c014f7ea9611a7141a758300), it uses 0x4616c243c014f7ea9611a7141a7583001 (Note the added 1 at the end).

phpmyadmin3

Due to the incorrect UUID, it is not possible to save the edited article because the (incorrect) UUID doesn't exist in the authors table and the database throws an foreign key constrains error.

@williamdes
Copy link
Member

it's strange I could not reproduce this

You can try on http://phpmyadmin-stable.public-instance.eu/ (root/public public/public)

Sélection_2021072216:39:36001

@williamdes williamdes removed this from the 5.1.2 milestone Jul 22, 2021
@williamdes williamdes added the question Used when we need feedback from the submitter or when the issue is a question about PMA label Jul 22, 2021
@chrisch297
Copy link
Author

chrisch297 commented Jul 23, 2021

You can try on http://phpmyadmin-stable.public-instance.eu/ (root/public public/public)

I have this issue also on your test database, see screenshot. The issue comes up when editing an existing entry. In your screenshot, you tried to insert a new entry which seems to work fine.

phpmyadmin4

@williamdes
Copy link
Member

I had missed that is needed to be in edit mode
Confirmed
image

@williamdes
Copy link
Member

Seems like it was added by mistake in: e9d3fdd#diff-a3501a31fbdb91c217f32a573019b35304950ed21b951f56db50ddfb6340ae04R1240

williamdes added a commit that referenced this issue Jul 28, 2021
Signed-off-by: William Desportes <williamdes@wdes.fr>
@williamdes williamdes self-assigned this Jul 28, 2021
@williamdes williamdes removed the question Used when we need feedback from the submitter or when the issue is a question about PMA label Jul 28, 2021
@williamdes williamdes added this to the 5.1.2 milestone Jul 28, 2021
issues automation moved this from to be fixed soon to Closed Jul 29, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A problem or regression with an existing feature
Projects
issues
  
Closed
Development

No branches or pull requests

2 participants