Skip to content

Invalid code has nonsense error line - it doesn't actually run changed code in build schema #67

@doug65536

Description

@doug65536

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions