#358 Unable to insert properly a new item into a 'bit' field

3.7.1
closed-works-for-me
nobody
None
5
2017-02-21
2014-01-04
Yoji
No

A table has a bit(9) type. Trying to insert a new value doesn't allow to enter all the 9 bits, because the input field is set to maxlength="9". So the user cannot enter the value b'100100100', because the expression is 12 chars long...

Discussion

  • Jakub Vrána

    Jakub Vrána - 2014-01-04

    You can insert bit field values just using 100100100.

     
  • Jakub Vrána

    Jakub Vrána - 2014-01-04
    • status: open --> closed-rejected
     
  • Yoji

    Yoji - 2014-01-13

    Having a bit(9) field:
    - inserting 100100100 results in 511 (9-bit integer overflow, 100100100 is treated as decimal)
    - inserting 292 results in the correct, 100100100 binary format
    - trying to insert the correct value of b'100100100' fails due to the limited textfield limit of 9, allowing to enter only b'1001001

    To reproduce the bug:
    - create a table having a field aaa of bit(9)
    - try to insert a new value by clicking (+) New item
    - edit/insert the value 1001; This will result in 511
    - edit/insert the value b'1001'; This will result in 9

    The solution would be removing the limit of the textfield or increasing the limit value by 3 to allow the extra b'' characters.

     
  • Jakub Vrána

    Jakub Vrána - 2014-01-14

    Are you using MySQL? Inserting 1001 in Adminer results in:

    INSERT INTO t (aaa) VALUES (CONV('1001', 2, 10) + 0);

    Adminer then selects:

    SELECT *, BIN(aaa + 0) AS aaa

     
  • Yoji

    Yoji - 2014-01-14

    These queries run when I click 'Save' on the page /adminer.php?username=root&db=xxx&edit=test
    -- begin log
    140114 22:50:39 77 Connect root@localhost on
    77 Query SET NAMES utf8
    77 Query SET sql_quote_show_create = 1
    77 Init DB xxx
    77 Query SHOW FULL COLUMNS FROM test
    77 Query INSERT INTO test (aaa)
    VALUES (1001)
    77 Query SELECT LAST_INSERT_ID()
    77 Quit
    78 Connect root@localhost on
    78 Query SET NAMES utf8
    78 Query SET sql_quote_show_create = 1
    78 Init DB xxx
    78 Query SHOW TABLE STATUS LIKE 'test'
    78 Query SHOW INDEX FROM test
    78 Query SHOW FULL COLUMNS FROM test
    78 Query SHOW CREATE TABLE test
    78 Query SELECT *
    FROM test
    LIMIT 30
    78 Quit
    -- end log

    show create table test;
    CREATE TABLE test (
    aaa bit(9) NOT NULL DEFAULT b'0'
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin

    SHOW VARIABLES LIKE "%version%";
    innodb_version 5.5.33
    protocol_version 10
    slave_type_conversions
    version 5.5.33-0+wheezy1
    version_comment (Debian)
    version_compile_machine x86_64
    version_compile_os debian-linux-gnu


    If I write b'1001' into the input field, the query log is
    88 Query INSERT INTO test (aaa) VALUES (b'1001')

    I hope that helps. As the log shows, there is no CONV() function used...

     
  • Jakub Vrána

    Jakub Vrána - 2014-01-15

    Can you upgrade Adminer to a recent version?

     
  • Yoji

    Yoji - 2014-01-15

    I just updated to 4.0.2, it's the same behavior...
    76 Query INSERT INTO test (aaa) VALUES (100100100)

     
  • Jakub Vrána

    Jakub Vrána - 2014-02-12
    • status: closed-rejected --> pending-works-for-me
     
  • Jakub Vrána

    Jakub Vrána - 2014-02-12

    Is it possible that you are using some customization? If not then please do this:

    Download Adminer source codes and add debug_backtrace() into drivers/mysql.inc.php:unconvert_field(). It should print something like this after Save and continue edit:

    #0 unconvert_field() called at [adminer/include/adminer.inc.php:588]
    #1 Adminer->processInput() called at [adminer/include/functions.inc.php:903]
    #2 process_input() called at [adminer/edit.inc.php:34]

     
    Last edit: Jakub Vrána 2014-02-12
  • Jakub Vrána

    Jakub Vrána - 2017-02-21
    • status: pending-works-for-me --> closed-works-for-me
     

Log in to post a comment.