Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-26 Thread James K. Lowden
On Tue, 24 Sep 2013 20:21:09 +0200 Petite Abeille wrote: > On Sep 24, 2013, at 8:05 PM, Simon Slavin > wrote: > > > Which is why you do an INSERT first, and allow it to fail, then do > > the UPDATE. > > Sure. A lot of error proce procedural code to do what one SQL > statement could do much mor

Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-25 Thread Jean-Marie CUAZ
To make clearer my former post, (not arguing against the current bahaviour of "INSERT OR REPLACE"), the usage (and misunderstanding) I had with INSERT OR REPLACE was a simple shortcut of 2 statements : - DELETE : erasing completely old values, with a constraint that no deletion should occur if

Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE"

2013-09-25 Thread Jean-Marie CUAZ
Thanks a lot for your explanations. I misread the doc... I intuitively thought that INSERT OR REPLACE operates only on a "one input -> one affected record" ("or in place") logic (as exercised for the PK constraint) and that UNIQUE constraint had some higher priority against "replace" : a kind

Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-24 Thread Richard Hipp
On Mon, Sep 23, 2013 at 12:19 PM, Jean-Marie CUAZ wrote: > Hello, > > Thanks to SQlite developement team for this wonderfull library > > We have been hit today by the following : > > package require sqlite3 > > sqlite3 db1 test > > db1 eval {CREATE TABLE T1 (A PRIMARY KEY, B, C, D UNIQUE DEFAULT

Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-24 Thread Petite Abeille
On Sep 24, 2013, at 8:16 PM, Simon Slavin wrote: > The first version (INSERT OR FAIL, then UPDATE) won't lead to any SQLite > errors if one of the rows already exists. So you can do a whole lot of both > lines in one transaction and the transaction will still succeed. Is that so? If 'INSERT O

Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-24 Thread Simon Slavin
On 24 Sep 2013, at 7:19pm, Marc L. Allen wrote: > INSERT OR IGNORE? Dammit, yes. I meant INSERT OR IGNORE, not INSERT OR FAIL. Thanks Marc. Simon. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo

Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-24 Thread Petite Abeille
On Sep 24, 2013, at 8:05 PM, Simon Slavin wrote: > Which is why you do an INSERT first, and allow it to fail, then do the UPDATE. Sure. A lot of error proce procedural code to do what one SQL statement could do much more naturally. ___ sqlite-users

Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-24 Thread Marc L. Allen
eille Sent: Tuesday, September 24, 2013 2:14 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement On Sep 24, 2013, at 8:09 PM, Marc L. Allen wrote: > Not complaining, mind you. MS SQL doesn't have it, and I've

Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-24 Thread Marc L. Allen
INSERT OR IGNORE? -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Simon Slavin Sent: Tuesday, September 24, 2013 2:16 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Bug : Tcl interface + "INSE

Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-24 Thread Simon Slavin
On 24 Sep 2013, at 7:09pm, Marc L. Allen wrote: > Also, there are times when you do a bulk insert, so you have to structure the > query to not fail on records that are already present. Yeah. Actually I got what I posted wrong. I should have written Which is why you do an INSERT OR FAIL, the

Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-24 Thread Petite Abeille
On Sep 24, 2013, at 8:09 PM, Marc L. Allen wrote: > Not complaining, mind you. MS SQL doesn't have it, and I've long learned to > deal with it. MS SQL Server sports a MERGE statement if I'm not mistaken: http://msdn.microsoft.com/en-us/library/bb510625.aspx __

Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-24 Thread Petite Abeille
On Sep 24, 2013, at 8:06 PM, Marc L. Allen wrote: > Considered harmful? How so? I wouldn't mind a version of ON CONFLICT UPDATE > fieldlist. In its current form. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/m

Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-24 Thread Marc L. Allen
PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement On 24 Sep 2013, at 6:58pm, Petite Abeille wrote: > On Sep 24, 2013, at 7:54 PM, "Marc L. Allen" > wrote: > >> Yep. What most people want is

Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-24 Thread Petite Abeille
On Sep 24, 2013, at 7:54 PM, "Marc L. Allen" wrote: > Yep. What most people want is an INSERT OR UPDATE. Yep. Which is what one usually calls 'MERGE': http://en.wikipedia.org/wiki/Merge_(SQL) And sadly, SQLite doesn't provide anything like that at all. Oh, well… 'ON CONFLICT clause' cons

Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-24 Thread Marc L. Allen
on of SQLite Database Subject: Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement On Sep 24, 2013, at 7:54 PM, "Marc L. Allen" wrote: > Yep. What most people want is an INSERT OR UPDATE. Yep. Which is what one usually calls 'MERGE': http://en.wik

Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-24 Thread Simon Slavin
On 24 Sep 2013, at 6:58pm, Petite Abeille wrote: > On Sep 24, 2013, at 7:54 PM, "Marc L. Allen" > wrote: > >> Yep. What most people want is an INSERT OR UPDATE. > > Yep. Which is what one usually calls 'MERGE': > > http://en.wikipedia.org/wiki/Merge_(SQL) > > And sadly, SQLite doesn't p

Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-24 Thread Marc L. Allen
] Bug : Tcl interface + "INSERT OR REPLACE" statement On Sep 23, 2013, at 6:19 PM, Jean-Marie CUAZ wrote: > -> no exception is raised to host langage Tcl for 2 rows not inserted > -> because a UNIQUE constraint is not respected partial execution : 2 > -> rows are defin

Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-24 Thread Petite Abeille
On Sep 23, 2013, at 6:19 PM, Jean-Marie CUAZ wrote: > -> no exception is raised to host langage Tcl for 2 rows not inserted because > a UNIQUE constraint is not respected > -> partial execution : 2 rows are definitely deleted from the table ...(ouch > !) Yep. Looks like it does exactly what i

[sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement

2013-09-24 Thread Jean-Marie CUAZ
Hello, Thanks to SQlite developement team for this wonderfull library We have been hit today by the following : package require sqlite3 sqlite3 db1 test db1 eval {CREATE TABLE T1 (A PRIMARY KEY, B, C, D UNIQUE DEFAULT '-')} db1 eval {INSERT INTO T1 VALUES (0, 1, 1, 'a') , (1, 1, 1, 'b') , (