]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
The sqlite_get_table() function now returns an error if you pass in two
authordrh <drh@noemail.net>
Sat, 23 Mar 2002 00:52:01 +0000 (00:52 +0000)
committerdrh <drh@noemail.net>
Sat, 23 Mar 2002 00:52:01 +0000 (00:52 +0000)
or more SELECT statements that return different numbers of columns. (CVS 436)

FossilOrigin-Name: e2558c34034cf49524084ec819df58934a8af983

manifest
manifest.uuid
src/table.c
test/tableapi.test
www/changes.tcl

index 207ff15b48dee7803747e315cc5bcfa812fc53d7..5f41b14b633f2baaaa4e361e2e9412dfaac761a8 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sbug\sin\ssubquery\sgeneration\swhen\sthe\ssubquery\sis\sa\scompound\sselect.\nAlso\sadded\snew\stests\sto\scover\sthis\scase.\s(CVS\s435)
-D 2002-03-23T00:31:29
+C The\ssqlite_get_table()\sfunction\snow\sreturns\san\serror\sif\syou\spass\sin\stwo\nor\smore\sSELECT\sstatements\sthat\sreturn\sdifferent\snumbers\sof\scolumns.\s(CVS\s436)
+D 2002-03-23T00:52:01
 F Makefile.in 50f1b3351df109b5774771350d8c1b8d3640130d
 F Makefile.template 89e373b2dad0321df00400fa968dc14b61a03296
 F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
@@ -42,7 +42,7 @@ F src/shell.c b3454229599246b944cdb5b95753af3fca5d8bb0
 F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
 F src/sqlite.h.in 1dae50411aee9439860d7fbe315183c582d27197
 F src/sqliteInt.h 73e7d0f39a3c11d395fc422986959261bd193eba
-F src/table.c 203a09d5d0009eeeb1f670370d52b4ce163a3b52
+F src/table.c eed2098c9b577aa17f8abe89313a9c4413f57d63
 F src/tclsqlite.c df847b71b28277f1cfa1ee1e3e51452ffe5a9a26
 F src/test1.c d46ab7a82a9c16a3b1ee363cb4c0f98c5ff65743
 F src/test2.c d410dbd8a90faa466c3ab694fa0aa57f5a773aa6
@@ -92,7 +92,7 @@ F test/select6.test 5b9b52e84c1f44fd3a4eeb75e78deceb085b78b0
 F test/sort.test 3b996ce7ca385f9cd559944ac0f4027a23aa546b
 F test/subselect.test 335d3dad8d585726c447dfee8d9c4f7383c76b78
 F test/table.test 17b0b6eafa3faaee5545b7a94e6c1ff73f0880f3
-F test/tableapi.test 51d0c209aa6b1158cb952ec917c656d4ce66e9e4
+F test/tableapi.test 3c80421a889e1d106df16e5800fa787f0d2914a6
 F test/tclsqlite.test ca8dd89b02ab68bd4540163c24551756a69f6783
 F test/temptable.test 0e9934283259a5e637eec756a7eefd6964c0f79b
 F test/tester.tcl dc1b56bd628b487e4d75bfd1e7480b5ed8810ac6
@@ -115,7 +115,7 @@ F www/arch.fig d5f9752a4dbf242e9cfffffd3f5762b6c63b3bcf
 F www/arch.png 82ef36db1143828a7abc88b1e308a5f55d4336f4
 F www/arch.tcl 72a0c80e9054cc7025a50928d28d9c75c02c2b8b
 F www/c_interface.tcl 567cda531aac9d68a61ef02e26c6b202bd856db2
-F www/changes.tcl 65c1e63566ddbe09ef016c4c78ed21b6537af512
+F www/changes.tcl 7137167dc4193b4658096559d94ce14fde33ddec
 F www/conflict.tcl 81dd21f9a679e60aae049e9dd8ab53d59570cda2
 F www/crosscompile.tcl 3622ebbe518927a3854a12de51344673eb2dd060
 F www/download.tcl a6d75b8b117cd33dcb090bef7e80d7556d28ebe0
@@ -130,7 +130,7 @@ F www/speed.tcl da8afcc1d3ccc5696cfb388a68982bc3d9f7f00f
 F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
 F www/tclsqlite.tcl 829b393d1ab187fd7a5e978631b3429318885c49
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P 49d032325553fa1dd7f31b852753cc6c9226d8f7
-R afbadc87908df7153445a9059806e384
+P aaf7fd4cef04d3d70a0444aad1b606bfc663c3e8
+R b3affb1ebed689441f43f9512795f044
 U drh
-Z 20aa27678bc9a0889ed47e36fd4764d7
+Z a9859b001a58df50bd87dfcc98d0ee86
index 2958797de27b41f442b86bfaa14c5de50f6c9900..bbc97bfb2abaf6068971a1f17982636c858185ac 100644 (file)
@@ -1 +1 @@
-aaf7fd4cef04d3d70a0444aad1b606bfc663c3e8
\ No newline at end of file
+e2558c34034cf49524084ec819df58934a8af983
\ No newline at end of file
index cc01f7c2be88b66fbbf9b188fadff345c7b9a822..eb3118fcc3611d7b92b50f6416e46bb794e7c405 100644 (file)
@@ -18,7 +18,7 @@
 */
 #include <stdlib.h>
 #include <string.h>
-#include "sqlite.h"
+#include "sqliteInt.h"
 
 /*
 ** This structure is used to pass data from sqlite_get_table() through
@@ -26,6 +26,7 @@
 */
 typedef struct TabResult {
   char **azResult;
+  char *zErrMsg;
   int nResult;
   int nAlloc;
   int nRow;
@@ -82,6 +83,11 @@ static int sqlite_get_table_cb(void *pArg, int nCol, char **argv, char **colv){
       }
       p->azResult[p->nData++] = z;
     }
+  }else if( p->nColumn!=nCol ){
+    sqliteSetString(&p->zErrMsg,
+       "sqlite_get_table() called with two or more incompatible queries", 0);
+    p->rc = SQLITE_ERROR;
+    return 1;
   }
 
   /* Copy over the row data
@@ -129,6 +135,7 @@ int sqlite_get_table(
   *pazResult = 0;
   if( pnColumn ) *pnColumn = 0;
   if( pnRow ) *pnRow = 0;
+  res.zErrMsg = 0;
   res.nResult = 0;
   res.nRow = 0;
   res.nColumn = 0;
@@ -146,8 +153,18 @@ int sqlite_get_table(
   }
   if( rc==SQLITE_ABORT ){
     sqlite_free_table(&res.azResult[1]);
+    if( res.zErrMsg ){
+      if( pzErrMsg ){
+        free(*pzErrMsg);
+        *pzErrMsg = res.zErrMsg;
+        sqliteStrRealloc(pzErrMsg);
+      }else{
+        sqliteFree(res.zErrMsg);
+      }
+    }
     return res.rc;
   }
+  sqliteFree(res.zErrMsg);
   if( rc!=SQLITE_OK ){
     sqlite_free_table(&res.azResult[1]);
     return rc;
index 5681f6159eb5d0ed55b7f3d3db2c99d552786fe7..da93ca041104751e94f072c96c4318e874930b2a 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this file is testing the sqlite_exec_printf() and
 # sqlite_get_table_printf() APIs.
 #
-# $Id: tableapi.test,v 1.4 2001/10/20 12:30:12 drh Exp $
+# $Id: tableapi.test,v 1.5 2002/03/23 00:52:01 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -144,6 +144,15 @@ do_test tableapi-3.7 {
   } {}
 } {0 0 2 a b}
 
+do_test tableapi-4.1 {
+  set rc [catch {
+    sqlite_get_table_printf $::dbx {
+      SELECT * FROM xyz;  SELECT * FROM sqlite_master
+    } {}
+  } msg]
+  concat $rc $msg
+} {0 1 {sqlite_get_table() called with two or more incompatible queries}}
+
 do_test tableapi-99.0 {
   sqlite_close $::dbx
 } {}
index 9947a844ba440efb29814b73452492fd138c4a1a..e4f57d62da97e597b6f005e722e0016cf5e7c0ac 100644 (file)
@@ -20,6 +20,8 @@ proc chng {date desc} {
 chng {2002 Mar 122 (2.4.3)} {
 <li>Fix a bug in SELECT that occurs when a compound SELECT is used as a
     subquery in the FROM of a SELECT.</li>
+<li>The <b>sqlite_get_table()</b> function now returns an error if you
+    give it two or more SELECTs that return different numbers of columns.</li>
 }
 
 chng {2002 Mar 14 (2.4.2)} {