Index: src/delete.c ================================================================== --- src/delete.c +++ src/delete.c @@ -634,11 +634,17 @@ sqlite3VdbeAddOp3(v, OP_Column, iCur, idx, regBase+j); sqlite3ColumnDefault(v, pTab, idx, -1); } } if( doMakeRec ){ + const char *zAff; + if( pTab->pSelect || (pParse->db->flags & SQLITE_IdxRealAsInt)!=0 ){ + zAff = 0; + }else{ + zAff = sqlite3IndexAffinityStr(v, pIdx); + } sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol+1, regOut); - sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), P4_TRANSIENT); + sqlite3VdbeChangeP4(v, -1, zAff, P4_TRANSIENT); } sqlite3ReleaseTempRange(pParse, regBase, nCol+1); return regBase; } Index: src/sqliteInt.h ================================================================== --- src/sqliteInt.h +++ src/sqliteInt.h @@ -953,10 +953,11 @@ #define SQLITE_IndexSort 0x04 /* Disable indexes for sorting */ #define SQLITE_IndexSearch 0x08 /* Disable indexes for searching */ #define SQLITE_IndexCover 0x10 /* Disable index covering table */ #define SQLITE_GroupByOrder 0x20 /* Disable GROUPBY cover of ORDERBY */ #define SQLITE_FactorOutConst 0x40 /* Disable factoring out constants */ +#define SQLITE_IdxRealAsInt 0x80 /* Store REAL as INT in indices */ #define SQLITE_OptMask 0xff /* Mask of all disablable opts */ /* ** Possible values for the sqlite.magic field. ** The numbers are obtained at random and have no special meaning, other Index: src/test1.c ================================================================== --- src/test1.c +++ src/test1.c @@ -5712,10 +5712,11 @@ { "index-sort", SQLITE_IndexSort }, { "index-search", SQLITE_IndexSearch }, { "index-cover", SQLITE_IndexCover }, { "groupby-order", SQLITE_GroupByOrder }, { "factor-constants", SQLITE_FactorOutConst }, + { "real-as-int", SQLITE_IdxRealAsInt }, }; if( objc!=4 ){ Tcl_WrongNumArgs(interp, 1, objv, "DB OPT BOOLEAN"); return TCL_ERROR; ADDED test/tkt-91e2e8ba6f.test Index: test/tkt-91e2e8ba6f.test ================================================================== --- /dev/null +++ test/tkt-91e2e8ba6f.test @@ -0,0 +1,52 @@ +# 2011 June 23 +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# This file contains tests for SQLite. Specifically, it tests that SQLite +# does not crash and an error is returned if localhost() fails. This +# is the problem reported by ticket 91e2e8ba6f. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +set testprefix tkt-91e2e8ba6f + + +do_execsql_test 1.1 { + CREATE TABLE t1(x INTEGER, y REAL); + INSERT INTO t1 VALUES(11, 11); +} {} + +do_execsql_test 1.2 { + SELECT x/10, y/10 FROM t1; +} {1 1.1} + +do_execsql_test 1.3 { + SELECT x/10, y/10 FROM (SELECT * FROM t1); +} {1 1.1} + +do_execsql_test 1.4 { + SELECT x/10, y/10 FROM (SELECT * FROM t1 LIMIT 5 OFFSET 0); +} {1 1.1} + +do_execsql_test 1.5 { + SELECT x/10, y/10 FROM (SELECT * FROM t1 LIMIT 5 OFFSET 0) LIMIT 5 OFFSET 0; +} {1 1.1} + +do_execsql_test 1.6 { + SELECT a.x/10, a.y/10 FROM + (SELECT * FROM t1 LIMIT 5 OFFSET 0) AS a, t1 AS b WHERE a.x = b.x + LIMIT 5 OFFSET 0; +} {1 1.1} + +do_execsql_test 1.7 { + CREATE VIEW v1 AS SELECT * FROM t1 LIMIT 5; + SELECT a.x/10, a.y/10 FROM v1 AS a, t1 AS b WHERE a.x = b.x LIMIT 5 OFFSET 0; +} {1 1.1} + +finish_test