Re: BUG #16818: progress reporting ALTER TABLE ADD UNIQUE

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: boekewurm+postgres(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16818: progress reporting ALTER TABLE ADD UNIQUE
Date: 2021-01-11 21:13:13
Message-ID: 20210111211313.GA25789@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
alter-table-add-progress.patch text/x-diff 2.0 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2021-01-11 22:12:27 Re: BUG #16818: progress reporting ALTER TABLE ADD UNIQUE
Previous Message PG Bug reporting form 2021-01-11 19:31:48 BUG #16818: progress reporting ALTER TABLE ADD UNIQUE