/ Check-in [610e7e96]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Fix fts handling of the case where both a rowid and docid are specified as part of an insert statement.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fts-languageid-bits
Files: files | file ages | folders
SHA1: 610e7e9612abcbd072a42ab83bd75148a15065b8
User & Date: dan 2013-06-20 11:01:33
Context
2013-06-20
11:48
Add tests (and a fix) for large and small fts docid values with various languageid_bits settings. check-in: 8dc261b7 user: dan tags: fts-languageid-bits
11:01
Fix fts handling of the case where both a rowid and docid are specified as part of an insert statement. check-in: 610e7e96 user: dan tags: fts-languageid-bits
2013-06-19
20:13
Add the languageid_bits= option to fts. Still some problems to work out. check-in: d36d7e68 user: dan tags: fts-languageid-bits
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3_write.c.

999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
....
5378
5379
5380
5381
5382
5383
5384





5385
5386
5387
5388
5389
5390
5391
  */
  assert( p->nLanguageidBits==0 || piRowid==0
      || sqlite3_value_type(apVal[1])!=SQLITE_NULL 
  );
  if( piRowid && p->nLanguageidBits==0 
   && SQLITE_NULL!=sqlite3_value_type(apVal[3+p->nColumn]) 
  ){
    if( SQLITE_NULL==sqlite3_value_type(apVal[0])
     && SQLITE_NULL!=sqlite3_value_type(apVal[1])
    ){
      /* A rowid/docid conflict. */
      return SQLITE_ERROR;
    }
    rc = sqlite3_bind_value(pContentInsert, 1, apVal[3+p->nColumn]);
    if( rc!=SQLITE_OK ) return rc;
  }

  /* Execute the statement to insert the record. Set *pRowid to the 
  ** new docid value. 
  */
................................................................................
    sqlite3_value *pNewDocid = apVal[3+p->nColumn];
    if( sqlite3_value_type(pNewDocid)==SQLITE_NULL ){
      if( p->nLanguageidBits ){
        rc = SQLITE_CONSTRAINT;
        goto update_out;
      }
      pNewDocid = apVal[1];





    }

    if( sqlite3_value_type(pNewDocid)!=SQLITE_NULL ){
      int e = sqlite3_value_numeric_type(pNewDocid);
      i64 iRowid = sqlite3_value_int64(pNewDocid);

      /* Check that the value specified by the user may be losslessly







<
<
<
<
<
<







 







>
>
>
>
>







999
1000
1001
1002
1003
1004
1005






1006
1007
1008
1009
1010
1011
1012
....
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
  */
  assert( p->nLanguageidBits==0 || piRowid==0
      || sqlite3_value_type(apVal[1])!=SQLITE_NULL 
  );
  if( piRowid && p->nLanguageidBits==0 
   && SQLITE_NULL!=sqlite3_value_type(apVal[3+p->nColumn]) 
  ){






    rc = sqlite3_bind_value(pContentInsert, 1, apVal[3+p->nColumn]);
    if( rc!=SQLITE_OK ) return rc;
  }

  /* Execute the statement to insert the record. Set *pRowid to the 
  ** new docid value. 
  */
................................................................................
    sqlite3_value *pNewDocid = apVal[3+p->nColumn];
    if( sqlite3_value_type(pNewDocid)==SQLITE_NULL ){
      if( p->nLanguageidBits ){
        rc = SQLITE_CONSTRAINT;
        goto update_out;
      }
      pNewDocid = apVal[1];
    }else if( sqlite3_value_type(apVal[0])==SQLITE_NULL 
           && sqlite3_value_type(apVal[1])!=SQLITE_NULL 
    ){
      rc = SQLITE_ERROR;
      goto update_out;
    }

    if( sqlite3_value_type(pNewDocid)!=SQLITE_NULL ){
      int e = sqlite3_value_numeric_type(pNewDocid);
      i64 iRowid = sqlite3_value_int64(pNewDocid);

      /* Check that the value specified by the user may be losslessly

Changes to test/fts4langid2.test.

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
  SELECT docid, lid, content FROM t1 WHERE t1 MATCH '2';
} {1 0 {1 2 3}}

do_execsql_test 4.5 {
  SELECT docid, lid, content FROM t1 WHERE t1 MATCH '2' AND lid=1;
} {1 1 {1 2 3 4}}

breakpoint
do_execsql_test 4.6 {
  UPDATE t1 SET content = 'x y z' || lid;
  SELECT docid, lid FROM t1;
} {1 0 1 1}


finish_test








<








119
120
121
122
123
124
125

126
127
128
129
130
131
132
133
  SELECT docid, lid, content FROM t1 WHERE t1 MATCH '2';
} {1 0 {1 2 3}}

do_execsql_test 4.5 {
  SELECT docid, lid, content FROM t1 WHERE t1 MATCH '2' AND lid=1;
} {1 1 {1 2 3 4}}


do_execsql_test 4.6 {
  UPDATE t1 SET content = 'x y z' || lid;
  SELECT docid, lid FROM t1;
} {1 0 1 1}


finish_test