]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Bug fix: if PRAGMA full_column_names=ON is set and you do a query like this:
authordrh <drh@noemail.net>
Wed, 13 Feb 2002 23:22:53 +0000 (23:22 +0000)
committerdrh <drh@noemail.net>
Wed, 13 Feb 2002 23:22:53 +0000 (23:22 +0000)
"SELECT rowid,* FROM ...", then an assertion failed.  Bummer. (CVS 368)

FossilOrigin-Name: df6bf627a51358e8b14297403feab7b888c38580

VERSION
manifest
manifest.uuid
src/select.c
src/where.c
test/misc1.test
www/changes.tcl

diff --git a/VERSION b/VERSION
index 276cbf9e2858c779297bb9f73b34170302949ec4..2bf1c1ccf363acd53eaf92ef33a7f11f5f4557c2 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.3.0
+2.3.1
index d067f29ce886ae46afbcb82ab0e87c62e9d703ad..6505fbd87e5fffb5a71a486cbca66c7ce72661c3 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,9 +1,9 @@
-C Version\s2.3.0\s(CVS\s447)
-D 2002-02-03T19:30:00
+C Bug\sfix:\sif\sPRAGMA\sfull_column_names=ON\sis\sset\sand\syou\sdo\sa\squery\slike\sthis:\n"SELECT\srowid,*\sFROM\s...",\sthen\san\sassertion\sfailed.\s\sBummer.\s(CVS\s368)
+D 2002-02-13T23:22:53
 F Makefile.in 9fa4277413bf1d9cf91365f07d4108d7d87ed2af
 F Makefile.template 3372d45f8853afdb70bd30cc6fb50a3cd9069834
 F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
-F VERSION 34f7c904a063d2d3791c38521e40ae1648cd2e7e
+F VERSION ed0510bca23ecd087a7c96ee72838b17e2b5d355
 F aclocal.m4 11faa843caa38fd451bc6aeb43e248d1723a269d
 F config.guess f38b1e93d1e0fa6f5a6913e9e7b12774b9232588
 F config.log 6a73d03433669b10a3f0c221198c3f26b9413914
@@ -36,7 +36,7 @@ F src/pager.h b28f004e2f5541dc60cc32db01bf80cf4d056283
 F src/parse.y 734ba1e0dce9882345e65de5a14d9fe02fb757c2
 F src/printf.c 300a90554345751f26e1fc0c0333b90a66110a1d
 F src/random.c f6b36bec5ebd3edb3440224bf5bf811fe4ac9a1b
-F src/select.c b32d3f38616f93f092b98c1c3e53c4dfe57dc359
+F src/select.c 4b4a25c57cc341565dad625c3100c71ce993f85f
 F src/shell.c c102dfe388c7618a668c944ff157c49cb48f28e3
 F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
 F src/sqlite.h.in f57074c84a2c112a5093ba7a9d9636aa9cacc87c
@@ -51,7 +51,7 @@ F src/update.c 95459f94a061860bf8e5716b3426a5ba85c79103
 F src/util.c 8f8973dd55a6ec63be9632fc5de86965c99d6327
 F src/vdbe.c 94704a5733db95b78cc902208c5e8e26a784e7f8
 F src/vdbe.h 3d49d22ba9ad14ea0e380bc582ff57347eaddb59
-F src/where.c 2dda39367f193194e4c7d2e0dcab31527d9d8aba
+F src/where.c fd4d817dedd2a29e7f118cac3517c4c9d9ff199c
 F test/all.test 2a51e5395ac7c2c539689b123b9782a05e3837fe
 F test/bigrow.test 8ab252dba108f12ad64e337b0f2ff31a807ac578
 F test/btree.test 6ab4dc5f595905a276ef588fad3c9236dc07a47b
@@ -72,7 +72,7 @@ F test/limit.test a930f3eba2a7691c8397ccab33710b931589566a
 F test/lock.test 19593689260c419efe7ced55b1418653a4b7bcd1
 F test/main.test 1626345b5f630c5398eede500d9354813b76b0fd
 F test/malloc.test 70fdd0812e2a57eb746aaf015350f58bb8eee0b1
-F test/misc1.test 50a5ca3481fc1f3cd6b978bcd6ed04c06f26a1e6
+F test/misc1.test 5ed0df7274912cbce56f1afa19c9510510b0a7f9
 F test/notnull.test b1f3e42fc475b0b5827b27b2e9b562081995ff30
 F test/pager.test b0c0d00cd5dce0ce21f16926956b195c0ab5044c
 F test/printf.test 3cb415073754cb8ff076f26173143c3cd293a9da
@@ -107,7 +107,7 @@ F www/arch.fig d5f9752a4dbf242e9cfffffd3f5762b6c63b3bcf
 F www/arch.png 82ef36db1143828a7abc88b1e308a5f55d4336f4
 F www/arch.tcl 72a0c80e9054cc7025a50928d28d9c75c02c2b8b
 F www/c_interface.tcl 82a026b1681757f13b3f62e035f3a31407c1d353
-F www/changes.tcl 445dd536ade7085f4ffe820805847451d01c87bb
+F www/changes.tcl f8f4837a26f49cff1c65bfd69a47f04ec705c1de
 F www/conflict.tcl 81dd21f9a679e60aae049e9dd8ab53d59570cda2
 F www/crosscompile.tcl 3622ebbe518927a3854a12de51344673eb2dd060
 F www/download.tcl a6d75b8b117cd33dcb090bef7e80d7556d28ebe0
@@ -122,7 +122,7 @@ F www/speed.tcl 83457b2bf6bb430900bd48ca3dd98264d9a916a5
 F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
 F www/tclsqlite.tcl 829b393d1ab187fd7a5e978631b3429318885c49
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P 0090c279d83ee355fbac8a484401d29bfa50b0dc
-R fc7dddb7f2cee20f2fcdc9937b75f980
+P 4c7dfd93530a2a3e50e78235f4e691a5fec109fe
+R 2dd44e4df5f1749abcfa5e153ebc4db9
 U drh
-Z b9766f8933c95b0873782841a8d26738
+Z 5a2ba11ead7f86f0ca4171fe5af6dcae
index c957f2942c1b2d0fe3031b39545d1ab7941194fc..2b77d691711ef43da890f2629c3b213ef9f9ba32 100644 (file)
@@ -1 +1 @@
-4c7dfd93530a2a3e50e78235f4e691a5fec109fe
\ No newline at end of file
+df6bf627a51358e8b14297403feab7b888c38580
\ No newline at end of file
index b2cf364f6fdda26f38e499953e511681be4c2306..84eb2c35a09dc499285b42a8d8abe4c999837c18 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.57 2002/02/03 19:06:03 drh Exp $
+** $Id: select.c,v 1.58 2002/02/13 23:22:54 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -256,23 +256,24 @@ void generateColumnNames(Parse *pParse, IdList *pTabList, ExprList *pEList){
       sqliteVdbeCompressSpace(v, addr);
     }else if( p->op==TK_COLUMN && pTabList ){
       Table *pTab = pTabList->a[p->iTable - pParse->nTab].pTab;
+      char *zCol;
       int iCol = p->iColumn;
       if( iCol<0 ) iCol = pTab->iPKey;
-      assert( iCol>=0 && iCol<pTab->nCol );
+      assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );
+      zCol = iCol<0 ? "_ROWID_" : pTab->aCol[iCol].zName;
       if( pTabList->nId>1 || showFullNames ){
         char *zName = 0;
         char *zTab;
  
         zTab = pTabList->a[p->iTable - pParse->nTab].zAlias;
         if( showFullNames || zTab==0 ) zTab = pTab->zName;
-        sqliteSetString(&zName, zTab, ".", pTab->aCol[iCol].zName, 0);
+        sqliteSetString(&zName, zTab, ".", zCol, 0);
         sqliteVdbeAddOp(v, OP_ColumnName, i, 0);
         sqliteVdbeChangeP3(v, -1, zName, strlen(zName));
         sqliteFree(zName);
       }else{
-        char *zName = pTab->aCol[iCol].zName;
         sqliteVdbeAddOp(v, OP_ColumnName, i, 0);
-        sqliteVdbeChangeP3(v, -1, zName, P3_STATIC);
+        sqliteVdbeChangeP3(v, -1, zCol, P3_STATIC);
       }
     }else if( p->span.z && p->span.z[0] ){
       int addr = sqliteVdbeAddOp(v,OP_ColumnName, i, 0);
index 022cfbb7b51a5fad2232675398eca3642581e197..dd112023914988805b5faee914da18c085ad5fc3 100644 (file)
@@ -13,7 +13,7 @@
 ** the WHERE clause of SQL statements.  Also found here are subroutines
 ** to generate VDBE code to evaluate expressions.
 **
-** $Id: where.c,v 1.33 2002/01/28 15:53:05 drh Exp $
+** $Id: where.c,v 1.34 2002/02/13 23:22:54 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -439,12 +439,14 @@ WhereInfo *sqliteWhereBegin(
       cont = pLevel->cont = brk;
       sqliteVdbeAddOp(v, OP_MustBeInt, 0, brk);
       if( i==pTabList->nId-1 && pushKey ){
-        /* Note: The OP_Dup below will cause the key to be left on the
-        ** stack if the key does not exists and the OP_NotExists jump is
+        /* Note: The OP_Dup below will cause the recno to be left on the
+        ** stack if the record does not exists and the OP_NotExists jump is
         ** taken.  This violates a general rule of the VDBE that you should
         ** never leave values on the stack in order to avoid a stack overflow.
         ** But in this case, the OP_Dup will never happen inside of a loop,
-        ** so it is safe to leave it on the stack.
+        ** because the pushKey flag is only true for UPDATE and DELETE, not
+        ** for SELECT, and nested loops only occur on a SELECT.
+        ** So it is safe to leave the recno on the stack.
         */
         haveKey = 1;
         sqliteVdbeAddOp(v, OP_Dup, 0, 0);
index cc2ec97c0833b357ce1c4973dfc640bcd351d4d2..a34e354d7a9faf4d7272c56642b26e558687a4ae 100644 (file)
@@ -13,7 +13,7 @@
 # This file implements tests for miscellanous features that were
 # left out of other test files.
 #
-# $Id: misc1.test,v 1.1 2001/09/18 22:17:45 drh Exp $
+# $Id: misc1.test,v 1.2 2002/02/13 23:22:54 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -101,4 +101,17 @@ do_test misc1-2.2 {
            GROUP BY two, four ORDER BY sum(one) desc}
 } {8 two no 6 one yes 4 two yes 3 thr yes}
 
+# Here's a test for a bug found by Joel Lucsy.  The code below
+# was causing an assertion failure.
+#
+do_test misc1-3.1 {
+  set r [execsql {
+    CREATE TABLE t1(a);
+    INSERT INTO t1 VALUES('hi');
+    PRAGMA full_column_names=on;
+    SELECT rowid, * FROM t1;
+  }]
+  lindex $r 1
+} {hi}
+
 finish_test
index 732fe6cc78bf77230e2ca4eb9b30e9e95fe8af85..68272e740c649dea25eda1b5f7bf6da3c5556d6a 100644 (file)
@@ -17,6 +17,12 @@ proc chng {date desc} {
   puts "<DD><P><UL>$desc</UL></P></DD>"
 }
 
+chng {2002 Feb 13 (2.3.1)} {
+<li>Bug fix: An assertion was failing if "PRAGMA full_column_names=ON;" was
+    set and you did a query that used a rowid, like this:  
+    "SELECT rowid, * FROM ...".</li>
+}
+
 chng {2002 Jan 30 (2.3.0)} {
 <li>Fix a serious bug in the INSERT command which was causing data to go
     into the wrong columns if the data source was a SELECT and the INSERT