From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
---|---|
To: | Marko Tiikkaja <marko(at)joh(dot)to> |
Cc: | Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: COPY (INSERT/UPDATE/DELETE .. RETURNING ..) |
Date: | 2015-11-16 07:24:59 |
Message-ID: | CAB7nPqSu=OvpO+Uu58HcgQRY1xnd0+bwGCEjra3QcEz-D0A6nQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sun, Nov 1, 2015 at 2:49 AM, Marko Tiikkaja <marko(at)joh(dot)to> wrote:
> Attached is a patch for being able to do $SUBJECT without a CTE. The
> reasons this is better than a CTE version are:
>
> 1) It's not obvious why a CTE version works but a plain one doesn't
> 2) This one has less overhead (I measured a ~12% improvement on a
> not-too-unreasonable test case)
Would you mind sharing this test case as well as numbers?
> With regard to RULEs, similar restrictions apply as the ones on
> data-modifying statements in WITH.
OK, so with this patch BeginCopy holds a light copy of
RewriteQuery(at)rewriteHandler(dot)c that rewrites queries with rules, and this
patch extends the error handling after calling pg_analyze_and_rewrite. This
looks like the right approach.
INSERT/UPDATE/DELETE ... RETURNING is a Postgres extension not part of the
SQL spec, so my first thought is that there is no reason to reject this
feature based on the grammar allowed.
Here are some comments about the patch.
Nice patch to begin with.
Regression tests are broken when copyselect is run in parallel because
test3 is a table used there as well. A simple idea to fix this is to rename
the table test3 to something else or to use a schema dedicated to this
test, I just renamed it to copydml_test in the patch attached.
- | COPY select_with_parens TO opt_program
copy_file_name opt_with copy_options
+ | COPY '(' PreparableStmt ')' TO opt_program
copy_file_name opt_with copy_options
This does not look right, PreparableStmt is used for statements that are
part of PREPARE queries, any modifications happening there would impact
COPY with this implementation. I think that we had better have a new option
query_with_parens. Please note that the patch attached has not changed that.
--
Michael
Attachment | Content-Type | Size |
---|---|---|
20151116_copydml_v2.patch | text/x-diff | 16.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Haribabu Kommi | 2015-11-16 07:37:41 | Re: pg_hba_lookup function to get all matching pg_hba.conf entries |
Previous Message | Thomas Munro | 2015-11-16 05:59:06 | Re: Making tab-complete.c easier to maintain |