Re: pageinspect: Hash index support

Ashutosh Sharma <ashu.coek88@gmail.com>

From: Ashutosh Sharma <ashu.coek88@gmail.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Jesper Pedersen <jesper.pedersen@redhat.com>, Tom Lane <tgl@sss.pgh.pa.us>, Peter Eisentraut <peter.eisentraut@2ndquadrant.com>, Michael Paquier <michael.paquier@gmail.com>, Jeff Janes <jeff.janes@gmail.com>, Alvaro Herrera <alvherre@2ndquadrant.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2017-01-11T14:13:37Z
Lists: pgsql-hackers
> +        itup = (IndexTuple) PageGetItem(uargs->page, id);
> +
> +        MemSet(nulls, 0, sizeof(nulls));
> +
> +        j = 0;
> +        values[j++] = UInt16GetDatum(uargs->offset);
> +        values[j++] = CStringGetTextDatum(psprintf("(%u,%u)",
> +
> BlockIdGetBlockNumber(&(itup->t_tid.ip_blkid)),
> +                                            itup->t_tid.ip_posid));
> +
> +        ptr = (char *) itup + IndexInfoFindDataOffset(itup->t_info);
> +        dlen = IndexTupleSize(itup) - IndexInfoFindDataOffset(itup->t_info);
>
> It seems like this could be used to index off the end of the page, if
> you feed it invalid data.
>

I think it should not exceed the page size. This is how it has been
implemented for btree as well. However, just to be on a safer side i
am planning to add following 'if check' to ensure that we do not go
beyond the page size while reading tuples.

    ptr = (char *) itup + IndexInfoFindDataOffset(itup->t_info);
+  if (ptr > page + BLCKSZ)
+      /* Error */
    dlen = IndexTupleSize(itup) - IndexInfoFindDataOffset(itup->t_info);

Meanwhile, I am working on other review comments and will try to share
an updated patch asap.

With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com


Commits

  1. Fix incorrect typecast.

  2. In pageinspect/hashfuncs.c, avoid crashes on alignment-picky machines.

  3. pageinspect: Support hash indexes.

  4. Add uuid to the set of types supported by contrib/btree_gist.

  5. Allow CREATE EXTENSION to follow extension update paths.