mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-06 15:49:35 +03:00
Accept a "/" or "go" on a line by itself as an SQL statement terminator
in the command-line shell. This allows SQL Server and Oracle scripts to be played into SQLite without change. (CVS 944) FossilOrigin-Name: 8211f57b38b87a42c856e267bd243984b5abf9cc
This commit is contained in:
20
src/shell.c
20
src/shell.c
@@ -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++){}
|
||||
|
||||
Reference in New Issue
Block a user