You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Docs: improve CREATE TABLE ref page's discussion of partition bounds.
Clarify in the syntax synopsis that partition bound values must be
exactly numeric literals or string literals; previously it
said "bound_literal" which was defined nowhere.
Replace confusing --- and, I think, incorrect in detail --- definition
of how range bounds work with a reference to row-wise comparison plus
a concrete example (which I stole from Robert Haas).
Minor copy-editing in the same area.
Discussion: https://postgr.es/m/30475.1496005465@sss.pgh.pa.us
Discussion: https://postgr.es/m/28106.1496041449@sss.pgh.pa.us
<phrase><replaceable class="PARAMETER">index_parameters</replaceable> in <literal>UNIQUE</literal>, <literal>PRIMARY KEY</literal>, and <literal>EXCLUDE</literal> constraints are:</phrase>
93
94
@@ -252,52 +253,60 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI
252
253
<term><literal>PARTITION OF <replaceable class="PARAMETER">parent_table</replaceable> FOR VALUES <replaceable class="PARAMETER">partition_bound_spec</replaceable></literal></term>
253
254
<listitem>
254
255
<para>
255
-
Creates the table as <firstterm>partition</firstterm> of the specified
256
+
Creates the table as a <firstterm>partition</firstterm> of the specified
256
257
parent table.
257
258
</para>
258
259
259
260
<para>
260
-
The partition bound specification must correspond to the partitioning
261
-
method and partition key of the parent table, and must not overlap with
262
-
any existing partition of that parent.
261
+
The <replaceable class="PARAMETER">partition_bound_spec</replaceable>
262
+
must correspond to the partitioning method and partition key of the
263
+
parent table, and must not overlap with any existing partition of that
264
+
parent. The form with <literal>IN</> is used for list partitioning,
265
+
while the form with <literal>FROM</> and <literal>TO</> is used for
266
+
range partitioning.
263
267
</para>
264
268
265
269
<para>
266
-
Each of the values specified in the partition bound specification is
270
+
Each of the values specified in
271
+
the <replaceable class="PARAMETER">partition_bound_spec</> is
267
272
a literal, <literal>NULL</literal>, or <literal>UNBOUNDED</literal>.
268
-
A literal is either a numeric constant or a string constant that is
269
-
coercible to the corresponding partition key column's type.
273
+
Each literal value must be either a numeric constant that is coercible
274
+
to the corresponding partition key column's type, or a string literal
275
+
that is valid input for that type.
276
+
</para>
277
+
278
+
<para>
279
+
When creating a list partition, <literal>NULL</literal> can be
280
+
specified to signify that the partition allows the partition key
281
+
column to be null. However, there cannot be more than one such
282
+
list partition for a given parent table. <literal>NULL</literal>
283
+
cannot be specified for range partitions.
270
284
</para>
271
285
272
286
<para>
273
287
When creating a range partition, the lower bound specified with
274
288
<literal>FROM</literal> is an inclusive bound, whereas the upper
275
289
bound specified with <literal>TO</literal> is an exclusive bound.
276
290
That is, the values specified in the <literal>FROM</literal> list
277
-
are accepted values of the corresponding partition key columns in a
278
-
given partition, whereas those in the <literal>TO</literal> list are
279
-
not. To be precise, this applies only to the first of the partition
280
-
key columns for which the corresponding values in the <literal>FROM</literal>
281
-
and <literal>TO</literal> lists are not equal. All rows in a given
282
-
partition contain the same values for all preceding columns, equal to
283
-
those specified in <literal>FROM</literal> and <literal>TO</literal>
284
-
lists. On the other hand, any subsequent columns are insignificant
285
-
as far as implicit partition constraint is concerned.
291
+
are valid values of the corresponding partition key columns for this
292
+
partition, whereas those in the <literal>TO</literal> list are
293
+
not. Note that this statement must be understood according to the
294
+
rules of row-wise comparison (<xref linkend="row-wise-comparison">).
295
+
For example, given <literal>PARTITION BY RANGE (x,y)</>, a partition
296
+
bound <literal>FROM (1, 2) TO (3, 4)</literal>
297
+
allows <literal>x=1</> with any <literal>y>=2</>,
298
+
<literal>x=2</> with any non-null <literal>y</>,
299
+
and <literal>x=3</> with any <literal>y<4</>.
286
300
</para>
287
301
288
302
<para>
289
-
Specifying <literal>UNBOUNDED</literal> in <literal>FROM</literal>
303
+
Writing <literal>UNBOUNDED</literal> in <literal>FROM</literal>
290
304
signifies <literal>-infinity</literal> as the lower bound of the
291
-
corresponding column, whereas it signifies <literal>+infinity</literal>
292
-
as the upper bound when specified in <literal>TO</literal>.
293
-
</para>
294
-
295
-
<para>
296
-
When creating a list partition, <literal>NULL</literal> can be
297
-
specified to signify that the partition allows the partition key
298
-
column to be null. However, there cannot be more than one such
299
-
list partition for a given parent table. <literal>NULL</literal>
300
-
cannot be specified for range partitions.
305
+
corresponding column, whereas when written in <literal>TO</literal>,
306
+
it signifies <literal>+infinity</literal> as the upper bound.
307
+
All items following an <literal>UNBOUNDED</literal> item within
308
+
a <literal>FROM</literal> or <literal>TO</literal> list must also
309
+
be <literal>UNBOUNDED</literal>.
301
310
</para>
302
311
303
312
<para>
@@ -318,8 +327,9 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI
318
327
<para>
319
328
Rows inserted into a partitioned table will be automatically routed to
320
329
the correct partition. If no suitable partition exists, an error will
321
-
occur. Also, if updating a row in a given partition causes it to move
322
-
to another partition due to the new partition key, an error will occur.
330
+
occur. Also, if updating a row in a given partition would require it
331
+
to move to another partition due to new partition key values, an error
0 commit comments