firtst release
修訂 | 5c6296e97818f7b74bdce7aab84dc40d0bb38dc5 (tree) |
---|---|
時間 | 2018-06-08 10:02:10 |
作者 | Kyotaro Horiguchi <horiguchi.kyotaro@lab....> |
Commiter | Kyotaro Horiguchi |
Fix a crash bug in case debug_query_string is NULL
pg_hint_plan believed that debug_query_string cannot be null when
parse_analyze is called, but for example in the case under
exec_describe_statement_message, it is not. We see the query string in
pstate even in the case, so use it instead in the case. Since pstate
is storing the query of the lowermost level, we should use
debug_query_string in other cases.
@@ -1659,6 +1659,21 @@ get_query_string(ParseState *pstate, Query *query, Query **jumblequery) | ||
1659 | 1659 | { |
1660 | 1660 | const char *p = debug_query_string; |
1661 | 1661 | |
1662 | + /* | |
1663 | + * If debug_query_string is set, it is the top level statement. But in some | |
1664 | + * cases we reach here with debug_query_string set NULL for example in the | |
1665 | + * case of DESCRIBE message handling. We may still see a candidate | |
1666 | + * top-level query in pstate in the case. | |
1667 | + */ | |
1668 | + if (!p) | |
1669 | + { | |
1670 | + /* We don't see a query string, return NULL */ | |
1671 | + if (!pstate->p_sourcetext) | |
1672 | + return NULL; | |
1673 | + | |
1674 | + p = pstate->p_sourcetext; | |
1675 | + } | |
1676 | + | |
1662 | 1677 | if (jumblequery != NULL) |
1663 | 1678 | *jumblequery = query; |
1664 | 1679 |