# xsql

sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= json_valid(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= last_insert_rowid()=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= length(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= lower(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= max(1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= printf(1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= quote(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= sqlite_compileoption_get(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= random()=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= sqlite_compileoption_get(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=1;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= sqlite_compileoption_get(9)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= sqlite_compileoption_used(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= sqlite_compileoption_used(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=7 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= sqlite_source_id()=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= sqlite_source_id()=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= strftime(1,1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= strftime(1,1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= substr(1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= total_changes()=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= typeof(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n= typeof(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n=.1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n=200/-01-01=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n=2001-0 || 1-01=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n=2001-01-01-1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n=2001-01-01=1;
  UPDATE counts SET n=n- replace(1,1,1);
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n=2001-01-01=1;
  UPDATE counts SET n=n-1 WHERE n=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n=2001-01-01=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(n,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n=2001-01-01=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(?);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n=2001-01-NULL;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n=2001-01.01=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n=2001-?1-01=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n=2001.01-01=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n=2<01-01-01=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n==1;
  UPDATE counts SET n= "a"WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n==1;
  UPDATE counts SET n= rtrim(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n==1;
  UPDATE counts SET n= unicode(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n==1;
  UPDATE counts SET n=n- lower(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n==1;
  UPDATE counts SET n=n- replace(1,1,1);
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n==1;
  UPDATE counts SET n=n-1 WHERE  hex(1);
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= printf(1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a<4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=7 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;EXPLAIN
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=7 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND replace(1,1,1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND v<=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND v==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND-n=2001-01-01=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE randomblob(1)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE randomblob(1)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE randomblob(1)==1;
  UPDATE counts SET n=n-1 WHERE v=ol�.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE substr(1,1,1)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=52001-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE substr(1,1,1)==1;
  UPDATE counts SET n=n-? WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CR(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE substr(1,1,1)==N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v% json(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v%CURRENT_TIME=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a+4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v%old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=52001-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v&CURRENT_TIME=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a+4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v&old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=52001-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v*CURRENT_TIME=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a+4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v+CURRENT_TIME=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a+4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v/CURRENT_TIME=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a+4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v/old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=52001-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n= hex(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n= json_test1(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n= json_valid(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n= nullif(1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n= printf(1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n= quote(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n= sqlite_compileoption_used(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n= sqlite_source_id()=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n= strftime(1,1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n= substr(1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n= time(1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE 6=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(1,1)OR true=N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= round(1,1)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_DATE=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a+7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_DATE=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=1;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_DATE=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(CURRENT_TIMESTAMP),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_DATEGROUP=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1 -12),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= lower(1)=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1 MATCH-12),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);EXPLAIN
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);REINDEX rtrim(1,1) t1 S


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);REINDEX t1 S


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_DATE=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n=CURRENT_DATE=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n=CURRENT_TIME=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n=CURRENT_TIMESTAMP=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND v>=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= date(1,1,1)=1;
  UPDATE counts SET n=n- upper(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= json(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE coalesce(1,1)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= json(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= max(1,1)=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= json(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=2001-01-014;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= json(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE `a`;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= json(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a<4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= json(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=1;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= json_quote(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= max(1,1)=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= json_quote(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=1;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= json_quote(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=52001-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= printf(1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= printf(1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=52001-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= randomblob(2);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= randomblob(N);
  UPDATE counts SET n= unicode(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= randomblob(N);
  UPDATE counts SET n= unicode(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a<4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= randomblob(N);
  UPDATE counts SET n= unicode(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=1;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= randomblob(N);
  UPDATE counts SET n= unicode(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= randomblob(N);
  UPDATE counts SET n= unicode(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(4),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= randomblob(N);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= randomblob(N);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=A;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= rtrim(1,1)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v= time(1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=52001-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME -1=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a+4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME%1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a+4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(n,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a+4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= -15 WHERE a+4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= instr(1,1);
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= random()+4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a+4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=1;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=7 WHERE a+4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(9),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a+4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME=1;
  UPDATE counts SET n=n-1 MATCH v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DE


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME=1;
  UPDATE counts SET n=n-1 MATCH v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);EXPLAIN
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TYME=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=o glob(1,1)==1;
  UPDATE counts SET n=n glob(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=oID-ODIATEn==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=oIMMEDIATEn==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=olDOd.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE ?14;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a /* */==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=0 AND t


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND  sqlite_compileoption_used( ltrim(1,1))=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND  sqlite_compileoption_used(1)NOT glob(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND -0 n==GIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n- json_object(1,1,1,1)OR true=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
  ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
D


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n<=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n<=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n<=N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;ANALYZE


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n<=N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n>=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n= json_array_length(1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE json_extract(1,1) a=4;
DEL7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n= json_object(1,1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
  ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n= strftime(1,1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
D


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n= json_object(1,1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
  ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE  time(1,1,1);
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
D


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n= json_object(1,1,1,1)OR true<N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
  ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
D


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n= json_object(1,1,1,1)OR true=V;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
  ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
D


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n= strftime(1,1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=52001-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n=#1;
  UP
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1  ; UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM cs WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a 
END;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1 ;  UPDATE counts SET n=n-1 WHERE v=old.a ;  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM cs WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a 
END;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==13
  UPDATE couE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n= sqlite_version();
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n= sqlite_version();
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=52001-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n glob ltrim(1,1);
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n glob(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n
1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n glob(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE@v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n glob(1,1)COLLATE nocase=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n glob(?,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-  "a","b"=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END+
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-  "a","b"=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- lower(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- quote(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- replace(1,1,1);
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- upper( -11)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- upper(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET CURRENT_DATEv=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- upper(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE `a`;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- upper(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=1;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- upper(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(4),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- upper(12001-01-01)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- upper(2001-01-011)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 OR true=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v-old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),( sqlite_compileoption_used(1));
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a 
  IN (1) INs(v,n) VALUES(neT n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) SELECT(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(ne++++++++++++++++++w.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALhES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE  abs(1) AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE  datetime( -1,1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE  datetime( 1=11);
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE  datetime(1 -11);
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE  datetime(1, -1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE  datetime(1,1,1);
  UPDATE counts SET n=n- lower(1)=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE  datetime(1,1,1);
  UPDATE counts SET n=n- replace(1,1,1);
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE  datetime(1,1,1);
  UPDATE counts SET n=n-1 WHERE char(1);
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE  datetime(1,1.1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE  datetime(1,12001-01-01,1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE  datetime(1,1E1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE  datetime(1.1,1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE  datetime(N,1,1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE  json_valid(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE  randomblob(1)IS true=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE 6= nullif(1,1)IS true=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE 6= nullif(1,1)OR true=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE NOT datetime(1,1,1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE coalesce(1,1)==1;
  UPDATE counts SET n=n- random()=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE json_test1(1)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE lower(1)AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE n= nullif(1,1)OR true=N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= affinity(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= affinity(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a -1


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= date(1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a -1


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= ifnull(1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= json(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= json_quote(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= ltrim(1,1)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(1,1)=1;
  UPDATE counts SET n=n-1 WHERE 6=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a -1


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(1,1)IS true=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a<4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(1,1)IS true=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(1,1)IS true=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a -1


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(1,1)IS true=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=1;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(1,1)IS true=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(1,1)OR true=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a<4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(1,1)OR true=N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(1,1)OR true=V;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(9,1)IS true=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(N,1)IS true=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(N,1)OR true=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(N,1)OR true=N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= printf(1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= round( -1)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= round(0,1)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= round(1, -11)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= round(1,0)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= round(1,1) *1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= round(1,1)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a -1


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= round(1,2001-01-011)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= round(1,3)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= round(1,4)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= round(1,5)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= round(1,7)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= round(1,8)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= round(1,9)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= round(1.1)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= rtrim(1,1)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= rtrim(1,1)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= time(1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a -1


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= time(1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= time(1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= unicode( -11)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= unicode(1)= 1=1=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= unicode(1)= abs(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= unicode(1)= json_patch(1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= unicode(1)= json_quote(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= unicode(1)= json_valid(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= unicode(1)= nullif(1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= unicode(1)= substr(1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= unicode(1)==1;
  UPDATE counts SET n= unicode(1)=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_DATE=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND  sqlite_compileoption_used(1)- random()=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n= date(1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n= json_array(1,1,1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n= sqlite_compileoption_get(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n= sqlite_compileoption_get(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n= sqlite_compileoption_used(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n= sqlite_source_id()=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n= typeof(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n= zeroblob(1)=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n= instr(1,1)=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a -1


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n= julianday(1,1,1);
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a -1


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n= sqlite_version();
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a -1


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n= sqlite_version();
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-  char(1)=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-  json(1)=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- quote(1)=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- quote(1)=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- random()*old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- random()+old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- random()/old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- random()=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(?),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- random()=old.a;
END;
INSERT INTO t1(a) VALUES(2001-01-011),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- random()=old.a;
END;
INSERT INTO t1(a) VALUES(?),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- random()AND false=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- random()AND true=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- replace(1,1,1);
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a -1


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- replace(1,1,1);
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 OR true=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v%old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v*old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=o glob(1,1)
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a+
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2)�


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a+
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3);(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FRO


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) SELECT(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES( total(1)),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a glob'�a')


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1 -12),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1 glob(1,1)),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),( random()),(1),(3),(2),(4),(7);
UPDATE t1 SET a=520012001-01-01-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),( sqlite_compileoption_used(1));
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;ANALYZE


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),( sqlite_compileoption_used(1));EXPLAIN
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),( ?13);(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FRO


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),( sqlite_compileoption_used(1) glob '?')


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),( sqlite_compileoption_used(1) glob '[')


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(2001-01-017);
UPDATE t1 SET a=520012001-01-01-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= random()=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=2001-01-014;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 AND  -1e4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 AND@true4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE ?1$;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a LIKE 'a *')


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a LIKE'�a')


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a glob ' abs(1)a')


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a glob ' bm25(1)a')


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a glob ' json_type(1,1)a')


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a glob ' sqlite_compileoption_used(1)200')


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a glob '200')


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a glob 'ADDa')


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a glob 'a *')


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a glob 'a'AND true)


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a glob 'a'OR true)


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a glob(1,1)ESCAPE FRO


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a glob:1;1)


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a/-1


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE total_changes()


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE(a glob '?')


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE(a glob '[')


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE(a glob'�a')


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE@a glob '200')


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=520012001-01-01-0E-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5200120012001-01-01-01-01-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=520012001501-01-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=52001501-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);ANALYZE TEMP


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);ANALYZE t1 S


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3);ANALYZE;ANALYZE
UPDATE t1 SET a=5 WHERE a=4;
DELETE FRO


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3);ANALYZE;ANALYZE t1 SET a=5 WHERE a=4;
DELETE FRO


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3);ANALYZE;REINDEX
UPDATE t1 SET a=5 WHERE a=4;
DELETE FRO


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=1;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1);(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(22001-01-01),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(9),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;EXPLAIN
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 MATCH a=4;
DE


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-NOT random()=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=~- random()=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n=CURRENT_TIME=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n=CURRENT_TIMESTAMP=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a ||  n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a -1


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM cs WHERE v=old.a AND n==1;
  SELECT cs SET n=


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM cs WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a 
 ;END;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(7),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a;7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3�AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO count�(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3);ANALYZE;
UPDATE t1 SET a=5 WHERE a=4;
DELETE FRO


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET v=n- upper(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=? WHERE a=4;
DE


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==N;
  UPDATE counts SET n= ltrim(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=A;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=A;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=A;
DELETE FROM t1 WHERE a=A;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=A;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n=?1;
  UPDATE counts SET n=n-  "a","b"=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CRRT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND sqlite_compileoption_get(1)=n COLLATE nocasea;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND v= json_object(1,1,1,1)OR true=N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
  ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
D


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a IN f (1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a IN false;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),()),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a IS NOT INDEXEDfalse;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a IS false;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a OR false;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(1,1)OR true=N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a OR false;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a IN false;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a OR false;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a OR false;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a OR fals�;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a REGEXP#1;
  UP
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a ||  n==N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=A;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n=   max(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n=   random()=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n=  glob(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n=  glob(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a<4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n=  glob(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=1;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n=  glob(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(4),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n=  length(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n=  length(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a<4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n=  length(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=1;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n=  length(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n=  length(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(4),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= instr( -11,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= instr(1, -11)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= instr(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a+4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= instr(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a<4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= instr(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=1;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= instr(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(4),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= instr(9,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= instr(N,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= round( -1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= round(1 || .1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= round(1, -11)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= round(1,0)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= round(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a<4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= round(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=1;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= round(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(4),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= round(1,2001-01-011)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= round(1,3)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= round(1,3)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= round(1,4)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= round(1,7)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= round(1,8)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= round(1,9)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= round(1.1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= round(1.1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=1;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n= round(1.1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET n=n-1 WHERE  abs(1);
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v> json(1);
  UPDATE counts SET v=  glob(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v>>json(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v>old.a AND n= json_object(1,1,1,1)OR true=N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
  ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
D


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v>old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= instr(1,1);
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v>old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=1;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v>old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(2001-01-011),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v>old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(4);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v>old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= unicode(1);
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v>old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;ANALYZE TEMP t1


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v>old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v>old.a AND n==1;
  UPDATE counts SET v=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;ANALYZE FROM t1


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v>old.a AND v==N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM �ounts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;END
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;EXPLAIN
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),( sqlite_compileoption_used(1));
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;EXPLAIN
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= lower(1)=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;EXPLAIN
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=A WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=s WHERE n+1;
END+
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREAEY, n t1 BEGIN
  DELETE FROM cs WHERE v=old.a AND n==1;
  SELECT cs SE


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=~ "a"+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=~NULL+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
   �  ON CONSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
 /* */  �  ERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,2001-01-011)
      ON CONFLICT(v) DO UPDATE SET v=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,3)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET v=n- upper(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DE


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new�a,1)
      ON CONFLICT( @1v) DO UPDATE SET n=n+1;
END;
C    ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(~ew.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND -1 n==GIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH  `a` AS (values(1))  VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(  a,ba,bx) AS (values(1))  VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c( a,bx) AS (values(1))  VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c( a,bx) AS (values(1))  VALUES(new.a,1)
  �  UES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS ( WITH c(x) AS ( WITH c(x) AS (values(1)) values(1)) values(1))  VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS ( WITH c(x) AS (values(1)) values(1))  VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a+
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS ( WITH c(x) AS (values(1)) values(1))  VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS ( WITH c(x) AS (values(?)) values(1))  VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
UPDATE ON t1 BEGIN
  DELR DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (SELECT(1))  VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (SELECT(1))  VALUES(new.a,1)EXCEPT SELECT(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a -1,1)
UNION VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(?);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+?;
END;
CREA     ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a,1)
UNION SELECT(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a,1)
UNION VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),( sqlite_version()),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a,1)
UNION VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),($sqlite_version()),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a,1)EXCEPT SELECT( WITH c(x) AS (values(1)) (v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a,1)EXCEPT VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END+
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a,1)EXCEPT VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2)(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a,1)EXCEPT VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a,1)EXCEPT VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a,1)EXCEPT VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1);(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a,1)EXCEPT VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1)UNION(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a,9)EXCEPT VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a<1)EXCEPT SELECT(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(?))  VALUES(new.a,1)
  ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRISET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,v) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(1,1)IS true=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,v) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=520012001-01-01-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v�n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
 WITH c(x) AS (values(1)) VALUES(new.a,1)
  �   ON CONSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN WITH ASc(x) AS (values(1))  VALUES(new.a,1)
      ON ERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN WITH CASEc(x) AS (values(1))  VALUES(new.a,1)
      ON CONSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN WITH Ec(x) AS (values(1))  VALUES(new.a,1)
      ON CRT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN WITH c(x) AS (values(1))  VALUES(nevalues(1))  VALUES.a,1)
  w.a,1)
  TEXT     N CONSERT INTO counts(v,n)CT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AZTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN WITH c(x) AS (values(1))  VALUES(new.a,1)
       N CONSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN WITH c(x) AS (values(1))  VALUES(new.a,1)
      ON CONSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN WITH c(x) AS (values(1))  VALUES(new.a,1)
    /* */   ON CONS counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER UPDATE ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=52001-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER UPDATE ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=520012001-01-01-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1�AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1�AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1�AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;EXPLAIN
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r3 AFTER INSERT ON t1 BEGIN
  INSERT /* */ INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n																								r2 AFTE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER b3 AFTER DEAETE ON t1 BEGIN
  DELETounts WHERE v=olM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r3 AFTER INSERT ON t1 BEGIN
  INSERT INTO ADDcounts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n																								r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER b3 AFTER DEAETE ON t1 BEGIN
  DELETounts WHERE v=olM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r3 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET CURRENT_TIMEv=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETounts WHERE v=olM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r3 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=����																					r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER b3 AFTER DEAETE ON t1 BEGIN
  DELETounts WHERE v=olM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;ANALYZETRIGGER r1 AFTER N t1 BEGE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;EXPLAIN
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts�WHERE v=old.=1;
  UPDATE cou
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;EXPLAIN
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;EXPLAIN
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;EXPLAIN
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;EXPLAIN
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=ol�.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;EXPLAIN
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;EXPLAIN QUERY PLAN
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n= json_object(1,1,1,1)OR true=N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
  ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
D


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a, 1=11)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1 -1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n -1+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+ 1=11;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE  total_changes();
  UPDATE counts SET n=n- random()=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n= instr(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET v=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v-old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET v=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v/old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a<4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;ANALYZE


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE �ounts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET v=n glob(1,1)ESCAPE+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET v=n glob(1,1)WHERE+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET v=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= lower(1)=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE 6=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE 6=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE 6=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= lower(1)=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=2001-01-014;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=1;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;REINDEX


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=52001-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET v=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET v=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET v=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a+4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=oID-EDIATEn==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n= unicode(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- upper(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= nullif(1,1)OR true=N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- random()=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=0 AND t


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=52001-01-01;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET v= json_remove(1,1);
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET v=n+glob(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET v=n- upper(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DE


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a OR false;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a OR false;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n<1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n a,b INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a+4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n a,b,I,T)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,I,T)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a, 1=11)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,I,T)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE 6=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,I,T)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=i+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,I,T)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n -1+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,I,T)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n glob(1,1)+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,I,T)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,I,T)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,I,T)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;ANALYZE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,I,T)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+I;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,I,T)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET t=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,I,T)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET v=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- upper(1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a -1,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1 -1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+ 1=11;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n= ltrim(1,1)=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= round(1,1);
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET v=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER PRIMARY KEY, n,INT)WITHOUT ROWID;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n<1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER�PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n- json_replace(1,1,1);
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER�PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(�),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER�PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1<�  UPDATE couE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEGER�PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER UPDATE ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INTEVER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) WITH c(x) AS (values(1))  VALUES(new.a,1)EXCEPT VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETEime FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v INT���� PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND v<=1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FRuset1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v TEXTGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=ol�.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v blobGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v<old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE 6=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v blobGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v<old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v<old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v blobGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v<old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=A;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v blobGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 MATCH a=4;
DE


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v blobGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND v==N;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v blobGER PRIMARY KEY, n,INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v blobGER PRIMARY KEY, n,INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=ol�.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v char(1) PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=7 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v char(1) PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND v==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= lower(1)=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v char(1) PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND v==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= ltrim(1,1);
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v char(1) PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND v==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;VACUUM


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v char(1) PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=CURRENT_TIME=1;
  UPDATE counts SET n=CURRENT_TIMESTAMP;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a+4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v char(1) PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v= unicode(1)==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 NOT INDEXED


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v char(1)COLLATE nocase PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE random()AND v==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(n,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND v=.1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(n,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=0 AND t


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a -1,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n -1+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v>old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE json(1)==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v< json(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v< json(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v< json_quote(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= instr(1,1);
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v< json_quote(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v< json_quote(1)COLLATE nocase;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<<json_quote(1);
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE n=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= lower(1)=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;ANALYZE


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(7),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a= ltrim(1,1);
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a-4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET v= julianday(1,1,1);
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=2;
DE


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET v= julianday(1,1,1);
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET v=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(2),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=2;
DE


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET v=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET v=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET v=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND n==1;
  UPDATE counts SET v=n-1 WHERE v>old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


sqltext:
CREATE TABLE t1(a INT);
CREATE TABLE counts(v �NTEGER PRIMARY KEY, n INT)/*WUT ROWID*/;
CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN
  DELETE FROM counts WHERE v<old.a AND v&.1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
  INSERT INTO counts(v,n) VALUES(new.a,1)
      ON CONFLICT(v) DO UPDATE SET n=n+1;
END;
CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN
  DELETE FROM counts WHERE v=old.a AND n==1;
  UPDATE counts SET n=n-1 WHERE v=old.a;
END;
INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7);
UPDATE t1 SET a=5 WHERE a=4;
DELETE FROM t1 WHERE a=7;


