From c93050101331a15815ca456128b7e48608bbe6d1 Mon Sep 17 00:00:00 2001 From: Noy Date: Tue, 24 Dec 2024 13:46:06 +0800 Subject: [PATCH] fix: adapt to tests --- pgserver/duck_handler.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pgserver/duck_handler.go b/pgserver/duck_handler.go index ccc5094..2e1a723 100644 --- a/pgserver/duck_handler.go +++ b/pgserver/duck_handler.go @@ -444,13 +444,10 @@ func (h *DuckHandler) executeQuery(ctx *sql.Context, query string, parsed tree.S if err != nil { break } - // If the query contains a schema name, we need to execute the query to set the schema as default. - if len(parts) > 1 { - exec() - } else { - schema = types.OkResultSchema - iter = sql.RowsToRowIter(sql.NewRow(types.OkResult{})) - } + // exec() will get the current schema from the underlying connection. If we don't set the schema to public here, + // exec() may fail because of the absence of the old schema in the newly switched catalog. + ctx.Session.SetCurrentDatabase("public") + exec() } else { exec() }