You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
The text was updated successfully, but these errors were encountered:
Steps to reproduce
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:
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;
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.
The text was updated successfully, but these errors were encountered: