aboutsummaryrefslogtreecommitdiff
path: root/src/shell.c.in
diff options
context:
space:
mode:
Diffstat (limited to 'src/shell.c.in')
-rw-r--r--src/shell.c.in23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/shell.c.in b/src/shell.c.in
index 1f49a5056..b97889f93 100644
--- a/src/shell.c.in
+++ b/src/shell.c.in
@@ -99,6 +99,7 @@ typedef unsigned short int u16;
#include <string.h>
#include <stdio.h>
#include <assert.h>
+#include <math.h>
#include "sqlite3.h"
typedef sqlite3_int64 i64;
typedef sqlite3_uint64 u64;
@@ -2774,6 +2775,7 @@ static char *shell_error_context(const char *zSql, sqlite3 *db){
if( db==0
|| zSql==0
|| (iOffset = sqlite3_error_offset(db))<0
+ || iOffset>=strlen(zSql)
){
return sqlite3_mprintf("");
}
@@ -3386,12 +3388,13 @@ static void bind_prepared_stmt(ShellState *pArg, sqlite3_stmt *pStmt){
if( nVar==0 ) return; /* Nothing to do */
if( sqlite3_table_column_metadata(pArg->db, "TEMP", "sqlite_parameters",
"key", 0, 0, 0, 0, 0)!=SQLITE_OK ){
- return; /* Parameter table does not exist */
+ rc = SQLITE_NOTFOUND;
+ pQ = 0;
+ }else{
+ rc = sqlite3_prepare_v2(pArg->db,
+ "SELECT value FROM temp.sqlite_parameters"
+ " WHERE key=?1", -1, &pQ, 0);
}
- rc = sqlite3_prepare_v2(pArg->db,
- "SELECT value FROM temp.sqlite_parameters"
- " WHERE key=?1", -1, &pQ, 0);
- if( rc || pQ==0 ) return;
for(i=1; i<=nVar; i++){
char zNum[30];
const char *zVar = sqlite3_bind_parameter_name(pStmt, i);
@@ -3400,8 +3403,12 @@ static void bind_prepared_stmt(ShellState *pArg, sqlite3_stmt *pStmt){
zVar = zNum;
}
sqlite3_bind_text(pQ, 1, zVar, -1, SQLITE_STATIC);
- if( sqlite3_step(pQ)==SQLITE_ROW ){
+ if( rc==SQLITE_OK && pQ && sqlite3_step(pQ)==SQLITE_ROW ){
sqlite3_bind_value(pStmt, i, sqlite3_column_value(pQ, 0));
+ }else if( sqlite3_strlike("_NAN", zVar, 0)==0 ){
+ sqlite3_bind_double(pStmt, i, NAN);
+ }else if( sqlite3_strlike("_INF", zVar, 0)==0 ){
+ sqlite3_bind_double(pStmt, i, INFINITY);
}else{
sqlite3_bind_null(pStmt, i);
}
@@ -11465,9 +11472,9 @@ static int process_input(ShellState *p){
}
/* No single-line dispositions remain; accumulate line(s). */
nLine = strlen(zLine);
- if( nSql+nLine+8>=nAlloc ){
+ if( nSql+nLine+2>=nAlloc ){
/* Grow buffer by half-again increments when big. */
- nAlloc = nSql+(nSql>>1)+nLine+104;
+ nAlloc = nSql+(nSql>>1)+nLine+100;
zSql = realloc(zSql, nAlloc);
shell_check_oom(zSql);
}