davidjanmercado / sqlite-jdbc

Automatically exported from code.google.com/p/sqlite-jdbc
Apache License 2.0
0 stars 0 forks source link

DDL statements return result other than 0 #22

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.First, establish a connection and execute sth like:

stat.executeUpdate("insert into people values ('blah', 'someone');"); 

2. then

stat.executeUpdate("drop table if exists people;");

What is the expected output? What do you see instead?

If you printout result returned by last statement, it is 1 instead of 0. This 
happens because executeUpdate returns changes = db.changes() without checking 
whether it is a DDL statement or not. In this case, it's 1, the result from 
INSERT statement.

What version of the product are you using? On what operating system?

I'm using 3.7.8-snapshot on Mac.

Please provide any additional information below.

In Stmt.executeUpdate(String sql) line: 157

                changes = db.changes();

here native method NativeDB.changes() calling for C function int 
sqlite3_changes(sqlite3*);, which " returns the number of changes in the most 
recent INSERT, UPDATE, or DELETE that also occurred at the top level. " 

Many thanks for your great work,

- Fiona

Original issue reported on code.google.com by lauraf...@gmail.com on 8 Mar 2012 at 8:26

GoogleCodeExporter commented 8 years ago
Moved to bitbucket issue: https://bitbucket.org/xerial/sqlite-jdbc/issue/16

Original comment by Grace.Ba...@gmail.com on 8 Sep 2012 at 4:32

GoogleCodeExporter commented 8 years ago
Fixed by: 
https://bitbucket.org/xerial/sqlite-jdbc/pull-request/19/fixes-16-ddl-statements
-return-result

Original comment by Grace.Ba...@gmail.com on 8 Sep 2012 at 4:47