doc: CREATE FOREIGN TABLE .. PARTITION OF .. DEFAULT

Started by Justin Pryzbyover 3 years ago13 messages
#1Justin Pryzby
pryzby@telsasoft.com

It looks like the docs weren't updated in 6f6b99d13 for v11.

The docs also seem to omit "FOR VALUES" literal.
And don't define partition_bound_spec (which I didn't fix here).

diff --git a/doc/src/sgml/ref/create_foreign_table.sgml b/doc/src/sgml/ref/create_foreign_table.sgml
index b374d8645db..1f1c4a52a2a 100644
--- a/doc/src/sgml/ref/create_foreign_table.sgml
+++ b/doc/src/sgml/ref/create_foreign_table.sgml
@@ -35,7 +35,8 @@ CREATE FOREIGN TABLE [ IF NOT EXISTS ] <replaceable class="parameter">table_name
   { <replaceable class="parameter">column_name</replaceable> [ WITH OPTIONS ] [ <replaceable class="parameter">column_constraint</replaceable> [ ... ] ]
     | <replaceable>table_constraint</replaceable> }
     [, ... ]
-) ] <replaceable class="parameter">partition_bound_spec</replaceable>
+) ]
+  { FOR VALUES <replaceable class="parameter">partition_bound_spec</replaceable> | DEFAULT }
   SERVER <replaceable class="parameter">server_name</replaceable>
 [ OPTIONS ( <replaceable class="parameter">option</replaceable> '<replaceable class="parameter">value</replaceable>' [, ... ] ) ]
#2Robert Haas
robertmhaas@gmail.com
In reply to: Justin Pryzby (#1)
Re: doc: CREATE FOREIGN TABLE .. PARTITION OF .. DEFAULT

On Sat, May 21, 2022 at 9:09 AM Justin Pryzby <pryzby@telsasoft.com> wrote:

It looks like the docs weren't updated in 6f6b99d13 for v11.

In my defense, that commit definitely contained documentation changes.
It updated alter_table.sgml and create_table.sgml. I guess we missed
create_foreign_table.sgml, though.

The docs also seem to omit "FOR VALUES" literal.
And don't define partition_bound_spec (which I didn't fix here).

diff --git a/doc/src/sgml/ref/create_foreign_table.sgml b/doc/src/sgml/ref/create_foreign_table.sgml
index b374d8645db..1f1c4a52a2a 100644
--- a/doc/src/sgml/ref/create_foreign_table.sgml
+++ b/doc/src/sgml/ref/create_foreign_table.sgml
@@ -35,7 +35,8 @@ CREATE FOREIGN TABLE [ IF NOT EXISTS ] <replaceable class="parameter">table_name
{ <replaceable class="parameter">column_name</replaceable> [ WITH OPTIONS ] [ <replaceable class="parameter">column_constraint</replaceable> [ ... ] ]
| <replaceable>table_constraint</replaceable> }
[, ... ]
-) ] <replaceable class="parameter">partition_bound_spec</replaceable>
+) ]
+  { FOR VALUES <replaceable class="parameter">partition_bound_spec</replaceable> | DEFAULT }
SERVER <replaceable class="parameter">server_name</replaceable>
[ OPTIONS ( <replaceable class="parameter">option</replaceable> '<replaceable class="parameter">value</replaceable>' [, ... ] ) ]

OK, makes sense. I guess we need to copy over the definition of
partition_bound_spec from create_table.sgml here as well.

--
Robert Haas
EDB: http://www.enterprisedb.com

#3Amit Langote
amitlangote09@gmail.com
In reply to: Robert Haas (#2)
2 attachment(s)
Re: doc: CREATE FOREIGN TABLE .. PARTITION OF .. DEFAULT

On Wed, May 25, 2022 at 9:44 PM Robert Haas <robertmhaas@gmail.com> wrote:

On Sat, May 21, 2022 at 9:09 AM Justin Pryzby <pryzby@telsasoft.com> wrote:

It looks like the docs weren't updated in 6f6b99d13 for v11.

In my defense, that commit definitely contained documentation changes.
It updated alter_table.sgml and create_table.sgml. I guess we missed
create_foreign_table.sgml, though.

The docs also seem to omit "FOR VALUES" literal.

That would be my mistake.

And don't define partition_bound_spec (which I didn't fix here).

diff --git a/doc/src/sgml/ref/create_foreign_table.sgml b/doc/src/sgml/ref/create_foreign_table.sgml
index b374d8645db..1f1c4a52a2a 100644
--- a/doc/src/sgml/ref/create_foreign_table.sgml
+++ b/doc/src/sgml/ref/create_foreign_table.sgml
@@ -35,7 +35,8 @@ CREATE FOREIGN TABLE [ IF NOT EXISTS ] <replaceable class="parameter">table_name
{ <replaceable class="parameter">column_name</replaceable> [ WITH OPTIONS ] [ <replaceable class="parameter">column_constraint</replaceable> [ ... ] ]
| <replaceable>table_constraint</replaceable> }
[, ... ]
-) ] <replaceable class="parameter">partition_bound_spec</replaceable>
+) ]
+  { FOR VALUES <replaceable class="parameter">partition_bound_spec</replaceable> | DEFAULT }
SERVER <replaceable class="parameter">server_name</replaceable>
[ OPTIONS ( <replaceable class="parameter">option</replaceable> '<replaceable class="parameter">value</replaceable>' [, ... ] ) ]

OK, makes sense. I guess we need to copy over the definition of
partition_bound_spec from create_table.sgml here as well.

Yes. a2a2205761 did that for alter_table.sgml and we evidently missed
including create_foreign_table.sgml in that discussion.

Attached 2 patches -- one for PG 11 onwards and another for PG 10.

--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com

Attachments:

PG10-missing-partition_bound_spec.patchapplication/octet-stream; name=PG10-missing-partition_bound_spec.patchDownload
diff --git a/doc/src/sgml/ref/create_foreign_table.sgml b/doc/src/sgml/ref/create_foreign_table.sgml
index 8e9caabfe7..69bbee044a 100644
--- a/doc/src/sgml/ref/create_foreign_table.sgml
+++ b/doc/src/sgml/ref/create_foreign_table.sgml
@@ -35,7 +35,8 @@ CREATE FOREIGN TABLE [ IF NOT EXISTS ] <replaceable class="PARAMETER">table_name
   { <replaceable class="PARAMETER">column_name</replaceable> [ WITH OPTIONS ] [ <replaceable class="PARAMETER">column_constraint</replaceable> [ ... ] ]
     | <replaceable>table_constraint</replaceable> }
     [, ... ]
-) ] <replaceable class="PARAMETER">partition_bound_spec</replaceable>
+) ]
+  FOR VALUES <replaceable class="parameter">partition_bound_spec</replaceable>
   SERVER <replaceable class="parameter">server_name</replaceable>
 [ OPTIONS ( <replaceable class="PARAMETER">option</replaceable> '<replaceable class="PARAMETER">value</replaceable>' [, ... ] ) ]
 
@@ -51,6 +52,12 @@ CREATE FOREIGN TABLE [ IF NOT EXISTS ] <replaceable class="PARAMETER">table_name
 
 [ CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ]
 CHECK ( <replaceable class="PARAMETER">expression</replaceable> ) [ NO INHERIT ]
+
+<phrase>and <replaceable class="PARAMETER">partition_bound_spec</replaceable> is:</phrase>
+
+IN ( { <replaceable class="PARAMETER">numeric_literal</replaceable> | <replaceable class="PARAMETER">string_literal</replaceable> | TRUE | FALSE | NULL } [, ...] ) |
+FROM ( { <replaceable class="PARAMETER">numeric_literal</replaceable> | <replaceable class="PARAMETER">string_literal</replaceable> | TRUE | FALSE | MINVALUE | MAXVALUE } [, ...] )
+  TO ( { <replaceable class="PARAMETER">numeric_literal</replaceable> | <replaceable class="PARAMETER">string_literal</replaceable> | TRUE | FALSE | MINVALUE | MAXVALUE } [, ...] )
 </synopsis>
  </refsynopsisdiv>
 
missing-partition_bound_spec.patchapplication/octet-stream; name=missing-partition_bound_spec.patchDownload
diff --git a/doc/src/sgml/ref/create_foreign_table.sgml b/doc/src/sgml/ref/create_foreign_table.sgml
index eabeaf36f5..c9b167edf9 100644
--- a/doc/src/sgml/ref/create_foreign_table.sgml
+++ b/doc/src/sgml/ref/create_foreign_table.sgml
@@ -35,7 +35,8 @@ CREATE FOREIGN TABLE [ IF NOT EXISTS ] <replaceable class="parameter">table_name
   { <replaceable class="parameter">column_name</replaceable> [ WITH OPTIONS ] [ <replaceable class="parameter">column_constraint</replaceable> [ ... ] ]
     | <replaceable>table_constraint</replaceable> }
     [, ... ]
-) ] <replaceable class="parameter">partition_bound_spec</replaceable>
+) ]
+{ FOR VALUES <replaceable class="parameter">partition_bound_spec</replaceable> | DEFAULT }
   SERVER <replaceable class="parameter">server_name</replaceable>
 [ OPTIONS ( <replaceable class="parameter">option</replaceable> '<replaceable class="parameter">value</replaceable>' [, ... ] ) ]
 
@@ -52,6 +53,13 @@ CREATE FOREIGN TABLE [ IF NOT EXISTS ] <replaceable class="parameter">table_name
 
 [ CONSTRAINT <replaceable class="parameter">constraint_name</replaceable> ]
 CHECK ( <replaceable class="parameter">expression</replaceable> ) [ NO INHERIT ]
+
+<phrase>and <replaceable class="parameter">partition_bound_spec</replaceable> is:</phrase>
+
+IN ( <replaceable class="parameter">partition_bound_expr</replaceable> [, ...] ) |
+FROM ( { <replaceable class="parameter">partition_bound_expr</replaceable> | MINVALUE | MAXVALUE } [, ...] )
+  TO ( { <replaceable class="parameter">partition_bound_expr</replaceable> | MINVALUE | MAXVALUE } [, ...] ) |
+WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REMAINDER <replaceable class="parameter">numeric_literal</replaceable> )
 </synopsis>
  </refsynopsisdiv>
 
#4Robert Haas
robertmhaas@gmail.com
In reply to: Amit Langote (#3)
Re: doc: CREATE FOREIGN TABLE .. PARTITION OF .. DEFAULT

On Thu, May 26, 2022 at 1:50 AM Amit Langote <amitlangote09@gmail.com> wrote:

Attached 2 patches -- one for PG 11 onwards and another for PG 10.

Committed, except I adjusted the v11 version so that the CREATE
FOREIGN TABLE documentation would match the CREATE TABLE documentation
in that branch.

--
Robert Haas
EDB: http://www.enterprisedb.com

#5Amit Langote
amitlangote09@gmail.com
In reply to: Robert Haas (#4)
Re: doc: CREATE FOREIGN TABLE .. PARTITION OF .. DEFAULT

On Fri, May 27, 2022 at 1:58 AM Robert Haas <robertmhaas@gmail.com> wrote:

On Thu, May 26, 2022 at 1:50 AM Amit Langote <amitlangote09@gmail.com> wrote:

Attached 2 patches -- one for PG 11 onwards and another for PG 10.

Committed, except I adjusted the v11 version so that the CREATE
FOREIGN TABLE documentation would match the CREATE TABLE documentation
in that branch.

Thank you.

--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com

#6Etsuro Fujita
etsuro.fujita@gmail.com
In reply to: Robert Haas (#4)
1 attachment(s)
Re: doc: CREATE FOREIGN TABLE .. PARTITION OF .. DEFAULT

On Fri, May 27, 2022 at 1:58 AM Robert Haas <robertmhaas@gmail.com> wrote:

Committed, except I adjusted the v11 version so that the CREATE
FOREIGN TABLE documentation would match the CREATE TABLE documentation
in that branch.

I think we should fix the syntax synopsis in the Parameters section
of the CREATE FOREIGN TABLE reference page as well. Attached is a
patch for that.

Sorry for being late for this.

Best regards,
Etsuro Fujita

Attachments:

Further-fix-CREATE-FOREIGN-TABLE-synopsis.patchapplication/octet-stream; name=Further-fix-CREATE-FOREIGN-TABLE-synopsis.patchDownload
diff --git a/doc/src/sgml/ref/create_foreign_table.sgml b/doc/src/sgml/ref/create_foreign_table.sgml
index 6b208c4848..ae1f94b9de 100644
--- a/doc/src/sgml/ref/create_foreign_table.sgml
+++ b/doc/src/sgml/ref/create_foreign_table.sgml
@@ -173,7 +173,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
    </varlistentry>
 
    <varlistentry>
-    <term><literal>PARTITION OF <replaceable>parent_table</replaceable> FOR VALUES <replaceable class="parameter">partition_bound_spec</replaceable></literal></term>
+    <term><literal>PARTITION OF <replaceable>parent_table</replaceable> { FOR VALUES <replaceable class="parameter">partition_bound_spec</replaceable> | DEFAULT }</literal></term>
     <listitem>
      <para>
       This form can be used to create the foreign table as partition of
#7Amit Langote
amitlangote09@gmail.com
In reply to: Etsuro Fujita (#6)
1 attachment(s)
Re: doc: CREATE FOREIGN TABLE .. PARTITION OF .. DEFAULT

On Fri, May 27, 2022 at 7:15 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:

On Fri, May 27, 2022 at 1:58 AM Robert Haas <robertmhaas@gmail.com> wrote:

Committed, except I adjusted the v11 version so that the CREATE
FOREIGN TABLE documentation would match the CREATE TABLE documentation
in that branch.

I think we should fix the syntax synopsis in the Parameters section
of the CREATE FOREIGN TABLE reference page as well.

Oops, good catch.

Attached is a patch for that.

Thank you.

I think we should also rewrite the description to match the CREATE
TABLE's text, as in the attached updated patch.

--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com

Attachments:

Further-fix-CREATE-FOREIGN-TABLE-synopsis_v2.patchapplication/octet-stream; name=Further-fix-CREATE-FOREIGN-TABLE-synopsis_v2.patchDownload
diff --git a/doc/src/sgml/ref/create_foreign_table.sgml b/doc/src/sgml/ref/create_foreign_table.sgml
index 6b208c4848..4cd5348a4e 100644
--- a/doc/src/sgml/ref/create_foreign_table.sgml
+++ b/doc/src/sgml/ref/create_foreign_table.sgml
@@ -173,11 +173,13 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
    </varlistentry>
 
    <varlistentry>
-    <term><literal>PARTITION OF <replaceable>parent_table</replaceable> FOR VALUES <replaceable class="parameter">partition_bound_spec</replaceable></literal></term>
+    <term><literal>PARTITION OF <replaceable>parent_table</replaceable> { FOR VALUES <replaceable class="parameter">partition_bound_spec</replaceable> | DEFAULT }</literal></term>
     <listitem>
      <para>
       This form can be used to create the foreign table as partition of
-      the given parent table with specified partition bound values.
+      the given parent table.  The table can be created either as a partition
+      for specific values using <literal>FOR VALUES</literal> or as a default
+      partition using <literal>DEFAULT</literal>.
       See the similar form of
       <link linkend="sql-createtable"><command>CREATE TABLE</command></link> for more details.
       Note that it is currently not allowed to create the foreign table as a
#8Etsuro Fujita
etsuro.fujita@gmail.com
In reply to: Amit Langote (#7)
Re: doc: CREATE FOREIGN TABLE .. PARTITION OF .. DEFAULT

Amit-san,

On Fri, May 27, 2022 at 9:22 PM Amit Langote <amitlangote09@gmail.com> wrote:

On Fri, May 27, 2022 at 7:15 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:

Attached is a patch for that.

I think we should also rewrite the description to match the CREATE
TABLE's text, as in the attached updated patch.

Actually, I thought the description would be OK as-is, because it says
“See the similar form of CREATE TABLE for more details”, but I agree
with you; it’s much better to also rewrite the description as you
suggest.

I’ll commit the patch unless Robert wants to.

Thanks for the review and patch!

Best regards,
Etsuro Fujita

#9Robert Haas
robertmhaas@gmail.com
In reply to: Etsuro Fujita (#8)
Re: doc: CREATE FOREIGN TABLE .. PARTITION OF .. DEFAULT

On Mon, May 30, 2022 at 2:27 AM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:

On Fri, May 27, 2022 at 9:22 PM Amit Langote <amitlangote09@gmail.com> wrote:

On Fri, May 27, 2022 at 7:15 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:

Attached is a patch for that.

I think we should also rewrite the description to match the CREATE
TABLE's text, as in the attached updated patch.

Actually, I thought the description would be OK as-is, because it says
“See the similar form of CREATE TABLE for more details”, but I agree
with you; it’s much better to also rewrite the description as you
suggest.

I would probably just update the synopsis. It's not very hard to
figure out what's likely to happen even without clicking through the
link, so it seems like it's just being long-winded to duplicate the
stuff here. But I don't care much if you feel otherwise.

I’ll commit the patch unless Robert wants to.

Please go ahead.

--
Robert Haas
EDB: http://www.enterprisedb.com

#10Etsuro Fujita
etsuro.fujita@gmail.com
In reply to: Robert Haas (#9)
Re: doc: CREATE FOREIGN TABLE .. PARTITION OF .. DEFAULT

On Tue, May 31, 2022 at 9:35 PM Robert Haas <robertmhaas@gmail.com> wrote:

On Mon, May 30, 2022 at 2:27 AM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:

On Fri, May 27, 2022 at 9:22 PM Amit Langote <amitlangote09@gmail.com> wrote:

On Fri, May 27, 2022 at 7:15 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:

Attached is a patch for that.

I think we should also rewrite the description to match the CREATE
TABLE's text, as in the attached updated patch.

Actually, I thought the description would be OK as-is, because it says
“See the similar form of CREATE TABLE for more details”, but I agree
with you; it’s much better to also rewrite the description as you
suggest.

I would probably just update the synopsis. It's not very hard to
figure out what's likely to happen even without clicking through the
link, so it seems like it's just being long-winded to duplicate the
stuff here. But I don't care much if you feel otherwise.

It looks like there are pros and cons. I think it’s a matter of
preference, though.

I thought it would be an improvement, but I agree that we can live
without it, so I changed my mind; I'll go with my version. I think we
could revisit this later.

I’ll commit the patch unless Robert wants to.

Please go ahead.

OK

Thanks!

Best regards,
Etsuro Fujita

#11Amit Langote
amitlangote09@gmail.com
In reply to: Etsuro Fujita (#10)
Re: doc: CREATE FOREIGN TABLE .. PARTITION OF .. DEFAULT

On Wed, Jun 1, 2022 at 6:15 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:

On Tue, May 31, 2022 at 9:35 PM Robert Haas <robertmhaas@gmail.com> wrote:

I would probably just update the synopsis. It's not very hard to
figure out what's likely to happen even without clicking through the
link, so it seems like it's just being long-winded to duplicate the
stuff here. But I don't care much if you feel otherwise.

It looks like there are pros and cons. I think it’s a matter of
preference, though.

I thought it would be an improvement, but I agree that we can live
without it, so I changed my mind; I'll go with my version. I think we
could revisit this later.

I guess I'm fine with leaving the text as-is, though slightly bothered
by leaving the phrase "partition of the given parent table with
specified partition bound values" to also cover the DEFAULT partition
case.

--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com

#12Etsuro Fujita
etsuro.fujita@gmail.com
In reply to: Amit Langote (#11)
Re: doc: CREATE FOREIGN TABLE .. PARTITION OF .. DEFAULT

On Thu, Jun 2, 2022 at 10:23 AM Amit Langote <amitlangote09@gmail.com> wrote:

On Wed, Jun 1, 2022 at 6:15 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:

On Tue, May 31, 2022 at 9:35 PM Robert Haas <robertmhaas@gmail.com> wrote:

I would probably just update the synopsis. It's not very hard to
figure out what's likely to happen even without clicking through the
link, so it seems like it's just being long-winded to duplicate the
stuff here. But I don't care much if you feel otherwise.

It looks like there are pros and cons. I think it’s a matter of
preference, though.

I thought it would be an improvement, but I agree that we can live
without it, so I changed my mind; I'll go with my version. I think we
could revisit this later.

I guess I'm fine with leaving the text as-is, though slightly bothered
by leaving the phrase "partition of the given parent table with
specified partition bound values" to also cover the DEFAULT partition
case.

I think we should discuss this separately, maybe as a HEAD-only patch,
so I pushed my version, leaving the description as-is.

Best regards,
Etsuro Fujita

#13Amit Langote
amitlangote09@gmail.com
In reply to: Etsuro Fujita (#12)
Re: doc: CREATE FOREIGN TABLE .. PARTITION OF .. DEFAULT

On Thu, Jun 2, 2022 at 6:14 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:

On Thu, Jun 2, 2022 at 10:23 AM Amit Langote <amitlangote09@gmail.com> wrote:

On Wed, Jun 1, 2022 at 6:15 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:

On Tue, May 31, 2022 at 9:35 PM Robert Haas <robertmhaas@gmail.com> wrote:

I would probably just update the synopsis. It's not very hard to
figure out what's likely to happen even without clicking through the
link, so it seems like it's just being long-winded to duplicate the
stuff here. But I don't care much if you feel otherwise.

It looks like there are pros and cons. I think it’s a matter of
preference, though.

I thought it would be an improvement, but I agree that we can live
without it, so I changed my mind; I'll go with my version. I think we
could revisit this later.

I guess I'm fine with leaving the text as-is, though slightly bothered
by leaving the phrase "partition of the given parent table with
specified partition bound values" to also cover the DEFAULT partition
case.

I think we should discuss this separately, maybe as a HEAD-only patch,
so I pushed my version, leaving the description as-is.

No problem, thanks for the fix.

--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com