Re: pgsql: Move I/O before the index_update_stats() buffer lock region.

From: Noah Misch <noah(at)leadboat(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Move I/O before the index_update_stats() buffer lock region.
Date: 2024-11-03 03:21:04
Message-ID: 20241103032104.bf.nmisch@google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On Sat, Nov 02, 2024 at 11:13:57PM -0400, Tom Lane wrote:
> Noah Misch <noah(at)leadboat(dot)com> writes:
> > On Sat, Nov 02, 2024 at 10:32:56PM -0400, Tom Lane wrote:
> >> In branches before 17, this commit is causing some compilers
> >> to complain:
>
> > Hopefully now the code won't fool any compiler.
>
> I saw your commit, and I'm content with it, but did you figure
> out why the warning only appears pre-17? (At least, that's
> what I got locally.)

Nope. The principles behind the variable's lifecycle didn't change. Here's
the function's diff between v16 and v17. (Same diff all the way from v12 to
v17.) Perhaps the reference to non-local variable IsBinaryUpgrade changed the
compiler's deductive capability, somehow.

@@ -2836,7 +2806,11 @@ index_update_stats(Relation rel,
if (reltuples == 0 && rel->rd_rel->reltuples < 0)
reltuples = -1;

- update_stats = reltuples >= 0;
+ /*
+ * Don't update statistics during binary upgrade, because the indexes are
+ * created before the data is moved into place.
+ */
+ update_stats = reltuples >= 0 && !IsBinaryUpgrade;

/*
* Finish I/O and visibility map buffer locks before

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2024-11-03 10:52:12 pgsql: Add missing newlines at the end of two SQL files
Previous Message Tom Lane 2024-11-03 03:13:57 Re: pgsql: Move I/O before the index_update_stats() buffer lock region.