aboutsummaryrefslogtreecommitdiff
path: root/src/shell.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2002-07-13 17:33:45 +0000
committerdrh <drh@noemail.net>2002-07-13 17:33:45 +0000
commit7f953e205267d5fa2670162c7e9624fade8b44c5 (patch)
treece30f7c95911e80af449a759e87d551d3496b974 /src/shell.c
parent70562cd34298a5d9d4af7c1df9aabc186a412df6 (diff)
downloadsqlite-7f953e205267d5fa2670162c7e9624fade8b44c5.tar.gz
sqlite-7f953e205267d5fa2670162c7e9624fade8b44c5.zip
Fix for ticket #64: Better error reporting in the shell. (CVS 676)
FossilOrigin-Name: e1842e04c4f47e1ce79575b5c787a164add5d559
Diffstat (limited to 'src/shell.c')
-rw-r--r--src/shell.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/shell.c b/src/shell.c
index ef31ceeaa..7616f6482 100644
--- a/src/shell.c
+++ b/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.60 2002/07/10 21:26:01 drh Exp $
+** $Id: shell.c,v 1.61 2002/07/13 17:33:45 drh Exp $
*/
#include <stdlib.h>
#include <string.h>
@@ -915,6 +915,7 @@ static void process_input(struct callback_data *p, FILE *in){
char *zSql = 0;
int nSql = 0;
char *zErrMsg;
+ int rc;
while( fflush(p->out), (zLine = one_input_line(zSql, in))!=0 ){
if( seenInterrupt ){
if( in!=0 ) break;
@@ -949,12 +950,16 @@ static void process_input(struct callback_data *p, FILE *in){
free(zLine);
if( zSql && sqlite_complete(zSql) ){
p->cnt = 0;
- if( sqlite_exec(db, zSql, callback, p, &zErrMsg)!=0
- && zErrMsg!=0 ){
+ rc = sqlite_exec(db, zSql, callback, p, &zErrMsg);
+ if( rc || zErrMsg ){
if( in!=0 && !p->echoOn ) printf("%s\n",zSql);
- printf("SQL error: %s\n", zErrMsg);
- free(zErrMsg);
- zErrMsg = 0;
+ if( zErrMsg!=0 ){
+ printf("SQL error: %s\n", zErrMsg);
+ free(zErrMsg);
+ zErrMsg = 0;
+ }else{
+ printf("SQL error: %s\n", sqlite_error_string(rc));
+ }
}
free(zSql);
zSql = 0;