/ Check-in [36c11ad5]
Login

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

Overview
Comment:Fix the OP_DeferredSeek index-to-table column map in P4 so that it works with generated columns. Ticket [ce22a07731530118]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 36c11ad51fe9ab1bde0b98d0ea9b8588e07d168cd8027486749372894941ad93
User & Date: drh 2019-11-06 17:31:18
References
2019-11-06
19:25
Minor simplification to the changes from check-in [36c11ad51f]. check-in: 7bc8205d user: mistachkin tags: trunk
Context
2019-11-06
19:25
Minor simplification to the changes from check-in [36c11ad51f]. check-in: 7bc8205d user: mistachkin tags: trunk
17:31
Fix the OP_DeferredSeek index-to-table column map in P4 so that it works with generated columns. Ticket [ce22a07731530118] check-in: 36c11ad5 user: drh tags: trunk
14:49
Fix the handling of NOT NULL constraint violations for generated columns in a REPLACE statement. Ticket [2399f5986134f79c] check-in: 77b1c90a user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/wherecode.c.

1050
1051
1052
1053
1054
1055
1056

1057



1058
1059
1060
1061
1062
1063
1064
1065
  ){
    int i;
    Table *pTab = pIdx->pTable;
    int *ai = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*(pTab->nCol+1));
    if( ai ){
      ai[0] = pTab->nCol;
      for(i=0; i<pIdx->nColumn-1; i++){

        assert( pIdx->aiColumn[i]<pTab->nCol );



        if( pIdx->aiColumn[i]>=0 ) ai[pIdx->aiColumn[i]+1] = i+1;
      }
      sqlite3VdbeChangeP4(v, -1, (char*)ai, P4_INTARRAY);
    }
  }
}

/*







>

>
>
>
|







1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
  ){
    int i;
    Table *pTab = pIdx->pTable;
    int *ai = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*(pTab->nCol+1));
    if( ai ){
      ai[0] = pTab->nCol;
      for(i=0; i<pIdx->nColumn-1; i++){
        int x1, x2;
        assert( pIdx->aiColumn[i]<pTab->nCol );
        x1 = pIdx->aiColumn[i];
        x2 = sqlite3TableColumnToStorage(pTab, x1);
        testcase( x1!=x2 );
        if( pIdx->aiColumn[i]>=0 ) ai[x2+1] = i+1;
      }
      sqlite3VdbeChangeP4(v, -1, (char*)ai, P4_INTARRAY);
    }
  }
}

/*

Changes to test/gencol1.test.

206
207
208
209
210
211
212
213











214
} {1 1 | 3 7 |}  

do_catchsql_test gencol1-6.10 {
  DROP TABLE IF EXISTS t0;
  CREATE TABLE t0(c0 NOT NULL AS(c1), c1);
  REPLACE INTO t0(c1) VALUES(NULL);
} {1 {NOT NULL constraint failed: t0.c0}}












finish_test








>
>
>
>
>
>
>
>
>
>
>

206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
} {1 1 | 3 7 |}  

do_catchsql_test gencol1-6.10 {
  DROP TABLE IF EXISTS t0;
  CREATE TABLE t0(c0 NOT NULL AS(c1), c1);
  REPLACE INTO t0(c1) VALUES(NULL);
} {1 {NOT NULL constraint failed: t0.c0}}

# 2019-11-06 ticket b13b7dce76e9352b34e7
do_execsql_test gencol1-7.10 {
  DROP TABLE IF EXISTS t0;
  CREATE TABLE t0 (c0 GENERATED ALWAYS AS (1), c1 UNIQUE, c2 UNIQUE);
  INSERT INTO t0(c1) VALUES (1);
  SELECT quote(0 = t0.c2 OR t0.c1 BETWEEN t0.c2 AND 1) FROM t0;
} {NULL}
do_execsql_test gencol1-7.20 {
  SELECT 99 FROM t0 WHERE 0 = t0.c2 OR t0.c1 BETWEEN t0.c2 AND 1;  
} {}

finish_test