Skip to content

Poco::Data::Statement should not be in ST_DONE state after a addBinding() call #5220

@renjipanicker

Description

@renjipanicker

Describe the bug
This is for the use-case when we want to reuse a precompiled statement multiple times. In this situation, we use addBinding to set (or reset) the bindings before each execute() call.
The problem is: after the first execute(), the statement is in ST_DONE state. So during the second call, the statement gets reset.
This can be seen in line 383 below:

Image

In line 383, isDone is false the first time, and true the second time.

To Reproduce
Consider the following code snippet:

Poco::Data::Statement stmt;
void init(Poco::Data::Session& sess) {
    stmt = Poco::Data::Statement(sess);
    stmt << "SELECT * FROM table WHERE id = ?";
}

void exec(int id) {
    Poco::Data::AbstractBindingVec bindings;
    bindings.push_back(new Poco::Data::Binding<int>(id));
    stmt.addBinding(bindings, true);
    stmt.execute();
}

I would like to call init() once, and exec() multiple times. But stmt.execute() fails the second time.

Expected behavior
The stmt.execute() line should run successfully every time.

Logs
None

Screenshots
None

Please add relevant environment information:

  • OS Type and Version: MacOS, Sequoia, 15.7.3
  • POCO Version: 1.14.1
  • Third-party product (eg. database or library) type and version: None, using built-in Sqlite3

Additional context
None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions