/ Check-in [359725ab]
Login

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

Overview
Comment:Fix UPSERT so that it plays nicely with AUTOINCREMENT.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:359725ab36339b443b7745e84f6d27991038ceb063c653805dde17f3eb5a03c5
User & Date: drh 2018-04-21 03:06:29
Context
2018-04-21
13:51
Add the %extra_context directive to lemon, as an alternative to %extra_argument. Use this to improve the performance of the parser. check-in: be47a6f5 user: drh tags: trunk
03:06
Fix UPSERT so that it plays nicely with AUTOINCREMENT. check-in: 359725ab user: drh tags: trunk
2018-04-20
20:47
Add the -dDIRECTORY command-line option to LEMON. check-in: 9cd20475 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/update.c.

751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
  }
  sqlite3VdbeResolveLabel(v, labelBreak);

  /* Update the sqlite_sequence table by storing the content of the
  ** maximum rowid counter values recorded while inserting into
  ** autoincrement tables.
  */
  if( pParse->nested==0 && pParse->pTriggerTab==0 ){
    sqlite3AutoincrementEnd(pParse);
  }

  /*
  ** Return the number of rows that were changed, if we are tracking
  ** that information.
  */







|







751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
  }
  sqlite3VdbeResolveLabel(v, labelBreak);

  /* Update the sqlite_sequence table by storing the content of the
  ** maximum rowid counter values recorded while inserting into
  ** autoincrement tables.
  */
  if( pParse->nested==0 && pParse->pTriggerTab==0 && pUpsert==0 ){
    sqlite3AutoincrementEnd(pParse);
  }

  /*
  ** Return the number of rows that were changed, if we are tracking
  ** that information.
  */

Changes to test/autoinc.test.

671
672
673
674
675
676
677

678






679
680
  CREATE TABLE t10a(a INTEGER PRIMARY KEY AUTOINCREMENT, b UNIQUE);
  INSERT INTO t10a VALUES(888,9999);
  CREATE TABLE t10b(x INTEGER PRIMARY KEY AUTOINCREMENT, y UNIQUE);
  INSERT INTO t10b SELECT * FROM t10a;
  SELECT * FROM sqlite_sequence;
} {t10a 888 t10b 888}










finish_test







>
|
>
>
>
>
>
>


671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
  CREATE TABLE t10a(a INTEGER PRIMARY KEY AUTOINCREMENT, b UNIQUE);
  INSERT INTO t10a VALUES(888,9999);
  CREATE TABLE t10b(x INTEGER PRIMARY KEY AUTOINCREMENT, y UNIQUE);
  INSERT INTO t10b SELECT * FROM t10a;
  SELECT * FROM sqlite_sequence;
} {t10a 888 t10b 888}

# 2018-04-21 autoincrement does not cause problems for upsert
#
do_execsql_test autoinc-11.1 {
  CREATE TABLE t11(a INTEGER PRIMARY KEY AUTOINCREMENT,b UNIQUE);
  INSERT INTO t11(a,b) VALUES(2,3),(5,6),(4,3),(1,2)
    ON CONFLICT(b) DO UPDATE SET a=a+1000;
  SELECT seq FROM sqlite_sequence WHERE name='t11';
} {5}

finish_test