mirror of
https://github.com/postgres/postgres.git
synced 2026-05-26 19:28:27 -04:00
Check for stack overflow when rewriting graph queries
generate_queries_for_path_pattern_recurse() and generate_setop_from_pathqueries() are recursive functions. For a property graph with hundreds of tables, a graph pattern with a handful element patterns can cause stack overflow. Fix it by calling check_stack_depth() at the beginning of these functions. Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com> Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> Discussion: https://www.postgresql.org/message-id/CAHg+QDfgK0xddH8f3eAb+UVn7sBDOnv8RvM6OkP4HtHAt6aD7w@mail.gmail.com
This commit is contained in:
parent
863c4b827d
commit
2ff289d039
1 changed files with 7 additions and 0 deletions
|
|
@ -23,6 +23,7 @@
|
|||
#include "catalog/pg_propgraph_label.h"
|
||||
#include "catalog/pg_propgraph_label_property.h"
|
||||
#include "catalog/pg_propgraph_property.h"
|
||||
#include "miscadmin.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
#include "nodes/nodeFuncs.h"
|
||||
#include "optimizer/optimizer.h"
|
||||
|
|
@ -361,6 +362,9 @@ generate_queries_for_path_pattern_recurse(RangeTblEntry *rte, List *pathqueries,
|
|||
{
|
||||
List *path_elems = list_nth_node(List, path_elem_lists, elempos);
|
||||
|
||||
/* Guard against stack overflow due to complex path patterns. */
|
||||
check_stack_depth();
|
||||
|
||||
foreach_ptr(struct path_element, pe, path_elems)
|
||||
{
|
||||
/* Update current path being built with current element. */
|
||||
|
|
@ -698,6 +702,9 @@ generate_setop_from_pathqueries(List *pathqueries, List **rtable, List **targetl
|
|||
List *rtargetlist;
|
||||
ParseNamespaceItem *pni;
|
||||
|
||||
/* Guard against stack overflow due to many path queries. */
|
||||
check_stack_depth();
|
||||
|
||||
/* Recursion termination condition. */
|
||||
if (list_length(pathqueries) == 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue