]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Accept a "/" or "go" on a line by itself as an SQL statement terminator
authordrh <drh@noemail.net>
Tue, 29 Apr 2003 18:01:28 +0000 (18:01 +0000)
committerdrh <drh@noemail.net>
Tue, 29 Apr 2003 18:01:28 +0000 (18:01 +0000)
in the command-line shell.  This allows SQL Server and Oracle scripts to
be played into SQLite without change. (CVS 944)

FossilOrigin-Name: 8211f57b38b87a42c856e267bd243984b5abf9cc

manifest
manifest.uuid
src/shell.c

index 9568d728dead44f6f3e7892e8b71ab24d89c80a9..25145ebadcc9ad6ac101d24c0505f87032ce608e 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Allow\sthe\sASC\sor\sDESC\skeyword\sto\sappear\safter\sa\scolumn\sname\sin\sa\sCREATE\sINDEX\nstatement.\s\sSQLite\sindices\sare\saways\sASC\s(ascending)\sregardless\sof\swhich\nkeyword\sis\sused.\s(CVS\s943)
-D 2003-04-29T17:19:18
+C Accept\sa\s"/"\sor\s"go"\son\sa\sline\sby\sitself\sas\san\sSQL\sstatement\sterminator\nin\sthe\scommand-line\sshell.\s\sThis\sallows\sSQL\sServer\sand\sOracle\sscripts\sto\nbe\splayed\sinto\sSQLite\swithout\schange.\s(CVS\s944)
+D 2003-04-29T18:01:28
 F Makefile.in 004acec253ecdde985c8ecd5b7c9accdb210378f
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -44,7 +44,7 @@ F src/pragma.c 118fe400d71b7fdcc03580d5eab6bb5aa00772a5
 F src/printf.c fc5fdef6e92ad205005263661fe9716f55a49f3e
 F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe
 F src/select.c d1c876b9078894bc956cf1a5b38abd1a5abaf70b
-F src/shell.c 6557e37e6c34564b72d6b98da23a88eb6ed88d59
+F src/shell.c 4dc33c49cc69ef864c1e19283b7b683a7639a251
 F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
 F src/sqlite.h.in eec06462cba262c0ee03f38462a18a4bc66dda4e
 F src/sqliteInt.h faf133e1441b7c7b93ad5d8a58201d4849033b75
@@ -165,7 +165,7 @@ F www/speed.tcl cb4c10a722614aea76d2c51f32ee43400d5951be
 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P c6bf62e41cf44e8ebf740b103204b00e8b826c90
-R 04afb247e830abab3943a6061d0bbc42
+P 1a0c542088618ba24d1efae9b13a8eca104d6cc8
+R b08733b79775152cc384c5b58062cc88
 U drh
-Z 338ae139004152359560f097d0453d1b
+Z 5e48773d80f83c12274e19cd1dafe308
index fd2f4d54df567249bffb86a6511940f9b5057b82..05f78f7b1d20a69a9c9eebd520c12a573b88ea4f 100644 (file)
@@ -1 +1 @@
-1a0c542088618ba24d1efae9b13a8eca104d6cc8
\ No newline at end of file
+8211f57b38b87a42c856e267bd243984b5abf9cc
\ No newline at end of file
index fd4485c207658f59a73697686ccac040082b0f66..3f7094e09637a2881705b53ee8959aec400a9528 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains code to implement the "sqlite" command line
 ** utility for accessing SQLite databases.
 **
-** $Id: shell.c,v 1.73 2003/04/26 03:03:07 drh Exp $
+** $Id: shell.c,v 1.74 2003/04/29 18:01:28 drh Exp $
 */
 #include <stdlib.h>
 #include <string.h>
@@ -922,6 +922,21 @@ static int _all_whitespace(const char *z){
   return 1;
 }
 
+/*
+** Return TRUE if the line typed in is an SQL command terminator other
+** than a semi-colon.  The SQL Server style "go" command is understood
+** as is the Oracle "/".
+*/
+static int _is_command_terminator(const char *zLine){
+  extern int sqliteStrNICmp(const char*,const char*,int);
+  while( isspace(*zLine) ){ zLine++; };
+  if( zLine[0]=='/' && _all_whitespace(&zLine[1]) ) return 1;  /* Oracle */
+  if( sqliteStrNICmp(zLine,"go",2)==0 && _all_whitespace(&zLine[2]) ){
+    return 1;  /* SQL Server */
+  }
+  return 0;
+}
+
 /*
 ** Read input from *in and process it.  If *in==0 then input
 ** is interactive - the user is typing it it.  Otherwise, input
@@ -948,6 +963,9 @@ static void process_input(struct callback_data *p, FILE *in){
       if( rc ) break;
       continue;
     }
+    if( _is_command_terminator(zLine) ){
+      strcpy(zLine,";");
+    }
     if( zSql==0 ){
       int i;
       for(i=0; zLine[i] && isspace(zLine[i]); i++){}