Elena Stepanova
added a comment - Thanks for the report.
It's an upstream issue http://bugs.mysql.com/bug.php?id=58342 (still reproducible on MySQL 5.1 - 5.7).
test INSERT test BEGIN BEFORE (NULL) NO_BACKSLASH_ESCAPES,STRICT_ALL_TABLES,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION root@::1 utf8 utf8_general_ci utf8_general_ci
SET NEW.a=CONCAT('ABC = '',1,''');
SET NEW.b=CONCAT('ABC = ',2);
END
INSERTINTO test(a,b) VALUES (NULL, NULL)
SELECT * FROM test
a b
--------- ---------
ABC = '1' ABC = 2
As you can see trigger is worked but I cannot get it body.
If for PROCEDURE and FUNCTIONS exists workaround with mysql database, for trigger this workaround not work because triggers not stored into mysql database.
Mikhail Gavrilov
added a comment - - edited I think priority must be increased because also affected triggers:
Demonstration:
CREATE TABLE `test` (
`a` MEDIUMTEXT,
`b` MEDIUMTEXT
) ENGINE=MYISAM DEFAULT CHARSET=utf8;
DELIMITER $$
CREATE TRIGGER `test` BEFORE INSERT ON `test`
FOR EACH ROW BEGIN
SET NEW.a=CONCAT( 'ABC = ' '' ,1, '' '' );
SET NEW.b=CONCAT( 'ABC = ' ,2);
END $$
DELIMITER ;
SELECT
IT.`TRIGGER_NAME`
,IT.`EVENT_OBJECT_TABLE`
,IT.ACTION_STATEMENT
FROM INFORMATION_SCHEMA.`TRIGGERS` IT
WHERE IT.`TRIGGER_SCHEMA`= 'test' AND IT.`TRIGGER_NAME` = 'test' ;
TRIGGER_NAME EVENT_OBJECT_TABLE ACTION_STATEMENT
------------ ------------------ ----------------------------------------------------------------------------
test test BEGIN
SET NEW.a=CONCAT('ABC = '',1,''');
SET NEW.b=CONCAT('ABC = ',2);
END
SHOW TRIGGERS FROM `test` WHERE ` trigger ` = 'test'
Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
------- ------ ------ -------------------------------------------------------------------------- ------ ------- ------------------------------------------------------------------------------------------------------------------------- -------- -------------------- -------------------- --------------------
test INSERT test BEGIN BEFORE (NULL) NO_BACKSLASH_ESCAPES,STRICT_ALL_TABLES,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION root@::1 utf8 utf8_general_ci utf8_general_ci
SET NEW.a=CONCAT('ABC = '',1,''');
SET NEW.b=CONCAT('ABC = ',2);
END
INSERT INTO test(a,b) VALUES ( NULL , NULL )
SELECT * FROM test
a b
--------- ---------
ABC = '1' ABC = 2
As you can see trigger is worked but I cannot get it body.
If for PROCEDURE and FUNCTIONS exists workaround with mysql database, for trigger this workaround not work because triggers not stored into mysql database.
It's just the standard procedure – we usually set priority for upstream bugs to minor, because we want to wait and see whether upstream fixes them; and if not, the priority can be raised.
On the other hand, the upstream bug has been there for quite a while, over 3 years, still not fixed. Increasing priority as requested.
Elena Stepanova
added a comment - It's just the standard procedure – we usually set priority for upstream bugs to minor, because we want to wait and see whether upstream fixes them; and if not, the priority can be raised.
On the other hand, the upstream bug has been there for quite a while, over 3 years, still not fixed. Increasing priority as requested.
This difference is made when procedure body is constructed while parsing and error is somewhere on literal handling.
Jan Lindström (Inactive)
added a comment - Problem is that on mysql.proc table body nad body_utf8 are not exactly the same even on default character set:
SELECT body FROM `mysql`.`proc` mp WHERE mp.db='test' AND mp.`name` = 'test';
body
BEGIN
SELECT CONCAT('ABC = ''',1,''''), CONCAT('ABC = ',2);
END
SELECT body_utf8 FROM `mysql`.`proc` mp WHERE mp.db='test' AND mp.`name` = 'test';
body_utf8
BEGIN
SELECT CONCAT('ABC = '',1,'''), CONCAT('ABC = ',2);
END
This difference is made when procedure body is constructed while parsing and error is somewhere on literal handling.
Peter Laursen
added a comment - Independent of this discussion I posted to bugs.mysql.com http://bugs.mysql.com/bug.php?id=75685 a few days ago.
It was originally reported by one of our users here: http://forums.webyog.com/index.php?showtopic=7625
CREATE FUNCTION f1() RETURNS TEXT RETURN 'I''m happy';
SELECT body_utf8 FROM mysql.proc WHERE name='f1';
SELECT ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME='f1';
Both SELECT queries return a wrong result with the quote character removed:
+--------------------+
| body_utf8 |
+--------------------+
| RETURN 'I'm happy' |
+--------------------+
If I rewrite the query slightly (notice the N prefix meaning NATIONAL CHARACTER literal):
DROP FUNCTION IF EXISTS f1;
CREATE FUNCTION f1() RETURNS TEXT RETURN N'I''m happy';
SELECT ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME='f1';
it returns a correct result:
+----------------------+
| body_utf8 |
+----------------------+
| RETURN N'I''m happy' |
+----------------------+
Alexander Barkov
added a comment - - edited A smaller test reproducing the problem:
DROP FUNCTION IF EXISTS f1;
CREATE FUNCTION f1() RETURNS TEXT RETURN 'I''m happy';
SELECT body_utf8 FROM mysql.proc WHERE name='f1';
SELECT ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME='f1';
Both SELECT queries return a wrong result with the quote character removed:
+--------------------+
| body_utf8 |
+--------------------+
| RETURN 'I'm happy' |
+--------------------+
If I rewrite the query slightly (notice the N prefix meaning NATIONAL CHARACTER literal):
DROP FUNCTION IF EXISTS f1;
CREATE FUNCTION f1() RETURNS TEXT RETURN N'I''m happy';
SELECT ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME='f1';
it returns a correct result:
+----------------------+
| body_utf8 |
+----------------------+
| RETURN N'I''m happy' |
+----------------------+
WHERE INFORMATION_SCHEMA.`ROUTINES`.`ROUTINE_TYPE` = 'PROCEDURE'
AND INFORMATION_SCHEMA.`ROUTINES`.`ROUTINE_SCHEMA` = DATABASE()) t1
JOIN
(SELECT `name` SPECIFIC_NAME
,`body`
FROM `mysql`.`proc`
WHERE db = DATABASE() AND `type`='PROCEDURE') t2 ON (t1.SPECIFIC_NAME = t2.SPECIFIC_NAME)
HAVING t1.`ROUTINE_DEFINITION` != t2.body
For fix this needed recreate all procedures. Can you add this in mysql_upgrade ???
Mikhail Gavrilov
added a comment - - edited Bug is not fixed if only upgrade server.
SELECT * FROM (SELECT
INFORMATION_SCHEMA.`ROUTINES`.`SPECIFIC_NAME`
, INFORMATION_SCHEMA.`ROUTINES`.`ROUTINE_DEFINITION`
FROM INFORMATION_SCHEMA.`ROUTINES`
WHERE INFORMATION_SCHEMA.`ROUTINES`.`ROUTINE_TYPE` = 'PROCEDURE'
AND INFORMATION_SCHEMA.`ROUTINES`.`ROUTINE_SCHEMA` = DATABASE()) t1
JOIN
(SELECT `name` SPECIFIC_NAME
,`body`
FROM `mysql`.`proc`
WHERE db = DATABASE() AND `type`='PROCEDURE') t2 ON (t1.SPECIFIC_NAME = t2.SPECIFIC_NAME)
HAVING t1.`ROUTINE_DEFINITION` != t2.body
For fix this needed recreate all procedures. Can you add this in mysql_upgrade ???
People
Alexander Barkov
Mikhail Gavrilov
Votes:
1Vote for this issue
Watchers:
6Start watching this issue
Dates
Created:
Updated:
Resolved:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":1439.6000003814697,"ttfb":618.5,"pageVisibility":"visible","entityId":49153,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"f9936b24-db44-4031-b070-0ea966ecc47f","navigationType":0,"readyForUser":1537.7000002861023,"redirectCount":0,"resourceLoadedEnd":1385,"resourceLoadedStart":625.9000000953674,"resourceTiming":[{"duration":174,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":625.9000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":625.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":799.9000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":174.2999997138977,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":626.2000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":626.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":800.5,"responseStart":0,"secureConnectionStart":0},{"duration":366.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":626.4000000953674,"connectEnd":626.4000000953674,"connectStart":626.4000000953674,"domainLookupEnd":626.4000000953674,"domainLookupStart":626.4000000953674,"fetchStart":626.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":805.2000002861023,"responseEnd":993.3000001907349,"responseStart":845.2000002861023,"secureConnectionStart":626.4000000953674},{"duration":542.9000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":626.5,"connectEnd":626.5,"connectStart":626.5,"domainLookupEnd":626.5,"domainLookupStart":626.5,"fetchStart":626.5,"redirectEnd":0,"redirectStart":0,"requestStart":805.9000000953674,"responseEnd":1169.4000000953674,"responseStart":861.2000002861023,"secureConnectionStart":626.5},{"duration":221.7999997138977,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":626.7000002861023,"connectEnd":626.7000002861023,"connectStart":626.7000002861023,"domainLookupEnd":626.7000002861023,"domainLookupStart":626.7000002861023,"fetchStart":626.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":810.8000001907349,"responseEnd":848.5,"responseStart":846.7000002861023,"secureConnectionStart":626.7000002861023},{"duration":225,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":626.9000000953674,"connectEnd":626.9000000953674,"connectStart":626.9000000953674,"domainLookupEnd":626.9000000953674,"domainLookupStart":626.9000000953674,"fetchStart":626.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":811.1000003814697,"responseEnd":851.9000000953674,"responseStart":848.7000002861023,"secureConnectionStart":626.9000000953674},{"duration":224.89999961853027,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":627.1000003814697,"connectEnd":627.1000003814697,"connectStart":627.1000003814697,"domainLookupEnd":627.1000003814697,"domainLookupStart":627.1000003814697,"fetchStart":627.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":811.3000001907349,"responseEnd":852,"responseStart":849.9000000953674,"secureConnectionStart":627.1000003814697},{"duration":183.30000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":627.4000000953674,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":627.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":810.7000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":225.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":627.5,"connectEnd":627.5,"connectStart":627.5,"domainLookupEnd":627.5,"domainLookupStart":627.5,"fetchStart":627.5,"redirectEnd":0,"redirectStart":0,"requestStart":814.1000003814697,"responseEnd":853.4000000953674,"responseStart":852.2000002861023,"secureConnectionStart":627.5},{"duration":185.09999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":627.7000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":627.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":812.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":231.40000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":627.7000002861023,"connectEnd":627.7000002861023,"connectStart":627.7000002861023,"domainLookupEnd":627.7000002861023,"domainLookupStart":627.7000002861023,"fetchStart":627.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":818.4000000953674,"responseEnd":859.1000003814697,"responseStart":853.7000002861023,"secureConnectionStart":627.7000002861023},{"duration":487.90000009536743,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":629.2000002861023,"connectEnd":629.2000002861023,"connectStart":629.2000002861023,"domainLookupEnd":629.2000002861023,"domainLookupStart":629.2000002861023,"fetchStart":629.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":1040,"responseEnd":1117.1000003814697,"responseStart":1114.4000000953674,"secureConnectionStart":629.2000002861023},{"duration":751.0999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":633.9000000953674,"connectEnd":633.9000000953674,"connectStart":633.9000000953674,"domainLookupEnd":633.9000000953674,"domainLookupStart":633.9000000953674,"fetchStart":633.9000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":1370.6000003814697,"responseEnd":1385,"responseStart":1383.7000002861023,"secureConnectionStart":633.9000000953674},{"duration":286.7999997138977,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1126.1000003814697,"connectEnd":1126.1000003814697,"connectStart":1126.1000003814697,"domainLookupEnd":1126.1000003814697,"domainLookupStart":1126.1000003814697,"fetchStart":1126.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":1377.9000000953674,"responseEnd":1412.9000000953674,"responseStart":1411.3000001907349,"secureConnectionStart":1126.1000003814697},{"duration":317.09999990463257,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1429.2000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1429.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1746.3000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":284.2999997138977,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1452.7000002861023,"connectEnd":1452.7000002861023,"connectStart":1452.7000002861023,"domainLookupEnd":1452.7000002861023,"domainLookupStart":1452.7000002861023,"fetchStart":1452.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":1690.7000002861023,"responseEnd":1737,"responseStart":1736,"secureConnectionStart":1452.7000002861023}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":428,"responseStart":619,"responseEnd":626,"domLoading":624,"domInteractive":1679,"domContentLoadedEventStart":1679,"domContentLoadedEventEnd":1746,"domComplete":2493,"loadEventStart":2493,"loadEventEnd":2493,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1599.6000003814697},{"name":"bigPipe.sidebar-id.end","time":1600.4000000953674},{"name":"bigPipe.activity-panel-pipe-id.start","time":1600.6000003814697},{"name":"bigPipe.activity-panel-pipe-id.end","time":1606.7000002861023},{"name":"activityTabFullyLoaded","time":1766.5}],"measures":[],"correlationId":"c0223d530029a3","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":110,"dbReadsTimeInMs":12,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Thanks for the report.
It's an upstream issue http://bugs.mysql.com/bug.php?id=58342 (still reproducible on MySQL 5.1 - 5.7).