The following code:
USE `securityMisconfigStealToken`;
-- DELIMITER $$
CREATE PROCEDURE `securityMisconfigStealToken`.`getToken`(IN theUserId VARCHAR(64))
BEGIN
DECLARE tokenExists INT;
COMMIT;
SELECT count(token) FROM `securityMisconfigStealToken`.`tokens` WHERE userId = theUserId INTO tokenExists;
IF (tokenExists < 1) THEN
INSERT INTO tokens (userId, token) VALUES (theUserId, SHA2(CONCAT(RAND(), now()), 256));
COMMIT;
END IF;
SELECT token FROM tokens WHERE userId = theUserId;
END
;
-- $$
Throws the exception:
ERROR 1064 (42000) at line 996: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 3
I am currently using mariaDB version 10.5.12.
The first line of code starts at line 994 and ends at 1008, however the error refers to syntax at line 3. I cannot seem to find at all why this code is throwing an error.
CodePudding user response:
From MariaDB Comment Syntax:
There are 3 supported comment styles in MariaDB:
...
From a '-- ' to the end of a line. The space after the two dashes is required (as in MySQL).
...
This means your delimiter will not be accepted, since it's a comment (And same with -- $$
at the end).