SQLite

Check-in [71f08b91]
Login

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

Overview
Comment:Fix the CREATE TABLE performance issue described by forum thread 4cf69794d9dfff7c in two different ways: (1) Omit the call to PRAGMA integrity_check('X') that was being done after CREATE TABLE "X" because the result was being ignored and the integrity_check was not doing anything other than burning CPU cycles. (2) Do not interpret the argument to PRAGMA integrity_check as a number if it is in fact a string that looks like a number.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 71f08b912251c8a3ac1bd8e344903336648e4187f7493f8c126e60b3b51b9f09
User & Date: drh 2024-05-02 12:14:31
Context
2024-05-02
14:48
Avoid an OP_Next in cases where an IN(...) query against a UNIQUE index may return at most 1 row. (check-in: d7648e21 user: dan tags: trunk)
12:14
Fix the CREATE TABLE performance issue described by forum thread 4cf69794d9dfff7c in two different ways: (1) Omit the call to PRAGMA integrity_check('X') that was being done after CREATE TABLE "X" because the result was being ignored and the integrity_check was not doing anything other than burning CPU cycles. (2) Do not interpret the argument to PRAGMA integrity_check as a number if it is in fact a string that looks like a number. (check-in: 71f08b91 user: drh tags: trunk)
12:00
Add a test case to the fix to PRAGMA integrity_check in the previous check-in. (Closed-Leaf check-in: 39a57b59 user: drh tags: faster-create)
2024-05-01
16:25
Fix another problem in the recovery extension where a corrupt sqlite_schema table could lead to excessive memory consumption. (check-in: 1c7e33a8 user: dan tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/build.c.

2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
    /* Test for cycles in generated columns and illegal expressions
    ** in CHECK constraints and in DEFAULT clauses. */
    if( p->tabFlags & TF_HasGenerated ){
      sqlite3VdbeAddOp4(v, OP_SqlExec, 0x0001, 0, 0,
             sqlite3MPrintf(db, "SELECT*FROM\"%w\".\"%w\"",
                   db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC);
    }
    sqlite3VdbeAddOp4(v, OP_SqlExec, 0x0001, 0, 0,
           sqlite3MPrintf(db, "PRAGMA \"%w\".integrity_check(%Q)",
                 db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC);
  }

  /* Add the table to the in-memory representation of the database.
  */
  if( db->init.busy ){
    Table *pOld;
    Schema *pSchema = p->pSchema;







<
<
<







2923
2924
2925
2926
2927
2928
2929



2930
2931
2932
2933
2934
2935
2936
    /* Test for cycles in generated columns and illegal expressions
    ** in CHECK constraints and in DEFAULT clauses. */
    if( p->tabFlags & TF_HasGenerated ){
      sqlite3VdbeAddOp4(v, OP_SqlExec, 0x0001, 0, 0,
             sqlite3MPrintf(db, "SELECT*FROM\"%w\".\"%w\"",
                   db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC);
    }



  }

  /* Add the table to the in-memory representation of the database.
  */
  if( db->init.busy ){
    Table *pOld;
    Schema *pSchema = p->pSchema;

Changes to src/pragma.c.

1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713

    /* Initialize the VDBE program */
    pParse->nMem = 6;

    /* Set the maximum error count */
    mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
    if( zRight ){
      if( sqlite3GetInt32(zRight, &mxErr) ){
        if( mxErr<=0 ){
          mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
        }
      }else{
        pObjTab = sqlite3LocateTable(pParse, 0, zRight,
                      iDb>=0 ? db->aDb[iDb].zDbSName : 0);
      }







|







1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713

    /* Initialize the VDBE program */
    pParse->nMem = 6;

    /* Set the maximum error count */
    mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
    if( zRight ){
      if( sqlite3GetInt32(pValue->z, &mxErr) ){
        if( mxErr<=0 ){
          mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
        }
      }else{
        pObjTab = sqlite3LocateTable(pParse, 0, zRight,
                      iDb>=0 ? db->aDb[iDb].zDbSName : 0);
      }

Changes to test/pragma.test.

383
384
385
386
387
388
389



390
391
392
393
394
395
396
      }
    } {{wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2}}
    do_test pragma-3.5 {
      execsql {
        PRAGMA integrity_check=4
      }
    } {{wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}}



    do_catchsql_test pragma-3.6 {
      PRAGMA integrity_check=xyz
    } {1 {no such table: xyz}}
    do_catchsql_test pragma-3.6b {
      PRAGMA integrity_check=t2
    } {0 {{wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2}}}
    do_catchsql_test pragma-3.6c {







>
>
>







383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
      }
    } {{wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2}}
    do_test pragma-3.5 {
      execsql {
        PRAGMA integrity_check=4
      }
    } {{wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}}
    do_catchsql_test pragma-3.5.2 {
      PRAGMA integrity_check='4'
    } {1 {no such table: 4}}
    do_catchsql_test pragma-3.6 {
      PRAGMA integrity_check=xyz
    } {1 {no such table: xyz}}
    do_catchsql_test pragma-3.6b {
      PRAGMA integrity_check=t2
    } {0 {{wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2}}}
    do_catchsql_test pragma-3.6c {