Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9dfcac8

Browse filesBrowse files
committed
Grammar fixes for split/merge partitions code
The fixes relate to comments, error messages, and corresponding expected output of regression tests. Discussion: https://postgr.es/m/CAMbWs49DDsknxyoycBqiE72VxzL_sYHF6zqL8dSeNehKPJhkKg%40mail.gmail.com Discussion: https://postgr.es/m/86bfd241-a58c-479a-9a72-2c67a02becf8%40postgrespro.ru Discussion: https://postgr.es/m/CAHewXNkGMPU50QG7V6Q60JGFORfo8LfYO1_GCkCa0VWbmB-fEw%40mail.gmail.com Author: Richard Guo, Dmitry Koval, Tender Wang
1 parent c370910 commit 9dfcac8
Copy full SHA for 9dfcac8

File tree

10 files changed

+104
-100
lines changed
Filter options

10 files changed

+104
-100
lines changed

‎doc/src/sgml/ddl.sgml

Copy file name to clipboardExpand all lines: doc/src/sgml/ddl.sgml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4387,7 +4387,7 @@ ALTER INDEX measurement_city_id_logdate_key
43874387
a single partition using the
43884388
<link linkend="sql-altertable-merge-partitions"><command>ALTER TABLE ... MERGE PARTITIONS</command></link>.
43894389
This feature simplifies the management of partitioned tables by allowing
4390-
administrators to combine partitions that are no longer needed as
4390+
users to combine partitions that are no longer needed as
43914391
separate entities. It's important to note that this operation is not
43924392
supported for hash-partitioned tables and acquires an
43934393
<literal>ACCESS EXCLUSIVE</literal> lock, which could impact high-load

‎doc/src/sgml/ref/alter_table.sgml

Copy file name to clipboardExpand all lines: doc/src/sgml/ref/alter_table.sgml
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
11751175
<itemizedlist>
11761176
<listitem>
11771177
<para>
1178-
For range-partitioned tables is necessary that the ranges
1178+
For range-partitioned tables it is necessary that the ranges
11791179
of the partitions <replaceable class="parameter">partition_name1</replaceable>,
11801180
<replaceable class="parameter">partition_name2</replaceable> [, ...] can
11811181
be merged into one range without spaces and overlaps (otherwise an error
@@ -1185,10 +1185,10 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
11851185
</listitem>
11861186
<listitem>
11871187
<para>
1188-
For list-partitioned tables the values lists of all partitions
1188+
For list-partitioned tables the value lists of all partitions
11891189
<replaceable class="parameter">partition_name1</replaceable>,
11901190
<replaceable class="parameter">partition_name2</replaceable> [, ...] are
1191-
combined and form a list of values of partition
1191+
combined and form the list of values of partition
11921192
<replaceable class="parameter">partition_name</replaceable>.
11931193
</para>
11941194
</listitem>

‎src/backend/commands/tablecmds.c

Copy file name to clipboardExpand all lines: src/backend/commands/tablecmds.c
+12-9Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20875,7 +20875,7 @@ GetAttributeStorage(Oid atttypid, const char *storagemode)
2087520875
}
2087620876

2087720877
/*
20878-
* Struct with context of new partition for insert rows from splited partition
20878+
* Struct with context of new partition for inserting rows from split partition
2087920879
*/
2088020880
typedef struct SplitPartitionContext
2088120881
{
@@ -20932,7 +20932,7 @@ deleteSplitPartitionContext(SplitPartitionContext *pc, int ti_options)
2093220932
*
2093320933
* New partitions description:
2093420934
* partlist: list of pointers to SinglePartitionSpec structures.
20935-
* newPartRels: list of Relation's.
20935+
* newPartRels: list of Relations.
2093620936
* defaultPartOid: oid of DEFAULT partition, for table rel.
2093720937
*/
2093820938
static void
@@ -21017,7 +21017,7 @@ moveSplitTableRows(Relation rel, Relation splitRel, List *partlist, List *newPar
2101721017

2101821018
/*
2101921019
* Map computing for moving attributes of split partition to new partition
21020-
* (for first new partition but other new partitions can use the same
21020+
* (for first new partition, but other new partitions can use the same
2102121021
* map).
2102221022
*/
2102321023
pc = (SplitPartitionContext *) lfirst(list_head(partContexts));
@@ -21071,7 +21071,7 @@ moveSplitTableRows(Relation rel, Relation splitRel, List *partlist, List *newPar
2107121071

2107221072
if (tuple_map)
2107321073
{
21074-
/* Need to use map for copy attributes. */
21074+
/* Need to use map to copy attributes. */
2107521075
insertslot = execute_attr_map_slot(tuple_map->attrMap, srcslot, pc->dstslot);
2107621076
}
2107721077
else
@@ -21226,8 +21226,8 @@ ATExecSplitPartition(List **wqueue, AlteredTableInfo *tab, Relation rel,
2122621226
RangeVarGetAndCheckCreationNamespace(sps->name, NoLock, NULL);
2122721227

2122821228
/*
21229-
* This would fail later on anyway, if the relation already exists.
21230-
* But by catching it here we can emit a nicer error message.
21229+
* This would fail later on anyway if the relation already exists. But
21230+
* by catching it here we can emit a nicer error message.
2123121231
*/
2123221232
existing_relid = get_relname_relid(relname, namespaceId);
2123321233
if (existing_relid == splitRelOid && !isSameName)
@@ -21293,7 +21293,10 @@ ATExecSplitPartition(List **wqueue, AlteredTableInfo *tab, Relation rel,
2129321293
SinglePartitionSpec *sps = (SinglePartitionSpec *) lfirst(listptr);
2129421294
Relation newPartRel = (Relation) lfirst(listptr2);
2129521295

21296-
/* wqueue = NULL: verification for each cloned constraint is not need. */
21296+
/*
21297+
* wqueue = NULL: verification for each cloned constraint is not
21298+
* needed.
21299+
*/
2129721300
attachPartitionTable(NULL, rel, newPartRel, sps->bound);
2129821301
/* Keep the lock until commit. */
2129921302
table_close(newPartRel, NoLock);
@@ -21366,7 +21369,7 @@ moveMergedTablesRows(Relation rel, List *mergingPartitionsList,
2136621369

2136721370
if (tuple_map)
2136821371
{
21369-
/* Need to use map for copy attributes. */
21372+
/* Need to use map to copy attributes. */
2137021373
insertslot = execute_attr_map_slot(tuple_map->attrMap, srcslot, dstslot);
2137121374
}
2137221375
else
@@ -21465,7 +21468,7 @@ ATExecMergePartitions(List **wqueue, AlteredTableInfo *tab, Relation rel,
2146521468
/* Create table for new partition, use partitioned table as model. */
2146621469
if (isSameName)
2146721470
{
21468-
/* Create partition table with generated temparary name. */
21471+
/* Create partition table with generated temporary name. */
2146921472
sprintf(tmpRelName, "merge-%u-%X-tmp", RelationGetRelid(rel), MyProcPid);
2147021473
mergePartName = makeRangeVar(get_namespace_name(RelationGetNamespace(rel)),
2147121474
tmpRelName, -1);

‎src/backend/parser/parse_utilcmd.c

Copy file name to clipboardExpand all lines: src/backend/parser/parse_utilcmd.c
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3492,7 +3492,7 @@ transformPartitionCmdForSplit(CreateStmtContext *cxt, PartitionCmd *partcmd)
34923492
* transformPartitionCmdForMerge
34933493
* Analyze the ALTER TABLLE ... MERGE PARTITIONS command
34943494
*
3495-
* Does simple checks for merged partitions. Calculates bound of result
3495+
* Does simple checks for merged partitions. Calculates bound of resulting
34963496
* partition.
34973497
*/
34983498
static void
@@ -3537,7 +3537,7 @@ transformPartitionCmdForMerge(CreateStmtContext *cxt, PartitionCmd *partcmd)
35373537
if (equal(name, name2))
35383538
ereport(ERROR,
35393539
(errcode(ERRCODE_DUPLICATE_TABLE),
3540-
errmsg("partition with name \"%s\" already used", name->relname)),
3540+
errmsg("partition with name \"%s\" is already used", name->relname)),
35413541
parser_errposition(cxt->pstate, name2->location));
35423542
}
35433543

@@ -3551,7 +3551,7 @@ transformPartitionCmdForMerge(CreateStmtContext *cxt, PartitionCmd *partcmd)
35513551
partOids = lappend_oid(partOids, partOid);
35523552
}
35533553

3554-
/* Allocate bound of result partition. */
3554+
/* Allocate bound of resulting partition. */
35553555
Assert(partcmd->bound == NULL);
35563556
partcmd->bound = makeNode(PartitionBoundSpec);
35573557

‎src/backend/partitioning/partbounds.c

Copy file name to clipboardExpand all lines: src/backend/partitioning/partbounds.c
+18-17Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3214,8 +3214,9 @@ check_new_partition_bound(char *relname, Relation parent,
32143214
PartitionRangeDatum *datum;
32153215

32163216
/*
3217-
* Point to problematic key in the lower datums list;
3218-
* if we have equality, point to the first one.
3217+
* Point to problematic key in the list of lower
3218+
* datums; if we have equality, point to the first
3219+
* one.
32193220
*/
32203221
datum = cmpval == 0 ? linitial(spec->lowerdatums) :
32213222
list_nth(spec->lowerdatums, abs(cmpval) - 1);
@@ -4986,10 +4987,10 @@ satisfies_hash_partition(PG_FUNCTION_ARGS)
49864987
* This is a helper function for check_partitions_for_split() and
49874988
* calculate_partition_bound_for_merge().
49884989
* This function compares upper bound of first_bound and lower bound of
4989-
* second_bound. These bounds should be equal except case
4990+
* second_bound. These bounds should be equal except when
49904991
* "defaultPart == true" (this means that one of split partitions is DEFAULT).
49914992
* In this case upper bound of first_bound can be less than lower bound of
4992-
* second_bound because space between of these bounds will be included in
4993+
* second_bound because space between these bounds will be included in
49934994
* DEFAULT partition.
49944995
*
49954996
* parent: partitioned table
@@ -4998,7 +4999,7 @@ satisfies_hash_partition(PG_FUNCTION_ARGS)
49984999
* second_name: name of second partition
49995000
* second_bound: bound of second partition
50005001
* defaultPart: true if one of split partitions is DEFAULT
5001-
* pstate: pointer to ParseState struct for determine error position
5002+
* pstate: pointer to ParseState struct for determining error position
50025003
*/
50035004
static void
50045005
check_two_partitions_bounds_range(Relation parent,
@@ -5020,8 +5021,8 @@ check_two_partitions_bounds_range(Relation parent,
50205021
second_lower = make_one_partition_rbound(key, -1, second_bound->lowerdatums, true);
50215022

50225023
/*
5023-
* lower1=false (the second to last argument) for correct comparison lower
5024-
* and upper bounds.
5024+
* lower1=false (the second to last argument) for correct comparison of
5025+
* lower and upper bounds.
50255026
*/
50265027
cmpval = partition_rbound_cmp(key->partnatts,
50275028
key->partsupfunc,
@@ -5140,7 +5141,7 @@ get_partition_bound_spec(Oid partOid, RangeVar *name)
51405141
*
51415142
* (function for BY RANGE partitioning)
51425143
*
5143-
* Checks that bounds of new partition "spec" is inside bounds of split
5144+
* Checks that bounds of new partition "spec" are inside bounds of split
51445145
* partition (with Oid splitPartOid). If first=true (this means that "spec" is
51455146
* the first of new partitions) then lower bound of "spec" should be equal (or
51465147
* greater than or equal in case defaultPart=true) to lower bound of split
@@ -5274,7 +5275,7 @@ check_partition_bounds_for_split_range(Relation parent,
52745275
*
52755276
* (function for BY LIST partitioning)
52765277
*
5277-
* Checks that bounds of new partition is inside bounds of split partition
5278+
* Checks that bounds of new partition are inside bounds of split partition
52785279
* (with Oid splitPartOid).
52795280
*
52805281
* parent: partitioned table
@@ -5445,8 +5446,8 @@ check_parent_values_in_new_partitions(Relation parent,
54455446
Assert(key->strategy == PARTITION_STRATEGY_LIST);
54465447

54475448
/*
5448-
* Special processing for NULL value. Search NULL-value if it contains
5449-
* split partition (partOid).
5449+
* Special processing for NULL value. Search NULL value if the split
5450+
* partition (partOid) contains it.
54505451
*/
54515452
if (partition_bound_accepts_nulls(boundinfo) &&
54525453
partdesc->oids[boundinfo->null_index] == partOid)
@@ -5461,7 +5462,7 @@ check_parent_values_in_new_partitions(Relation parent,
54615462

54625463
/*
54635464
* Search all values of split partition with partOid in PartitionDesc of
5464-
* partitionde table.
5465+
* partitioned table.
54655466
*/
54665467
for (i = 0; i < boundinfo->ndatums; i++)
54675468
{
@@ -5498,7 +5499,7 @@ check_parent_values_in_new_partitions(Relation parent,
54985499

54995500
ereport(ERROR,
55005501
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
5501-
errmsg("new partitions not have value %s but split partition has",
5502+
errmsg("new partitions do not have value %s but split partition does",
55025503
searchNull ? "NULL" : get_list_partvalue_string(notFoundVal))));
55035504
}
55045505
}
@@ -5645,7 +5646,7 @@ check_partitions_for_split(Relation parent,
56455646
{
56465647
ereport(ERROR,
56475648
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
5648-
errmsg("any partition in the list should be DEFAULT because split partition is DEFAULT")),
5649+
errmsg("one partition in the list should be DEFAULT because split partition is DEFAULT")),
56495650
parser_errposition(pstate, ((SinglePartitionSpec *) linitial(partlist))->name->location));
56505651
}
56515652
else if (!isSplitPartDefault && (default_index >= 0) && OidIsValid(defaultPartOid))
@@ -5714,7 +5715,7 @@ check_partitions_for_split(Relation parent,
57145715
if (equal(sps->name, sps2->name))
57155716
ereport(ERROR,
57165717
(errcode(ERRCODE_DUPLICATE_TABLE),
5717-
errmsg("name \"%s\" already used", sps2->name->relname)),
5718+
errmsg("name \"%s\" is already used", sps2->name->relname)),
57185719
parser_errposition(pstate, sps2->name->location));
57195720
}
57205721
}
@@ -5805,14 +5806,14 @@ calculate_partition_bound_for_merge(Relation parent,
58055806
}
58065807

58075808
/*
5808-
* Lower bound of first partition is a lower bound of merged
5809+
* Lower bound of first partition is the lower bound of merged
58095810
* partition.
58105811
*/
58115812
spec->lowerdatums =
58125813
((PartitionBoundSpec *) list_nth(bounds, lower_bounds[0]->index))->lowerdatums;
58135814

58145815
/*
5815-
* Upper bound of last partition is a upper bound of merged
5816+
* Upper bound of last partition is the upper bound of merged
58165817
* partition.
58175818
*/
58185819
spec->upperdatums =

‎src/test/isolation/specs/partition-merge.spec

Copy file name to clipboardExpand all lines: src/test/isolation/specs/partition-merge.spec
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ step s2s { SELECT * FROM tpart; }
3838

3939

4040
# s2 inserts row into table. s1 starts MERGE PARTITIONS then
41-
# s2 trying to update inserted row and waits until s1 finished
41+
# s2 is trying to update inserted row and waits until s1 finishes
4242
# MERGE operation.
4343

4444
permutation s2b s2i s2c s1b s1merg s2b s2u s1c s2c s2s

‎src/test/regress/expected/partition_merge.out

Copy file name to clipboardExpand all lines: src/test/regress/expected/partition_merge.out
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ CREATE TABLE sales_apr_1 PARTITION OF sales_apr2022 FOR VALUES FROM ('2022-04-01
2020
CREATE TABLE sales_apr_2 PARTITION OF sales_apr2022 FOR VALUES FROM ('2022-04-15') TO ('2022-05-01');
2121
ALTER TABLE sales_range ATTACH PARTITION sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-05-01');
2222
CREATE TABLE sales_others PARTITION OF sales_range DEFAULT;
23-
-- ERROR: partition with name "sales_feb2022" already used
23+
-- ERROR: partition with name "sales_feb2022" is already used
2424
ALTER TABLE sales_range MERGE PARTITIONS (sales_feb2022, sales_mar2022, sales_feb2022) INTO sales_feb_mar_apr2022;
25-
ERROR: partition with name "sales_feb2022" already used
25+
ERROR: partition with name "sales_feb2022" is already used
2626
LINE 1: ...e MERGE PARTITIONS (sales_feb2022, sales_mar2022, sales_feb2...
2727
^
2828
-- ERROR: "sales_apr2022" is not a table
2929
ALTER TABLE sales_range MERGE PARTITIONS (sales_feb2022, sales_mar2022, sales_apr2022) INTO sales_feb_mar_apr2022;
3030
ERROR: "sales_apr2022" is not a table
31-
-- ERROR: invalid partitions order, partition "sales_mar2022" can not be merged
31+
-- ERROR: lower bound of partition "sales_mar2022" conflicts with upper bound of previous partition "sales_jan2022"
3232
-- (space between sections sales_jan2022 and sales_mar2022)
3333
ALTER TABLE sales_range MERGE PARTITIONS (sales_jan2022, sales_mar2022) INTO sales_jan_mar2022;
3434
ERROR: lower bound of partition "sales_mar2022" conflicts with upper bound of previous partition "sales_jan2022"
35-
-- ERROR: invalid partitions order, partition "sales_jan2022" can not be merged
35+
-- ERROR: lower bound of partition "sales_jan2022" conflicts with upper bound of previous partition "sales_dec2021"
3636
-- (space between sections sales_dec2021 and sales_jan2022)
3737
ALTER TABLE sales_range MERGE PARTITIONS (sales_dec2021, sales_jan2022, sales_feb2022) INTO sales_dec_jan_feb2022;
3838
ERROR: lower bound of partition "sales_jan2022" conflicts with upper bound of previous partition "sales_dec2021"
@@ -52,7 +52,7 @@ SELECT c.oid::pg_catalog.regclass, c.relkind, inhdetachpending, pg_catalog.pg_ge
5252

5353
DROP TABLE sales_range;
5454
--
55-
-- Add rows into partitioned table then merge partitions
55+
-- Add rows into partitioned table, then merge partitions
5656
--
5757
CREATE TABLE sales_range (salesman_id INT, salesman_name VARCHAR(30), sales_amount INT, sales_date DATE) PARTITION BY RANGE (sales_date);
5858
CREATE TABLE sales_jan2022 PARTITION OF sales_range FOR VALUES FROM ('2022-01-01') TO ('2022-02-01');
@@ -162,7 +162,7 @@ SELECT * FROM sales_others;
162162
14 | Smith | 510 | 05-04-2022
163163
(1 row)
164164

165-
-- Use indexscan for test indexes
165+
-- Use indexscan for testing indexes
166166
SET enable_seqscan = OFF;
167167
SELECT * FROM sales_feb_mar_apr2022 where sales_date > '2022-01-01';
168168
salesman_id | salesman_name | sales_amount | sales_date
@@ -704,7 +704,7 @@ SELECT * FROM sales_all;
704704
13 | Gandi | Warsaw | 150 | 03-08-2022
705705
(10 rows)
706706

707-
-- Use indexscan for test indexes after merge partitions
707+
-- Use indexscan for testing indexes after merging partitions
708708
SET enable_seqscan = OFF;
709709
SELECT * FROM sales_all WHERE sales_state = 'Warsaw';
710710
salesman_id | salesman_name | sales_state | sales_amount | sales_date

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.