SQLite

Check-in [de19abb950]
Login

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

Overview
Comment:Include the value of the "flags" byte of the relevant page in the log message emitted when a BEGIN CONCURRENT commit conflict is detected.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | begin-concurrent-pnu
Files: files | file ages | folders
SHA3-256: de19abb950e4186c491c39112a52062871ac44fc2bdc5b611e9fdfa611352716
User & Date: dan 2018-05-15 09:03:57.472
Context
2018-05-15
11:33
Instead of just the flags byte, include the first 8 bytes of the relevant page in an on-commit conflict log message. (check-in: 52e443eb55 user: dan tags: begin-concurrent-pnu)
09:03
Include the value of the "flags" byte of the relevant page in the log message emitted when a BEGIN CONCURRENT commit conflict is detected. (check-in: de19abb950 user: dan tags: begin-concurrent-pnu)
08:51
Include the value of the "flags" byte of the relevant page in the log message emitted when a BEGIN CONCURRENT commit conflict is detected. (check-in: fbfa547177 user: dan tags: begin-concurrent)
2018-04-26
18:01
Merge latest changes from trunk. Including the "ORDER BY ... LIMIT" optimization. (check-in: 83a4c9f088 user: dan tags: begin-concurrent-pnu)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/btree.c.
10473
10474
10475
10476
10477
10478
10479

10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490

10491
10492
10493
10494
10495
10496
10497
#ifdef SQLITE_OMIT_CONCURRENT
  assert( pgno==0 );
#else
  if( rc==SQLITE_BUSY_SNAPSHOT && pgno ){
    PgHdr *pPg = 0;
    int rc2 = sqlite3PagerGet(pBt->pPager, pgno, &pPg, 0);
    if( rc2==SQLITE_OK ){

      int bWrite = -1;
      const char *zObj = 0;
      const char *zTab = 0;

      if( pPg ){
        Pgno pgnoRoot = 0;
        HashElem *pE;
        Schema *pSchema;

        pgnoRoot = ((MemPage*)sqlite3PagerGetExtra(pPg))->pgnoRoot;
        bWrite = sqlite3PagerIswriteable(pPg);

        sqlite3PagerUnref(pPg);

        pSchema = sqlite3SchemaGet(p->db, p);
        if( pSchema ){
          for(pE=sqliteHashFirst(&pSchema->tblHash); pE; pE=sqliteHashNext(pE)){
            Table *pTab = (Table *)sqliteHashData(pE);
            if( pTab->tnum==(int)pgnoRoot ){







>











>







10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
#ifdef SQLITE_OMIT_CONCURRENT
  assert( pgno==0 );
#else
  if( rc==SQLITE_BUSY_SNAPSHOT && pgno ){
    PgHdr *pPg = 0;
    int rc2 = sqlite3PagerGet(pBt->pPager, pgno, &pPg, 0);
    if( rc2==SQLITE_OK ){
      u8 pageFlags = 0;
      int bWrite = -1;
      const char *zObj = 0;
      const char *zTab = 0;

      if( pPg ){
        Pgno pgnoRoot = 0;
        HashElem *pE;
        Schema *pSchema;

        pgnoRoot = ((MemPage*)sqlite3PagerGetExtra(pPg))->pgnoRoot;
        bWrite = sqlite3PagerIswriteable(pPg);
        pageFlags = ((u8*)sqlite3PagerGetData(pPg))[0];
        sqlite3PagerUnref(pPg);

        pSchema = sqlite3SchemaGet(p->db, p);
        if( pSchema ){
          for(pE=sqliteHashFirst(&pSchema->tblHash); pE; pE=sqliteHashNext(pE)){
            Table *pTab = (Table *)sqliteHashData(pE);
            if( pTab->tnum==(int)pgnoRoot ){
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520

10521
10522
10523
10524
10525
10526
10527
          }
        }
      }

      sqlite3_log(SQLITE_OK,
          "cannot commit CONCURRENT transaction "
          "- conflict at page %d "
          "(%s page; part of db %s %s%s%s)",
          (int)pgno,
          (bWrite==0?"read-only":(bWrite>0?"read/write":"unknown")),
          (zTab ? "index" : "table"),
          (zTab ? zTab : ""), (zTab ? "." : ""), (zObj ? zObj : "UNKNOWN")

      );
    }
  }
#endif
  sqlite3BtreeLeave(p);
  return rc;
}







|



|
>







10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
          }
        }
      }

      sqlite3_log(SQLITE_OK,
          "cannot commit CONCURRENT transaction "
          "- conflict at page %d "
          "(%s page; part of db %s %s%s%s; flags=0x%02x)",
          (int)pgno,
          (bWrite==0?"read-only":(bWrite>0?"read/write":"unknown")),
          (zTab ? "index" : "table"),
          (zTab ? zTab : ""), (zTab ? "." : ""), (zObj ? zObj : "UNKNOWN"),
          pageFlags
      );
    }
  }
#endif
  sqlite3BtreeLeave(p);
  return rc;
}
Changes to test/concurrent5.test.
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
  db eval {
    INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
  }

  catchsql COMMIT db2
} {1 {database is locked}}
do_test_conflict_msg 1.1.2 {
  conflict at page 2 (read-only page; part of db table t1)
}

do_test 1.2.1 {
  set ::log [list]
  db2 eval {
    ROLLBACK;
    BEGIN CONCURRENT;
      INSERT INTO t1 VALUES(11, 12);
  }

  db eval {
    INSERT INTO t1 VALUES(12, 11);
  }

  catchsql COMMIT db2
} {1 {database is locked}}

do_test_conflict_msg 1.2.2 {
  conflict at page 105 (read/write page; part of db table t1)
}

do_test 1.3.1 {
  set ::log [list]
  db2 eval {
    ROLLBACK;
    BEGIN CONCURRENT;
      INSERT INTO t2 VALUES('x');
  }

  db eval {
    INSERT INTO t2 VALUES('y');
  }

  catchsql COMMIT db2
} {1 {database is locked}}

do_test_conflict_msg 1.3.2 {
  conflict at page 3 (read/write page; part of db table t2)
}

do_test 1.4.1 {
  set ::log [list]

  execsql {
    ROLLBACK;







|


















|


















|







55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
  db eval {
    INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
  }

  catchsql COMMIT db2
} {1 {database is locked}}
do_test_conflict_msg 1.1.2 {
  conflict at page 2 (read-only page; part of db table t1; flags=0x05)
}

do_test 1.2.1 {
  set ::log [list]
  db2 eval {
    ROLLBACK;
    BEGIN CONCURRENT;
      INSERT INTO t1 VALUES(11, 12);
  }

  db eval {
    INSERT INTO t1 VALUES(12, 11);
  }

  catchsql COMMIT db2
} {1 {database is locked}}

do_test_conflict_msg 1.2.2 {
  conflict at page 105 (read/write page; part of db table t1; flags=0x0d)
}

do_test 1.3.1 {
  set ::log [list]
  db2 eval {
    ROLLBACK;
    BEGIN CONCURRENT;
      INSERT INTO t2 VALUES('x');
  }

  db eval {
    INSERT INTO t2 VALUES('y');
  }

  catchsql COMMIT db2
} {1 {database is locked}}

do_test_conflict_msg 1.3.2 {
  conflict at page 3 (read/write page; part of db table t2; flags=0x0d)
}

do_test 1.4.1 {
  set ::log [list]

  execsql {
    ROLLBACK;
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
  } db2

  execsql { INSERT INTO t3 VALUES(NULL, 5002) } db
  catchsql COMMIT db2
} {1 {database is locked}}

do_test_conflict_msg 1.3.2 {
  conflict at page 211 (read/write page; part of db index t3.i3)
}

db close
db2 close
sqlite3_shutdown
test_sqlite3_log 
sqlite3_initialize
finish_test








|









117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
  } db2

  execsql { INSERT INTO t3 VALUES(NULL, 5002) } db
  catchsql COMMIT db2
} {1 {database is locked}}

do_test_conflict_msg 1.3.2 {
  conflict at page 211 (read/write page; part of db index t3.i3; flags=0x0a)
}

db close
db2 close
sqlite3_shutdown
test_sqlite3_log 
sqlite3_initialize
finish_test