From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
---|---|
To: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | deparsing utility commands |
Date: | 2015-02-15 04:48:15 |
Message-ID: | 20150215044814.GL3391@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
This is a repost of the patch to add CREATE command deparsing support to
event triggers. It now supports not only CREATE but also ALTER and
other commands such as GRANT/REVOKE, COMMENT ON and SECURITY LABEL.
This patch series is broken up in a rather large number of patches, but
my intention would be to commit separately only the first 6 patches; the
remaining parts are split up only so that it's easy to see how deparsing
each patch is implemented, and would be committed as a single changeset
(but before that I need a bunch of extra fixes and additions to other
parts.)
One of the worries regarding this code is whether we will be able to
keep it up to date as the grammar changes. We have come up with a
testing harness for this that's pretty simple: we will have a new make
target in src/test/regress that creates a new pg_regress schedule file,
then run pg_regress with it. That schedule contains a "deparse
initialization" test, then the contents of serial_schedule, then a
final deparse test. The initialization test creates a table and an
event trigger, and stores all deparsed commands in the table; the final
deparse test is about executing those commands. (There are actually two
event triggers; the other one stores DROP commands for objects dropped,
using the sql_drop event.) The deparse_init.sql file is attached.
Just by storing the deparsed command in the table we're doing the first
level of deparse testing: make sure that all commands deparse to
something. Running the commands is the second level: make sure that the
commands generated by the deparsing step works correctly. (The third
level is making sure that each command generated by deparse creates an
object idential to the one generated by the original command. The plan
here is to run two databases through pg_dump and compare.)
One line of defense which I just tought about is that instead of
sprinkling EventTriggerStashCommand() calls all over ProcessUtilitySlow,
we should add only one at the bottom.
There are some issues remaining:
1. ruleutils.c seems to deparse temp schemas as pg_temp_X instead of
just pg_temp; so some commands like CREATE VIEW..AS SELECT FROM temp_table
fail in an ugly way. Maybe the solution is to tell ruleutils that the
temp schema is always visible; or maybe the solution is to tell it that
it's spelled pg_temp instead.
2. I need to complete support for all object types in
getObjectIdentityParts. The ones not implemented cause the generated
DROP commands to fail.
3. Some commands are still not supported by the deparsing code:
1 + WARNING: state: XX000 errm: unimplemented deparse of ALTER TABLE OPTIONS (...)
2 + WARNING: state: XX000 errm: unimplemented deparse of ALTER TABLE RESET
2 + WARNING: state: XX000 errm: unimplemented deparse of ALTER TABLE SET OPTIONS
2 + WARNING: state: XX000 errm: unimplemented deparse of CREATE FOREIGN TABLE
2 + WARNING: state: XX000 errm: unimplemented deparse of CREATE LANGUAGE
3 + WARNING: hash indexes are not WAL-logged and their use is discouraged
3 + WARNING: state: XX000 errm: unimplemented deparse of ALTER TABLE ALTER COLUMN OPTIONS
3 + WARNING: state: XX000 errm: unimplemented deparse of CREATE TABLE AS EXECUTE
4 + WARNING: state: XX000 errm: unimplemented deparse of ALTER TABLE ALTER CONSTRAINT
4 + WARNING: state: XX000 errm: unimplemented deparse of ALTER TABLE TYPE USING
4 + WARNING: state: XX000 errm: unimplemented deparse of ALTER TEXT SEARCH CONFIGURATION
4 + WARNING: state: XX000 errm: unimplemented deparse of ALTER USER MAPPING
5 + WARNING: state: XX000 errm: unimplemented deparse of CREATE OPERATOR CLASS
5 + WARNING: state: XX000 errm: unsupported deparse of ALTER FUNCTION SET
5 + WARNING: state: XX000 errm: unsupported deparse of CREATE SERVER ... OPTIONS
7 + WARNING: state: XX000 errm: unimplemented deparse of ALTER FOREIGN DATA WRAPPER
7 + WARNING: state: XX000 errm: unimplemented deparse of ALTER SERVER
8 + WARNING: state: XX000 errm: unimplemented deparse of ALTER POLICY
9 + WARNING: state: XX000 errm: unimplemented deparse of ALTER TABLE SET
10 + WARNING: state: XX000 errm: unimplemented deparse of CREATE FOREIGN DATA WRAPPER
11 + WARNING: state: XX000 errm: can't recreate text search configuration with mappings
12 + WARNING: state: XX000 errm: unimplemented deparse of CREATE USER MAPPING
14 + WARNING: state: XX000 errm: unimplemented deparse of ALTER OPERATOR FAMILY
I expect most of these are simple to implement. The only one that seems
to present a challenge is ALTER OPERATOR FAMILY: it needs to pass back
the OID of all the added/removed operator class members.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2015-02-15 06:18:46 | Re: parallel mode and parallel contexts |
Previous Message | Peter Eisentraut | 2015-02-15 03:51:44 | forward vs backward slashes in msvc build code |