/ Check-in [f4342774]
Login

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

Overview
Comment:Avoid a memory leak and/or assertion failure when parsing a table declaration that contains a duplicate column name. Ticket #1418. (CVS 2684)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f43427742b1c086f2621c900f4ede1a34a8b44ee
User & Date: drh 2005-09-10 15:35:07
Context
2005-09-10
16:46
Add the experimental EXPLAIN QUERY PLAN diagnostic capability. (CVS 2685) check-in: 986efb7b user: drh tags: trunk
15:35
Avoid a memory leak and/or assertion failure when parsing a table declaration that contains a duplicate column name. Ticket #1418. (CVS 2684) check-in: f4342774 user: drh tags: trunk
15:28
Use of the CROSS keyword in a join prevents table reordering. Ticket #1414. (CVS 2683) check-in: 415b8b24 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/build.c.

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
...
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
**     CREATE INDEX
**     DROP INDEX
**     creating ID lists
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**
** $Id: build.c,v 1.347 2005/09/08 14:17:20 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** This routine is called when a new SQL statement is beginning to
** be parsed.  Initialize the pParse structure as needed.
................................................................................
  int i;
  Column *pCol;

  if( (p = pParse->pNewTable)==0 ) return;
  i = p->nCol-1;
  if( i<0 ) return;
  pCol = &p->aCol[i];
  assert( pCol->zType==0 );
  pCol->zType = sqlite3NameFromToken(pType);
  pCol->affinity = sqlite3AffinityType(pType);
}

/*
** The expression is the default value for the most recently added column
** of the table currently under construction.







|







 







|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
...
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
**     CREATE INDEX
**     DROP INDEX
**     creating ID lists
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**
** $Id: build.c,v 1.348 2005/09/10 15:35:07 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** This routine is called when a new SQL statement is beginning to
** be parsed.  Initialize the pParse structure as needed.
................................................................................
  int i;
  Column *pCol;

  if( (p = pParse->pNewTable)==0 ) return;
  i = p->nCol-1;
  if( i<0 ) return;
  pCol = &p->aCol[i];
  sqliteFree(pCol->zType);
  pCol->zType = sqlite3NameFromToken(pType);
  pCol->affinity = sqlite3AffinityType(pType);
}

/*
** The expression is the default value for the most recently added column
** of the table currently under construction.

Changes to test/table.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
383
384
385
386
387
388
389





390
391
392
393
394
395
396
#    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 testing the CREATE TABLE statement.
#
# $Id: table.test,v 1.40 2005/08/13 00:56:28 drh Exp $

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

# Create a basic table and verify it is added to sqlite_master
#
do_test table-1.1 {
................................................................................

# Make sure we cannot have duplicate column names within a table.
#
do_test table-9.1 {
  catchsql {
    CREATE TABLE t6(a,b,a);
  }





} {1 {duplicate column name: a}}

# Check the foreign key syntax.
#
ifcapable {foreignkey} {
do_test table-10.1 {
  catchsql {







|







 







>
>
>
>
>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
#    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 testing the CREATE TABLE statement.
#
# $Id: table.test,v 1.41 2005/09/10 15:35:07 drh Exp $

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

# Create a basic table and verify it is added to sqlite_master
#
do_test table-1.1 {
................................................................................

# Make sure we cannot have duplicate column names within a table.
#
do_test table-9.1 {
  catchsql {
    CREATE TABLE t6(a,b,a);
  }
} {1 {duplicate column name: a}}
do_test table-9.2 {
  catchsql {
    CREATE TABLE t6(a varchar(100), b blob, a integer);
  }
} {1 {duplicate column name: a}}

# Check the foreign key syntax.
#
ifcapable {foreignkey} {
do_test table-10.1 {
  catchsql {