Closed tideri closed 1 year ago
I found the workaround for this issue. Instead of writing a hint clause for the partition table (parent table), write the hint clause by enumerating the partitions (child table) and the indexes of the partitions by the number of partitions like following:
/*+ IndexScan(child table 1 child index 1) IndexScan(child table 2 child index 2) IndexScan(child table 3 child index 3) */
Sorry for being late. This is fixed in pg_hint_plan 15. It will be back-patched soon.
Hi This back-patch does not seem to be supported yet. Do you have any plans to deal with it?
hi. Is it possible to patch this bug, at least for version 13?
Hi! At one of my customers, when SQL was executed with IndexScan hint for non-btree indexes (such as the gin index) against a partitioned table, the backend process crashed and a core dump was output. (Actually, I found it when pg_bigm was used.)
The details are described below, but it seems that pg_hint_plan does not take into consideration indexes that do not support order by such as GIN indexes (indexes other than btree indexes).
This issue appears to occur in all currently released branches of pg_hint_plan. I have confirmed that this phenomenon occurs in the following versions.
How to reproduce this issue
You can reproduce this event with the following SQL. Also, as I wrote in [Occurrence condition], I confirmed that this isse occured with indexes other than btree, such as HASH indexes.
Occurrence condition
In my observation, this issue can be reproduced following condition.
Cause & backtrace
Below is the backtrace for the combination of PostgreSQL 13.8 and pg_hint_plan 13_1_3_7.
The segmentation fault seems to be caused by
info->reserver_sort[i]
being NULL inrestrict_indexes()
. Alsoinfo->nulls_first[i]
is NULL. This is because the IndexOptInfo type reverse_sort and nulls_first seem to be set to NULL except for btree indexes in PostgreSQL. It seems thatrestrict_indexes()
does not consider anything other than btree indexes.I think we need to check if
info->amcanorderbyop
is true or false andif (info->amcanorderbyop == false)
, we need to skip checkinginfo->reserver_sort[i]
andinfo->nulls_first[i]
.