Thanks Amit and Tom for the quick response. I have attached a file that
contains the execution of the code via GDB and also what the backtrace
command shows when it gets the error. If I forgot to add something or if it
is necessary to add anything else, please let me know.

Thank you,
Matheus Farias

Em sex., 14 de jul. de 2023 às 00:05, Amit Langote <amitlangot...@gmail.com>
escreveu:

> On Fri, Jul 14, 2023 at 7:12 AM Tom Lane <t...@sss.pgh.pa.us> wrote:
> > Farias de Oliveira <matheusfarias...@gmail.com> writes:
> > > With further inspection in AGE's code, after executing the SET query,
> > > it goes inside transform_cypher_clause_as_subquery() function and the
> > > ParseNamespaceItem has the following values:
> >
> > >  {p_names = 0x1205638, p_rte = 0x11edb70, p_rtindex = 1, p_perminfo =
> > > 0x7f7f7f7f7f7f7f7f,
> > >   p_nscolumns = 0x1205848, p_rel_visible = true, p_cols_visible =
> > > true, p_lateral_only = false,
> > >   p_lateral_ok = true}
> >
> > Hmm, that uninitialized value for p_perminfo is pretty suspicious.
> > I see that transformFromClauseItem and buildNSItemFromLists both
> > create ParseNamespaceItems without bothering to fill p_perminfo,
> > while buildNSItemFromTupleDesc fills it per the caller and
> > addRangeTableEntryForJoin always sets it to NULL.  I think we
> > ought to make the first two set it to NULL as well, because
> > uninitialized fields are invariably a bad idea (even though the
> > lack of valgrind complaints says that the core code is managing
> > to avoid touching those fields).
>
> Agreed, I'll go ahead and fix that.
>
> > If we do that, is it sufficient to resolve your problem?
>
> Hmm, I'm afraid maybe not, because if the above were the root issue,
> we'd have seen a segfault and not the error the OP mentioned?  I'm
> thinking the issue is that their code appears to be consing up an RTE
> that the core code (getRTEPermissionInfo() most likely via
> markRTEForSelectPriv()) is not expecting to be called with?  I would
> be helpful to see a backtrace when the error occurs to be sure.
>
> --
> Thanks, Amit Langote
> EDB: http://www.enterprisedb.com
>
(gdb) b getRTEPermissionInfo 
Breakpoint 1 at 0x5bc188: file parse_relation.c, line 3900.
(gdb) c
Continuing.

Breakpoint 1, getRTEPermissionInfo (rteperminfos=0x1375d78, rte=0x135d5c8) at 
parse_relation.c:3900
3900    {
(gdb) n
3903            if (rte->perminfoindex == 0 ||
(gdb) 
3904                    rte->perminfoindex > list_length(rteperminfos))
(gdb) 
3907            perminfo = list_nth_node(RTEPermissionInfo, rteperminfos,
(gdb) 
3909            if (perminfo->relid != rte->relid)
(gdb) 
markRTEForSelectPriv (pstate=<optimized out>, rtindex=1, col=<optimized out>) 
at parse_relation.c:1076
1076                    perminfo->requiredPerms |= ACL_SELECT;
(gdb) 
1078                    perminfo->selectedCols =
(gdb) 
scanNSItemForColumn (pstate=pstate@entry=0x1375448, 
nsitem=nsitem@entry=0x1375e68, sublevels_up=sublevels_up@entry=0, 
    colname=colname@entry=0x7f197fb5df1b "id", location=location@entry=-1) at 
parse_relation.c:772
772             return (Node *) var;
(gdb) 
make_vertex_expr (cpstate=cpstate@entry=0x1375448, pnsi=pnsi@entry=0x1375e68, 
label=<optimized out>)
    at src/backend/parser/cypher_clause.c:4561

4561        label_name_func_oid = get_ag_func_oid("_label_name", 2, OIDOID,
(gdb) 

254             return (Datum) X;
(gdb) 
4568        label_name_args = list_make2(graph_oid_const, id);
(gdb) 
4570        label_name_func_expr = makeFuncExpr(label_name_func_oid, CSTRINGOID,
(gdb) 
4573        label_name_func_expr->location = -1;
(gdb) 
4575        props = scanNSItemForColumn(pstate, pnsi, 0, 
AG_VERTEX_COLNAME_PROPERTIES, -1);
(gdb) 

Breakpoint 1, getRTEPermissionInfo (rteperminfos=0x1375d78, rte=0x135d5c8) at 
parse_relation.c:3900
3900    {
(gdb) 
3903            if (rte->perminfoindex == 0 ||
(gdb) 
3904                    rte->perminfoindex > list_length(rteperminfos))
(gdb) 
3907            perminfo = list_nth_node(RTEPermissionInfo, rteperminfos,
(gdb) 
3909            if (perminfo->relid != rte->relid)
(gdb) 
markRTEForSelectPriv (pstate=<optimized out>, rtindex=1, col=<optimized out>) 
at parse_relation.c:1076
1076                    perminfo->requiredPerms |= ACL_SELECT;
(gdb) 
1078                    perminfo->selectedCols =
(gdb) 
scanNSItemForColumn (pstate=pstate@entry=0x1375448, 
nsitem=nsitem@entry=0x1375e68, sublevels_up=sublevels_up@entry=0, 
    colname=colname@entry=0x7f197fb5defb "properties", 
location=location@entry=-1) at parse_relation.c:772
772             return (Node *) var;
(gdb) 
make_vertex_expr (cpstate=cpstate@entry=0x1375448, pnsi=pnsi@entry=0x1375e68, 
label=<optimized out>)
    at src/backend/parser/cypher_clause.c:4577
4577        args = list_make3(id, label_name_func_expr, props);
(gdb) 
4579        func_expr = makeFuncExpr(func_oid, AGTYPEOID, args, InvalidOid, 
InvalidOid,
(gdb) 
4581        func_expr->location = -1;
(gdb) 
4583        return (Node *)func_expr;
(gdb) 
transform_cypher_node (cpstate=cpstate@entry=0x1375448, 
node=node@entry=0x135edf0, target_list=target_list@entry=0x135d740, 
    output_node=output_node@entry=true, valid_label=valid_label@entry=true) at 
src/backend/parser/cypher_clause.c:4478
4478        if (valid_label)
(gdb) 
4480            expr = (Expr *)make_vertex_expr(cpstate, pnsi, node->label);
(gdb) 

Breakpoint 1, getRTEPermissionInfo (rteperminfos=0x1375d78, rte=0x135d5c8) at 
parse_relation.c:3900
3900    {
(gdb) 
3903            if (rte->perminfoindex == 0 ||
(gdb) 
3904                    rte->perminfoindex > list_length(rteperminfos))
(gdb) 
3907            perminfo = list_nth_node(RTEPermissionInfo, rteperminfos,
(gdb) 
3909            if (perminfo->relid != rte->relid)
(gdb) 
markRTEForSelectPriv (pstate=<optimized out>, rtindex=1, col=<optimized out>) 
at parse_relation.c:1076
1076                    perminfo->requiredPerms |= ACL_SELECT;
(gdb) 
1078                    perminfo->selectedCols =
(gdb) 
scanNSItemForColumn (pstate=pstate@entry=0x1375448, 
nsitem=nsitem@entry=0x1375e68, sublevels_up=sublevels_up@entry=0, 
    colname=colname@entry=0x7f197fb5df1b "id", location=location@entry=-1) at 
parse_relation.c:772
772             return (Node *) var;
(gdb) 
make_vertex_expr (cpstate=cpstate@entry=0x1375448, pnsi=pnsi@entry=0x1375e68, 
label=<optimized out>)
    at src/backend/parser/cypher_clause.c:4561
4561        label_name_func_oid = get_ag_func_oid("_label_name", 2, OIDOID,
(gdb) 
254             return (Datum) X;
(gdb) 
4568        label_name_args = list_make2(graph_oid_const, id);
(gdb) 
4570        label_name_func_expr = makeFuncExpr(label_name_func_oid, CSTRINGOID,
(gdb) 
4573        label_name_func_expr->location = -1;
(gdb) 
4575        props = scanNSItemForColumn(pstate, pnsi, 0, 
AG_VERTEX_COLNAME_PROPERTIES, -1);
(gdb) 

Breakpoint 1, getRTEPermissionInfo (rteperminfos=0x1375d78, rte=0x135d5c8) at 
parse_relation.c:3900
3900    {
(gdb) 
3903            if (rte->perminfoindex == 0 ||
(gdb) 
3904                    rte->perminfoindex > list_length(rteperminfos))
(gdb) 
3907            perminfo = list_nth_node(RTEPermissionInfo, rteperminfos,
(gdb) 
3909            if (perminfo->relid != rte->relid)
(gdb) 
markRTEForSelectPriv (pstate=<optimized out>, rtindex=1, col=<optimized out>) 
at parse_relation.c:1076
1076                    perminfo->requiredPerms |= ACL_SELECT;
(gdb) 
1078                    perminfo->selectedCols =
(gdb) 
scanNSItemForColumn (pstate=pstate@entry=0x1375448, 
nsitem=nsitem@entry=0x1375e68, sublevels_up=sublevels_up@entry=0, 
    colname=colname@entry=0x7f197fb5defb "properties", 
location=location@entry=-1) at parse_relation.c:772
772             return (Node *) var;
(gdb) 
make_vertex_expr (cpstate=cpstate@entry=0x1375448, pnsi=pnsi@entry=0x1375e68, 
label=<optimized out>)
    at src/backend/parser/cypher_clause.c:4577
4577        args = list_make3(id, label_name_func_expr, props);
(gdb) 
4579        func_expr = makeFuncExpr(func_oid, AGTYPEOID, args, InvalidOid, 
InvalidOid,
(gdb) 
4581        func_expr->location = -1;
(gdb) 
4583        return (Node *)func_expr;
(gdb) 
transform_cypher_node (cpstate=cpstate@entry=0x1375448, 
node=node@entry=0x135edf0, target_list=target_list@entry=0x135d740, 
    output_node=output_node@entry=true, valid_label=valid_label@entry=true) at 
src/backend/parser/cypher_clause.c:4488
4488        te = makeTargetEntry(expr, resno, node->name, false);
(gdb) 
4489        *target_list = lappend(*target_list, te);
(gdb) 
4491        return expr;
(gdb) 
transform_match_entities (cpstate=cpstate@entry=0x1375448, 
query=query@entry=0x135d6d8, path=path@entry=0x135ee90)
    at src/backend/parser/cypher_clause.c:3848
3848                entity = make_transform_entity(cpstate, ENT_VERTEX, (Node 
*)node,
(gdb) 

3852                if (node->props)
(gdb) 
3863                cpstate->entities = lappend(cpstate->entities, entity);
(gdb) 
3864                entities = lappend(entities, entity);
(gdb) 
3966            i++;
(gdb) 
3805        foreach (lc, path->path)
(gdb) 
3968        return entities;
(gdb) 
transform_match_path (cpstate=cpstate@entry=0x1375448, 
query=query@entry=0x135d6d8, path=0x135ee90)
    at src/backend/parser/cypher_clause.c:3591
3591        if (path->var_name != NULL)
(gdb) 
3601        join_quals = make_path_join_quals(cpstate, entities);
(gdb) 
3602        qual = list_concat(qual, join_quals);
(gdb) 
3605        if (list_length(entities) > 3)
(gdb) 
transform_match_pattern (cpstate=cpstate@entry=0x1375448, 
query=query@entry=0x135d6d8, pattern=0x135eee0, where=where@entry=0x0)
    at src/backend/parser/cypher_clause.c:2953
2953            quals = list_concat(quals, qual);
(gdb) 
2943        foreach (lc, pattern)
(gdb) 
2956        if (quals != NIL)
(gdb) 
2963        if (cpstate->property_constraint_quals != NIL)
(gdb) 
2979        if (where != NULL)
(gdb) 
3006        if (expr != NULL)
(gdb) 
3011        query->rtable = cpstate->pstate.p_rtable;
(gdb) 
3012        query->rteperminfos = cpstate->pstate.p_rteperminfos;
(gdb) 
3013        query->jointree = makeFromExpr(cpstate->pstate.p_joinlist, (Node 
*)expr);
(gdb) 
transform_cypher_match_pattern (cpstate=0x1375448, clause=0x135f2f0) at 
src/backend/parser/cypher_clause.c:2592
2592        markTargetListOrigins(pstate, query->targetList);
(gdb) 
2594        query->hasSubLinks = pstate->p_hasSubLinks;
(gdb) 
2595        query->hasWindowFuncs = pstate->p_hasWindowFuncs;
(gdb) 
2596        query->hasTargetSRFs = pstate->p_hasTargetSRFs;
(gdb) 
2597        query->hasAggs = pstate->p_hasAggs;
(gdb) 
2599        assign_query_collations(pstate, query);
(gdb) 
2601        return query;
(gdb) 
transform_cypher_clause_with_where (cpstate=cpstate@entry=0x1375448, 
    transform=transform@entry=0x7f197fb25318 <transform_cypher_match_pattern>, 
clause=clause@entry=0x135f2f0)
    at src/backend/parser/cypher_clause.c:2349
2349        query->hasSubLinks = pstate->p_hasSubLinks;
(gdb) 
2350        query->hasTargetSRFs = pstate->p_hasTargetSRFs;
(gdb) 
2351        query->hasAggs = pstate->p_hasAggs;
(gdb) 
2353        return query;
(gdb) 
transform_cypher_clause (cpstate=cpstate@entry=0x1375448, 
clause=clause@entry=0x135f2f0)
    at src/backend/parser/cypher_clause.c:400
400         result->querySource = QSRC_ORIGINAL;
(gdb) 
401         result->canSetTag = true;
(gdb) 
403         return result;
(gdb) 
analyze_cypher_clause (transform=<optimized out>, clause=0x135f2f0, 
parent_cpstate=parent_cpstate@entry=0x128db38)
    at src/backend/parser/cypher_clause.c:5312
5312        advance_transform_entities_to_next_clause(cpstate->entities);
(gdb) 
5314        parent_cpstate->entities = list_concat(parent_cpstate->entities,
(gdb) 
5317        free_cypher_parsestate(cpstate);
(gdb) 
5319        return query;
(gdb) 
transform_cypher_clause_as_subquery (cpstate=cpstate@entry=0x128db38, 
    transform=transform@entry=0x7f197fb28bc2 <transform_cypher_clause>, 
clause=<optimized out>, alias=alias@entry=0x0, 
    add_rte_to_query=add_rte_to_query@entry=true) at 
src/backend/parser/cypher_clause.c:5234
5234        pstate->p_expr_kind = old_expr_kind;
(gdb) 
5236        if (alias == NULL)
(gdb) 
5238            alias = makeAlias(PREV_CYPHER_CLAUSE_ALIAS, NIL);
(gdb) 
5241        pnsi = addRangeTableEntryForSubquery(pstate, query, alias, lateral, 
true);
(gdb) 
5242        rte = pnsi->p_rte;
(gdb) 
5248        if (list_length(pstate->p_rtable) > 1)
(gdb) 
5269        if (add_rte_to_query)
(gdb) 
5272            addNSItemToQuery(pstate, pnsi, true, false, true);
(gdb) 
5275        return pnsi;
(gdb) 
handle_prev_clause (cpstate=cpstate@entry=0x128db38, 
query=query@entry=0x135d4b8, clause=<optimized out>, 
    first_rte=first_rte@entry=true) at src/backend/parser/cypher_clause.c:6096
6096        rtindex = list_length(pstate->p_rtable);
(gdb) 
6099        if (first_rte)
(gdb) 
6101            Assert(rtindex == 1);
(gdb) 
6105        query->targetList = expandNSItemAttrs(pstate, pnsi, 0, true, -1);
(gdb) 
transform_cypher_set (cpstate=cpstate@entry=0x128db38, 
clause=clause@entry=0x1375418) at src/backend/parser/cypher_clause.c:1477
1477        if (self->is_remove == true)
(gdb) 
1485            set_items_target_list = transform_cypher_set_item_list(cpstate,
(gdb) 
1490        set_items_target_list->clause_name = clause_name;
(gdb) 
1491        set_items_target_list->graph_name = cpstate->graph_name;
(gdb) 
1493        if (!clause->next)
(gdb) 
1495            set_items_target_list->flags |= CYPHER_CLAUSE_FLAG_TERMINAL;
(gdb) 
1498        func_expr = make_clause_func_expr(SET_CLAUSE_FUNCTION_NAME,
(gdb) 
1502        tle = makeTargetEntry((Expr *)func_expr, pstate->p_next_resno++,
(gdb) 
1504        query->targetList = lappend(query->targetList, tle);
(gdb) 
1506        query->rtable = pstate->p_rtable;
(gdb) 
1507        query->jointree = makeFromExpr(pstate->p_joinlist, NULL);
(gdb) 
1509        return query;
(gdb) 
transform_cypher_clause (cpstate=cpstate@entry=0x128db38, 
clause=clause@entry=0x1375418)
    at src/backend/parser/cypher_clause.c:400
400         result->querySource = QSRC_ORIGINAL;
(gdb) 
401         result->canSetTag = true;
(gdb) 
403         return result;
(gdb) 
analyze_cypher (stmt=stmt@entry=0x135f2a0, 
parent_pstate=parent_pstate@entry=0x128d720, 
    query_str=query_str@entry=0x128da30 "MATCH (n) SET n.i = 3", 
query_loc=query_loc@entry=37, 
    graph_name=graph_name@entry=0x128e128 "cypher_set", 
graph_oid=graph_oid@entry=16968, params=0x0)
    at src/backend/parser/cypher_analyze.c:679
679         cancel_errpos_ecb(&ecb_state);
(gdb) 
681         free_cypher_parsestate(cpstate);
(gdb) 
683         return query;
(gdb) 
convert_cypher_to_subquery (rte=rte@entry=0x128dd48, 
pstate=pstate@entry=0x128d720) at src/backend/parser/cypher_analyze.c:556
556         pstate->p_lateral_active = false;
(gdb) 
557         pstate->p_expr_kind = EXPR_KIND_NONE;
(gdb) 
563         rte->rtekind = RTE_SUBQUERY;
(gdb) 
564         rte->subquery = query;
(gdb) 
convert_cypher_walker (node=node@entry=0x128dd48, 
pstate=pstate@entry=0x128d720) at src/backend/parser/cypher_analyze.c:141
141                 return false;
(gdb) 
range_table_entry_walker_impl (rte=0x128dd48, 
walker=walker@entry=0x7f197fb2026a <convert_cypher_walker>, 
    context=context@entry=0x128d720, flags=flags@entry=21) at nodeFuncs.c:2701
2701            switch (rte->rtekind)
(gdb) 
2708                            if (!(flags & QTW_IGNORE_RT_SUBQUERIES))
(gdb) 
2736            if (WALK(rte->securityQuals))
(gdb) 
2739            if (flags & QTW_EXAMINE_RTES_AFTER)
(gdb) 
range_table_walker_impl (rtable=0x135d9a8, walker=walker@entry=0x7f197fb2026a 
<convert_cypher_walker>, 
    context=context@entry=0x128d720, flags=flags@entry=21) at nodeFuncs.c:2680
2680            return false;
(gdb) 
convert_cypher_walker (node=node@entry=0x128d830, 
pstate=pstate@entry=0x128d720) at src/backend/parser/cypher_analyze.c:220
220             return result;
(gdb) 
post_parse_analyze (pstate=0x128d720, query=0x128d830, jstate=<optimized out>) 
at src/backend/parser/cypher_analyze.c:109
109         if (extra_node != NULL)
(gdb) 
parse_analyze_fixedparams (parseTree=parseTree@entry=0x128d6a0, 
    sourceText=sourceText@entry=0x128c4f8 "SELECT * FROM cypher('cypher_set', 
$$MATCH (n) SET n.i = 3$$) AS (a agtype);", 

    paramTypes=paramTypes@entry=0x0, numParams=numParams@entry=0, 
queryEnv=queryEnv@entry=0x0) at analyze.c:132
132             free_parsestate(pstate);
(gdb) 
134             pgstat_report_query_id(query->queryId, false);
(gdb) 
136             return query;
(gdb) 
pg_analyze_and_rewrite_fixedparams (parsetree=parsetree@entry=0x128d6a0, 
    query_string=query_string@entry=0x128c4f8 "SELECT * FROM 
cypher('cypher_set', $$MATCH (n) SET n.i = 3$$) AS (a agtype);", 
    paramTypes=paramTypes@entry=0x0, numParams=numParams@entry=0, 
queryEnv=queryEnv@entry=0x0) at postgres.c:691
691             if (log_parser_stats)
(gdb) 
697             querytree_list = pg_rewrite_query(query);
(gdb) 

Breakpoint 1, getRTEPermissionInfo (rteperminfos=0x1375d78, rte=0x135d5c8) at 
parse_relation.c:3900
3900    {
(gdb) 
3903            if (rte->perminfoindex == 0 ||
(gdb) 
3904                    rte->perminfoindex > list_length(rteperminfos))
(gdb) 
3907            perminfo = list_nth_node(RTEPermissionInfo, rteperminfos,
(gdb) 
3909            if (perminfo->relid != rte->relid)
(gdb) 
get_row_security_policies (root=root@entry=0x135d6d8, rte=rte@entry=0x135d5c8, 
rt_index=rt_index@entry=1, 
    securityQuals=securityQuals@entry=0x7fff582d4e30, 
withCheckOptions=withCheckOptions@entry=0x7fff582d4e38, 
    hasRowSecurity=hasRowSecurity@entry=0x7fff582d4e2d, 
hasSubLinks=0x7fff582d4e2e) at rowsecurity.c:137
137             user_id = OidIsValid(perminfo->checkAsUser) ?
(gdb) 
141             rls_status = check_enable_rls(rte->relid, 
perminfo->checkAsUser, false);
(gdb) 
144             if (rls_status == RLS_NONE)
(gdb) 
fireRIRrules (parsetree=0x135d6d8, activeRIRs=activeRIRs@entry=0x0) at 
rewriteHandler.c:2191
2191                    if (securityQuals != NIL || withCheckOptions != NIL)
(gdb) 
2252                    if (hasRowSecurity)
(gdb) 
2254                    if (hasSubLinks)
(gdb) 
2257                    table_close(rel, NoLock);
(gdb) 
2165            foreach(lc, parsetree->rtable)
(gdb) 
2260            return parsetree;
(gdb) 
2035                            continue;
(gdb) 
2014            while (rt_index < list_length(parsetree->rtable))
(gdb) 
2142            foreach(lc, parsetree->cteList)
(gdb) 
2154            if (parsetree->hasSubLinks)
(gdb) 
2165            foreach(lc, parsetree->rtable)
(gdb) 
2167                    RangeTblEntry *rte = (RangeTblEntry *) lfirst(lc);
(gdb) 
2174                    ++rt_index;
(gdb) 
2177                    if (rte->rtekind != RTE_RELATION ||
(gdb) 
2165            foreach(lc, parsetree->rtable)
(gdb) 
2260            return parsetree;
(gdb) 
2035                            continue;
(gdb) 
2014            while (rt_index < list_length(parsetree->rtable))
(gdb) 
2142            foreach(lc, parsetree->cteList)
(gdb) 
2154            if (parsetree->hasSubLinks)
(gdb) 
2165            foreach(lc, parsetree->rtable)
(gdb) 
2167                    RangeTblEntry *rte = (RangeTblEntry *) lfirst(lc);
(gdb) 
2174                    ++rt_index;
(gdb) 
2177                    if (rte->rtekind != RTE_RELATION ||
(gdb) 
2165            foreach(lc, parsetree->rtable)
(gdb) 
2260            return parsetree;
(gdb) 
QueryRewrite (parsetree=parsetree@entry=0x128d830) at rewriteHandler.c:4234
4234                    query->queryId = input_query_id;
(gdb) 
4236                    results = lappend(results, query);
(gdb) 
4228            foreach(l, querylist)
(gdb) 
4255            origCmdType = parsetree->commandType;
(gdb) 
4259            foreach(l, results)
(gdb) 
4261                    Query      *query = (Query *) lfirst(l);
(gdb) 
4263                    if (query->querySource == QSRC_ORIGINAL)
(gdb) 
4265                            Assert(query->canSetTag);
(gdb) 
4266                            Assert(!foundOriginalQuery);
(gdb) 
4259            foreach(l, results)
(gdb) 
4282            if (!foundOriginalQuery && lastInstead != NULL)
(gdb) 
4285            return results;
(gdb) 
pg_rewrite_query (query=query@entry=0x128d830) at postgres.c:826
826             if (log_parser_stats)
(gdb) 
873             if (Debug_print_rewritten)
(gdb) 
pg_analyze_and_rewrite_fixedparams (parsetree=parsetree@entry=0x128d6a0, 
    query_string=query_string@entry=0x128c4f8 "SELECT * FROM 
cypher('cypher_set', $$MATCH (n) SET n.i = 3$$) AS (a agtype);", 
    paramTypes=paramTypes@entry=0x0, numParams=numParams@entry=0, 
queryEnv=queryEnv@entry=0x0) at postgres.c:701
701             return querytree_list;
(gdb) 
exec_simple_query (
    query_string=query_string@entry=0x128c4f8 "SELECT * FROM 
cypher('cypher_set', $$MATCH (n) SET n.i = 3$$) AS (a agtype);")
    at postgres.c:1193
1193                    plantree_list = pg_plan_queries(querytree_list, 
query_string,
(gdb) 

Breakpoint 1, getRTEPermissionInfo (rteperminfos=0x1385e88, 
rte=rte@entry=0x13791e0) at parse_relation.c:3900
3900    {
(gdb) 
3903            if (rte->perminfoindex == 0 ||
(gdb) 
3904                    rte->perminfoindex > list_length(rteperminfos))
(gdb) 
3907            perminfo = list_nth_node(RTEPermissionInfo, rteperminfos,
(gdb) 
3909            if (perminfo->relid != rte->relid)
(gdb) 
build_simple_rel (root=0x1378bc0, relid=2, parent=parent@entry=0x0) at 
relnode.c:258
258                             rel->userid = perminfo->checkAsUser;
(gdb) 
265             rel->useridiscurrent = false;
(gdb) 
266             rel->fdwroutine = NULL;
(gdb) 
267             rel->fdw_private = NULL;
(gdb) 
268             rel->unique_for_rels = NIL;
(gdb) 
269             rel->non_unique_for_rels = NIL;
(gdb) 
270             rel->baserestrictinfo = NIL;
(gdb) 
271             rel->baserestrictcost.startup = 0;
(gdb) 
272             rel->baserestrictcost.per_tuple = 0;
(gdb) 
273             rel->baserestrict_min_security = UINT_MAX;
(gdb) 
274             rel->joininfo = NIL;
(gdb) 
275             rel->has_eclass_joins = false;
(gdb) 
276             rel->consider_partitionwise_join = false;       /* might get 
changed later */
(gdb) 
277             rel->part_scheme = NULL;
(gdb) 
278             rel->nparts = -1;
(gdb) 
279             rel->boundinfo = NULL;
(gdb) 
280             rel->partbounds_merged = false;
(gdb) 
281             rel->partition_qual = NIL;
(gdb) 
282             rel->part_rels = NULL;
(gdb) 
283             rel->live_parts = NULL;
(gdb) 
284             rel->all_partrels = NULL;
(gdb) 
285             rel->partexprs = NULL;
(gdb) 
286             rel->nullable_partexprs = NULL;
(gdb) 
291             if (parent)
(gdb) 
324                     rel->parent = NULL;
(gdb) 
325                     rel->top_parent = NULL;
(gdb) 
326                     rel->top_parent_relids = NULL;
(gdb) 
327                     rel->nulling_relids = NULL;
(gdb) 
328                     rel->direct_lateral_relids = NULL;
(gdb) 
329                     rel->lateral_relids = NULL;
(gdb) 
330                     rel->lateral_referencers = NULL;
(gdb) 
334             switch (rte->rtekind)
(gdb) 
338                             get_relation_info(root, rte->relid, rte->inh, 
rel);
(gdb) 
379             if (parent)
(gdb) 
395             root->simple_rel_array[relid] = rel;
(gdb) 
397             return rel;
(gdb) 
add_base_rels_to_query (root=root@entry=0x1378bc0, 
jtnode=jtnode@entry=0x1378648) at initsplan.c:173
173                     foreach(l, f->fromlist)
(gdb) 
query_planner (root=root@entry=0x1378bc0, 
qp_callback=qp_callback@entry=0x743e08 <standard_qp_callback>, 
    qp_extra=qp_extra@entry=0x7fff582d4ab0) at planmain.c:180
180             build_base_rel_tlists(root, root->processed_tlist);
(gdb) 
182             find_placeholders_in_jointree(root);
(gdb) 
184             find_lateral_references(root);
(gdb) 
186             joinlist = deconstruct_jointree(root);
(gdb) 
193             reconsider_outer_join_clauses(root);
(gdb) 
200             generate_base_implied_equalities(root);
(gdb) 
207             (*qp_callback) (root, qp_extra);
(gdb) 
216             fix_placeholder_input_needed_levels(root);
(gdb) 
223             joinlist = remove_useless_joins(root, joinlist);
(gdb) 
229             reduce_unique_semijoins(root);
(gdb) 
236             add_placeholders_to_base_rels(root);
(gdb) 
242             create_lateral_join_info(root);
(gdb) c
Continuing.

Breakpoint 1, getRTEPermissionInfo (rteperminfos=rteperminfos@entry=0x1385e88, 
rte=rte@entry=0x138a350) at parse_relation.c:3900
3900    {
(gdb) 
Continuing.

Breakpoint 1, getRTEPermissionInfo (rteperminfos=rteperminfos@entry=0x1385e88, 
rte=rte@entry=0x138a550) at parse_relation.c:3900
3900    {
(gdb) n
3903            if (rte->perminfoindex == 0 ||
(gdb) 
3904                    rte->perminfoindex > list_length(rteperminfos))
(gdb) 
3907            perminfo = list_nth_node(RTEPermissionInfo, rteperminfos,
(gdb) 
3909            if (perminfo->relid != rte->relid)
(gdb) 
add_rte_to_flat_rtable (glob=glob@entry=0x128d720, rteperminfos=0x1385e88, 
rte=<optimized out>) at setrefs.c:598
598                     newrte->perminfoindex = 0;      /* expected by 
addRTEPermissionInfo() */
(gdb) 
599                     newperminfo = 
addRTEPermissionInfo(&glob->finalrteperminfos, newrte);
(gdb) 
600                     memcpy(newperminfo, perminfo, 
sizeof(RTEPermissionInfo));
(gdb) 
add_rtes_to_flat_rtable (root=root@entry=0x1378bc0, 
recursing=recursing@entry=false) at setrefs.c:405
405             foreach(lc, root->parse->rtable)
(gdb) 
407                     RangeTblEntry *rte = (RangeTblEntry *) lfirst(lc);
(gdb) 
409                     if (!recursing || rte->rtekind == RTE_RELATION ||
(gdb) 
411                             add_rte_to_flat_rtable(glob, 
root->parse->rteperminfos, rte);
(gdb) 
405             foreach(lc, root->parse->rtable)
(gdb) 
425             foreach(lc, root->parse->rtable)
(gdb) c
Continuing.

Breakpoint 1, getRTEPermissionInfo (rteperminfos=rteperminfos@entry=0x138a500, 
rte=rte@entry=0x138a350) at parse_relation.c:3900
3900    {
(gdb) n
3903            if (rte->perminfoindex == 0 ||
(gdb) 
3904                    rte->perminfoindex > list_length(rteperminfos))
(gdb) 
3907            perminfo = list_nth_node(RTEPermissionInfo, rteperminfos,
(gdb) 
3909            if (perminfo->relid != rte->relid)
(gdb) 
ExecCheckPermissions (rangeTable=rangeTable@entry=0x138a0d0, 
rteperminfos=0x138a500, 
    ereport_on_violation=ereport_on_violation@entry=true) at execMain.c:609
609                             Assert(!bms_is_member(rte->perminfoindex, 
indexset));
(gdb) 
610                             indexset = bms_add_member(indexset, 
rte->perminfoindex);
(gdb) c
Continuing.

Breakpoint 1, getRTEPermissionInfo (rteperminfos=rteperminfos@entry=0x138a500, 
rte=rte@entry=0x138a550) at parse_relation.c:3900
3900    {
(gdb) n
3903            if (rte->perminfoindex == 0 ||
(gdb) 
3904                    rte->perminfoindex > list_length(rteperminfos))
(gdb) 
3907            perminfo = list_nth_node(RTEPermissionInfo, rteperminfos,
(gdb) c
Continuing.

Breakpoint 1, getRTEPermissionInfo (rteperminfos=0x138a500, rte=0x138a6b0) at 
parse_relation.c:3900
3900    {
(gdb) n
3903            if (rte->perminfoindex == 0 ||
(gdb) 
3905                    elog(ERROR, "invalid perminfoindex %u in RTE with relid 
%u",
(gdb) bt
#0  getRTEPermissionInfo (rteperminfos=0x138a500, rte=0x138a6b0) at 
parse_relation.c:3905
#1  0x0000000000676e29 in GetResultRTEPermissionInfo 
(relinfo=relinfo@entry=0x13b8f50, estate=estate@entry=0x138ce48)
    at execUtils.c:1412
#2  0x0000000000677c30 in ExecGetUpdatedCols (relinfo=relinfo@entry=0x13b8f50, 
estate=estate@entry=0x138ce48)
    at execUtils.c:1321
#3  0x0000000000677cd7 in ExecGetAllUpdatedCols 
(relinfo=relinfo@entry=0x13b8f50, estate=estate@entry=0x138ce48)
    at execUtils.c:1362
#4  0x000000000066b9bf in ExecUpdateLockMode (estate=estate@entry=0x138ce48, 
relinfo=relinfo@entry=0x13b8f50) at execMain.c:2385
#5  0x00007f197fb19a8d in update_entity_tuple (resultRelInfo=<optimized out>, 
resultRelInfo@entry=0x13b8f50, 
    elemTupleSlot=elemTupleSlot@entry=0x13b9730, estate=estate@entry=0x138ce48, 
old_tuple=0x13bae80)
    at src/backend/executor/cypher_set.c:120
#6  0x00007f197fb1a2ff in process_update_list (node=node@entry=0x138d0c8) at 
src/backend/executor/cypher_set.c:595
#7  0x00007f197fb1a348 in process_all_tuples (node=node@entry=0x138d0c8) at 
src/backend/executor/cypher_set.c:212
#8  0x00007f197fb1a455 in exec_cypher_set (node=0x138d0c8) at 
src/backend/executor/cypher_set.c:641
#9  0x0000000000683414 in ExecCustomScan (pstate=<optimized out>) at 
nodeCustom.c:124
#10 0x00000000006705c7 in ExecProcNodeFirst (node=0x138d0c8) at 
execProcnode.c:464
#11 0x0000000000668a35 in ExecProcNode (node=node@entry=0x138d0c8) at 
../../../src/include/executor/executor.h:273
#12 0x0000000000668ac5 in ExecutePlan (estate=estate@entry=0x138ce48, 
planstate=0x138d0c8, use_parallel_mode=<optimized out>, 
    operation=operation@entry=CMD_SELECT, sendTuples=sendTuples@entry=true, 
numberTuples=numberTuples@entry=0, 
    direction=ForwardScanDirection, dest=0x138b570, execute_once=true) at 
execMain.c:1670
#13 0x000000000066978f in standard_ExecutorRun (queryDesc=0x137e978, 
direction=ForwardScanDirection, count=0, execute_once=true)
    at execMain.c:365
#14 0x00000000006698a2 in ExecutorRun (queryDesc=queryDesc@entry=0x137e978, 
direction=direction@entry=ForwardScanDirection, 
    count=count@entry=0, execute_once=<optimized out>) at execMain.c:309
#15 0x000000000081dc15 in PortalRunSelect (portal=portal@entry=0x1305e68, 
forward=forward@entry=true, count=0, 
    count@entry=9223372036854775807, dest=dest@entry=0x138b570) at pquery.c:924
#16 0x000000000081f336 in PortalRun (portal=portal@entry=0x1305e68, 
count=count@entry=9223372036854775807, 
    isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, 
dest=dest@entry=0x138b570, altdest=altdest@entry=0x138b570, 
    qc=0x7fff582d5010) at pquery.c:768
--Type <RET> for more, q to quit, c to continue without paging--
#17 0x000000000081b823 in exec_simple_query (
    query_string=query_string@entry=0x128c4f8 "SELECT * FROM 
cypher('cypher_set', $$MATCH (n) SET n.i = 3$$) AS (a agtype);")
    at postgres.c:1274
#18 0x000000000081d4b9 in PostgresMain (dbname=<optimized out>, 
username=<optimized out>) at postgres.c:4632
#19 0x000000000078ba20 in BackendRun (port=port@entry=0x12b6730) at 
postmaster.c:4461
#20 0x000000000078d841 in BackendStartup (port=port@entry=0x12b6730) at 
postmaster.c:4189
#21 0x000000000078d9c1 in ServerLoop () at postmaster.c:1779
#22 0x000000000078edaf in PostmasterMain (argc=argc@entry=3, 
argv=argv@entry=0x1286730) at postmaster.c:1463
#23 0x00000000006beef9 in main (argc=3, argv=0x1286730) at main.c:198
(gdb) n
0x000000000081f180 in PortalRun (portal=portal@entry=0x1305e68, 
count=count@entry=9223372036854775807, 
    isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, 
dest=dest@entry=0x138b570, altdest=altdest@entry=0x138b570, 
    qc=0x7fff582d5010) at pquery.c:741
741             PG_TRY();
(gdb) 
808             PG_CATCH();
(gdb) 
811                     MarkPortalFailed(portal);

Reply via email to