preinheimer / xhprof

XHGUI is a GUI for the XHProf PHP extension, using a database backend, and pretty graphs to make it easy to use and interpret.
Other
833 stars 185 forks source link

SQL Insert Error #99

Closed tperalta82 closed 4 years ago

tperalta82 commented 7 years ago

As per a previous #97 PR where I changed the table schema because server_id was just too small, here is a sample insert that will fail:

INSERT INTO `details` (`id`, `url`, `c_url`, `timestamp`, `server name`, `perfdata`, `type`, `cookie`, `post`, `get`, `pmu`, `wt`, `cpu`, `server_id`, `aggregateCalls_include`) VALUES('57fbf3e8c7f14', '/wp/wp-admin/plugins.php?plugin_status=all&paged=1&s&error_rep', '/wp/wp-admin/plugins.php?plugin_status=all&paged=1&s&error_rep', FROM_UNIXTIME('1476129768'), '192.168.100.182', 'x^�+��\0_�', '1', '{\"wordpress_fb2b7f76e2c619dfcf884c05be48a525\":\"devil|1476282007|QCRWYveNGDfOh2NMXMf4SPxk9JefdoA5Z3CtjzzheMx|83effa02d40e09d6c0563447e5f4323d97088329ded1bc3c097b5425da9a54c8\",\"_profile\":\"1\",\"wordpress_logged_in_fb2b7f76e2c619dfcf884c05be48a525\":\"devil|1476282007|QCRWYveNGDfOh2NMXMf4SPxk9JefdoA5Z3CtjzzheMx|fdf80232c2e39ce6ddd3ad00abbf82d5c2bc46eef44c4c47a241e25b66b76d63\",\"wordpress_test_cookie\":\"WP Cookie check\",\"wp-settings-time-1\":\"1476129743\",\"wp-settings-1\":\"\"}', '[]', '{\"plugin_status\":\"all\",\"paged\":\"1\",\"s\":\"\",\"error_rep\":\"\"}', '0', '0', '0', 'development', '')

Will throw:

21:03:13    INSERT INTO `details` (`id`, `url`, `c_url`, `timestamp`, `server name`, `perfdata`, `type`, `cookie`, `post`, `get`, `pmu`, `wt`, `cpu`, `server_id`, `aggregateCalls_include`) VALUES('57fbf3e8c7f14', '/wp/wp-admin/plugins.php?plugin_status=all&paged=1&s&error_rep', '/wp/wp-admin/plugins.php?plugin_status=all&paged=1&s&error_rep', FROM_UNIXTIME('1476129768'), '192.168.100.182', 'x^�+��\0_�', '1', '{\"wordpress_fb2b7f76e2c619dfcf884c05be48a525\":\"devil|1476282007|QCRWYveNGDfOh2NMXMf4SPxk9JefdoA5Z3CtjzzheMx|83effa02d40e09d6c0563447e5f4323d97088329ded1bc3c097b5425da9a54c8\",\"_profile\":\"1\",\"wordpress_logged_in_fb2b7f76e2c619dfcf884c05be48a525\":\"devil|1476282007|QCRWYveNGDfOh2NMXMf4SPxk9JefdoA5Z3CtjzzheMx|fdf80232c2e39ce6ddd3ad00abbf82d5c2bc46eef44c4c47a241e25b66b76d63\",\"wordpress_test_cookie\":\"WP Cookie check\",\"wp-settings-time-1\":\"1476129743\",\"wp-settings-1\":\"\"}', '[]', '{\"plugin_status\":\"all\",\"paged\":\"1\",\"s\":\"\",\"error_rep\":\"\"}', '0', '0', '0', 'development', '')  Error Code: 1406. Data too long for column 'server_id' at row 1 0,00075 sec

if you change "development" to let's say, dev, it will work.

Also, on your config.sample.php you have servername='myserver'; which doesn't have 3 chars, but has 8.

On the previous PR you mentioned that strict comes disabled by default, maybe on previous versions of mysql.

Tested on mysql default package from ubuntu 16.04, as well as the .deb package from mysql.com and they both come with strict_mode on, so it does not truncate the values, it just throws anerror and doesn't insert anything, personally I think it should have a bigger char allowance.

Before mysql 5.7.7 this was not enabled by default: http://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_strict_mode

This is not a bug, anyways.

aik099 commented 7 years ago

Also, on your config.sample.php you have servername='myserver'; which doesn't have 3 chars, but has 8.

The config.php file is used, not config.sample.php. The config.sample.php exists only for end user to create config.php from it once.

aik099 commented 7 years ago

Would you please create PR for that. I've counted 6 CREATE TABLE statements (in xhprof_runs.php and each of db adapter classes) where length of server_id column needs to be increased.