public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH v7 5/7] Invalidate parent index cluster on attach
2+ messages / 2 participants
[nested] [flat]

* [PATCH v7 5/7] Invalidate parent index cluster on attach
@ 2020-11-06 01:11  Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Justin Pryzby @ 2020-11-06 01:11 UTC (permalink / raw)

---
 src/backend/commands/indexcmds.c      | 21 +++++++++++++++++++++
 src/test/regress/expected/cluster.out | 14 ++++++++++++++
 src/test/regress/sql/cluster.sql      |  5 +++++
 3 files changed, 40 insertions(+)

diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 4ca1ffbfa4..cc57c149ed 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -4117,6 +4117,27 @@ IndexSetParentIndex(Relation partitionIdx, Oid parentOid)
 	/* set relispartition correctly on the partition */
 	update_relispartition(partRelid, OidIsValid(parentOid));
 
+	/*
+	 * If the attached index is not clustered, invalidate cluster mark on
+	 * any parents
+	 */
+	if ((OidIsValid(parentOid) && get_index_isclustered(parentOid)) ||
+			get_index_isclustered(partRelid))
+	{
+		Relation indrel;
+
+		/* Make relispartition visible */
+		CommandCounterIncrement();
+
+		indrel = table_open(IndexGetRelation(partRelid, false),
+				ShareUpdateExclusiveLock);
+		mark_index_clustered(indrel,
+				get_index_isclustered(partRelid) ? partRelid : InvalidOid,
+				true);
+		table_close(indrel, ShareUpdateExclusiveLock);
+
+	}
+
 	if (fix_dependencies)
 	{
 		/*
diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out
index 6cba3cc4f9..e7f0889743 100644
--- a/src/test/regress/expected/cluster.out
+++ b/src/test/regress/expected/cluster.out
@@ -567,6 +567,20 @@ Indexes:
     "clstrpart_idx" btree (a)
 Number of partitions: 3 (Use \d+ to list them.)
 
+-- Check that attaching an unclustered index marks the parent unclustered:
+ALTER TABLE clstrpart CLUSTER ON clstrpart_idx;
+CREATE TABLE clstrpart5 (LIKE clstrpart INCLUDING INDEXES);
+ALTER TABLE clstrpart ATTACH PARTITION clstrpart5 FOR VALUES FROM (40)TO(50);
+\d clstrpart
+       Partitioned table "public.clstrpart"
+ Column |  Type   | Collation | Nullable | Default 
+--------+---------+-----------+----------+---------
+ a      | integer |           |          | 
+Partition key: RANGE (a)
+Indexes:
+    "clstrpart_idx" btree (a)
+Number of partitions: 4 (Use \d+ to list them.)
+
 -- Test CLUSTER with external tuplesorting
 create table clstr_4 as select * from tenk1;
 create index cluster_sort on clstr_4 (hundred, thousand, tenthous);
diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql
index a1d132f288..3c8085c69e 100644
--- a/src/test/regress/sql/cluster.sql
+++ b/src/test/regress/sql/cluster.sql
@@ -239,6 +239,11 @@ CLUSTER clstrpart1 USING clstrpart1_idx_2;
 ALTER TABLE clstrpart CLUSTER ON clstrpart_idx;
 ALTER TABLE clstrpart1 SET WITHOUT CLUSTER;
 \d clstrpart
+-- Check that attaching an unclustered index marks the parent unclustered:
+ALTER TABLE clstrpart CLUSTER ON clstrpart_idx;
+CREATE TABLE clstrpart5 (LIKE clstrpart INCLUDING INDEXES);
+ALTER TABLE clstrpart ATTACH PARTITION clstrpart5 FOR VALUES FROM (40)TO(50);
+\d clstrpart
 
 -- Test CLUSTER with external tuplesorting
 
-- 
2.17.0


--AA9g+nFNFPYNJKiL
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v7-0006-Preserve-indisclustered-on-children-of-clustered-.patch"



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: CI CompilerWarnings test fails on 15 in mingw_cross_warning
@ 2024-11-18 11:09  Peter Eisentraut <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Eisentraut @ 2024-11-18 11:09 UTC (permalink / raw)
  To: Andres Freund <[email protected]>; pgsql-hackers

On 17.11.24 02:59, Andres Freund wrote:
> Hi,
> 
> See https://cirrus-ci.com/task/5880116075560960
> 
> [18:14:04.821] time make -s -j${BUILD_JOBS} world-bin
> [18:15:49.090] pg_locale.c: In function ‘get_collation_actual_version’:
> [18:15:49.090] pg_locale.c:1763:42: error: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Werror=format=]
> [18:15:49.090]  1763 |                 collversion = psprintf("%d.%d,%d.%d",
> [18:15:49.090]       |                                         ~^
> [18:15:49.090]       |                                          |
> [18:15:49.090]       |                                          int
> [18:15:49.090]       |                                         %ld
> [18:15:49.090]  1764 |                                                            (version.dwNLSVersion >> 8) & 0xFFFF,
> [18:15:49.090]       |                                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> [18:15:49.090]       |                                                                                        |
> [18:15:49.090]       |                                                                                        long unsigned int
> 
> I have no idea why we are seeing this error now when we didn't in the past -
> there don't seem to have been any relevant changes?
> 
> It does reproduce on my debian sid machine, so it's something we ought to fix,
> I think?
> 
> We did fix it in newer versions:
> 
> Author: Peter Eisentraut <[email protected]>
> Branch: master Release: REL_16_BR [a9bc04b21] 2023-03-24 07:21:40 +0100
> 
>      Fix incorrect format placeholders
> 
>      The fields of NLSVERSIONINFOEX are of type DWORD, which is unsigned
>      long, so the results of the computations being printed are also of
>      type unsigned long.
> 
> Peter, any reason you didn't backpatch that?

The more interesting patch is 495ed0ef2d7, which did

-       collversion = psprintf("%d.%d,%d.%d",
+       collversion = psprintf("%ld.%ld,%ld.%ld",

whereas my patch just did

-       collversion = psprintf("%ld.%ld,%ld.%ld",
+       collversion = psprintf("%lu.%lu,%lu.%lu",

The former change was part of a larger patch, so it was not a candidate 
for backpatching.

As to why it's happening now, the code in question is guarded by

#elif defined(WIN32) && _WIN32_WINNT >= 0x0600

so if it didn't happen before, maybe the _WIN32_WINNT value changed.







^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2024-11-18 11:09 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-11-06 01:11 [PATCH v7 5/7] Invalidate parent index cluster on attach Justin Pryzby <[email protected]>
2024-11-18 11:09 Re: CI CompilerWarnings test fails on 15 in mingw_cross_warning Peter Eisentraut <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox