Sqlite3 version 3.7.7.1 2011-06-28 17:39:05
af0d91adf497f5f36ec3813f04235a6e195a605f

Comments in views could result in broken database dumps.

Consider broken-backup.sql (that sets up a toy db) and broken-backup.sh
(that illustrates the bug):

=== broken-backup.sql ===
create table a (int);
create view b as
  select *
  from a -- pretty useless view
  ;
create view c as select * from b;
=========================

=== broken-backup.sh ===
#!/bin/bash
sqlite3 tmp.db < broken-backup.sql
sqlite3 tmp.db ".dump" > tmp.dump
rm tmp.db
sqlite3 tmp.db < tmp.dump
========================

What goes wrong: tmp.db is not being recreated from backup. Instead the
following happens:
Error: near line 4: near "CREATE": syntax error

If you take a look into tmp.dump, you could see that comment in the
definition of "b" swallowed the trailing semicolon:

PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE a (int);
CREATE VIEW b as
  select *
  from a -- pretty useless view;
CREATE VIEW c as select * from b;
COMMIT;

As far as I was able to tell, this is not a known bug.

-- 
Dmitry Astapov
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to