From 4f4fa848e002704595651353fca810b919d92b87 Mon Sep 17 00:00:00 2001 From: Piotr Sarna Date: Mon, 31 Jul 2023 13:16:23 +0200 Subject: [PATCH] sqld: allow CREATE VIEW and DROP VIEW MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... but disallow CREATE TEMP VIEW. Examples: → create temp view v as select v from t; Error: failed to execute SQL: create temp view v as select v from t; unsupported statement → create view v as select v from t; → drop view v; Fixes #563 --- sqld/src/query_analysis.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sqld/src/query_analysis.rs b/sqld/src/query_analysis.rs index 4234c62e..2b75a4b4 100644 --- a/sqld/src/query_analysis.rs +++ b/sqld/src/query_analysis.rs @@ -93,6 +93,12 @@ impl StmtKind { ) => Some(Self::Write), Cmd::Stmt(Stmt::Select { .. }) => Some(Self::Read), Cmd::Stmt(Stmt::Pragma(name, body)) => Self::pragma_kind(name, body.as_ref()), + // Creating regular views is OK, temporary views are bound to a connection + // and thus disallowed in sqld. + Cmd::Stmt(Stmt::CreateView { + temporary: false, .. + }) => Some(Self::Write), + Cmd::Stmt(Stmt::DropView { .. }) => Some(Self::Write), _ => None, } }