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

Support using hexadecimal constants in input fields for numeric values #14396

Open
AphidGit opened this issue Jun 13, 2018 · 2 comments
Open
Labels
enhancement A feature request for improving phpMyAdmin

Comments

@AphidGit
Copy link

AphidGit commented Jun 13, 2018

Steps to reproduce

  1. Create a table with at least one integer column
  2. Try to specify a default value using a hexadecimal constant for this column (e.g. 0x101) using the GUI interface.

Expected behaviour

PHPmyadmin should recognize this particular format and transform this into either simply 0x101 or X'101' inside the query.

It cannot do so. Manually setting the default value will work. For example: consider being able to produce a query like this:

ALTER TABLE `myTable` ADD `newColumn` SMALLINT NOT NULL DEFAULT 0x101 AFTER `lastColumn` 

Alternatively, PHPMyadmin could use PHP's builtin hex conversion functions and calculate the decimal value itself instead, producing this query for the previous example instead;

ALTER TABLE `myTable` ADD `newColumn` SMALLINT NOT NULL DEFAULT '257' AFTER `lastColumn` 

Actual behaviour

The provided value is treated as a string and fully quoted. The result is of course a syntax error, as '0x101' is not a valid integer constant in sql. The particular error is always:
Error 1067 - Invalid default value for 'COLUMNNAME'

Why this would be useful

If a database column stores information usually expressed as a hexadecimal constant (such as integer flags) and there is a sensible default value it would be nice to be able to create or modify such a column using the GUI without having to use a calculator or pen&paper to calculate the decimal value of said constant, or use the 'preview SQL' and 'SQL' functions, copying the preview SQL to the custom query form and then manually modifying the query to remove the extraneous quotes.

External reference

See also: https://dev.mysql.com/doc/refman/8.0/en/hexadecimal-literals.html
(replace 8.0 with the version relevant to you. This page, and with it the notation supported, hasn't changed in a long time)

Server configuration

Operating system:
Any operating system
Web server:
Any web server.
Database:
Any SQL database
PHP version:
Any supported PHP version.
phpMyAdmin version:
5.5.60-0+deb8u1

Client configuration

Browser:
Any browser.
Operating system:
Any operating system.

@aroralakshya
Copy link
Contributor

I think these functions(hex to decimal, decimal to hex, etc) could also be added to the insert page, in the functions dropdown.

@lem9
Copy link
Contributor

lem9 commented Jun 19, 2018

The phpMyAdmin version you provided (5.5.60-0+deb8u1) does not exist.

@williamdes williamdes added the enhancement A feature request for improving phpMyAdmin label Nov 28, 2018
@williamdes williamdes added this to Triage zone in Enhancements Jan 23, 2020
@williamdes williamdes moved this from Triage zone to Nice to have soon in Enhancements Jan 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature request for improving phpMyAdmin
Projects
Enhancements
  
Nice to have soon
Development

No branches or pull requests

4 participants