-
-
Notifications
You must be signed in to change notification settings - Fork 106
Fix way end of functions, procedures and triggers' bodies is identified #438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## 5.8.x #438 +/- ##
=========================================
Coverage 97.04% 97.04%
- Complexity 2216 2218 +2
=========================================
Files 69 69
Lines 5103 5107 +4
=========================================
+ Hits 4952 4956 +4
Misses 151 151
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
@williamdes Code coverage is yelling but at unchanged files, like it did a few weeks ago with some PR of mine. I think therefore we shouldn't consider those "failures" and this PR is OK and could be merged, wdyt? Thanks 🙂 |
Hi PS: that's okay for codecov |
Hi, Thanks for the answer. I think I can provide an pretty clear example about what's happening with triggers, procedures and functions. $body = $this->statements[2]->statements[6]->body;
die(var_dump(implode(' ', array_column($body, 'token')))); Now, let's parse the INSERT INTO monitoring__times_mirror
( `idServer` , `time` , `totalTime` ) VALUES ( new . idServer , new . time , new . totalTime )
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `deleteTimes` AFTER DELETE ON `monitoring__times` FOR EACH ROW DELETE FROM monitoring__times_mirror
WHERE `idServer` = old . idServer
AND `time` = old . time
AND `totalTime` = old . totalTime
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `updateTimes` AFTER UPDATE ON `monitoring__times` FOR EACH ROW UPDATE monitoring__times_mirror
SET `idServer` = new . idServer ,
`time` = new . time ,
`totalTime` = new . totalTime
WHERE `idServer` = old . idServer
AND `time` = old . time
AND `totalTime` = old . totalTime
$$
DELIMITER ;
--
-- Index pour les tables déchargées
--
--
-- Index pour la table `monitoring__times`
--
ALTER TABLE `monitoring__times`
ADD UNIQUE KEY `idServer` ( `idServer` , `time` ) USING BTREE COMMENT 'Unique idServer/time' ,
ADD KEY `INDEX_totalTime` ( `totalTime` ) USING BTREE COMMENT 'Index for totalTime column' ;
--
-- Contraintes pour les tables déchargées
--
--
-- Contraintes pour la table `monitoring__times`
--
ALTER TABLE `monitoring__times`
ADD CONSTRAINT `monitoring__times__idServer` FOREIGN KEY ( `idServer` ) REFERENCES `monitoring__servers` ( `id` ) ;
COMMIT ;
/*!40101 SET CHARACTER_SET_CLIENT = @OLD_CHARACTER_SET_CLIENT */ ;
/*!40101 SET CHARACTER_SET_RESULTS = @OLD_CHARACTER_SET_RESULTS */ ;
/*!40101 SET COLLATION_CONNECTION = @OLD_COLLATION_CONNECTION */ ; As you can see, everything after the beginning of the trigger (next statements, comments, …) are considered as being part of the first trigger… Let's do the exact same test but on the fix branch now. The result is: INSERT INTO monitoring__times_mirror
( `idServer` , `time` , `totalTime` ) VALUES ( new . idServer , new . time , new . totalTime ) Please let me know if you need any additional information. |
Signed-off-by: William Desportes <[email protected]>
10373f9
to
599c597
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for all your contributions @Tithugues !
Pull-request: #438 Signed-off-by: William Desportes <[email protected]>
Related to phpmyadmin/sql-parser#438 Signed-off-by: Maurício Meneghini Fauth <[email protected]>
Oh yeah I was right, phpMyAdmin needs fixing after this PR If you view a complex procedure that has a The fixes: |
Related to 5a2baf6 Related to phpmyadmin/sql-parser#438 Signed-off-by: William Desportes <[email protected]>
Related to 5a2baf6 Related to phpmyadmin/sql-parser#438 Signed-off-by: William Desportes <[email protected]>
@williamdes reported that
sql-parser/tests/Parser/ParserLongExportsTest.php
Line 59 in 4bfd15c
Indeed, in this file https://github.com/phpmyadmin/sql-parser/blob/4bfd15c40c6e7cec3592095cd405f52931af1b10/tests/data/parser/parsephpMyAdminExport1.in, the variables defined in the last comments where not reported (as we can see in the unit test).
This is due to the fact that when parsing functions, procedures and triggers, the sql-parser includes everything in the body of the statements.
With the current fix, this is not the case anymore. This has an impact on existing data test sets which seemed not to be valid.