deparsing utility commands

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

Attachment Content-Type Size
0001-getObjectIdentity-Fix-opclass-opfamily-names.patch text/x-diff 1.8 KB
0002-deparse-core-return-affected-attnum-in-RENAME.patch text/x-diff 5.2 KB
0003-deparse-core-event-triggers-support-GRANT-REVOKE.patch text/x-diff 6.0 KB
0004-deparse-core-event-triggers-support-COMMENT.patch text/x-diff 4.8 KB
0005-deparse-core-have-event-triggers-support-SECURITY-LA.patch text/x-diff 3.6 KB
0006-deparse-core-have-ALTER-TABLE-return-table-OID-and-o.patch text/x-diff 41.5 KB
0007-deparse-infrastructure-needed-for-command-deparsing.patch text/x-diff 69.1 KB
0008-deparse-add-EventTriggerStashCommand-calls-to-Proces.patch text/x-diff 20.0 KB
0009-deparse-Support-CREATE-TYPE-AS.patch text/x-diff 9.5 KB
0010-deparse-Support-CREATE-TYPE-AS-ENUM.patch text/x-diff 1.8 KB
0011-deparse-Support-CREATE-SCHEMA-TABLE-SEQUENCE-INDEX-T.patch text/x-diff 44.5 KB
0012-deparse-Support-CREATE-TYPE-AS-RANGE.patch text/x-diff 4.2 KB
0013-deparse-Support-CREATE-EXTENSION.patch text/x-diff 3.5 KB
0014-deparse-Support-CREATE-RULE.patch text/x-diff 6.8 KB
0015-deparse-Support-ALTER-TYPE-ADD-VALUE-enums.patch text/x-diff 1.9 KB
0016-deparse-Support-for-ALTER-OBJECT-RENAME.patch text/x-diff 17.6 KB
0017-deparse-Support-CREATE-DOMAIN.patch text/x-diff 2.5 KB
0018-deparse-Support-CREATE-FUNCTION.patch text/x-diff 11.9 KB
0019-deparse-Support-ALTER-TABLE.patch text/x-diff 27.8 KB
0020-deparse-Support-CREATE-VIEW.patch text/x-diff 3.2 KB
0021-deparse-Support-CREATE-OPERATOR-FAMILY.patch text/x-diff 2.2 KB
0022-deparse-Support-CREATE-CONVERSION.patch text/x-diff 2.6 KB
0023-deparse-Support-DefineStmt-commands.patch text/x-diff 25.6 KB
0024-deparse-support-ALTER-THING-OWNER-TO.patch text/x-diff 1.5 KB
0025-deparse-Support-ALTER-EXTENSION-UPDATE-TO.patch text/x-diff 2.1 KB
0026-deparse-Support-GRANT-REVOKE.patch text/x-diff 16.8 KB
0027-deparse-Support-ALTER-FUNCTION.patch text/x-diff 3.9 KB
0028-deparse-support-COMMENT-ON.patch text/x-diff 3.5 KB
0029-deparse-support-SECURITY-LABEL.patch text/x-diff 2.4 KB
0030-deparse-support-ALTER-DOMAIN.patch text/x-diff 10.5 KB
0031-deparse-support-ALTER-.-SET-SCHEMA.patch text/x-diff 10.7 KB
0032-deparse-support-ALTER-EXTENSION-ADD-DROP.patch text/x-diff 4.2 KB
0033-deparse-support-CREATE-CAST.patch text/x-diff 3.5 KB
0034-deparse-support-CREATE-TABLE-AS.patch text/x-diff 6.4 KB
0035-deparse-support-CREATE-POLICY.patch text/x-diff 3.8 KB
0036-deparse-support-CREATE-SERVER.patch text/x-diff 2.3 KB
0037-deparse-support-REFRESH-MATERIALIZED-VIEW.patch text/x-diff 1.8 KB
deparse_init.sql application/x-sql 2.5 KB

Responses

Browse pgsql-hackers by date

  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