Select base for integer values in Data table

david@dalbert.net's profile image david@dalbert.net posted 2 years ago in General Permalink

It would be great if HeidiSQL allowed users to select the base (hexadecimal, decimal, binary) for integers in the Data table. Allowing this as a selection from the column header would be helpful. Even better would be to make that setting persistent since you already store persistent format information for each table such as which columns to display. Thanks!

DigiLive's profile image DigiLive posted 2 years ago Permalink

I second this one.

Also it would be nice if we could enter values using a different base.
Now, when entering 0x000aa7 in a uint32 column, it results in an error popup

SQL Error (1265): Data truncated for column 'xxx' at row 1

and an error in the query history.

/* #1634496361: Access violation at address 00000000005DE1FB in module 'heidisql.exe'. Read of address FFFFFFFFFFFFFFFF Message CharCode:13 Msg:256 */"
Code modification/commit ea1149f from Ansgar Becker <anse@heidisql.com>, 2 years ago, revision 12.1.0.6560
Allow integers and floats to be entered in hexadecimal format in grids. Basically means they're not wrapped in quotes now. See https://www.heidisql.com/forum.php?t=39864
ansgar's profile image ansgar posted 2 years ago Permalink

The message in the log panel is caused by the grid editor and certain keyboard shortcuts like Tab. It has nothing to do with the numeric violation.

I just modified the place where values for integers and floats are normally wrapped in quotes when the user entered a non-numeric value. Hex values are also not quoted any longer, and so are accepeted by the server. Please update to the next build to get this.

-- previously:
INSERT INTO `test2`.`test` (`num`) VALUES ('0x000aa7');
-- now:
INSERT INTO `test2`.`test` (`num`) VALUES (0x000aa7);
DigiLive's profile image DigiLive posted 1 year ago Permalink

I gave it a try.

0xaa7   is quoted.
0x0aa7  is not quoted.
0x00aa7 is quoted.
and so on.

0xa7   is not quoted.
0x0a7  is quoted.
0x00a7 is not quoted.
and so on.

Version 12.1.0.6560

ansgar's profile image ansgar posted 1 year ago Permalink

Yes, that's because these hex values are expected with 2 digits pairs. Isn't that correct for integers as well?

david@dalbert.net's profile image david@dalbert.net posted 1 year ago Permalink

I'm sorry, I wasn't clear in the request. It would be great if the Data table provided a way to select the base to display integer values in the table (not just in the value editor). Ideally, this would be selectable by column, but even a global setting for integer display would help. My need is driven by numeric data that has bit/byte specific encoding. For example, an IPv4 address or software version number often encodes data as a sequence of bytes (1.2.3.4) where you want to see the byte values separately. Hexadecimal display is a fairly generic way to allow displaying data that has bit/byte semantics.

Thanks again for such a wonderful product...I love HeidiSQL.

DigiLive's profile image DigiLive posted 1 year ago Permalink

Yes, that's because these hex values are expected with 2 digits pairs. Isn't that correct for integers as well?

value is a sequence of hexadecimal digits (from 0 to 9 and from A to F). The case of the digits does not matter. With the first two syntaxes, value must consist of an even number of digits. With the last syntax, digits can be even, and they are treated as if they had an extra 0 at the beginning.

DigiLive's profile image DigiLive posted 1 year ago Permalink

Sorry, I didn't copy all from https://mariadb.com/kb/en/hexadecimal-literals/ what I meant to.

Please refer to the link about hex literals.

@david: Sorry for hijacking your topic. I still second your request. Being able to select other bases (like hex) for numeric columns would be awesome. Hopefully it can be implemented on a per column setting.

Code modification/commit 1756d46 from Ansgar Becker <anse@heidisql.com>, 1 year ago, revision 12.1.0.6562
Allow hex values to have an odd number of digits. See https://www.heidisql.com/forum.php?t=39864

Please login to leave a reply, or register at first.