Re: pgstatindex vs. !indisready

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Noah Misch <noah@leadboat.com>
Cc: Peter Geoghegan <pg@bowt.ie>, Tom Lane <tgl@sss.pgh.pa.us>, pgsql-hackers@postgresql.org
Date: 2023-10-23T01:47:50Z
Lists: pgsql-hackers
On Sun, Oct 22, 2023 at 02:02:45PM -0700, Noah Misch wrote:
> -	/* OK, do it */
> -	brinsummarize(indexRel, heapRel, heapBlk, true, &numSummarized, NULL);
> +	/* see gin_clean_pending_list() */
> +	if (indexRel->rd_index->indisvalid)
> +		brinsummarize(indexRel, heapRel, heapBlk, true, &numSummarized, NULL);
> +	else
> +		ereport(DEBUG1,
> +				(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> +				 errmsg("index \"%s\" is not valid",
> +						RelationGetRelationName(indexRel))));

brinsummarize() could return 0 even for a valid index, and we would
not be able to make the difference with an invalid index.  Perhaps you
are right and this is not a big deal in practice to do as you are
suggesting.
--
Michael

Commits

  1. Diagnose !indisvalid in more SQL functions.