/ 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 Unified Diffs Show Whitespace Changes Patch

Changes to src/hash.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
358
359
360
361
362
363
364




365
366
367
368
369
370
371
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** 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 $
*/
#include "sqliteInt.h"
#include <assert.h>

/* Turn bulk memory into a hash table object by initializing the
** fields of the Hash structure.
**
................................................................................
  elem = findElementGivenHash(pH,pKey,nKey,h);
  if( elem ){
    void *old_data = elem->data;
    if( data==0 ){
      removeElementGivenHash(pH,elem,h);
    }else{
      elem->data = data;




    }
    return old_data;
  }
  if( data==0 ) return 0;
  new_elem = (HashElem*)sqlite3_malloc( sizeof(HashElem) );
  if( new_elem==0 ) return data;
  if( pH->copyKey && pKey!=0 ){







|







 







>
>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This is the implementation of generic hash-tables
** used in SQLite.
**
** $Id: hash.c,v 1.23 2007/09/03 15:03:21 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <assert.h>

/* Turn bulk memory into a hash table object by initializing the
** fields of the Hash structure.
**
................................................................................
  elem = findElementGivenHash(pH,pKey,nKey,h);
  if( elem ){
    void *old_data = elem->data;
    if( data==0 ){
      removeElementGivenHash(pH,elem,h);
    }else{
      elem->data = data;
      if( !pH->copyKey ){
        elem->pKey = (void *)pKey;
      }
      assert(nKey==elem->nKey);
    }
    return old_data;
  }
  if( data==0 ) return 0;
  new_elem = (HashElem*)sqlite3_malloc( sizeof(HashElem) );
  if( new_elem==0 ) return data;
  if( pH->copyKey && pKey!=0 ){

Changes to src/test8.c.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
448
449
450
451
452
453
454








455
456
457
458
459
460
461
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing the virtual table interfaces.  This code
** 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 $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include <stdlib.h>
#include <string.h>

#ifndef SQLITE_OMIT_VIRTUALTABLE
................................................................................
  if( rc==SQLITE_OK && argc==5 ){
    char *zSql;
    echo_vtab *pVtab = *(echo_vtab **)ppVtab;
    pVtab->zLogName = sqlite3MPrintf(0, "%s", argv[4]);
    zSql = sqlite3MPrintf(0, "CREATE TABLE %Q(logmsg)", pVtab->zLogName);
    rc = sqlite3_exec(db, zSql, 0, 0, 0);
    sqlite3_free(zSql);








  }

  return rc;
}

/* 
** Echo virtual table module xConnect method.







|







 







>
>
>
>
>
>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing the virtual table interfaces.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test8.c,v 1.57 2007/09/03 15:03:21 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include <stdlib.h>
#include <string.h>

#ifndef SQLITE_OMIT_VIRTUALTABLE
................................................................................
  if( rc==SQLITE_OK && argc==5 ){
    char *zSql;
    echo_vtab *pVtab = *(echo_vtab **)ppVtab;
    pVtab->zLogName = sqlite3MPrintf(0, "%s", argv[4]);
    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;
}

/* 
** Echo virtual table module xConnect method.

Changes to test/vtab1.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
175
176
177
178
179
180
181




182
183
184









185

186
187
188
189
190
191
192
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# 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 $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

ifcapable !vtab||!schema_pragmas {
  finish_test
  return
................................................................................
do_test vtab1-1.15 {
  catchsql {
    DROP TABLE techo;
  }
} {1 {no such module: echo}}

register_echo_module [sqlite3_connection_pointer db]




do_test vtab1-1.X {
  execsql {
    DROP TABLE techo;









    DROP TABLE treal;

    SELECT sql FROM sqlite_master;
  }
} {}

#----------------------------------------------------------------------
# Test cases vtab1.2.*
#







|







 







>
>
>
>
|


>
>
>
>
>
>
>
>
>

>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is creating and dropping virtual tables.
#
# $Id: vtab1.test,v 1.46 2007/09/03 15:03:21 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

ifcapable !vtab||!schema_pragmas {
  finish_test
  return
................................................................................
do_test vtab1-1.15 {
  catchsql {
    DROP TABLE techo;
  }
} {1 {no such module: echo}}

register_echo_module [sqlite3_connection_pointer db]
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;
  }
} {}

#----------------------------------------------------------------------
# Test cases vtab1.2.*
#