• R/O
  • HTTP
  • SSH
  • HTTPS

pg_hint_plan: Commit

firtst release


Commit MetaInfo

Revisionb9e4cfb9ce8b605d46c00b2344040d65e4075e78 (tree)
Time2013-09-12 09:30:56
AuthorTakashi Suzuki <suzuki.takashi@metr...>
CommiterTakashi Suzuki

Log Message

いくつかのPL/pgSQL文でもクエリ文字列を取得するようにした。

指定ヒント適用の必要性の高いPL/pgSQL文にヒントを適用させるため。

Change Summary

Incremental Difference

--- a/pg_hint_plan.c
+++ b/pg_hint_plan.c
@@ -3587,16 +3587,45 @@ set_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
35873587 static void
35883588 pg_hint_plan_plpgsql_stmt_beg(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
35893589 {
3590- PLpgSQL_expr *expr;
3590+ PLpgSQL_expr *expr = NULL;
3591+
35913592 switch ((enum PLpgSQL_stmt_types) stmt->cmd_type)
35923593 {
3594+ case PLPGSQL_STMT_FORS:
3595+ expr = ((PLpgSQL_stmt_fors *) stmt)->query;
3596+ break;
3597+ case PLPGSQL_STMT_FORC:
3598+ expr = ((PLpgSQL_stmt_forc *) stmt)->argquery;
3599+ break;
3600+ case PLPGSQL_STMT_RETURN_QUERY:
3601+ if (((PLpgSQL_stmt_return_query *) stmt)->query != NULL)
3602+ expr = ((PLpgSQL_stmt_return_query *) stmt)->query;
3603+ else
3604+ expr = ((PLpgSQL_stmt_return_query *) stmt)->dynquery;
3605+ break;
35933606 case PLPGSQL_STMT_EXECSQL:
35943607 expr = ((PLpgSQL_stmt_execsql *) stmt)->sqlstmt;
3595- plpgsql_query_string = expr->query;
3608+ break;
3609+ case PLPGSQL_STMT_DYNEXECUTE:
3610+ expr = ((PLpgSQL_stmt_dynexecute *) stmt)->query;
3611+ break;
3612+ case PLPGSQL_STMT_DYNFORS:
3613+ expr = ((PLpgSQL_stmt_dynfors *) stmt)->query;
3614+ break;
3615+ case PLPGSQL_STMT_OPEN:
3616+ if (((PLpgSQL_stmt_open *) stmt)->query != NULL)
3617+ expr = ((PLpgSQL_stmt_open *) stmt)->query;
3618+ else if (((PLpgSQL_stmt_open *) stmt)->dynquery != NULL)
3619+ expr = ((PLpgSQL_stmt_open *) stmt)->dynquery;
3620+ else
3621+ expr = ((PLpgSQL_var *) (estate->datums[((PLpgSQL_stmt_open *)stmt)->curvar]))->cursor_explicit_expr;
35963622 break;
35973623 default:
35983624 break;
35993625 }
3626+
3627+ if (expr)
3628+ plpgsql_query_string = expr->query;
36003629 }
36013630
36023631 /*
Show on old repository browser