/ Check-in [88a09dbb]
Login

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

Overview
Comment:Fix a segfault that can be caused by an INSTEAD OF trigger on a view that includes an expression of the form "table.column" in the select list. (CVS 5940)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 88a09dbb4b54be4010aae767157a1e2002237909
User & Date: danielk1977 2008-11-21 16:22:18
Context
2008-11-21
16:58
Fix the OOM handling for explain statements so that it is the same as for regular statements if the OOM error occurs from within a call to sqlite3_column_text() or text16(). (CVS 5941) check-in: 891b14e1 user: danielk1977 tags: trunk
16:22
Fix a segfault that can be caused by an INSTEAD OF trigger on a view that includes an expression of the form "table.column" in the select list. (CVS 5940) check-in: 88a09dbb user: danielk1977 tags: trunk
09:43
Fix an assert() failure that can occur after an OOM error. (CVS 5939) check-in: 4c765758 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/select.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle SELECT statements in SQLite.
    14     14   **
    15         -** $Id: select.c,v 1.487 2008/11/21 09:43:20 danielk1977 Exp $
           15  +** $Id: select.c,v 1.488 2008/11/21 16:22:18 danielk1977 Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   
    20     20   /*
    21     21   ** Delete all the content of a Select structure but do not deallocate
    22     22   ** the select structure itself.
................................................................................
  1177   1177           /* For columns use the column name name */
  1178   1178           int iCol = pCol->iColumn;
  1179   1179           if( iCol<0 ) iCol = pTab->iPKey;
  1180   1180           zName = sqlite3MPrintf(db, "%s",
  1181   1181                    iCol>=0 ? pTab->aCol[iCol].zName : "rowid");
  1182   1182         }else{
  1183   1183           /* Use the original text of the column expression as its name */
  1184         -        zName = sqlite3MPrintf(db, "%T", &pCol->span);
         1184  +        Token *pToken = (pCol->span.z?&pCol->span:&pCol->token);
         1185  +        zName = sqlite3MPrintf(db, "%T", pToken);
  1185   1186         }
  1186   1187       }
  1187   1188       if( db->mallocFailed ){
  1188   1189         sqlite3DbFree(db, zName);
  1189   1190         break;
  1190   1191       }
  1191   1192       sqlite3Dequote(zName);

Changes to test/trigger2.test.

   730    730         INSERT INTO v1log VALUES(OLD.x,NEW.x,OLD.y,NEW.y,OLD.z,NEW.z);
   731    731       END;
   732    732       DELETE FROM v1log;
   733    733       UPDATE v1 SET x=x+100, y=y+200, z=z+300;
   734    734       SELECT * FROM v1log;
   735    735     }
   736    736   } {3 103 5 205 4 304 9 109 11 211 10 310}
          737  +
          738  +# At one point the following was causing a segfault.
          739  +do_test trigger2-9.1 {
          740  +  execsql {
          741  +    CREATE TABLE t3(a TEXT, b TEXT);
          742  +    CREATE VIEW v3 AS SELECT t3.a FROM t3;
          743  +    CREATE TRIGGER trig1 INSTEAD OF DELETE ON v3 BEGIN
          744  +      SELECT 1;
          745  +    END;
          746  +    DELETE FROM v3 WHERE a = 1;
          747  +  }
          748  +} {}
   737    749   
   738    750   } ;# ifcapable view
   739    751   
   740    752   integrity_check trigger2-9.9
   741    753   
   742    754   finish_test