Alter table documentation page (again)
Hi,
I was trying to answer a former colleague question about postgres' default
behaviour when deleting or updating when she pointed out that Postgres
alter table documentation page used twice the 'action' keywords for two
different things.
And indeed she is right :
- it's used to described any action actionable with ALTER TABLE statement
- and also to reference action taken on update or delete
Here are my thoughts about that conflict :
- We should keep the action keyword for on update or on delete action as
it's what's done on the CREATE TABLE documentation page.
- Option 1: We could either categorized the "actions" we can do with ALTER
TABLE (as column_action, trigger_action, constraint_action, rule_action,
other_action), but I'm not a big fan of "other_action" and I can't think of
another name
- Option 2: Or we could just rename the first action as "alter-table_action"
Any thought ? Which option do you prefer ? I can write the patch, but I'd
like to know what you think about that.
Anyway, thanks to Brigitte Blanc-Lafay tohave pointed this out! :-)
Cheers,
Lætitia
--
*Think! Do you really need to print this email ? *
*There is no Planet B.*
On 2018-Dec-06, L�titia Avrot wrote:
Any thought ? Which option do you prefer ? I can write the patch, but I'd
like to know what you think about that.
I'd rename the action in ON DELETE/UPDATE to referential_action, both in
alter_table and in create_table (the latter just for consistency).
--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
I'd rename the action in ON DELETE/UPDATE to referential_action, both in
alter_table and in create_table (the latter just for consistency).
I love that "option 3" ! So clever!
On 2018-Dec-06, L�titia Avrot wrote:
I'd rename the action in ON DELETE/UPDATE to referential_action, both in
alter_table and in create_table (the latter just for consistency).I love that "option 3" ! So clever!
Thanks :-) I checked the SQL standard after sending that email, and
indeed it calls those elements <referential action>. Go figure.
--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Hi all,
Here's the patch.
The patch should apply to MASTER. I built and tested it successfully on my
laptop.
I'll add it to January's commitfest.
Cheers,
Lætitia
Attachments:
referential_action_alter_or_create_table_v1.patchtext/x-patch; charset=US-ASCII; name=referential_action_alter_or_create_table_v1.patchDownload
diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml
index be1647937d..c49a20fb93 100644
--- a/doc/src/sgml/ref/alter_table.sgml
+++ b/doc/src/sgml/ref/alter_table.sgml
@@ -102,7 +102,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
UNIQUE <replaceable class="parameter">index_parameters</replaceable> |
PRIMARY KEY <replaceable class="parameter">index_parameters</replaceable> |
REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ]
- [ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ] }
+ [ ON DELETE <replaceable class="parameter">referential_action</replaceable> ] [ ON UPDATE <replaceable class="parameter">referential_action</replaceable> ] }
[ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
<phrase>and <replaceable class="parameter">table_constraint</replaceable> is:</phrase>
@@ -113,7 +113,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
PRIMARY KEY ( <replaceable class="parameter">column_name</replaceable> [, ... ] ) <replaceable class="parameter">index_parameters</replaceable> |
EXCLUDE [ USING <replaceable class="parameter">index_method</replaceable> ] ( <replaceable class="parameter">exclude_element</replaceable> WITH <replaceable class="parameter">operator</replaceable> [, ... ] ) <replaceable class="parameter">index_parameters</replaceable> [ WHERE ( <replaceable class="parameter">predicate</replaceable> ) ] |
FOREIGN KEY ( <replaceable class="parameter">column_name</replaceable> [, ... ] ) REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> [, ... ] ) ]
- [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ] }
+ [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE <replaceable class="parameter">referential_action</replaceable> ] [ ON UPDATE <replaceable class="parameter">referential_action</replaceable> ] }
[ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
<phrase>and <replaceable class="parameter">table_constraint_using_index</replaceable> is:</phrase>
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index d3e33132f3..d01dd4c913 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -66,7 +66,7 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI
UNIQUE <replaceable class="parameter">index_parameters</replaceable> |
PRIMARY KEY <replaceable class="parameter">index_parameters</replaceable> |
REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ]
- [ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ] }
+ [ ON DELETE <replaceable class="parameter">referential_action</replaceable> ] [ ON UPDATE <replaceable class="parameter">referential_action</replaceable> ] }
[ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
<phrase>and <replaceable class="parameter">table_constraint</replaceable> is:</phrase>
@@ -77,7 +77,8 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI
PRIMARY KEY ( <replaceable class="parameter">column_name</replaceable> [, ... ] ) <replaceable class="parameter">index_parameters</replaceable> |
EXCLUDE [ USING <replaceable class="parameter">index_method</replaceable> ] ( <replaceable class="parameter">exclude_element</replaceable> WITH <replaceable class="parameter">operator</replaceable> [, ... ] ) <replaceable class="parameter">index_parameters</replaceable> [ WHERE ( <replaceable class="parameter">predicate</replaceable> ) ] |
FOREIGN KEY ( <replaceable class="parameter">column_name</replaceable> [, ... ] ) REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> [, ... ] ) ]
- [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ] }
+ [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE <replaceable
+class="parameter">referential_action</replaceable> ] [ ON UPDATE <replaceable class="parameter">referential_action</replaceable> ] }
[ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
<phrase>and <replaceable class="parameter">like_option</replaceable> is:</phrase>
@@ -969,13 +970,13 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
</varlistentry>
<varlistentry>
- <term><literal>REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> ) ] [ MATCH <replaceable class="parameter">matchtype</replaceable> ] [ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ]</literal> (column constraint)</term>
+ <term><literal>REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> ) ] [ MATCH <replaceable class="parameter">matchtype</replaceable> ] [ ON DELETE <replaceable class="parameter">referential_action</replaceable> ] [ ON UPDATE <replaceable class="parameter">referential_action</replaceable> ]</literal> (column constraint)</term>
<term><literal>FOREIGN KEY ( <replaceable class="parameter">column_name</replaceable> [, ... ] )
REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> [, ... ] ) ]
[ MATCH <replaceable class="parameter">matchtype</replaceable> ]
- [ ON DELETE <replaceable class="parameter">action</replaceable> ]
- [ ON UPDATE <replaceable class="parameter">action</replaceable> ]</literal>
+ [ ON DELETE <replaceable class="parameter">referential_action</replaceable> ]
+ [ ON UPDATE <replaceable class="parameter">referential_action</replaceable> ]</literal>
(table constraint)</term>
<listitem>
On Fri, Dec 07, 2018 at 07:48:39PM +0100, Lætitia Avrot wrote:
Here's the patch.
The patch should apply to MASTER. I built and tested it successfully on my
laptop.I'll add it to January's commitfest.
What's proposed here looks good to me, and all the grounds are
covered, so I am switching the patch as ready for committer.
Álvaro, perhaps you would prefer committing it yourself?
--
Michael
On Wed, Dec 26, 2018 at 01:46:48PM +0900, Michael Paquier wrote:
What's proposed here looks good to me, and all the grounds are
covered, so I am switching the patch as ready for committer.
And committed, mentioning on the way Brigitte for the report.
--
Michael
On 2018-Dec-28, Michael Paquier wrote:
On Wed, Dec 26, 2018 at 01:46:48PM +0900, Michael Paquier wrote:
What's proposed here looks good to me, and all the grounds are
covered, so I am switching the patch as ready for committer.And committed, mentioning on the way Brigitte for the report.
Thanks, I was not paying attention here.
--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services