Add support for CREATE TABLE IF NOT EXISTS. (CVS 2847)
FossilOrigin-Name: 0bd9e35fd22946640f4fb1c1874922ae096916f7
This commit is contained in:
parent
72e5c6dbb9
commit
faa59554c3
18
manifest
18
manifest
@ -1,5 +1,5 @@
|
||||
C Bug\sfix\sin\scodec\sprocessing.\s(CVS\s2846)
|
||||
D 2005-12-29T23:04:02
|
||||
C Add\ssupport\sfor\sCREATE\sTABLE\sIF\sNOT\sEXISTS.\s(CVS\s2847)
|
||||
D 2005-12-29T23:33:54
|
||||
F Makefile.in e3c6b3a38d734d41574c04f2fc90d18de2b87102
|
||||
F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
|
||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||
@ -36,7 +36,7 @@ F src/attach.c 07822dbd2dcf6de548aba6cb24142aec800fa3b6
|
||||
F src/auth.c 31e2304bef67f44d635655f44234387ea7d21454
|
||||
F src/btree.c 2b2651e0f6f9f8c5976b662fbfab7fc8f54f02c9
|
||||
F src/btree.h 8ff86378bb5af0cde282614c16bf0c0190b6d216
|
||||
F src/build.c 0982b00aeab443c1469ff83f54df4b383247ca92
|
||||
F src/build.c bb4c9df2583246728167659d401fd75aa3d9997f
|
||||
F src/callback.c 62066afd516f220575e81b1a1239ab92a2eae252
|
||||
F src/complete.c df1681cef40dec33a286006981845f87b194e7a4
|
||||
F src/date.c bb079317bff6a2b78aba5c0d2ddae5f6f03acfb7
|
||||
@ -61,7 +61,7 @@ F src/os_win.c 9feb97f49b93d451f8ef7c5dd388e05a44647dc6
|
||||
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
|
||||
F src/pager.c 5227ea29acbea4b6a9c6f1dfd3e8493de5fc2a93
|
||||
F src/pager.h e0acb095b3ad0bca48f2ab00c87346665643f64f
|
||||
F src/parse.y 13343510907419ecd2fe72a245f9880df9a7dc20
|
||||
F src/parse.y fea607bdc0f4440e001ca277a49f507b5a3fb1e5
|
||||
F src/pragma.c 8883b4d34796efa315bdd0ec1b03f580ef1575b9
|
||||
F src/prepare.c 1f2bf83038792294ef4a307d95993f90e6c70561
|
||||
F src/printf.c f47a2f4b5387cd2ebb12e9117a1a5d6bd9a2b812
|
||||
@ -69,7 +69,7 @@ F src/random.c ff5e9a8cad790e2a51cd4d2e7737dc8540e09d1d
|
||||
F src/select.c 2292b065bc6be61e01aad39a2e1b93e332fb7e57
|
||||
F src/shell.c 66b073375efbdee19045e7e0cd38b85f9aff71da
|
||||
F src/sqlite.h.in 015e02efa9e8bafa31b6c270116369ddff4e9803
|
||||
F src/sqliteInt.h e3a49f17bd7cb6d3bf33d53d2fdb4e5d69c18e67
|
||||
F src/sqliteInt.h 3541350fd0617225a61c6ff4af5e6e9d33bc3794
|
||||
F src/table.c 486dcfce532685b53b5a2b5da8bba0ded6fb2316
|
||||
F src/tclsqlite.c ce481c0a21a20641cdfe87c9cbbb328cfb3a58b9
|
||||
F src/test1.c 4691cc7235683324791a0be560308ca338de36de
|
||||
@ -222,7 +222,7 @@ F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5
|
||||
F test/subquery.test e6de53332c0301b3cfa34edc3f3cd5fa1e859efd
|
||||
F test/subselect.test 2d13fb7f450db3595adcdd24079a0dd1d2d6abc2
|
||||
F test/sync.test 6e8b885cec5ccba2090e92c90f747a7142f53c88
|
||||
F test/table.test c3c0302f0481e2610f50ede7d20d8bfed40bdd11
|
||||
F test/table.test 149b76a28bbe2a1cd799232e4ae5133881e1902a
|
||||
F test/tableapi.test 6a66d58b37d46dc0f2b3c7d4bd2617d209399bd1
|
||||
F test/tclsqlite.test 19578d32a7692311918caf0ae3521d19525bcb62
|
||||
F test/temptable.test 7927261befdbc7b0a7ffebb85ecc70a74fa7b15b
|
||||
@ -331,7 +331,7 @@ F www/tclsqlite.tcl ddcf912ea48695603c8ed7efb29f0812ef8d1b49
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
|
||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||
P ae301db8a61a74bc72f67f5766811d89a3b3ec72
|
||||
R 970835b0215388a3e334b58a7d07025c
|
||||
P a88580bce045ee1c11cc6fd986ee7bab043ded4f
|
||||
R 2caf522c84042dde1b412f517fefbe54
|
||||
U drh
|
||||
Z 1eae3162f7e9d21fbce45ab030354f27
|
||||
Z a798ff6c2214d388933326d22672d220
|
||||
|
@ -1 +1 @@
|
||||
a88580bce045ee1c11cc6fd986ee7bab043ded4f
|
||||
0bd9e35fd22946640f4fb1c1874922ae096916f7
|
11
src/build.c
11
src/build.c
@ -22,7 +22,7 @@
|
||||
** COMMIT
|
||||
** ROLLBACK
|
||||
**
|
||||
** $Id: build.c,v 1.363 2005/12/29 19:23:07 drh Exp $
|
||||
** $Id: build.c,v 1.364 2005/12/29 23:33:54 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <ctype.h>
|
||||
@ -635,7 +635,8 @@ void sqlite3StartTable(
|
||||
Token *pName1, /* First part of the name of the table or view */
|
||||
Token *pName2, /* Second part of the name of the table or view */
|
||||
int isTemp, /* True if this is a TEMP table */
|
||||
int isView /* True if this is a VIEW */
|
||||
int isView, /* True if this is a VIEW */
|
||||
int noErr /* Do nothing if table already exists */
|
||||
){
|
||||
Table *pTable;
|
||||
char *zName = 0; /* The name of the new table */
|
||||
@ -713,7 +714,9 @@ void sqlite3StartTable(
|
||||
}
|
||||
pTable = sqlite3FindTable(db, zName, db->aDb[iDb].zName);
|
||||
if( pTable ){
|
||||
sqlite3ErrorMsg(pParse, "table %T already exists", pName);
|
||||
if( !noErr ){
|
||||
sqlite3ErrorMsg(pParse, "table %T already exists", pName);
|
||||
}
|
||||
goto begin_table_error;
|
||||
}
|
||||
if( sqlite3FindIndex(db, zName, 0)!=0 && (iDb==0 || !db->init.busy) ){
|
||||
@ -1505,7 +1508,7 @@ void sqlite3CreateView(
|
||||
sqlite3SelectDelete(pSelect);
|
||||
return;
|
||||
}
|
||||
sqlite3StartTable(pParse, pBegin, pName1, pName2, isTemp, 1);
|
||||
sqlite3StartTable(pParse, pBegin, pName1, pName2, isTemp, 1, 0);
|
||||
p = pParse->pNewTable;
|
||||
if( p==0 || pParse->nErr ){
|
||||
sqlite3SelectDelete(pSelect);
|
||||
|
@ -14,7 +14,7 @@
|
||||
** the parser. Lemon will also generate a header file containing
|
||||
** numeric codes for all of the tokens.
|
||||
**
|
||||
** @(#) $Id: parse.y,v 1.189 2005/12/29 01:11:37 drh Exp $
|
||||
** @(#) $Id: parse.y,v 1.190 2005/12/29 23:33:54 drh Exp $
|
||||
*/
|
||||
|
||||
// All token codes are small integers with #defines that begin with "TK_"
|
||||
@ -120,9 +120,12 @@ cmd ::= ROLLBACK trans_opt. {sqlite3RollbackTransaction(pParse);}
|
||||
///////////////////// The CREATE TABLE statement ////////////////////////////
|
||||
//
|
||||
cmd ::= create_table create_table_args.
|
||||
create_table ::= CREATE(X) temp(T) TABLE nm(Y) dbnm(Z). {
|
||||
sqlite3StartTable(pParse,&X,&Y,&Z,T,0);
|
||||
create_table ::= CREATE(X) temp(T) TABLE ifnotexists(E) nm(Y) dbnm(Z). {
|
||||
sqlite3StartTable(pParse,&X,&Y,&Z,T,0,E);
|
||||
}
|
||||
%type ifnotexists {int}
|
||||
ifnotexists(A) ::= . {A = 0;}
|
||||
ifnotexists(A) ::= IF NOT EXISTS. {A = 1;}
|
||||
%type temp {int}
|
||||
%ifndef SQLITE_OMIT_TEMPDB
|
||||
temp(A) ::= TEMP. {A = 1;}
|
||||
|
@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** Internal interface definitions for SQLite.
|
||||
**
|
||||
** @(#) $Id: sqliteInt.h,v 1.444 2005/12/29 19:23:07 drh Exp $
|
||||
** @(#) $Id: sqliteInt.h,v 1.445 2005/12/29 23:33:54 drh Exp $
|
||||
*/
|
||||
#ifndef _SQLITEINT_H_
|
||||
#define _SQLITEINT_H_
|
||||
@ -1482,7 +1482,7 @@ void sqlite3RollbackInternalChanges(sqlite3*);
|
||||
void sqlite3CommitInternalChanges(sqlite3*);
|
||||
Table *sqlite3ResultSetOfSelect(Parse*,char*,Select*);
|
||||
void sqlite3OpenMasterTable(Vdbe *v, int);
|
||||
void sqlite3StartTable(Parse*,Token*,Token*,Token*,int,int);
|
||||
void sqlite3StartTable(Parse*,Token*,Token*,Token*,int,int,int);
|
||||
void sqlite3AddColumn(Parse*,Token*);
|
||||
void sqlite3AddNotNull(Parse*, int);
|
||||
void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the CREATE TABLE statement.
|
||||
#
|
||||
# $Id: table.test,v 1.42 2005/12/29 01:11:37 drh Exp $
|
||||
# $Id: table.test,v 1.43 2005/12/29 23:33:54 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -103,6 +103,9 @@ do_test table-2.1c {
|
||||
lappend v $msg
|
||||
} {1 {object name reserved for internal use: sqlite_master}}
|
||||
do_test table-2.1d {
|
||||
catchsql {CREATE TABLE IF NOT EXISTS test2(x,y)}
|
||||
} {0 {}}
|
||||
do_test table-2.1e {
|
||||
execsql {DROP TABLE test2; SELECT name FROM sqlite_master WHERE type!='meta'}
|
||||
} {}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user