Re: Support for REINDEX CONCURRENTLY

Michael Paquier <michael.paquier@gmail.com>

From: Michael Paquier <michael.paquier@gmail.com>
To: Fujii Masao <masao.fujii@gmail.com>
Cc: Andres Freund <andres@2ndquadrant.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>, Peter Eisentraut <peter_e@gmx.net>, Tom Lane <tgl@sss.pgh.pa.us>, Simon Riggs <simon@2ndquadrant.com>
Date: 2013-03-28T01:18:45Z
Lists: pgsql-hackers

Attachments

Thanks for the comments. Please find updated patches attached.

On Thu, Mar 28, 2013 at 3:12 AM, Fujii Masao <masao.fujii@gmail.com> wrote:

> -       reltoastidxid = rel->rd_rel->reltoastidxid;
> +       /* Fetch the list of indexes on toast relation if necessary */
> +       if (OidIsValid(reltoastrelid))
> +       {
> +               Relation toastRel = relation_open(reltoastrelid, lockmode);
> +               RelationGetIndexList(toastRel);
> +               reltoastidxids = list_copy(toastRel->rd_indexlist);
> +               relation_close(toastRel, NoLock);
>
> list_copy() seems not to be required here. We can just set reltoastidxids
> to
> the return list of RelationGetIndexList().
>
Good catch. I thought that I took care of such things in previous versions
at
all the places.

Since we call relation_open() with lockmode, ISTM that we should also call
> relation_close() with the same lockmode instead of NoLock. No?
>
Agreed on that.


>
> -       if (OidIsValid(reltoastidxid))
> -               ATExecSetTableSpace(reltoastidxid, newTableSpace,
> lockmode);
> +       foreach(lc, reltoastidxids)
> +       {
> +               Oid idxid = lfirst_oid(lc);
> +               if (OidIsValid(idxid))
> +                       ATExecSetTableSpace(idxid, newTableSpace,
> lockmode);
>
> Since idxid is the pg_index.indexrelid, ISTM it should never be invalid.
> If this is true, the check of OidIsValid(idxid) is not required.
>
Indeed...
-- 
Michael

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Background worker processes

  2. Fix assorted bugs in CREATE/DROP INDEX CONCURRENTLY.

  3. Work around unportable behavior of malloc(0) and realloc(NULL, 0).

  4. Properly set relpersistence for fake relcache entries.