Re: pgsql: Get rid of pg_class.reltoastidxid. - Mailing list pgsql-committers

From Andres Freund
Subject Re: pgsql: Get rid of pg_class.reltoastidxid.
Date
Msg-id 20140115122948.GF9762@awork2.anarazel.de
Whole thread Raw
In response to pgsql: Get rid of pg_class.reltoastidxid.  (Fujii Masao <fujii@postgresql.org>)
Responses Re: pgsql: Get rid of pg_class.reltoastidxid.
List pgsql-committers
Hi Fujii, Michael,

Coverity indicated that there's a problem with this - a quick look
confirms that:

    foreach(lc, indexlist)
        (*toastidxs)[i++] = index_open(lfirst_oid(lc), lock);

    /* Fetch the first valid index in list */
    for (i = 0; i < *num_indexes; i++)
    {
        Relation toastidx = *toastidxs[i];
        if (toastidx->rd_index->indisvalid)
        {
            res = i;
            found = true;
            break;
        }
    }

Note how the second access to toastidxs is missing parentheses. It
should be (*toastidxs)[i].

I think this happens to mostly work because usually the older index will
still be valid when we open the toast indexes when there are multiple
ones and RelationGetIndexList() returns indexes in toast order.

Greetings,

Andres Freund

--
 Andres Freund                       http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Improve FILES section of psql reference page.
Next
From: Michael Paquier
Date:
Subject: Re: pgsql: Get rid of pg_class.reltoastidxid.