SQLite

Check-in [f69624373e]
Login

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

Overview
Comment:Fix an imbalanced lock problem in sqlite3Normalize() introduced by the simplification in [94ea6379178e3ff6a].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f69624373e33c4d370a9264a317ffdb0adbce967a950f243de2b41161a8c7ded
User & Date: drh 2018-12-05 21:55:39.342
Context
2018-12-05
23:45
The sqlite3_normalized_sql() interface should not be transforming quoted identifier names into wildcards. Fix this, and at the same time simplify the code substantially. (check-in: e8540377ec user: drh tags: trunk)
23:25
Bungled checkin. Ignore. (Closed-Leaf check-in: 9b6e9a6e45 user: drh tags: mistake)
21:55
Fix an imbalanced lock problem in sqlite3Normalize() introduced by the simplification in [94ea6379178e3ff6a]. (check-in: f69624373e user: drh tags: trunk)
19:42
Increase the version number to 3.27.0 for the next development cycle. (check-in: 8f8d682825 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/prepare.c.
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
    zId = zSpace;
  }else{
    zId = sqlite3DbStrNDup(db, zToken, nToken);
    if( zId==0 ) return 0;
  }
  if( sqlite3IsRowid(zId) ){
    bFound = 1;
    goto done;
  }
  if( nToken>0 ){
    int hash = SQLITE_FUNC_HASH(sqlite3UpperToLower[(u8)zToken[0]], nToken);
    if( sqlite3FunctionSearch(hash, zId) ){
      bFound = 1;
      goto done;
    }
  }
  assert( db!=0 );
  sqlite3_mutex_enter(db->mutex);
  sqlite3BtreeEnterAll(db);
  for(i=0; i<db->nDb; i++){
    pHash = &db->aFunc;







|





|







737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
    zId = zSpace;
  }else{
    zId = sqlite3DbStrNDup(db, zToken, nToken);
    if( zId==0 ) return 0;
  }
  if( sqlite3IsRowid(zId) ){
    bFound = 1;
    goto done1;
  }
  if( nToken>0 ){
    int hash = SQLITE_FUNC_HASH(sqlite3UpperToLower[(u8)zToken[0]], nToken);
    if( sqlite3FunctionSearch(hash, zId) ){
      bFound = 1;
      goto done1;
    }
  }
  assert( db!=0 );
  sqlite3_mutex_enter(db->mutex);
  sqlite3BtreeEnterAll(db);
  for(i=0; i<db->nDb; i++){
    pHash = &db->aFunc;
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795

796
797
798
799
800
801
802
          for(j=0; j<pTab->nCol; j++){
            Column *pCol = &pTab->aCol[j];
            sqlite3HashInsert(pHash, pCol->zName, pCol);
          }
        }else{
          *pRc = SQLITE_NOMEM_BKPT;
          bFound = 0;
          goto done;
        }
      }
      if( pHash && sqlite3HashFind(pHash, zId) ){
        bFound = 1;
        goto done;
      }
    }
  }
done:
  sqlite3BtreeLeaveAll(db);
  sqlite3_mutex_leave(db->mutex);

  if( zId!=zSpace ) sqlite3DbFree(db, zId);
  return bFound;
}

/*
** Attempt to estimate the final output buffer size needed for the fully
** normalized version of the specified SQL string.  This should take into







|




|



|


>







777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
          for(j=0; j<pTab->nCol; j++){
            Column *pCol = &pTab->aCol[j];
            sqlite3HashInsert(pHash, pCol->zName, pCol);
          }
        }else{
          *pRc = SQLITE_NOMEM_BKPT;
          bFound = 0;
          goto done2;
        }
      }
      if( pHash && sqlite3HashFind(pHash, zId) ){
        bFound = 1;
        goto done2;
      }
    }
  }
done2:
  sqlite3BtreeLeaveAll(db);
  sqlite3_mutex_leave(db->mutex);
done1:
  if( zId!=zSpace ) sqlite3DbFree(db, zId);
  return bFound;
}

/*
** Attempt to estimate the final output buffer size needed for the fully
** normalized version of the specified SQL string.  This should take into
Changes to test/normalize.test.
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
  set STMT [sqlite3_prepare_v3 $DB \
      "SELECT a, b FROM t1 WHERE b = ? ORDER BY a;" -1 0 TAIL]

  sqlite3_bind_null $STMT 1
} {}
do_test 202 {
  sqlite3_normalized_sql $STMT
} {}
do_test 203 {
  sqlite3_finalize $STMT
} {SQLITE_OK}

do_test 210 {
  set STMT [sqlite3_prepare_v3 $DB \
      "SELECT a, b FROM t1 WHERE b = ? ORDER BY a;" -1 2 TAIL]







|







82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
  set STMT [sqlite3_prepare_v3 $DB \
      "SELECT a, b FROM t1 WHERE b = ? ORDER BY a;" -1 0 TAIL]

  sqlite3_bind_null $STMT 1
} {}
do_test 202 {
  sqlite3_normalized_sql $STMT
} {SELECT a,b FROM t1 WHERE b=?ORDER BY a;}
do_test 203 {
  sqlite3_finalize $STMT
} {SQLITE_OK}

do_test 210 {
  set STMT [sqlite3_prepare_v3 $DB \
      "SELECT a, b FROM t1 WHERE b = ? ORDER BY a;" -1 2 TAIL]