]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Better error message when coalesce() has too few arguments. Ticket #3623. (CVS 6222)
authordrh <drh@noemail.net>
Sat, 31 Jan 2009 22:28:48 +0000 (22:28 +0000)
committerdrh <drh@noemail.net>
Sat, 31 Jan 2009 22:28:48 +0000 (22:28 +0000)
FossilOrigin-Name: 9cd43c82a3c123829806aa7bf14efdd29f4424d8

manifest
manifest.uuid
src/callback.c
test/func.test

index ef0ec39e676a2984952f819c91b46a6c5369ddb2..9a561d8843d1e57b3951daafa69a90d07821be6e 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Avoid\sa\ssegfault\swhen\srunning\svacuum\son\san\sin-memory\sdatabase.\sTicket\s#3620.\s(CVS\s6221)
-D 2009-01-31T14:54:07
+C Better\serror\smessage\swhen\scoalesce()\shas\stoo\sfew\sarguments.\s\sTicket\s#3623.\s(CVS\s6222)
+D 2009-01-31T22:28:49
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 3871d308188cefcb7c5ab20da4c7b6aad023bc52
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -107,7 +107,7 @@ F src/btree.c dfbbfc396fdd8cbc29754864a97c4df484b78870
 F src/btree.h 07359623fa24748709dd61212a32364a6adc6b56
 F src/btreeInt.h 44bcbfe387ba99a3a9f2527bd12fa1bb8bc574b3
 F src/build.c c8bf5dcef4d5889bc57eecdb8b3dba178e5e06a8
-F src/callback.c bee8949d619b1b7b1e4dfac8a19c5116ae1dd12a
+F src/callback.c 5f10bca853e59a2c272bbfd5b720303f8b69e520
 F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
 F src/date.c 870770dde3fb56772ab247dfb6a6eda44d16cfbc
 F src/delete.c 6249005bdd8f85db6ec5f31ddb5c07de023693cc
@@ -371,7 +371,7 @@ F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851
 F test/fts3expr.test 000f05df771e203187ceac49ad21c303c720b783
 F test/fts3expr2.test 8501de895a4c0631e7226c9bac055cd49c9f6646
 F test/fts3near.test dc196dd17b4606f440c580d45b3d23aa975fd077
-F test/func.test a50f0a4b69ac251debe1dce3ba29da7476dc8c52
+F test/func.test e361349bcae8c51976f1826fd7d6355e483cf9b8
 F test/fuzz.test 8bad3b9b09bad47c50f3433f9598707a70247ce1
 F test/fuzz2.test ea38692ce2da99ad79fe0be5eb1a452c1c4d37bb
 F test/fuzz3.test aec64345184d1662bd30e6a17851ff659d596dc5
@@ -693,7 +693,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 86be908c5e77ba2b9ac98e394fa987b443d790f8
-R 338358bbac17f79c52e09eabfb9a08f6
-U danielk1977
-Z 69820336f312727069bd2180b04a2b93
+P 407830c6839a81fa0a1010940740df3011713a88
+R c3945ec4bae662615ea149b764aed5c3
+U drh
+Z 5e40bffc92d9593bf4b2389c15a0c92c
index 5e1149aa8cce9979e43ea5ec7e6e2863582f5db4..ac5d2e560988e640ca08231de144b8ae4a1d16d3 100644 (file)
@@ -1 +1 @@
-407830c6839a81fa0a1010940740df3011713a88
\ No newline at end of file
+9cd43c82a3c123829806aa7bf14efdd29f4424d8
\ No newline at end of file
index 7204d170d13108e6057be6e16a5089abe2aacdcc..0c1e657f9352e71533c440370251f45751f36663 100644 (file)
@@ -13,7 +13,7 @@
 ** This file contains functions used to access the internal hash tables
 ** of user defined functions and collation sequences.
 **
-** $Id: callback.c,v 1.34 2008/12/10 21:19:57 drh Exp $
+** $Id: callback.c,v 1.35 2009/01/31 22:28:49 drh Exp $
 */
 
 #include "sqliteInt.h"
@@ -228,8 +228,9 @@ CollSeq *sqlite3FindCollSeq(
 ** that uses encoding enc. The value returned indicates how well the
 ** request is matched. A higher value indicates a better match.
 **
-** The returned value is always between 1 and 6, as follows:
+** The returned value is always between 0 and 6, as follows:
 **
+** 0: Not a match, or if nArg<0 and the function is has no implementation.
 ** 1: A variable arguments function that prefers UTF-8 when a UTF-16
 **    encoding is requested, or vice versa.
 ** 2: A variable arguments function that uses UTF-16BE when UTF-16LE is
@@ -244,7 +245,9 @@ CollSeq *sqlite3FindCollSeq(
 */
 static int matchQuality(FuncDef *p, int nArg, u8 enc){
   int match = 0;
-  if( p->nArg==-1 || p->nArg==nArg || nArg==-1 ){
+  if( p->nArg==-1 || p->nArg==nArg 
+   || (nArg==-1 && (p->xFunc!=0 || p->xStep!=0))
+  ){
     match = 1;
     if( p->nArg==nArg || nArg==-1 ){
       match = 4;
index 3aaf82bf3df98ff6a29fa513b022231136676441..755af1d1d8acaced9075f9e80201b60b3358f25c 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing built-in functions.
 #
-# $Id: func.test,v 1.87 2008/10/12 00:27:54 shane Exp $
+# $Id: func.test,v 1.88 2009/01/31 22:28:49 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -1031,4 +1031,14 @@ do_test func-26.6 {
   "
 } {1 {no such function: nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789a}}
 
+do_test func-27.1 {
+  catchsql {SELECT coalesce()}
+} {1 {wrong number of arguments to function coalesce()}}
+do_test func-27.2 {
+  catchsql {SELECT coalesce(1)}
+} {1 {wrong number of arguments to function coalesce()}}
+do_test func-27.3 {
+  catchsql {SELECT coalesce(1,2)}
+} {0 1}
+
 finish_test