/ Check-in [a19d3a73]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a problem in hash.c when replacing entries in tables configured with copyKey==0. (CVS 4375)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a19d3a73a91f2040ec35d913f11743ff4913ffb7
User & Date: danielk1977 2007-09-03 15:03:21
Context
2007-09-03
15:19
Honor the SQLITE_OPEN_ flags passed into sqlite3_open_v2(). Some test cases added but more are needed. Ticket #2616. (CVS 4376) check-in: 020a2b10 user: drh tags: trunk
15:03
Fix a problem in hash.c when replacing entries in tables configured with copyKey==0. (CVS 4375) check-in: a19d3a73 user: danielk1977 tags: trunk
13:06
Improvements to the xRandomness() method on the default windows VFS. Ticket #2615. (CVS 4374) check-in: 91b50f31 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/hash.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This is the implementation of generic hash-tables
    13     13   ** used in SQLite.
    14     14   **
    15         -** $Id: hash.c,v 1.22 2007/08/29 12:31:26 danielk1977 Exp $
           15  +** $Id: hash.c,v 1.23 2007/09/03 15:03:21 danielk1977 Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <assert.h>
    19     19   
    20     20   /* Turn bulk memory into a hash table object by initializing the
    21     21   ** fields of the Hash structure.
    22     22   **
................................................................................
   358    358     elem = findElementGivenHash(pH,pKey,nKey,h);
   359    359     if( elem ){
   360    360       void *old_data = elem->data;
   361    361       if( data==0 ){
   362    362         removeElementGivenHash(pH,elem,h);
   363    363       }else{
   364    364         elem->data = data;
          365  +      if( !pH->copyKey ){
          366  +        elem->pKey = (void *)pKey;
          367  +      }
          368  +      assert(nKey==elem->nKey);
   365    369       }
   366    370       return old_data;
   367    371     }
   368    372     if( data==0 ) return 0;
   369    373     new_elem = (HashElem*)sqlite3_malloc( sizeof(HashElem) );
   370    374     if( new_elem==0 ) return data;
   371    375     if( pH->copyKey && pKey!=0 ){

Changes to src/test8.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing the virtual table interfaces.  This code
    13     13   ** is not included in the SQLite library.  It is used for automated
    14     14   ** testing of the SQLite library.
    15     15   **
    16         -** $Id: test8.c,v 1.56 2007/09/03 11:51:50 danielk1977 Exp $
           16  +** $Id: test8.c,v 1.57 2007/09/03 15:03:21 danielk1977 Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "tcl.h"
    20     20   #include <stdlib.h>
    21     21   #include <string.h>
    22     22   
    23     23   #ifndef SQLITE_OMIT_VIRTUALTABLE
................................................................................
   448    448     if( rc==SQLITE_OK && argc==5 ){
   449    449       char *zSql;
   450    450       echo_vtab *pVtab = *(echo_vtab **)ppVtab;
   451    451       pVtab->zLogName = sqlite3MPrintf(0, "%s", argv[4]);
   452    452       zSql = sqlite3MPrintf(0, "CREATE TABLE %Q(logmsg)", pVtab->zLogName);
   453    453       rc = sqlite3_exec(db, zSql, 0, 0, 0);
   454    454       sqlite3_free(zSql);
          455  +    if( rc!=SQLITE_OK ){
          456  +      *pzErr = sqlite3StrDup(sqlite3_errmsg(db));
          457  +    }
          458  +  }
          459  +
          460  +  if( *ppVtab && rc!=SQLITE_OK ){
          461  +    echoDestructor(*ppVtab);
          462  +    *ppVtab = 0;
   455    463     }
   456    464   
   457    465     return rc;
   458    466   }
   459    467   
   460    468   /* 
   461    469   ** Echo virtual table module xConnect method.

Changes to test/vtab1.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is creating and dropping virtual tables.
    13     13   #
    14         -# $Id: vtab1.test,v 1.45 2007/08/22 02:57:17 drh Exp $
           14  +# $Id: vtab1.test,v 1.46 2007/09/03 15:03:21 danielk1977 Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   ifcapable !vtab||!schema_pragmas {
    20     20     finish_test
    21     21     return
................................................................................
   175    175   do_test vtab1-1.15 {
   176    176     catchsql {
   177    177       DROP TABLE techo;
   178    178     }
   179    179   } {1 {no such module: echo}}
   180    180   
   181    181   register_echo_module [sqlite3_connection_pointer db]
   182         -do_test vtab1-1.X {
          182  +register_echo_module [sqlite3_connection_pointer db]
          183  +
          184  +# Test an error message returned from a v-table constructor.
          185  +#
          186  +do_test vtab1-1.16 {
   183    187     execsql {
   184    188       DROP TABLE techo;
          189  +    CREATE TABLE logmsg(log);
          190  +  }
          191  +  catchsql {
          192  +    CREATE VIRTUAL TABLE techo USING echo(treal, logmsg);
          193  +  }
          194  +} {1 {table 'logmsg' already exists}}
          195  +
          196  +do_test vtab1-1.17 {
          197  +  execsql {
   185    198       DROP TABLE treal;
          199  +    DROP TABLE logmsg;
   186    200       SELECT sql FROM sqlite_master;
   187    201     }
   188    202   } {}
   189    203   
   190    204   #----------------------------------------------------------------------
   191    205   # Test cases vtab1.2.*
   192    206   #