Skip to content

Commit 99fd6b6

Browse files
committed
Add comment with link to tail parsing issue
1 parent 9d04876 commit 99fd6b6

File tree

3 files changed

+45
-43
lines changed

3 files changed

+45
-43
lines changed

src/better_sqlite3.cpp

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,7 @@ void Statement::JS_new (v8::FunctionCallbackInfo <v8 :: Value> const & info)
859859
if (handle == NULL) {
860860
return ThrowRangeError("The supplied SQL string contains no statements");
861861
}
862+
862863
for (char c; (c = *tail); ) {
863864
if (IS_SKIPPED(c)) {
864865
++tail;
@@ -894,9 +895,9 @@ void Statement::JS_new (v8::FunctionCallbackInfo <v8 :: Value> const & info)
894895

895896
info.GetReturnValue().Set(info.This());
896897
}
897-
#line 152 "./src/objects/statement.lzz"
898+
#line 153 "./src/objects/statement.lzz"
898899
void Statement::JS_run (v8::FunctionCallbackInfo <v8 :: Value> const & info)
899-
#line 152 "./src/objects/statement.lzz"
900+
#line 153 "./src/objects/statement.lzz"
900901
{
901902
Statement * stmt = node :: ObjectWrap :: Unwrap < Statement > ( info . This ( ) ) ; ( ( void ) 0 ) ; sqlite3_stmt * handle = stmt -> handle ; Database * db = stmt -> db ; if ( ! db -> GetState ( ) -> open ) return ThrowTypeError ( "The database connection is not open" ) ; if ( db -> GetState ( ) -> busy ) return ThrowTypeError ( "This database connection is busy executing a query" ) ; if ( stmt -> locked ) return ThrowTypeError ( "This statement is busy executing a query" ) ; if ( ! db -> GetState ( ) -> unsafe_mode ) { if ( db -> GetState ( ) -> iterators ) return ThrowTypeError ( "This database connection is busy executing a query" ) ; } ( ( void ) 0 ) ; const bool bound = stmt -> bound ; if ( ! bound ) { Binder binder ( handle ) ; if ( ! binder . Bind ( info , info . Length ( ) , stmt ) ) { sqlite3_clear_bindings ( handle ) ; return ; } ( ( void ) 0 ) ; } else if ( info . Length ( ) > 0 ) { return ThrowTypeError ( "This statement already has bound parameters" ) ; } ( ( void ) 0 ) ; db -> GetState ( ) -> busy = true ; v8 :: Isolate * isolate = info . GetIsolate ( ) ; if ( db -> Log ( isolate , handle ) ) { db -> GetState ( ) -> busy = false ; db -> ThrowDatabaseError ( ) ; if ( ! bound ) { sqlite3_clear_bindings ( handle ) ; } return ; } ( ( void ) 0 ) ;
902903
sqlite3* db_handle = db->GetHandle();
@@ -919,9 +920,9 @@ void Statement::JS_run (v8::FunctionCallbackInfo <v8 :: Value> const & info)
919920
}
920921
db -> GetState ( ) -> busy = false ; db -> ThrowDatabaseError ( ) ; if ( ! bound ) { sqlite3_clear_bindings ( handle ) ; } return ;
921922
}
922-
#line 175 "./src/objects/statement.lzz"
923+
#line 176 "./src/objects/statement.lzz"
923924
void Statement::JS_get (v8::FunctionCallbackInfo <v8 :: Value> const & info)
924-
#line 175 "./src/objects/statement.lzz"
925+
#line 176 "./src/objects/statement.lzz"
925926
{
926927
Statement * stmt = node :: ObjectWrap :: Unwrap < Statement > ( info . This ( ) ) ; if ( ! stmt -> returns_data ) return ThrowTypeError ( "This statement does not return data. Use run() instead" ) ; sqlite3_stmt * handle = stmt -> handle ; Database * db = stmt -> db ; if ( ! db -> GetState ( ) -> open ) return ThrowTypeError ( "The database connection is not open" ) ; if ( db -> GetState ( ) -> busy ) return ThrowTypeError ( "This database connection is busy executing a query" ) ; if ( stmt -> locked ) return ThrowTypeError ( "This statement is busy executing a query" ) ; const bool bound = stmt -> bound ; if ( ! bound ) { Binder binder ( handle ) ; if ( ! binder . Bind ( info , info . Length ( ) , stmt ) ) { sqlite3_clear_bindings ( handle ) ; return ; } ( ( void ) 0 ) ; } else if ( info . Length ( ) > 0 ) { return ThrowTypeError ( "This statement already has bound parameters" ) ; } ( ( void ) 0 ) ; db -> GetState ( ) -> busy = true ; v8 :: Isolate * isolate = info . GetIsolate ( ) ; if ( db -> Log ( isolate , handle ) ) { db -> GetState ( ) -> busy = false ; db -> ThrowDatabaseError ( ) ; if ( ! bound ) { sqlite3_clear_bindings ( handle ) ; } return ; } ( ( void ) 0 ) ;
927928
int status = sqlite3_step(handle);
@@ -936,9 +937,9 @@ void Statement::JS_get (v8::FunctionCallbackInfo <v8 :: Value> const & info)
936937
sqlite3_reset(handle);
937938
db -> GetState ( ) -> busy = false ; db -> ThrowDatabaseError ( ) ; if ( ! bound ) { sqlite3_clear_bindings ( handle ) ; } return ;
938939
}
939-
#line 190 "./src/objects/statement.lzz"
940+
#line 191 "./src/objects/statement.lzz"
940941
void Statement::JS_all (v8::FunctionCallbackInfo <v8 :: Value> const & info)
941-
#line 190 "./src/objects/statement.lzz"
942+
#line 191 "./src/objects/statement.lzz"
942943
{
943944
Statement * stmt = node :: ObjectWrap :: Unwrap < Statement > ( info . This ( ) ) ; if ( ! stmt -> returns_data ) return ThrowTypeError ( "This statement does not return data. Use run() instead" ) ; sqlite3_stmt * handle = stmt -> handle ; Database * db = stmt -> db ; if ( ! db -> GetState ( ) -> open ) return ThrowTypeError ( "The database connection is not open" ) ; if ( db -> GetState ( ) -> busy ) return ThrowTypeError ( "This database connection is busy executing a query" ) ; if ( stmt -> locked ) return ThrowTypeError ( "This statement is busy executing a query" ) ; const bool bound = stmt -> bound ; if ( ! bound ) { Binder binder ( handle ) ; if ( ! binder . Bind ( info , info . Length ( ) , stmt ) ) { sqlite3_clear_bindings ( handle ) ; return ; } ( ( void ) 0 ) ; } else if ( info . Length ( ) > 0 ) { return ThrowTypeError ( "This statement already has bound parameters" ) ; } ( ( void ) 0 ) ; db -> GetState ( ) -> busy = true ; v8 :: Isolate * isolate = info . GetIsolate ( ) ; if ( db -> Log ( isolate , handle ) ) { db -> GetState ( ) -> busy = false ; db -> ThrowDatabaseError ( ) ; if ( ! bound ) { sqlite3_clear_bindings ( handle ) ; } return ; } ( ( void ) 0 ) ;
944945
v8 :: Local < v8 :: Context > ctx = isolate -> GetCurrentContext ( ) ;
@@ -959,9 +960,9 @@ void Statement::JS_all (v8::FunctionCallbackInfo <v8 :: Value> const & info)
959960
if (js_error) db->GetState()->was_js_error = true;
960961
db -> GetState ( ) -> busy = false ; db -> ThrowDatabaseError ( ) ; if ( ! bound ) { sqlite3_clear_bindings ( handle ) ; } return ;
961962
}
962-
#line 211 "./src/objects/statement.lzz"
963+
#line 212 "./src/objects/statement.lzz"
963964
void Statement::JS_iterate (v8::FunctionCallbackInfo <v8 :: Value> const & info)
964-
#line 211 "./src/objects/statement.lzz"
965+
#line 212 "./src/objects/statement.lzz"
965966
{
966967
Addon * addon = static_cast < Addon * > ( info . Data ( ) . As < v8 :: External > ( ) -> Value ( ) ) ;
967968
v8 :: Isolate * isolate = info . GetIsolate ( ) ;
@@ -971,9 +972,9 @@ void Statement::JS_iterate (v8::FunctionCallbackInfo <v8 :: Value> const & info)
971972
addon->privileged_info = NULL;
972973
if (!maybeIterator.IsEmpty()) info.GetReturnValue().Set(maybeIterator.ToLocalChecked());
973974
}
974-
#line 221 "./src/objects/statement.lzz"
975+
#line 222 "./src/objects/statement.lzz"
975976
void Statement::JS_bind (v8::FunctionCallbackInfo <v8 :: Value> const & info)
976-
#line 221 "./src/objects/statement.lzz"
977+
#line 222 "./src/objects/statement.lzz"
977978
{
978979
Statement* stmt = node :: ObjectWrap :: Unwrap <Statement>(info.This());
979980
if (stmt->bound) return ThrowTypeError("The bind() method can only be invoked once per statement object");
@@ -984,9 +985,9 @@ void Statement::JS_bind (v8::FunctionCallbackInfo <v8 :: Value> const & info)
984985
stmt->bound = true;
985986
info.GetReturnValue().Set(info.This());
986987
}
987-
#line 232 "./src/objects/statement.lzz"
988+
#line 233 "./src/objects/statement.lzz"
988989
void Statement::JS_pluck (v8::FunctionCallbackInfo <v8 :: Value> const & info)
989-
#line 232 "./src/objects/statement.lzz"
990+
#line 233 "./src/objects/statement.lzz"
990991
{
991992
Statement* stmt = node :: ObjectWrap :: Unwrap <Statement>(info.This());
992993
if (!stmt->returns_data) return ThrowTypeError("The pluck() method is only for statements that return data");
@@ -997,9 +998,9 @@ void Statement::JS_pluck (v8::FunctionCallbackInfo <v8 :: Value> const & info)
997998
stmt->mode = use ? Data::PLUCK : stmt->mode == Data::PLUCK ? Data::FLAT : stmt->mode;
998999
info.GetReturnValue().Set(info.This());
9991000
}
1000-
#line 243 "./src/objects/statement.lzz"
1001+
#line 244 "./src/objects/statement.lzz"
10011002
void Statement::JS_expand (v8::FunctionCallbackInfo <v8 :: Value> const & info)
1002-
#line 243 "./src/objects/statement.lzz"
1003+
#line 244 "./src/objects/statement.lzz"
10031004
{
10041005
Statement* stmt = node :: ObjectWrap :: Unwrap <Statement>(info.This());
10051006
if (!stmt->returns_data) return ThrowTypeError("The expand() method is only for statements that return data");
@@ -1010,9 +1011,9 @@ void Statement::JS_expand (v8::FunctionCallbackInfo <v8 :: Value> const & info)
10101011
stmt->mode = use ? Data::EXPAND : stmt->mode == Data::EXPAND ? Data::FLAT : stmt->mode;
10111012
info.GetReturnValue().Set(info.This());
10121013
}
1013-
#line 254 "./src/objects/statement.lzz"
1014+
#line 255 "./src/objects/statement.lzz"
10141015
void Statement::JS_raw (v8::FunctionCallbackInfo <v8 :: Value> const & info)
1015-
#line 254 "./src/objects/statement.lzz"
1016+
#line 255 "./src/objects/statement.lzz"
10161017
{
10171018
Statement* stmt = node :: ObjectWrap :: Unwrap <Statement>(info.This());
10181019
if (!stmt->returns_data) return ThrowTypeError("The raw() method is only for statements that return data");
@@ -1023,9 +1024,9 @@ void Statement::JS_raw (v8::FunctionCallbackInfo <v8 :: Value> const & info)
10231024
stmt->mode = use ? Data::RAW : stmt->mode == Data::RAW ? Data::FLAT : stmt->mode;
10241025
info.GetReturnValue().Set(info.This());
10251026
}
1026-
#line 265 "./src/objects/statement.lzz"
1027+
#line 266 "./src/objects/statement.lzz"
10271028
void Statement::JS_safeIntegers (v8::FunctionCallbackInfo <v8 :: Value> const & info)
1028-
#line 265 "./src/objects/statement.lzz"
1029+
#line 266 "./src/objects/statement.lzz"
10291030
{
10301031
Statement* stmt = node :: ObjectWrap :: Unwrap <Statement>(info.This());
10311032
if ( stmt -> db -> GetState ( ) -> busy ) return ThrowTypeError ( "This database connection is busy executing a query" ) ;
@@ -1034,9 +1035,9 @@ void Statement::JS_safeIntegers (v8::FunctionCallbackInfo <v8 :: Value> const &
10341035
else { if ( info . Length ( ) <= ( 0 ) || ! info [ 0 ] -> IsBoolean ( ) ) return ThrowTypeError ( "Expected " "first" " argument to be " "a boolean" ) ; stmt -> safe_ints = ( info [ 0 ] . As < v8 :: Boolean > ( ) ) -> Value ( ) ; }
10351036
info.GetReturnValue().Set(info.This());
10361037
}
1037-
#line 274 "./src/objects/statement.lzz"
1038+
#line 275 "./src/objects/statement.lzz"
10381039
void Statement::JS_columns (v8::FunctionCallbackInfo <v8 :: Value> const & info)
1039-
#line 274 "./src/objects/statement.lzz"
1040+
#line 275 "./src/objects/statement.lzz"
10401041
{
10411042
Statement* stmt = node :: ObjectWrap :: Unwrap <Statement>(info.This());
10421043
if (!stmt->returns_data) return ThrowTypeError("The columns() method is only for statements that return data");
@@ -1079,9 +1080,9 @@ void Statement::JS_columns (v8::FunctionCallbackInfo <v8 :: Value> const & info)
10791080

10801081
info.GetReturnValue().Set(columns);
10811082
}
1082-
#line 317 "./src/objects/statement.lzz"
1083+
#line 318 "./src/objects/statement.lzz"
10831084
void Statement::JS_busy (v8::Local <v8 :: String> _, v8::PropertyCallbackInfo <v8 :: Value> const & info)
1084-
#line 317 "./src/objects/statement.lzz"
1085+
#line 318 "./src/objects/statement.lzz"
10851086
{
10861087
Statement* stmt = node :: ObjectWrap :: Unwrap <Statement>(info.This());
10871088
info.GetReturnValue().Set(stmt->alive && stmt->locked);

src/better_sqlite3.hpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -340,47 +340,47 @@ class Statement : public node::ObjectWrap
340340
explicit Statement (Database * db, sqlite3_stmt * handle, sqlite3_uint64 id, bool returns_data);
341341
#line 85 "./src/objects/statement.lzz"
342342
static void JS_new (v8::FunctionCallbackInfo <v8 :: Value> const & info);
343-
#line 152 "./src/objects/statement.lzz"
343+
#line 153 "./src/objects/statement.lzz"
344344
static void JS_run (v8::FunctionCallbackInfo <v8 :: Value> const & info);
345-
#line 175 "./src/objects/statement.lzz"
345+
#line 176 "./src/objects/statement.lzz"
346346
static void JS_get (v8::FunctionCallbackInfo <v8 :: Value> const & info);
347-
#line 190 "./src/objects/statement.lzz"
347+
#line 191 "./src/objects/statement.lzz"
348348
static void JS_all (v8::FunctionCallbackInfo <v8 :: Value> const & info);
349-
#line 211 "./src/objects/statement.lzz"
349+
#line 212 "./src/objects/statement.lzz"
350350
static void JS_iterate (v8::FunctionCallbackInfo <v8 :: Value> const & info);
351-
#line 221 "./src/objects/statement.lzz"
351+
#line 222 "./src/objects/statement.lzz"
352352
static void JS_bind (v8::FunctionCallbackInfo <v8 :: Value> const & info);
353-
#line 232 "./src/objects/statement.lzz"
353+
#line 233 "./src/objects/statement.lzz"
354354
static void JS_pluck (v8::FunctionCallbackInfo <v8 :: Value> const & info);
355-
#line 243 "./src/objects/statement.lzz"
355+
#line 244 "./src/objects/statement.lzz"
356356
static void JS_expand (v8::FunctionCallbackInfo <v8 :: Value> const & info);
357-
#line 254 "./src/objects/statement.lzz"
357+
#line 255 "./src/objects/statement.lzz"
358358
static void JS_raw (v8::FunctionCallbackInfo <v8 :: Value> const & info);
359-
#line 265 "./src/objects/statement.lzz"
359+
#line 266 "./src/objects/statement.lzz"
360360
static void JS_safeIntegers (v8::FunctionCallbackInfo <v8 :: Value> const & info);
361-
#line 274 "./src/objects/statement.lzz"
361+
#line 275 "./src/objects/statement.lzz"
362362
static void JS_columns (v8::FunctionCallbackInfo <v8 :: Value> const & info);
363-
#line 317 "./src/objects/statement.lzz"
363+
#line 318 "./src/objects/statement.lzz"
364364
static void JS_busy (v8::Local <v8 :: String> _, v8::PropertyCallbackInfo <v8 :: Value> const & info);
365-
#line 322 "./src/objects/statement.lzz"
366-
Database * const db;
367365
#line 323 "./src/objects/statement.lzz"
368-
sqlite3_stmt * const handle;
366+
Database * const db;
369367
#line 324 "./src/objects/statement.lzz"
370-
Extras * const extras;
368+
sqlite3_stmt * const handle;
371369
#line 325 "./src/objects/statement.lzz"
372-
bool alive;
370+
Extras * const extras;
373371
#line 326 "./src/objects/statement.lzz"
374-
bool locked;
372+
bool alive;
375373
#line 327 "./src/objects/statement.lzz"
376-
bool bound;
374+
bool locked;
377375
#line 328 "./src/objects/statement.lzz"
378-
bool has_bind_map;
376+
bool bound;
379377
#line 329 "./src/objects/statement.lzz"
380-
bool safe_ints;
378+
bool has_bind_map;
381379
#line 330 "./src/objects/statement.lzz"
382-
char mode;
380+
bool safe_ints;
383381
#line 331 "./src/objects/statement.lzz"
382+
char mode;
383+
#line 332 "./src/objects/statement.lzz"
384384
bool const returns_data;
385385
};
386386
#line 1 "./src/objects/statement-iterator.lzz"

src/objects/statement.lzz

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ private:
113113
if (handle == NULL) {
114114
return ThrowRangeError("The supplied SQL string contains no statements");
115115
}
116+
// https://github.com/WiseLibs/better-sqlite3/issues/975#issuecomment-1520934678
116117
for (char c; (c = *tail); ) {
117118
if (IS_SKIPPED(c)) {
118119
++tail;

0 commit comments

Comments
 (0)