/ Check-in [7b1cfd65]
Login

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

Overview
Comment:Allow zero-length names for tables, columns, and indices. Fix for ticket [78e04e52eaf].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7b1cfd65a6f7c85ef8f6e4622973457cff9d007c
User & Date: drh 2009-12-08 14:34:08
References
2009-12-08
14:34 Fixed ticket [78e04e52]: Assertion failure dropping table with zero length name plus 3 other changes artifact: 17c1e71a user: drh
Context
2009-12-08
15:16
Begin updating API documentation to use the new MD5-hash based automatic requirements numbering. Comment changes only. Many similar changes will follow. check-in: 973c5c86 user: drh tags: trunk
14:34
Allow zero-length names for tables, columns, and indices. Fix for ticket [78e04e52eaf]. check-in: 7b1cfd65 user: drh tags: trunk
13:44
Add test cases for ticket [abe728bbc311]. check-in: 4eb9bf0b user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/build.c.

545
546
547
548
549
550
551
552

553
554
555
556
557
558
559
*/
void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char *zTabName){
  Table *p;
  Db *pDb;

  assert( db!=0 );
  assert( iDb>=0 && iDb<db->nDb );
  assert( zTabName && zTabName[0] );

  pDb = &db->aDb[iDb];
  p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName,
                        sqlite3Strlen30(zTabName),0);
  sqlite3DeleteTable(p);
  db->flags |= SQLITE_InternChanges;
}








|
>







545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
*/
void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char *zTabName){
  Table *p;
  Db *pDb;

  assert( db!=0 );
  assert( iDb>=0 && iDb<db->nDb );
  assert( zTabName );
  testcase( zTabName[0]==0 );  /* Zero-length table names are allowed */
  pDb = &db->aDb[iDb];
  p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName,
                        sqlite3Strlen30(zTabName),0);
  sqlite3DeleteTable(p);
  db->flags |= SQLITE_InternChanges;
}

Added test/tkt-78e04e52ea.test.









































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# 2009 December 8
#
# 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.
#
# Verify that we can create zero-length tables.
#

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

do_test tkt-78e04-1.0 {
  execsql {
    CREATE TABLE ""("" UNIQUE);
    CREATE TABLE t2(x);
    INSERT INTO "" VALUES(1);
    INSERT INTO t2 VALUES(2);
    SELECT * FROM "", t2;
  }
} {1 2}
do_test tkt-78e04-1.1 {
  catchsql {
    INSERT INTO "" VALUES(1);
  }
} {1 {column  is not unique}}
do_test tkt-78e04-1.2 {
  execsql {
    PRAGMA table_info("");
  }
} {0 {} {} 0 {} 0}
do_test tkt-78e04-1.3 {
  execsql {
    CREATE INDEX i1 ON ""("" COLLATE nocase);
  }
} {}
do_test tkt-78e04-1.4 {
  execsql {
    EXPLAIN QUERY PLAN SELECT * FROM "" WHERE "" LIKE 'abc%';
  }
} {0 0 {TABLE }}
do_test tkt-78e04-1.5 {
  execsql {
    DROP TABLE "";
    SELECT name FROM sqlite_master;
  }
} {t2}

do_test tkt-78e04-2.1 {
  execsql {
    CREATE INDEX "" ON t2(x);
    EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE x=5;
  }
} {0 0 {TABLE t2 WITH INDEX }}
do_test tkt-78e04-2.2 {
  execsql {
    DROP INDEX "";
    EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE x=2;
  }
} {0 0 {TABLE t2}}

finish_test