Skip to content

Commit 51ced64

Browse files
author
Sean Loiselle
committed
fix
1 parent 6e4ef4f commit 51ced64

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

src/adapter/src/client.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,36 @@ impl SessionClient {
537537
let mut results = vec![];
538538

539539
for stmt in stmts {
540+
let execute_responses = Plan::generated_from((&stmt).into())
541+
.into_iter()
542+
.map(ExecuteResponse::generated_from)
543+
.flatten()
544+
.collect::<Vec<_>>();
545+
546+
if execute_responses.iter().any(|execute_response| {
547+
matches!(
548+
execute_response,
549+
ExecuteResponseKind::Fetch
550+
| ExecuteResponseKind::SetVariable
551+
| ExecuteResponseKind::Tailing
552+
| ExecuteResponseKind::CopyTo
553+
| ExecuteResponseKind::CopyFrom
554+
| ExecuteResponseKind::Raise
555+
| ExecuteResponseKind::DeclaredCursor
556+
| ExecuteResponseKind::ClosedCursor
557+
)
558+
}) && !matches!(
559+
stmt,
560+
// Both `SelectStatement` and `CopyStatement` generate
561+
// `PeekPlan`, but `SELECT` should be permitted and `COPY` not.
562+
Statement::Select(SelectStatement { query: _, as_of: _ })
563+
) {
564+
results.push(SimpleResult::err(format!(
565+
"unsupported via this API: {}",
566+
stmt.to_ast_string()
567+
)));
568+
}
569+
540570
if matches!(self.session().transaction(), TransactionStatus::Failed(_)) {
541571
break;
542572
}

src/sql/src/plan.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl Plan {
147147
/// Expresses which [`StatementKind`] can generate which set of
148148
/// [`PlanKind`].
149149
pub fn generated_from(stmt: StatementKind) -> Vec<PlanKind> {
150-
match stmt {
150+
match dbg!(stmt) {
151151
StatementKind::AlterConnection => vec![PlanKind::AlterNoop, PlanKind::RotateKeys],
152152
StatementKind::AlterIndex => vec![
153153
PlanKind::AlterIndexResetOptions,
@@ -168,7 +168,12 @@ impl Plan {
168168
StatementKind::AlterSystemSet => vec![PlanKind::AlterNoop, PlanKind::AlterSystemSet],
169169
StatementKind::Close => vec![PlanKind::Close],
170170
StatementKind::Commit => vec![PlanKind::CommitTransaction],
171-
StatementKind::Copy => vec![PlanKind::CopyFrom, PlanKind::Peek, PlanKind::SendDiffs],
171+
StatementKind::Copy => vec![
172+
PlanKind::CopyFrom,
173+
PlanKind::Peek,
174+
PlanKind::SendDiffs,
175+
PlanKind::Tail,
176+
],
172177
StatementKind::CreateCluster => vec![PlanKind::CreateComputeInstance],
173178
StatementKind::CreateClusterReplica => vec![PlanKind::CreateComputeInstanceReplica],
174179
StatementKind::CreateConnection => vec![PlanKind::CreateConnection],
@@ -207,6 +212,7 @@ impl Plan {
207212
StatementKind::SetVariable => vec![PlanKind::SetVariable],
208213
StatementKind::Show => vec![
209214
PlanKind::Peek,
215+
PlanKind::SendRows,
210216
PlanKind::ShowVariable,
211217
PlanKind::ShowAllVariables,
212218
],

0 commit comments

Comments
 (0)