firtst release
修訂 | c56520a41063c0403afc6ec972b0eabffc19668c (tree) |
---|---|
時間 | 2018-05-24 18:18:29 |
作者 | 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.
@@ -1803,6 +1803,21 @@ get_query_string(ParseState *pstate, Query *query, Query **jumblequery) | ||
1803 | 1803 | { |
1804 | 1804 | const char *p = debug_query_string; |
1805 | 1805 | |
1806 | + /* | |
1807 | + * If debug_query_string is set, it is the top level statement. But in some | |
1808 | + * cases we reach here with debug_query_string set NULL for example in the | |
1809 | + * case of DESCRIBE message handling. We may still see a candidate | |
1810 | + * top-level query in pstate in the case. | |
1811 | + */ | |
1812 | + if (!p) | |
1813 | + { | |
1814 | + /* We don't see a query string, return NULL */ | |
1815 | + if (!pstate->p_sourcetext) | |
1816 | + return NULL; | |
1817 | + | |
1818 | + p = pstate->p_sourcetext; | |
1819 | + } | |
1820 | + | |
1806 | 1821 | if (jumblequery != NULL) |
1807 | 1822 | *jumblequery = query; |
1808 | 1823 |