Delimiter set to GO:
CREATE TABLE ids (
doc INT NOT NULL AUTO_INCREMENT,
rev INT NOT NULL,
PRIMARY KEY (doc)
) GO
CREATE FUNCTION test(a INT, b INT) RETURNS INT BEGIN
RETURN a + b;
END GO
CREATE FUNCTION test2(docId INT) RETURNS INT BEGIN
DECLARE newId INT DEFAULT 0;
UPDATE ids set rev=(newId = rev+1) WHERE doc = docId;
IF ROW_COUNT() <> 1 THEN BEGIN
SET newId = 1;
INSERT INTO ids set doc=docId,rev=revId;
END;
RETURN newId;
END GO
Try building that schema. Try changing it (perhaps adding 10 or 20 blank lines after the create table, and building schema again. The error message will refer to a line that is now whitespace.
I know that the THEN BEGIN and END is wrong. The problem is, it is almost impossible to find errors in sqlfiddle when it gives you nonsense error lines.
Delimiter set to GO:
Try building that schema. Try changing it (perhaps adding 10 or 20 blank lines after the create table, and building schema again. The error message will refer to a line that is now whitespace.
I know that the
THEN BEGINandENDis wrong. The problem is, it is almost impossible to find errors in sqlfiddle when it gives you nonsense error lines.