Re: [sqlite] How to verify referential integrity of SQLite database

2013-01-03 Thread Levi Haskell (BLOOMBERG/ 731 LEXIN)
Perfect! Exactly what I needed Thanks a lot, - Levi - Original Message - From: d...@sqlite.org To: LEVI HASKELL (BLOOMBERG/ 731 LEXIN) Cc: sqlite-users@sqlite.org At: Jan 1 2013 09:03:00 On Thu, Dec 27, 2012 at 11:43 AM, Levi Haskell (BLOOMBERG/ 731 LEXIN) wrote: Hi Rich

Re: [sqlite] How to verify referential integrity of SQLite database

2013-01-01 Thread Richard Hipp
On Thu, Dec 27, 2012 at 11:43 AM, Levi Haskell (BLOOMBERG/ 731 LEXIN) < lhask...@bloomberg.net> wrote: > Hi Richard, > > Sorry, I missed your message before. > > Look, in my example: > > SQLite version 3.7.16 2012-12-20 01:15:20 > Enter ".help" for instructions > Enter SQL statements terminated wi

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-27 Thread Levi Haskell (BLOOMBERG/ 731 LEXIN)
Hi Richard, Sorry, I missed your message before. Look, in my example: SQLite version 3.7.16 2012-12-20 01:15:20Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table p(a, b, primary key(a, b), unique(b, a)); sqlite> create table c(x, y, foreign key(x,

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-22 Thread Baruch Burstein
On Fri, Dec 21, 2012 at 6:04 AM, Richard Hipp wrote: > On Thu, Dec 20, 2012 at 3:05 PM, Levi Haskell (BLOOMBERG/ 731 LEXIN) < > lhask...@bloomberg.net> wrote: > > > Tested, works perfectly. Thanks! > > > > Two questions/observation: > > > > 1. Should there be a way to determine the parent key w/o

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-20 Thread Richard Hipp
On Thu, Dec 20, 2012 at 3:05 PM, Levi Haskell (BLOOMBERG/ 731 LEXIN) < lhask...@bloomberg.net> wrote: > Tested, works perfectly. Thanks! > > Two questions/observation: > > 1. Should there be a way to determine the parent key w/o looking at or > parsing the schema DDL commands? > > For example: > S

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-20 Thread Levi Haskell (BLOOMBERG/ 731 LEXIN)
Tested, works perfectly. Thanks! Two questions/observation: 1. Should there be a way to determine the parent key w/o looking at or parsing the schema DDL commands? For example: SQLite version 3.7.16 2012-12-20 01:15:20 Enter ".help" for instructions Enter SQL statements terminated with a ";

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-19 Thread Kees Nuyt
On Wed, 19 Dec 2012 21:10:28 -0500, Richard Hipp wrote: > The latest SQLite from trunk (not the 3.7.15.1 patch release, > but the code that is destined to become 3.7.16) has a new pragma: > >PRAGMA foreign_key_check; >PRAGMA foreign_key_check(TABLE); > > The second from checks all of the

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-19 Thread Richard Hipp
On Wed, Dec 12, 2012 at 2:29 PM, Levi Haskell (BLOOMBERG/ 731 LEXIN) < lhask...@bloomberg.net> wrote: > My suggestion would be to have check_integrity command verify referential > integrity as well only if it's executed while the foreign key enforcement > is enabled on the connection. > The lates

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-13 Thread gwenn
Hello, You can give the following tool a try if you want: https://github.com/gwenn/checkfkey But I'm not sure that it correctly handles composite. Regards. On Thu, Dec 13, 2012 at 4:22 PM, Jean-Christophe Deschamps wrote: > >> Jay A. Kreibich wrote: >> > I can also see situations when someone m

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-13 Thread Jean-Christophe Deschamps
Jay A. Kreibich wrote: > I can also see situations when someone might want to run one > set or the other set of checks. Breaking it out, so that these > checks are done by a different PRAGMA (integrity_check_v2 ?) seems > like a wise idea. Indeed; with a separate PRAGMA fk_integrity_ch

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-13 Thread Clemens Ladisch
Jay A. Kreibich wrote: > I can also see situations when someone might want to run one > set or the other set of checks. Breaking it out, so that these > checks are done by a different PRAGMA (integrity_check_v2 ?) seems > like a wise idea. Indeed; with a separate PRAGMA fk_integrity_check

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-13 Thread Dominique Devienne
On Wed, Dec 12, 2012 at 10:01 PM, Jos Groot Lipman wrote: > When you enable foreign keys *after* you insert records, no guarantee is > given by SQLite that the foreign key constraints are fulfilled. This may not > be what most users would want or expect but it certainly not a corrupt > database by

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-12 Thread Simon Slavin
On 12 Dec 2012, at 9:30pm, "Levi Haskell (BLOOMBERG/ 731 LEXIN)" wrote: > I see your point but another way to look at it is that PRAGMA > foreign_keys=0/1 changes the definition of what constitutes a > legal/consistent state of the database, thus it makes sense that behavior of > check_integ

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-12 Thread Jos Groot Lipman
A way to verify the constraint integrety would be great. Some thoughts: - Introduce a boolean 'all_foreign_key_constraits_are_known_valid' (default false) that is stored in the database header - A new PRAGMA foreign_key_check checks the foreign key constraints - If it finds invalid constraints an

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-12 Thread Jay A. Kreibich
On Wed, Dec 12, 2012 at 04:28:21PM -0500, Richard Hipp scratched on the wall: > On Wed, Dec 12, 2012 at 4:18 PM, Levi Haskell (BLOOMBERG/ 731 LEXIN) < > lhask...@bloomberg.net> wrote: > > Intresting, doesn't sqlite3FkCheck() already take these into account? > > > > Yes, it does. But not every ho

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-12 Thread Levi Haskell (BLOOMBERG/ 731 LEXIN)
Agreed. I originally thought your complexity argument was against implementing it inside SQLite. - Levi - Original Message - From: d...@sqlite.org To: LEVI HASKELL (BLOOMBERG/ 731 LEXIN), sqlite-users@sqlite.org At: Dec 12 2012 16:28:43 On Wed, Dec 12, 2012 at 4:18 PM, Levi Has

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-12 Thread Levi Haskell (BLOOMBERG/ 731 LEXIN)
Jos, I see your point but another way to look at it is that PRAGMA foreign_keys=0/1 changes the definition of what constitutes a legal/consistent state of the database, thus it makes sense that behavior of check_integrity PRAGMA would change accordingly. Thanks, - Levi - Original Message

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-12 Thread Richard Hipp
On Wed, Dec 12, 2012 at 4:18 PM, Levi Haskell (BLOOMBERG/ 731 LEXIN) < lhask...@bloomberg.net> wrote: > On Wed, Dec 12, 2012 at 3:40 PM, Richard Hipp wrote: > >On Wed, Dec 12, 2012 at 3:36 PM, Richard Hipp wrote: > >> On Wed, Dec 12, 2012 at 2:29 PM, Levi Haskell (BLOOMBERG/ 731 LEXIN) < > >> lh

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-12 Thread Levi Haskell (BLOOMBERG/ 731 LEXIN)
On Wed, Dec 12, 2012 at 3:40 PM, Richard Hipp wrote: >On Wed, Dec 12, 2012 at 3:36 PM, Richard Hipp wrote: >> On Wed, Dec 12, 2012 at 2:29 PM, Levi Haskell (BLOOMBERG/ 731 LEXIN) < >> lhask...@bloomberg.net> wrote: >> >>> My suggestion would be to have check_integrity command verify referential >

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-12 Thread Jos Groot Lipman
> This seems like a reasonable request. And while we are at > it, we will likely also verify UNIQUE and CHECK constraints too. > > PRAGMA quick_check is still available for users who do not > want to take the extra overhead of verifying UNIQUE, CHECK, > and foreign key constraints. > > Does

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-12 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/12/12 12:36, Richard Hipp wrote: > Does anybody know of any reason why we should not do this? I would love if this was combined with an optional per page checksum that detects corruption early. Roger -BEGIN PGP SIGNATURE- Version: GnuPG

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-12 Thread Richard Hipp
On Wed, Dec 12, 2012 at 3:36 PM, Richard Hipp wrote: > On Wed, Dec 12, 2012 at 2:29 PM, Levi Haskell (BLOOMBERG/ 731 LEXIN) < > lhask...@bloomberg.net> wrote: > >> My suggestion would be to have check_integrity command verify referential >> integrity as well only if it's executed while the foreig

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-12 Thread Richard Hipp
On Wed, Dec 12, 2012 at 2:29 PM, Levi Haskell (BLOOMBERG/ 731 LEXIN) < lhask...@bloomberg.net> wrote: > My suggestion would be to have check_integrity command verify referential > integrity as well only if it's executed while the foreign key enforcement > is enabled on the connection. > This seem

Re: [sqlite] How to verify referential integrity of SQLite database

2012-12-12 Thread Simon Slavin
On 12 Dec 2012, at 7:29pm, Levi Haskell (BLOOMBERG/ 731 LEXIN) wrote: > In a couple of cases due to minor bugs in an upgrade script and the fact > foreign keys are not enforced during their operation the database was left in > an inconsistent state with regards to the referential integrity. W