/ Check-in [e30062e9]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Bug fix: the conflict resolution behavior for the implied NOT NULL constraint on the PRIMARY KEY of a WITHOUT ROWID table should be ABORT.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e30062e9f6cae980150dda7df440b36dfdcb7bbe
User & Date: drh 2016-01-03 18:07:57
References
2016-01-04
13:06
Fix the conflict2.test module which was broken by check-in [e30062e9f6c]. check-in: b779ca8a user: drh tags: trunk
Context
2016-01-04
01:08
Add releasetest.tcl cases for SQLITE_LIKE_DOESNT_MATCH_BLOB and for SQLITE_ENABLE_CURSOR_HINTS. check-in: f300c35e user: drh tags: trunk
2016-01-03
18:59
Alternative to [76f5efa6], move definition of utf8_printf up. check-in: 54c5522d user: mistachkin tags: altShellFix
18:07
Bug fix: the conflict resolution behavior for the implied NOT NULL constraint on the PRIMARY KEY of a WITHOUT ROWID table should be ABORT. check-in: e30062e9 user: drh tags: trunk
11:27
Fix a premature reference to utf8_printf in shell.c. check-in: 76f5efa6 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

  1770   1770     assert( pPk!=0 );
  1771   1771     nPk = pPk->nKeyCol;
  1772   1772   
  1773   1773     /* Make sure every column of the PRIMARY KEY is NOT NULL.  (Except,
  1774   1774     ** do not enforce this for imposter tables.) */
  1775   1775     if( !db->init.imposterTable ){
  1776   1776       for(i=0; i<nPk; i++){
  1777         -      pTab->aCol[pPk->aiColumn[i]].notNull = 1;
         1777  +      pTab->aCol[pPk->aiColumn[i]].notNull = OE_Abort;
  1778   1778       }
  1779   1779       pPk->uniqNotNull = 1;
  1780   1780     }
  1781   1781   
  1782   1782     /* The root page of the PRIMARY KEY is the table root page */
  1783   1783     pPk->tnum = pTab->tnum;
  1784   1784   

Changes to test/conflict2.test.

   285    285   #   t4     Number of temporary files for statement journals
   286    286   #
   287    287   # Update: Since temporary table files are now opened lazily, and none
   288    288   # of the following tests use large quantities of data, t3 is always 0.
   289    289   #
   290    290   foreach {i conf1 cmd t0 t1 t2 t3 t4} {
   291    291     1 {}       UPDATE                  1 {6 7 8 9}  1 0 1
   292         -  2 REPLACE  UPDATE                  0 {7 6 9}    1 0 0
   293         -  3 IGNORE   UPDATE                  0 {6 7 3 9}  1 0 0
   294         -  4 FAIL     UPDATE                  1 {6 7 3 4}  1 0 0
          292  +  2 REPLACE  UPDATE                  0 {7 6 9}    1 1 0
          293  +  3 IGNORE   UPDATE                  0 {6 7 3 9}  1 1 0
          294  +  4 FAIL     UPDATE                  1 {6 7 3 4}  1 1 0
   295    295     5 ABORT    UPDATE                  1 {1 2 3 4}  1 0 1
   296         -  6 ROLLBACK UPDATE                  1 {1 2 3 4}  0 0 0
          296  +  6 ROLLBACK UPDATE                  1 {1 2 3 4}  0 1 0
   297    297     7 REPLACE  {UPDATE OR IGNORE}      0 {6 7 3 9}  1 0 0
   298    298     8 IGNORE   {UPDATE OR REPLACE}     0 {7 6 9}    1 0 1
   299    299     9 FAIL     {UPDATE OR IGNORE}      0 {6 7 3 9}  1 0 0
   300    300    10 ABORT    {UPDATE OR REPLACE}     0 {7 6 9}    1 0 1
   301    301    11 ROLLBACK {UPDATE OR IGNORE}      0 {6 7 3 9}  1 0 0
   302    302    12 {}       {UPDATE OR IGNORE}      0 {6 7 3 9}  1 0 0
   303    303    13 {}       {UPDATE OR REPLACE}     0 {7 6 9}    1 0 1

Changes to test/without_rowid5.test.

   128    128   # PRIMARY KEY" do not apply on WITHOUT ROWID tables.
   129    129   #
   130    130   do_execsql_test without_rowid5-5.1 {
   131    131     CREATE TABLE ipk(key INTEGER PRIMARY KEY, val TEXT) WITHOUT ROWID;
   132    132     INSERT INTO ipk VALUES('rival','bonus'); -- ok to insert non-integer key
   133    133     SELECT * FROM ipk;
   134    134   } {rival bonus}
   135         -do_catchsql_test without_rowid5-5.2 {
          135  +do_catchsql_test without_rowid5-5.2a {
          136  +  BEGIN;
   136    137     INSERT INTO ipk VALUES(NULL,'sample'); -- no automatic generation of keys
   137    138   } {1 {NOT NULL constraint failed: ipk.key}}
          139  +do_execsql_test without_rowid5-5.2b {
          140  +  ROLLBACK;
          141  +} {}
   138    142   
   139    143   # EVIDENCE-OF: R-33142-02092 AUTOINCREMENT does not work on WITHOUT
   140    144   # ROWID tables.
   141    145   #
   142    146   # EVIDENCE-OF: R-53084-07740 An error is raised if the "AUTOINCREMENT"
   143    147   # keyword is used in the CREATE TABLE statement for a WITHOUT ROWID
   144    148   # table.