Index: src/select.c ================================================================== --- src/select.c +++ src/select.c @@ -10,11 +10,11 @@ ** ************************************************************************* ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** -** $Id: select.c,v 1.487 2008/11/21 09:43:20 danielk1977 Exp $ +** $Id: select.c,v 1.488 2008/11/21 16:22:18 danielk1977 Exp $ */ #include "sqliteInt.h" /* @@ -1179,11 +1179,12 @@ if( iCol<0 ) iCol = pTab->iPKey; zName = sqlite3MPrintf(db, "%s", iCol>=0 ? pTab->aCol[iCol].zName : "rowid"); }else{ /* Use the original text of the column expression as its name */ - zName = sqlite3MPrintf(db, "%T", &pCol->span); + Token *pToken = (pCol->span.z?&pCol->span:&pCol->token); + zName = sqlite3MPrintf(db, "%T", pToken); } } if( db->mallocFailed ){ sqlite3DbFree(db, zName); break; Index: test/trigger2.test ================================================================== --- test/trigger2.test +++ test/trigger2.test @@ -732,10 +732,22 @@ DELETE FROM v1log; UPDATE v1 SET x=x+100, y=y+200, z=z+300; SELECT * FROM v1log; } } {3 103 5 205 4 304 9 109 11 211 10 310} + +# At one point the following was causing a segfault. +do_test trigger2-9.1 { + execsql { + CREATE TABLE t3(a TEXT, b TEXT); + CREATE VIEW v3 AS SELECT t3.a FROM t3; + CREATE TRIGGER trig1 INSTEAD OF DELETE ON v3 BEGIN + SELECT 1; + END; + DELETE FROM v3 WHERE a = 1; + } +} {} } ;# ifcapable view integrity_check trigger2-9.9