You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CREATE INDEX IF NOT EXISTS, DROP INDEX IF EXISTS, CREATE TRIGGER IF NOT EXISTS and DROP TRIGGER IF EXISTS are parse errors #2775
Four IF [NOT] EXISTS forms are parse errors in alasql. SQLite runs all four. Checked on 4.20.1:
alasql('CREATE INDEX IF NOT EXISTS i1 ON s (a)');// Parse erroralasql('DROP INDEX IF EXISTS i1');// Parse erroralasql('CREATE TRIGGER IF NOT EXISTS tr1 BEFORE INSERT ON s CALL f()');// Parse erroralasql('DROP TRIGGER IF EXISTS tr1');// Parse error
The same forms already work for tables and views (CREATE VIEW IF NOT EXISTS, DROP VIEW IF EXISTS).
Why 4.x
Adding them is not breaking: every statement is a parse error today. They also give a clean way to write setup and clean-up code that runs more than once. Today that code depends on CREATE TRIGGER replacing an existing trigger (#2755) and DROP INDEX of a missing index returning 1 (#2759). Those stay as they are in the alasql dialect, but the sqlite dialect will throw, as SQLite does. The IF [NOT] EXISTS forms work the same in every dialect.
Behaviour
As for tables: the statement does nothing when the index or trigger already exists (CREATE ... IF NOT EXISTS) or does not exist (DROP ... IF EXISTS), and returns 0.
Grammar change: yarn jison, and the conflict count must stay at the baseline.
Activity
mateuscmtropical commentedon Nov 11, 2026
Hi, I'd like to work on this one.
mateuscmtropical commentedon Nov 11, 2026
Hi, I've opened a PR for this: #3028
Add IF [NOT] EXISTS for CREATE/DROP INDEX and TRIGGER to close AlaSQL…