• R/O
  • HTTP
  • SSH
  • HTTPS

pg_hint_plan: Commit

firtst release


Commit MetaInfo

Revision59a773301ea6f56ba52873f000fb53448982312f (tree)
Time2014-01-17 16:56:40
AuthorTakashi Suzuki <suzuki.takashi@metr...>
CommiterTakashi Suzuki

Log Message

bug fix #2

件数補正のときに、全ての結合パスにおいて部分集合となってしまい、他
のRowsヒント句適用後に見積もり件数を再計算してしまった。。

理由

Rowsヒント句に存在しないテーブル組合せを指定すると、pg_hint_plan
内部で空のテーブル集合として扱っていたため。

Change Summary

Incremental Difference

--- a/make_join_rel.c
+++ b/make_join_rel.c
@@ -117,6 +117,13 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
117117 {
118118 rows_hint = current_hint->rows_hints[i];
119119
120+ /*
121+ * This Rows hint specifies aliasname is error, or does not exist in
122+ * query.
123+ */
124+ if (!rows_hint->joinrelids ||
125+ rows_hint->base.state == HINT_STATE_ERROR)
126+ continue;
120127 if (bms_equal(joinrelids, rows_hint->joinrelids))
121128 {
122129 /*
--- a/pg_hint_plan.c
+++ b/pg_hint_plan.c
@@ -3198,9 +3198,15 @@ create_bms_of_relids(Hint *base, PlannerInfo *root, List *initial_rels,
31983198 if (relid == -1)
31993199 base->state = HINT_STATE_ERROR;
32003200
3201+ /*
3202+ * the aliasname is not found(relid == 0) or same aliasname was used
3203+ * multiple times in a query(relid == -1)
3204+ */
32013205 if (relid <= 0)
3206+ {
3207+ relids = NULL;
32023208 break;
3203-
3209+ }
32043210 if (bms_is_member(relid, relids))
32053211 {
32063212 hint_ereport(base->hint_str,
@@ -3267,9 +3273,6 @@ transform_join_hints(HintState *hstate, PlannerInfo *root, int nbaserel,
32673273
32683274 hint->joinrelids = create_bms_of_relids(&(hint->base), root,
32693275 initial_rels, hint->nrels, hint->relnames);
3270-
3271- if (hint->joinrelids == NULL || hint->base.state == HINT_STATE_ERROR)
3272- continue;
32733276 }
32743277
32753278 /* Do nothing if no Leading hint was supplied. */
Show on old repository browser