Re: BUG #16818: progress reporting ALTER TABLE ADD UNIQUE - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: BUG #16818: progress reporting ALTER TABLE ADD UNIQUE
Date
Msg-id 20210111211313.GA25789@alvherre.pgsql
Whole thread Raw
In response to BUG #16818: progress reporting ALTER TABLE ADD UNIQUE  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #16818: progress reporting ALTER TABLE ADD UNIQUE  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On 2021-Jan-11, PG Bug reporting form wrote:

> The progress reprorting for `ALTER TABLE test ADD UNIQUE (col)` is in
> `pg_stat_progress_create_index`. As it indeed creates an index, that is not
> too unexpected, but the `command` column of that view reports `CREATE
> INDEX`, and _that_ is somewhat unexpected. A reasonable expectation would be
> `ALTER TABLE ADD CONSTRAINT` or comparable. 

Hmm, seems a reasonable complaint.  Are there other command wordings
that would need to be handled?  I can't think of any (but I already
overlooked this one, evidently ...)

This seems fixed easily, in a way -- we'd need to set a distinct value
to the PROGRESS_CREATEIDX_COMMAND param when ALTER TABLE ADD; currently
possible values are in progress.h:

/* Commands of PROGRESS_CREATEIDX */
#define PROGRESS_CREATEIDX_COMMAND_CREATE        1
#define PROGRESS_CREATEIDX_COMMAND_CREATE_CONCURRENTLY    2
#define PROGRESS_CREATEIDX_COMMAND_REINDEX        3
#define PROGRESS_CREATEIDX_COMMAND_REINDEX_CONCURRENTLY    4

The problem is that we'd need to change system_view.sql to recognize the
new value, and we can't change that on existing systems.  If we fail to
adjust that view definition, the column will show NULL when the command
is ALTER TABLE ADD.

Something like the attached patch, but I haven't tried to compile it
yet.  Probably need docs adjustments also.


(Also: I don't see we set
PROGRESS_CREATEIDX_COMMAND_REINDEX_CONCURRENTLY anywhere ... an
oversight?)

-- 
Álvaro Herrera

Attachment

pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #16818: progress reporting ALTER TABLE ADD UNIQUE
Next
From: Tom Lane
Date:
Subject: Re: BUG #16818: progress reporting ALTER TABLE ADD UNIQUE