Re: [sqlite] Strange foreign key constraint failed with DROP TABLE

2011-08-23 Thread Boris Kolpackov
Hi Richard, Richard Hipp writes: > Dan has convinced me that the SQLite code is correct as documented. The > documentation states: "Foreign key DML errors are may be reported if: (1) > The parent table does not exist..." And for the DELETE statement above, the > parent table

Re: [sqlite] Strange foreign key constraint failed with DROP TABLE

2011-08-22 Thread Richard Hipp
On Mon, Aug 22, 2011 at 12:54 PM, Boris Kolpackov wrote: > Hi Dan, > > Dan Kennedy writes: > > > It is. Now fixed in the trunk. > > Thanks for the fix. I patched 3.7.7.1 with it and indeed this now > works: > > BEGIN TRANSACTION; > DROP TABLE

Re: [sqlite] Strange foreign key constraint failed with DROP TABLE

2011-08-22 Thread Boris Kolpackov
Hi Dan, Dan Kennedy writes: > It is. Now fixed in the trunk. Thanks for the fix. I patched 3.7.7.1 with it and indeed this now works: BEGIN TRANSACTION; DROP TABLE employer; DROP TABLE employee; COMMIT; However, this transaction: BEGIN TRANSACTION; DELETE FROM

Re: [sqlite] Strange foreign key constraint failed with DROP TABLE

2011-08-22 Thread Dan Kennedy
On 08/20/2011 12:50 AM, Duquette, William H (318K) wrote: > > On 8/19/11 10:44 AM, "Boris Kolpackov" wrote: > >> Hi William, >> >> "Duquette, William H (318K)" writes: >> >>> On 8/19/11 10:18 AM, "Boris Kolpackov"

Re: [sqlite] Strange foreign key constraint failed with DROP TABLE

2011-08-19 Thread Duquette, William H (318K)
On 8/19/11 10:44 AM, "Boris Kolpackov" wrote: >Hi William, > >"Duquette, William H (318K)" writes: > >> On 8/19/11 10:18 AM, "Boris Kolpackov" wrote: >> >> There's something odd here. You have the FK

Re: [sqlite] Strange foreign key constraint failed with DROP TABLE

2011-08-19 Thread Boris Kolpackov
Hi William, "Duquette, William H (318K)" writes: > On 8/19/11 10:18 AM, "Boris Kolpackov" wrote: > > There's something odd here. You have the FK constraints deferred, and > your code looks like this: > > BEGIN TRANSACTION; > DROP TABLE

Re: [sqlite] Strange foreign key constraint failed with DROP TABLE

2011-08-19 Thread Duquette, William H (318K)
On 8/19/11 10:18 AM, "Boris Kolpackov" wrote: >Hi William, > >"Duquette, William H (318K)" writes: > >> What if you defined the foreign key with "ON DELETE CASCADE"? Dropping >> the employer table will delete the employees. > >That

Re: [sqlite] Strange foreign key constraint failed with DROP TABLE

2011-08-19 Thread Boris Kolpackov
Hi William, "Duquette, William H (318K)" writes: > What if you defined the foreign key with "ON DELETE CASCADE"? Dropping > the employer table will delete the employees. That would be bad for the normal use. In other words, I don't want the CASCADE semantics

Re: [sqlite] Strange foreign key constraint failed with DROP TABLE

2011-08-19 Thread Duquette, William H (318K)
What if you defined the foreign key with "ON DELETE CASCADE"? Dropping the employer table will delete the employees. Will -- Will Duquette -- william.h.duque...@jpl.nasa.gov Athena Development Lead -- Jet Propulsion Laboratory "It's amazing what you can do with the right tools." On 8/19/11

Re: [sqlite] Strange foreign key constraint failed with DROP TABLE

2011-08-19 Thread Stephan Beal
On Fri, Aug 19, 2011 at 4:19 PM, Boris Kolpackov wrote: > In this simple case, yes. However, I need to support multiple levels > of references which makes creating "perfect" DROP order difficult or > even impossible (e.g., if there are cycles). > > Maybe (and i'm just

Re: [sqlite] Strange foreign key constraint failed with DROP TABLE

2011-08-19 Thread Boris Kolpackov
Hi Stephan, Stephan Beal writes: > The workaround would be simply to switch the order of the DROP TABLEs, > wouldn't it? In this simple case, yes. However, I need to support multiple levels of references which makes creating "perfect" DROP order difficult or even

Re: [sqlite] Strange foreign key constraint failed with DROP TABLE

2011-08-19 Thread Stephan Beal
On Fri, Aug 19, 2011 at 3:56 PM, Boris Kolpackov wrote: > Can someone confirm if this is a bug in SQLite? If so, I would also > appreciate any suggestions for work-arounds. I know I can disable > constraint checking, but in my case it is not easy since I am already > in

[sqlite] Strange foreign key constraint failed with DROP TABLE

2011-08-19 Thread Boris Kolpackov
Hi, I am observing a "foreign key constraint failed" error that looks like an SQLite bug to me. I have tried the following using 3.7.7.1: First I create two tables: PRAGMA foreign_keys=ON; BEGIN TRANSACTION; CREATE TABLE employer (name TEXT NOT NULL PRIMARY KEY); INSERT INTO employer