SQLite

Check-in [e8ed62f82e]
Login

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

Overview
Comment:Fix a crash in FTS5 caused by specifying NULL as the rhs of a MATCH operator.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e8ed62f82e8acc40b818bf86fafe3d480687514e
User & Date: dan 2015-09-17 09:48:01.737
Context
2015-09-17
17:21
Avoid passing (signed char) values directly to isspace(), isalnum() or isdigit() in json1.c. Cast the value to (unsigned char) first. (check-in: 6713e35b8a user: dan tags: trunk)
09:48
Fix a crash in FTS5 caused by specifying NULL as the rhs of a MATCH operator. (check-in: e8ed62f82e user: dan tags: trunk)
2015-09-16
17:46
Add a "flush" to force incremental output to releasetest-out.txt while running the test/releasetest.tcl. script. (check-in: 0f3de2d337 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to ext/fts5/fts5_main.c.
1112
1113
1114
1115
1116
1117
1118

1119
1120
1121
1122
1123
1124
1125
    assert( pCsr->iLastRowid==LARGEST_INT64 );
    assert( pCsr->iFirstRowid==SMALLEST_INT64 );
    pCsr->ePlan = FTS5_PLAN_SOURCE;
    pCsr->pExpr = pTab->pSortCsr->pExpr;
    rc = fts5CursorFirst(pTab, pCsr, bDesc);
  }else if( pMatch ){
    const char *zExpr = (const char*)sqlite3_value_text(apVal[0]);


    rc = fts5CursorParseRank(pConfig, pCsr, pRank);
    if( rc==SQLITE_OK ){
      if( zExpr[0]=='*' ){
        /* The user has issued a query of the form "MATCH '*...'". This
        ** indicates that the MATCH expression is not a full text query,
        ** but a request for an internal parameter.  */







>







1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
    assert( pCsr->iLastRowid==LARGEST_INT64 );
    assert( pCsr->iFirstRowid==SMALLEST_INT64 );
    pCsr->ePlan = FTS5_PLAN_SOURCE;
    pCsr->pExpr = pTab->pSortCsr->pExpr;
    rc = fts5CursorFirst(pTab, pCsr, bDesc);
  }else if( pMatch ){
    const char *zExpr = (const char*)sqlite3_value_text(apVal[0]);
    if( zExpr==0 ) zExpr = "";

    rc = fts5CursorParseRank(pConfig, pCsr, pRank);
    if( rc==SQLITE_OK ){
      if( zExpr[0]=='*' ){
        /* The user has issued a query of the form "MATCH '*...'". This
        ** indicates that the MATCH expression is not a full text query,
        ** but a request for an internal parameter.  */
Changes to ext/fts5/test/fts5simple.test.
164
165
166
167
168
169
170
















171
172
173
  INSERT INTO tt(tt, rank) VALUES('pgsz', 32);
  INSERT INTO tt VALUES('aa ab ac ad ae af');
}

do_execsql_test 5.8 {
  SELECT rowid FROM tt WHERE tt MATCH 'a*';
} {1}

















finish_test








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
  INSERT INTO tt(tt, rank) VALUES('pgsz', 32);
  INSERT INTO tt VALUES('aa ab ac ad ae af');
}

do_execsql_test 5.8 {
  SELECT rowid FROM tt WHERE tt MATCH 'a*';
} {1}

#-------------------------------------------------------------------------

reset_db
do_execsql_test 6.1 {
  CREATE VIRTUAL TABLE xyz USING fts5(x, y, z);
  INSERT INTO xyz VALUES('x', 'y', 'z');
}

do_catchsql_test 6.2 { 
  SELECT * FROM xyz WHERE xyz MATCH '' 
} {1 {fts5: syntax error near ""}}
do_catchsql_test 6.3 { 
  SELECT * FROM xyz WHERE xyz MATCH NULL 
} {1 {fts5: syntax error near ""}}


finish_test