From cd2543b6ae6a3ac7dff3232624c93a073824bf06 Mon Sep 17 00:00:00 2001 From: danielk1977 Date: Mon, 3 Sep 2007 15:03:20 +0000 Subject: [PATCH] Fix a problem in hash.c when replacing entries in tables configured with copyKey==0. (CVS 4375) FossilOrigin-Name: a19d3a73a91f2040ec35d913f11743ff4913ffb7 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/hash.c | 6 +++++- src/test8.c | 10 +++++++++- test/vtab1.test | 18 ++++++++++++++++-- 5 files changed, 40 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 12598c2fc6..68cc015425 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improvements\sto\sthe\sxRandomness()\smethod\son\sthe\sdefault\swindows\sVFS.\nTicket\s#2615.\s(CVS\s4374) -D 2007-09-03T13:06:12 +C Fix\sa\sproblem\sin\shash.c\swhen\sreplacing\sentries\sin\stables\sconfigured\swith\scopyKey==0.\s(CVS\s4375) +D 2007-09-03T15:03:21 F Makefile.in bfcc303429a5d9dcd552d807ee016c77427418c3 F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -92,7 +92,7 @@ F src/delete.c 849846d06d29851dde0d9f424a5de5817eb140d1 F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b F src/expr.c 7853a8161ec0b0fce62fc8da921db557899f1ec1 F src/func.c 9d88141c4cffb3a04719e5a0fda65cde34bfa1e5 -F src/hash.c 8fe2fa52bd17869c87748e42cff5b1e7fbf90822 +F src/hash.c 06c69a3a038b713c43353c79023372bcfe7f5180 F src/hash.h 3ad3da76bfb954978d227bf495568b0e6da2c19e F src/insert.c b11e5ca0d68bf2a7a56f47a052a0ee67dd4e2f89 F src/journal.c 63f8a40827e871997272eb2598f5cd9e66aa0947 @@ -143,7 +143,7 @@ F src/test4.c c2c0f5dc907f1346f5d4b65eb5799f11eb9e4071 F src/test5.c 3a6a5717a149d7ca2e6d14f5be72cf7555d54dc4 F src/test6.c 0513982dfef4da2a4154b538d2bf538b84ca21d3 F src/test7.c a9d509d0e9ad214b4772696f49f6e61be26213d1 -F src/test8.c 146cb2c2e7e9bac0e30e4890e7880ffe3e223a68 +F src/test8.c f113aa3723a52113d0fa7c28155ecd37e7e04077 F src/test9.c b46c8fe02ac7cca1a7316436d8d38d50c66f4b2f F src/test_async.c 8b6aa6a5701bf3cf52708db178379ee608b44b0c F src/test_autoext.c 855157d97aa28cf84233847548bfacda21807436 @@ -470,7 +470,7 @@ F test/vacuum.test cf839fc3ff24d601057319bbb5c700ce9c8e0fb0 F test/vacuum2.test e198d81a1cbc3f3f6b8aeee27cadfffea8995d42 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102 F test/view.test 852bd4101e6d171c46ad682eb5c5faf662b2eba4 -F test/vtab1.test 607cddf5b425ff3076b8caacc6d6b4422f66ffab +F test/vtab1.test 2f0afae624babc671af2052e88e98b4ac4aafd1e F test/vtab2.test 94bb3bf691ac10e34cf7dad46b1cf94b861d513c F test/vtab3.test f38d6d7d19f08bffdadce4d5b8cba078f8118587 F test/vtab4.test a9d7104d41a787754a734740d7aa61c807a69f87 @@ -568,7 +568,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P e89d4131a1b55da1a7f226d7f7b416f02f5e2c6e -R 70eed1b737d2685751d3043c11b74d10 -U drh -Z 3dfc552072668685c58ab6fae3991bd7 +P 91b50f31e35652a40d51f5d9bf22efce36d515e4 +R 1f20fef17ef49080f07da6476975a4c8 +U danielk1977 +Z a985adb5f326fdf3ef20c1c9a11c8b46 diff --git a/manifest.uuid b/manifest.uuid index 1297970574..3c33bb48af 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -91b50f31e35652a40d51f5d9bf22efce36d515e4 \ No newline at end of file +a19d3a73a91f2040ec35d913f11743ff4913ffb7 \ No newline at end of file diff --git a/src/hash.c b/src/hash.c index e917197d6a..d01ab92f72 100644 --- a/src/hash.c +++ b/src/hash.c @@ -12,7 +12,7 @@ ** This is the implementation of generic hash-tables ** used in SQLite. ** -** $Id: hash.c,v 1.22 2007/08/29 12:31:26 danielk1977 Exp $ +** $Id: hash.c,v 1.23 2007/09/03 15:03:21 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -362,6 +362,10 @@ void *sqlite3HashInsert(Hash *pH, const void *pKey, int nKey, void *data){ removeElementGivenHash(pH,elem,h); }else{ elem->data = data; + if( !pH->copyKey ){ + elem->pKey = (void *)pKey; + } + assert(nKey==elem->nKey); } return old_data; } diff --git a/src/test8.c b/src/test8.c index d95612269a..1a6baea59e 100644 --- a/src/test8.c +++ b/src/test8.c @@ -13,7 +13,7 @@ ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test8.c,v 1.56 2007/09/03 11:51:50 danielk1977 Exp $ +** $Id: test8.c,v 1.57 2007/09/03 15:03:21 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -452,6 +452,14 @@ static int echoCreate( zSql = sqlite3MPrintf(0, "CREATE TABLE %Q(logmsg)", pVtab->zLogName); rc = sqlite3_exec(db, zSql, 0, 0, 0); sqlite3_free(zSql); + if( rc!=SQLITE_OK ){ + *pzErr = sqlite3StrDup(sqlite3_errmsg(db)); + } + } + + if( *ppVtab && rc!=SQLITE_OK ){ + echoDestructor(*ppVtab); + *ppVtab = 0; } return rc; diff --git a/test/vtab1.test b/test/vtab1.test index 6ee3634aa1..b86ca4aa41 100644 --- a/test/vtab1.test +++ b/test/vtab1.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is creating and dropping virtual tables. # -# $Id: vtab1.test,v 1.45 2007/08/22 02:57:17 drh Exp $ +# $Id: vtab1.test,v 1.46 2007/09/03 15:03:21 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -179,10 +179,24 @@ do_test vtab1-1.15 { } {1 {no such module: echo}} register_echo_module [sqlite3_connection_pointer db] -do_test vtab1-1.X { +register_echo_module [sqlite3_connection_pointer db] + +# Test an error message returned from a v-table constructor. +# +do_test vtab1-1.16 { execsql { DROP TABLE techo; + CREATE TABLE logmsg(log); + } + catchsql { + CREATE VIRTUAL TABLE techo USING echo(treal, logmsg); + } +} {1 {table 'logmsg' already exists}} + +do_test vtab1-1.17 { + execsql { DROP TABLE treal; + DROP TABLE logmsg; SELECT sql FROM sqlite_master; } } {}