-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Labels
Description
What happens?
duckdb::Connection
has Prepare
method accepting duckdb::SQLStatement
Calling Prepare
method after duckdb::SQLStatement::ToString
led to throwing an exception:
GetUsingBinding: expected non-empty binding_name.
it seems to forget reverting alias
property.
duckdb/src/parser/statement/insert_statement.cpp
Lines 99 to 103 in 45559f5
if (values_list) { | |
D_ASSERT(!default_values); | |
values_list->alias = string(); | |
result += values_list->ToString(); | |
} else if (select_statement) { |
Is this expected feature?
To Reproduce
Code
auto db = duckdb::Duckdb(nullptr);
auto conn = duckdb::Connection(db);
// It supporses to exist `Foo` table
// `Foo` table is `CREATE TABLE Foo (id int primary key, name varchar, age int)`
std::string sql("INSERT INTO Foo values (1, 'qwerty', 42)";
// get parsed statements
auto stmts = conn.ExtractStatements(sql);
auto &stmt = stmts[0];
// Call Tostring
stmt->ToString();
// Call prepare
auto prepared_stmt = conn.Prepare(stmt); // <- `duckdb::InternalException` is throws here
Expected result
duckdb::unique_ptr<duckdb::PreparedStatement>
is returned successfully.
Actual result
duckdb::InternalException
is throws
from
duckdb/src/planner/bind_context.cpp
Line 100 in 45559f5
throw InternalException("GetUsingBinding: expected non-empty binding_name"); |
Workaround
stmt->Copy()->ToString();
auto prepared_stmt = conn.Prepare(stmt);
OS:
MacOS Ventura 13.6.7 (x86_64 16GB RAM)
DuckDB Version:
1.1.0
DuckDB Client:
C++
Hardware:
No response
Full Name:
Kazuhiko TAMURA
Affiliation:
Free
What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have not tested with any build
Did you include all relevant data sets for reproducing the issue?
Yes
Did you include all code required to reproduce the issue?
- Yes, I have
Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?
- Yes, I have