]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Prevent a segfault described by ticket #1229. (CVS 2450)
authordrh <drh@noemail.net>
Fri, 29 Apr 2005 02:10:00 +0000 (02:10 +0000)
committerdrh <drh@noemail.net>
Fri, 29 Apr 2005 02:10:00 +0000 (02:10 +0000)
FossilOrigin-Name: 0667eae9a97059125a77bd90452d19dc17c30a12

manifest
manifest.uuid
src/select.c
src/sqliteInt.h
test/misc2.test

index f58527645244f71c3e41e2dab45f299c53515218..0e5a248e0033797fda7a998a10ab0767fc13cf43 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\shooks\sfor\sthe\sSSE\sextension.\s(CVS\s2449)
-D 2005-04-28T19:03:37
+C Prevent\sa\ssegfault\sdescribed\sby\sticket\s#1229.\s(CVS\s2450)
+D 2005-04-29T02:10:00
 F Makefile.in 5c00d0037104de2a50ac7647a5f12769795957a3
 F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -58,10 +58,10 @@ F src/parse.y 3e314b3a96b199b0501ed426f2cee3392ffce806
 F src/pragma.c 93d447670b367e7aec9191ed952fe04f6a052eb5
 F src/printf.c 3d20b21cfecadacecac3fb7274e746cb81d3d357
 F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
-F src/select.c 277cf8893db3d822905097b31dfa209198a4febe
+F src/select.c def26b6fe7752704e4201fe9dcee99dba361a7cf
 F src/shell.c 25b3217d7c64e6497225439d261a253a23efff26
 F src/sqlite.h.in 3675e3ada207e09b9d52a0463561325df4ac26b5
-F src/sqliteInt.h 3833e39dc06168d098ab48ccdb99b669f6b12fd2
+F src/sqliteInt.h 7123b9d5632d7eaab90cf595c83c89521ea1c3b6
 F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9
 F src/tclsqlite.c d56821995513b2d68fa8c4a66ec2fbdfe615d8b7
 F src/test1.c 4ad7ffe5a74fd99d4f73f6fd28ba27f403b3adba
@@ -160,7 +160,7 @@ F test/memdb.test 1860e060be810bf0775bc57408a5b7c4954bcaea
 F test/memleak.test df2b2b96e77f8ba159a332299535b1e5f18e49ac
 F test/minmax.test 9429a06f1f93acf76fcacafd17160a4392e88526
 F test/misc1.test a4a36c19f05e4c8646efe7a0d7242ba645d07379
-F test/misc2.test d51379cc670b850827cd37b7fc07c0f17736004e
+F test/misc2.test 5c699af2fede2694736a9f45aea7e2f052686e15
 F test/misc3.test 7bd937e2c62bcc6be71939faf068d506467b1e03
 F test/misc4.test edd3e3adf5b6e3b995b29843565ca58dd602f9a7
 F test/misc5.test 5158e1be2c878af42b60f99d963001e4cae309fc
@@ -279,7 +279,7 @@ F www/tclsqlite.tcl 425be741b8ae664f55cb1ef2371aab0a75109cf9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 528299b8316726dbcc5548e9aa0648c8b1bd055b
-P 6863703abcb2bf31d65792d4de9ae20aba2eadb5
-R b77b663f333cae602abc3d855b901dc7
+P 90f4cf2ad57309dbd20954fc7fd60859bc44bcf4
+R 19065ec8289228f6ac9c4c1c0322b483
 U drh
-Z a5c2a369bbf6d9dce1c373a949ecd04a
+Z 34c74af76dd24aa096c57e614d4ab655
index 33e943eeb75a82ae30eb3cdc86898b7d67359730..6ad3863efe07f6459af437adffcad6fa30f72c28 100644 (file)
@@ -1 +1 @@
-90f4cf2ad57309dbd20954fc7fd60859bc44bcf4
\ No newline at end of file
+0667eae9a97059125a77bd90452d19dc17c30a12
\ No newline at end of file
index ee15c72168463fd475f33525056bc1f48b8c07b7..f64645a8c3718f5f85b347efce8b604740260c5d 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that are called by the parser
 ** to handle SELECT statements in SQLite.
 **
-** $Id: select.c,v 1.244 2005/04/22 02:38:38 drh Exp $
+** $Id: select.c,v 1.245 2005/04/29 02:10:00 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -689,6 +689,20 @@ static const char *columnType(NameContext *pNC, Expr *pExpr){
           pNC = pNC->pNext;
         }
       }
+      if( pTab==0 ){
+        /* FIX ME:
+        ** This can occurs if you have something like "SELECT new.x;" inside
+        ** a trigger.  In other words, if you reference the special "new"
+        ** table in the result set of a select.  We do not have a good way
+        ** to find the actual table type, so call it "TEXT".  This is really
+        ** something of a bug, but I do not know how to fix it.
+        **
+        ** This code does not produce the correct answer - it just prevents
+        ** a segfault.  See ticket #1229.
+        */
+        zType = "TEXT";
+        break;
+      }
       assert( pTab );
       if( iCol<0 ) iCol = pTab->iPKey;
       assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );
index fdf4a8cdda27a3e4c618eb813a936205c3c6f63b..516455c34fae87dc58b103221519f4dbb03d678a 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** Internal interface definitions for SQLite.
 **
-** @(#) $Id: sqliteInt.h,v 1.377 2005/04/28 17:18:49 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.378 2005/04/29 02:10:00 drh Exp $
 */
 #ifndef _SQLITEINT_H_
 #define _SQLITEINT_H_
@@ -715,7 +715,8 @@ struct FKey {
 ** comparison of the two index keys.
 **
 ** If the KeyInfo.incrKey value is true and the comparison would
-** otherwise be equal, then return a result as if the second key larger.
+** otherwise be equal, then return a result as if the second key
+** were larger.
 */
 struct KeyInfo {
   u8 enc;             /* Text encoding - one of the TEXT_Utf* values */
index 3c89777229c8730283958810c3adb8318eb6f644..7cb0983503fb26e9d8eefdf2c3cc54730e9a2b75 100644 (file)
@@ -13,7 +13,7 @@
 # This file implements tests for miscellanous features that were
 # left out of other test files.
 #
-# $Id: misc2.test,v 1.21 2005/03/29 03:11:00 danielk1977 Exp $
+# $Id: misc2.test,v 1.22 2005/04/29 02:10:00 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -250,4 +250,21 @@ ifcapable tempdb {
   } [expr 5*5*5*5]
 }
 
+# Ticket #1229.  Sometimes when a "NEW.X" appears in a SELECT without
+# a FROM clause deep within a trigger, the code generator is unable to
+# trace the NEW.X back to an original table and thus figure out its
+# declared datatype.
+#
+# The SQL code below was causing a segfault.
+#
+do_test misc2-10.1 {
+  execsql {
+    CREATE TABLE t1229(x);
+    CREATE TRIGGER r1229 BEFORE INSERT ON t1229 BEGIN
+      INSERT INTO t1229 SELECT y FROM (SELECT new.x y);
+    END;
+    INSERT INTO t1229 VALUES(1);
+  }
+} {}
+
 finish_test