Fix command completion for CREATE TABEL ... AS

From: Fernando Nasser <fnasser(at)redhat(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: Fix command completion for CREATE TABEL ... AS
Date: 2002-02-22 14:44:13
Message-ID: 3C76593D.79492350@redhat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

(Please note that the patches:
"[PATCHES] Allow arbitrary levels of analyze/rewriting" and
"[PATCHES] Fix issuing of multiple command completions per command"
must be applied before this on)

This patch fixes the response for a CREATE TABLE ... AS statement.
Before you would see:

test=# create table b as select * from a;
SELECT

because it is internally transformed into the equivalent of

test=# select * into c from a;
SELECT

With this patch one now sees:

test=# create table b as select * from a;
CREATE

as expected.

ChangeLog:

* src/backend/tcop/pquery.c (ProcessQuery): Allow the caller to
specify the command tag. Create a tag based on commandType if
no
tag specified by caller.
* src/include/tcop/pquery.h: Adjust declaration for the above
function.
* src/backend/commands/explain.c (ExplainOneQuery): Adjust call
to
the above function.
* src/backend/tcop/postgres.c (pg_exec_query_string): Call
ProcessQuery() with the command tag that refers to the original
command, before rewriting.
(CreateCommandTag): Handle T_CreateAsStmt nodes.
* src/include/nodes/nodes.h: Add T_CreateAsStmt for CREATE
TABLE...AS.
* src/include/nodes/parsenodes.h: Add CreateAsStmt for CREATE
TABLE...AS.
* src/backend/nodes/copyfuncs.c (copyObject): Handle
T_CreateAsStmt.
* src/backend/nodes/equalfuncs.c (equal): Ditto.
* src/backend/parser/gram.y: Parse CREATE TABLE...AS into a
CreateAsStmt.
* src/backend/parser/analyze.c (transformStmt): Rewrite a
CreateAsStmt into a SelectStmt.

--
Fernando Nasser
Red Hat Canada Ltd. E-Mail: fnasser(at)redhat(dot)com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9

Attachment Content-Type Size
CREATEAS.PATCH text/plain 7.1 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Thomas Lockhart 2002-02-22 15:21:51 Re: [PATCHES] Automatic transactions in psql
Previous Message Fernando Nasser 2002-02-22 14:39:13 Fix issuing of multiple command completions per command