SQLite

Check-in [a19d3a73a9]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a19d3a73a91f2040ec35d913f11743ff4913ffb7
User & Date: danielk1977 2007-09-03 15:03:21.000
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: 020a2b10d4 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: a19d3a73a9 user: danielk1977 tags: trunk)
13:06
Improvements to the xRandomness() method on the default windows VFS. Ticket #2615. (CVS 4374) (check-in: 91b50f31e3 user: drh tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/hash.c.
8
9
10
11
12
13
14
15

16
17
18
19
20
21
22
8
9
10
11
12
13
14

15
16
17
18
19
20
21
22







-
+







**    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 $
** $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.
**
358
359
360
361
362
363
364




365
366
367
368
369
370
371
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375







+
+
+
+







  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
9
10
11
12
13
14
15

16
17
18
19
20
21
22
23







-
+







**    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 $
** $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
448
449
450
451
452
453
454








455
456
457
458
459
460
461
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469







+
+
+
+
+
+
+
+







  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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14

15
16
17
18
19
20
21
1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
21













-
+







# 2006 June 10
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    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 $
# $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
175
176
177
178
179
180
181




182

183
184









185

186
187
188
189
190
191
192
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







+
+
+
+
-
+


+
+
+
+
+
+
+
+
+

+







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.X {
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.*
#