Hi,

Using the C API if i submit the statements:

BEGIN;
CREATE TABLE test (id, name);
COMMIT;

within a single Exec command (or as a single line on the command line tool) then it works the first time and displays an error the second time as expected due to the table already existing.

However, when the error occurs I am then unable to run anymore transactions because it says that a transaction is already active.

So if I ran that set of statements a third time it would come up with the error:

SQL error: cannot start a transaction within a transaction

When reading the documentation I realised that sending a set of statements in an Exec command is treated as a single transaction
anyway and therefore I can remove the BEGIN and COMMIT statements.


When I do this then I can run that set of statements multiple times without SQLite displaying an error saying that a Transaction is already active.

I haven't looked deep into the code but I thought I would ask the list if this is a bug or if it's just me not reading the documentation properly.

Not knowing the code that well but guessing I would say that because the statements are on a single line I believe maybe the SQL interpreter is reading the BEGIN (start a transaction) but not reading the rest of the commands when an error occurs and therefore doesn't see the COMMIT (end transaction) at the end.

Andrew
--
Andrew Clark



Reply via email to