margelo / margelo/react-native-nitro-sqlite

Cannot execute multiple statements with one call

Open
#3 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C
Stars
565
Forks
53
Avg merge
1d 21h
Merged PRs (30d)
18

Description

Consider the following sql script:

CREATE TABLE foo (id INTEGER);
CREATE TABLE bar (id INTEGER);

With the current interface, only the first statement will be executed and no error is given. I would've expected to have the whole sql script executed, or at least to get an error.

I digged through the code, and found out that the pzTail parameter is unused in the sqliteExecute's prepare call:

https://github.com/margelo/react-native-quick-sqlite/blob/d70108549e7d5855a497dc14be25e7dafb00524c/cpp/sqliteBridge.cpp#L260

Apparently that pointer gets populated with the remaining text that is yet to be processed: https://sqlite.org/forum/info/2a9775b88a90d2e6.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in cpp/sqliteBridge.cpp around the sqliteExecute prepare call at line 260, and inspect how the unused pzTail value is handled. Reproduce the two-statement script, then determine whether the interface should execute all statements or report trailing SQL; done means the behavior is explicit and no statement is silently ignored.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, react-native, sqlite
Domain
databases, mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.