]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Have the sqlite3_index_writer() VMs check that the final values of records inserted...
authordan <dan@noemail.net>
Mon, 15 Sep 2014 12:18:29 +0000 (12:18 +0000)
committerdan <dan@noemail.net>
Mon, 15 Sep 2014 12:18:29 +0000 (12:18 +0000)
FossilOrigin-Name: cca376bff3510dc5e99fc5824862c3471ceced16

ext/ota/ota3.test
ext/ota/sqlite3ota.h
manifest
manifest.uuid
src/vdbeblob.c

index 7907974767939ba54e1e550bd1f38c89f303cfb8..a4eee322716ed508638d8482c508743e13782584 100644 (file)
@@ -49,6 +49,31 @@ do_execsql_test 1.2 {
   PRAGMA integrity_check;
 } {ok}
 
+#--------------------------------------------------------------------
+# Test that NULL values may not be inserted into INTEGER PRIMARY KEY
+# columns.
+#
+forcedelete ota.db
+reset_db
+
+do_execsql_test 2.0 {
+  CREATE TABLE x1(a INTEGER PRIMARY KEY, b TEXT, c REAL);
+  CREATE INDEX i1 ON x1(b, c);
+} {}
+
+do_test 2.1 {
+  sqlite3 db2 ota.db
+  db2 eval {
+    CREATE TABLE data_x1(a, b, c, ota_control);
+    INSERT INTO data_x1 VALUES(NULL, 'a', 'b', 0);
+  }
+  db2 close
+  list [catch { run_ota test.db ota.db } msg] $msg
+} {1 {SQLITE_MISMATCH - datatype mismatch}}
+
+do_execsql_test 2.2 {
+  PRAGMA integrity_check;
+} {ok}
 
 
 finish_test
index 12832674c7f94bf8efdc4d8a4a3295fe258d88fe..9473b359f2b1b0349d7d9e61c6a689bc8d487bb7 100644 (file)
 ** update, the corresponding data_% table should contain a single record
 ** with the "ota_control" column set to contain integer value 0. The
 ** other columns should be set to the values that make up the new record 
-** to insert.
+** to insert. 
+**
+** If the target database table has an INTEGER PRIMARY KEY and there are
+** one or more auxiliary indexes, it is not possible to insert a NULL value
+** into the IPK column. Attempting to do so results in an SQLITE_MISMATCH
+** error.
 **
 ** For each row to DELETE from the target database as part of the OTA 
 ** update, the corresponding data_% table should contain a single record
index 16fda27393da40e0298a8abc236b975522c68238..344ec70e0074c1c799e1dc39c087b1fa8020ed8e 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sOP_Affinity\sopcodes\sto\sthe\sVMs\sgenerated\sby\ssqlite3_index_writer().
-D 2014-09-15T10:44:24.271
+C Have\sthe\ssqlite3_index_writer()\sVMs\scheck\sthat\sthe\sfinal\svalues\sof\srecords\sinserted\sinto\sindexes\son\srowid\stables\sare\sintegers.
+D 2014-09-15T12:18:29.913
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -124,9 +124,9 @@ F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212
 F ext/ota/ota.c d37097e92a005d3915883adefbb93019ea6f8841
 F ext/ota/ota1.test fe0bb8acf0caef6c19937b84c6547b788342610d
 F ext/ota/ota2.test 13f76922446c62ed96192e938b8e625ebf0142fa
-F ext/ota/ota3.test 9e3e42c6083e92909c408f1fe62aa07b0c9f905c
+F ext/ota/ota3.test 7179a90eb64cf8135a6885568653f158fb130872
 F ext/ota/sqlite3ota.c 3697f6db2d51d5f7c0f0306fe94514785361e521
-F ext/ota/sqlite3ota.h 545f0008b5f02f2595899cb9841caddada5c17c0
+F ext/ota/sqlite3ota.h 39ce4dffbfcf4ade9e4526369fe2243709345c8e
 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
 F ext/rtree/rtree.c 57bec53e1a677ab74217fe1f20a58c3a47261d6b
 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e
@@ -296,7 +296,7 @@ F src/vdbe.h c63fad052c9e7388d551e556e119c0bcf6bebdf8
 F src/vdbeInt.h cdc8e421f85beb1ac9b4669ec5beadab6faa15e0
 F src/vdbeapi.c 09677a53dd8c71bcd670b0bd073bb9aefa02b441
 F src/vdbeaux.c cef5d34a64ae3a65b56d96d3fd663246ec8e1c36
-F src/vdbeblob.c 7a28ade0cae13bd99f5c4c8f008f68e942c23115
+F src/vdbeblob.c 7ddae314db27c39f654fd2af577c9afc33d089d9
 F src/vdbemem.c 921d5468a68ac06f369810992e84ca22cc730a62
 F src/vdbesort.c 7c45bfcd823f30d172bbbc1b9f51ef4402fbfe8d
 F src/vdbetrace.c 6f52bc0c51e144b7efdcfb2a8f771167a8816767
@@ -1199,7 +1199,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P e109b27e4d66b83e1a804e7556d9c91aa37fea28
-R 75f9e5319b2343a328ed4364426b7add
+P b9b38cb8e21826ddfb4c87a1f166ad33c3c7b6eb
+R 6282c8b629d24290f7b2f44befcb6a71
 U dan
-Z c56c0b8cb355334f7ef68c91cc8c371e
+Z 32d433205c33319cd81cbc2b152b81af
index 6154d2dd6bf363f36cbdbe46745ef67200ab0335..8423c49a14d9a31abbbb20fe3c16120cb5e92e84 100644 (file)
@@ -1 +1 @@
-b9b38cb8e21826ddfb4c87a1f166ad33c3c7b6eb
\ No newline at end of file
+cca376bff3510dc5e99fc5824862c3471ceced16
\ No newline at end of file
index dd08b0b8aaba374bae93626e22f65e910f0f037d..09c519cb592c9178b4bc48a113177f805e162a4c 100644 (file)
@@ -549,6 +549,11 @@ int sqlite3_index_writer(
   }
   regRec = ++pParse->nMem;
 
+  /* If this is a rowid table, check that the rowid field is an integer. */
+  if( HasRowid(pTab) ){
+    sqlite3VdbeAddOp2(v, OP_MustBeInt, pIdx->nColumn, 0);
+  }
+
   if( bDelete==0 ){
     sqlite3VdbeAddOp4(v, OP_MakeRecord, 1, pIdx->nColumn, regRec, zAffinity, 0);