Re: [HACKERS] pageinspect: Hash index support - Mailing list pgsql-hackers

From Ashutosh Sharma
Subject Re: [HACKERS] pageinspect: Hash index support
Date
Msg-id CAE9k0PmzAQKdtft_DGii+f=ZbN-bd452EnRKF0EzNRa1_xazSw@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] pageinspect: Hash index support  (Robert Haas <robertmhaas@gmail.com>)
List 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



pgsql-hackers by date:

Previous
From: Marko Tiikkaja
Date:
Subject: Re: [HACKERS] plpgsql - additional extra checks
Next
From: Dilip Kumar
Date:
Subject: Re: [HACKERS] New SQL counter statistics view (pg_stat_sql)