fix: ident value in set search_path (#6153)

* fix: ident value in set search_path

* refactor: remove unneeded clone
This commit is contained in:
Ning Sun
2025-05-22 05:58:18 +02:00
committed by Zhenchi
parent 5c9cbb5f4c
commit d596dba240
3 changed files with 12 additions and 1 deletions

View File

@@ -122,7 +122,11 @@ pub fn set_search_path(exprs: Vec<Expr>, ctx: QueryContextRef) -> Result<()> {
match search_expr {
Expr::Value(Value::SingleQuotedString(search_path))
| Expr::Value(Value::DoubleQuotedString(search_path)) => {
ctx.set_current_schema(&search_path.clone());
ctx.set_current_schema(search_path);
Ok(())
}
Expr::Identifier(Ident { value, .. }) => {
ctx.set_current_schema(value);
Ok(())
}
expr => NotSupportedSnafu {

View File

@@ -52,6 +52,11 @@ set search_path to 'public';
Affected Rows: 0
-- SQLNESS PROTOCOL POSTGRES
set search_path = public;
Affected Rows: 0
-- SQLNESS PROTOCOL POSTGRES
select current_schema();

View File

@@ -20,6 +20,8 @@ set search_path to 'test';
drop database test;
-- SQLNESS PROTOCOL POSTGRES
set search_path to 'public';
-- SQLNESS PROTOCOL POSTGRES
set search_path = public;
-- SQLNESS PROTOCOL POSTGRES
select current_schema();