/ Check-in [e7dc03e7]
Login

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

Overview
Comment:Instead of just the flags byte, include the first 8 bytes of the relevant page in an on-commit conflict log message.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | begin-concurrent
Files: files | file ages | folders
SHA3-256: e7dc03e7439f224e4bec458f27fe364f2fb1ac637328657a578ada693ae22842
User & Date: dan 2018-05-15 11:28:36
Wiki:begin-concurrent
Context
2018-05-15
11:45
Merge latest trunk changes with this branch. check-in: ae86cf60 user: dan tags: begin-concurrent
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: 52e443eb user: dan tags: begin-concurrent-pnu
11:28
Instead of just the flags byte, include the first 8 bytes of the relevant page in an on-commit conflict log message. check-in: e7dc03e7 user: dan tags: begin-concurrent
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: fbfa5471 user: dan tags: begin-concurrent
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

 10429  10429   #ifdef SQLITE_OMIT_CONCURRENT
 10430  10430     assert( pgno==0 );
 10431  10431   #else
 10432  10432     if( rc==SQLITE_BUSY_SNAPSHOT && pgno ){
 10433  10433       PgHdr *pPg = 0;
 10434  10434       int rc2 = sqlite3PagerGet(pBt->pPager, pgno, &pPg, 0);
 10435  10435       if( rc2==SQLITE_OK ){
 10436         -      u8 pageFlags = 0;
 10437  10436         int bWrite = -1;
 10438  10437         const char *zObj = 0;
 10439  10438         const char *zTab = 0;
        10439  +      char zContent[17];
 10440  10440   
 10441  10441         if( pPg ){
 10442  10442           Pgno pgnoRoot = 0;
 10443  10443           HashElem *pE;
 10444  10444           Schema *pSchema;
        10445  +        u8 *aData = (u8*)sqlite3PagerGetData(pPg);
        10446  +        int i;
        10447  +        for(i=0; i<8; i++){
        10448  +          static const char hexdigits[] = {
        10449  +            '0', '1', '2', '3', '4', '5', '6', '7',
        10450  +            '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' 
        10451  +          };
        10452  +          zContent[i*2] = hexdigits[(aData[i] >> 4)];
        10453  +          zContent[i*2+1] = hexdigits[(aData[i] & 0xF)];
        10454  +        }
        10455  +        zContent[16] = '\0';
 10445  10456   
 10446  10457           pgnoRoot = ((MemPage*)sqlite3PagerGetExtra(pPg))->pgnoRoot;
 10447  10458           bWrite = sqlite3PagerIswriteable(pPg);
 10448         -        pageFlags = ((u8*)sqlite3PagerGetData(pPg))[0];
 10449  10459           sqlite3PagerUnref(pPg);
 10450  10460   
 10451  10461           pSchema = sqlite3SchemaGet(p->db, p);
 10452  10462           if( pSchema ){
 10453  10463             for(pE=sqliteHashFirst(&pSchema->tblHash); pE; pE=sqliteHashNext(pE)){
 10454  10464               Table *pTab = (Table *)sqliteHashData(pE);
 10455  10465               if( pTab->tnum==(int)pgnoRoot ){
................................................................................
 10467  10477             }
 10468  10478           }
 10469  10479         }
 10470  10480   
 10471  10481         sqlite3_log(SQLITE_OK,
 10472  10482             "cannot commit CONCURRENT transaction "
 10473  10483             "- conflict at page %d "
 10474         -          "(%s page; part of db %s %s%s%s; flags=0x%02x)",
        10484  +          "(%s page; part of db %s %s%s%s; content=%s...)",
 10475  10485             (int)pgno,
 10476  10486             (bWrite==0?"read-only":(bWrite>0?"read/write":"unknown")),
 10477  10487             (zTab ? "index" : "table"),
 10478  10488             (zTab ? zTab : ""), (zTab ? "." : ""), (zObj ? zObj : "UNKNOWN"),
 10479         -          pageFlags
        10489  +          zContent
 10480  10490         );
 10481  10491       }
 10482  10492     }
 10483  10493   #endif
 10484  10494     sqlite3BtreeLeave(p);
 10485  10495     return rc;
 10486  10496   }

Changes to test/concurrent5.test.

    55     55     db eval {
    56     56       INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
    57     57     }
    58     58   
    59     59     catchsql COMMIT db2
    60     60   } {1 {database is locked}}
    61     61   do_test_conflict_msg 1.1.2 {
    62         -  conflict at page 2 (read-only page; part of db table t1; flags=0x05)
           62  +  conflict at page 2 (read-only page; part of db table t1; content=0500000063021100...)
    63     63   }
    64     64   
    65     65   do_test 1.2.1 {
    66     66     set ::log [list]
    67     67     db2 eval {
    68     68       ROLLBACK;
    69     69       BEGIN CONCURRENT;
................................................................................
    74     74       INSERT INTO t1 VALUES(12, 11);
    75     75     }
    76     76   
    77     77     catchsql COMMIT db2
    78     78   } {1 {database is locked}}
    79     79   
    80     80   do_test_conflict_msg 1.2.2 {
    81         -  conflict at page 105 (read/write page; part of db table t1; flags=0x0d)
           81  +  conflict at page 105 (read/write page; part of db table t1; content=0D00000002026100...)
    82     82   }
    83     83   
    84     84   do_test 1.3.1 {
    85     85     set ::log [list]
    86     86     db2 eval {
    87     87       ROLLBACK;
    88     88       BEGIN CONCURRENT;
................................................................................
    93     93       INSERT INTO t2 VALUES('y');
    94     94     }
    95     95   
    96     96     catchsql COMMIT db2
    97     97   } {1 {database is locked}}
    98     98   
    99     99   do_test_conflict_msg 1.3.2 {
   100         -  conflict at page 3 (read/write page; part of db table t2; flags=0x0d)
          100  +  conflict at page 3 (read/write page; part of db table t2; content=0D0000000103FB00...)
   101    101   }
   102    102   
   103    103   do_test 1.4.1 {
   104    104     set ::log [list]
   105    105   
   106    106     execsql {
   107    107       ROLLBACK;
................................................................................
   117    117     } db2
   118    118   
   119    119     execsql { INSERT INTO t3 VALUES(NULL, 5002) } db
   120    120     catchsql COMMIT db2
   121    121   } {1 {database is locked}}
   122    122   
   123    123   do_test_conflict_msg 1.3.2 {
   124         -  conflict at page 211 (read/write page; part of db index t3.i3; flags=0x0a)
          124  +  conflict at page 211 (read/write page; part of db index t3.i3; content=0A0310006300D800...)
   125    125   }
   126    126   
   127    127   db close
   128    128   db2 close
   129    129   sqlite3_shutdown
   130    130   test_sqlite3_log 
   131    131   sqlite3_initialize
   132    132   finish_test
   133    133