Skip to content

Server crashes when trying to execute SELECT '{...}'::agtype -> '"n"'::agtype -> '"1"'::agtype; #1389

Closed

Description

@saygoodbyye

Describe the bug
erver crashes when executing the following SQL-script

How are you accessing AGE (Command line, driver, etc.)?
Accessing AGE through command line.

What data setup do we need to do?
Apache AGE (master branch) with PostgreSQL (REL_15_STABLE).

What is the necessary configuration info needed?
My PostgreSQL configuration:

./configure CFLAGS=" -Og" --enable-tap-tests --enable-debug --enable-cassert

What is the command that caused the error?

CREATE EXTENSION age;
SET search_path TO ag_catalog;
SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"automatically":{"1":[2,3]}}'::agtype -> '"n"'::agtype -> '"1"'::agtype;

backtrace:

#0  agtype_value_to_agtype (val=0x0) at src/backend/utils/adt/agtype_util.c:110
#1  0x00007f827022c705 in agtype_object_field_impl (fcinfo=fcinfo@entry=0x56236aa27d88, agtype_in=agtype_in@entry=0x56236a8c6710, key=0x56236aa17a18 "1", key_len=1, as_text=as_text@entry=false) at src/backend/utils/adt/agtype.c:3648
#2  0x00007f827022c7b5 in agtype_object_field_agtype (fcinfo=0x56236aa27d88) at src/backend/utils/adt/agtype.c:3690
#3  0x000056236a21a2a8 in ExecInterpExpr (state=0x56236aa27c98, econtext=0x56236aa281f8, isnull=0x7ffd42174d14) at execExprInterp.c:751
#4  0x000056236a216fe1 in ExecInterpExprStillValid (state=0x56236aa27c98, econtext=0x56236aa281f8, isNull=0x7ffd42174d14) at execExprInterp.c:1826
#5  0x000056236a2fcedf in ExecEvalExprSwitchContext (isNull=0x7ffd42174d14, econtext=<optimized out>, state=0x56236aa27c98) at ../../../../src/include/executor/executor.h:344
#6  evaluate_expr (expr=<optimized out>, result_type=result_type@entry=16453, result_typmod=result_typmod@entry=-1, result_collation=result_collation@entry=0) at clauses.c:4823
#7  0x000056236a2fd0bb in evaluate_function (funcid=funcid@entry=16774, result_type=result_type@entry=16453, result_typmod=result_typmod@entry=-1, result_collid=result_collid@entry=0, input_collid=input_collid@entry=0, args=args@entry=0x56236ab62d68, 
    funcvariadic=false, func_tuple=0x7f8279549340, context=0x7ffd42175100) at clauses.c:4325
#8  0x000056236a2ff146 in simplify_function (funcid=16774, result_type=16453, result_typmod=result_typmod@entry=-1, result_collid=0, input_collid=0, args_p=args_p@entry=0x7ffd42174f00, funcvariadic=false, process_args=true, allow_non_const=true, 
    context=0x7ffd42175100) at clauses.c:3908
#9  0x000056236a2fd42b in eval_const_expressions_mutator (node=0x56236ab62448, context=0x7ffd42175100) at clauses.c:2475
#10 0x000056236a2943d7 in expression_tree_mutator (node=node@entry=0x56236ab624a0, mutator=mutator@entry=0x56236a2fd0fd <eval_const_expressions_mutator>, context=context@entry=0x7ffd42175100) at nodeFuncs.c:3080
#11 0x000056236a2fe5b9 in eval_const_expressions_mutator (node=0x56236ab624a0, context=0x7ffd42175100) at clauses.c:3527
#12 0x000056236a294621 in expression_tree_mutator (node=node@entry=0x56236ab624f8, mutator=mutator@entry=0x56236a2fd0fd <eval_const_expressions_mutator>, context=context@entry=0x7ffd42175100) at nodeFuncs.c:3166
#13 0x000056236a2fe5b9 in eval_const_expressions_mutator (node=0x56236ab624f8, context=context@entry=0x7ffd42175100) at clauses.c:3527
#14 0x000056236a2fe71d in eval_const_expressions (root=root@entry=0x56236ab62638, node=<optimized out>) at clauses.c:2107
#15 0x000056236a2dfd4f in preprocess_expression (root=root@entry=0x56236ab62638, expr=<optimized out>, kind=kind@entry=1) at planner.c:1127
#16 0x000056236a2e76f0 in subquery_planner (glob=glob@entry=0x56236a992480, parse=parse@entry=0x56236a8c65d0, parent_root=parent_root@entry=0x0, hasRecursion=hasRecursion@entry=false, tuple_fraction=tuple_fraction@entry=0) at planner.c:792
#17 0x000056236a2e82d3 in standard_planner (parse=0x56236a8c65d0, query_string=<optimized out>, cursorOptions=2048, boundParams=<optimized out>) at planner.c:408
#18 0x000056236a2e888b in planner (parse=parse@entry=0x56236a8c65d0, 
    query_string=query_string@entry=0x56236a8c50e0 "SELECT '{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"automatically\":{\"1\":[2,3]}}'::agtype -> '\"n\"'::agtype -> '\"1\"'::agtype;", cursorOptions=cursorOptions@entry=2048, 
    boundParams=boundParams@entry=0x0) at planner.c:277
#19 0x000056236a3c445d in pg_plan_query (querytree=querytree@entry=0x56236a8c65d0, 
    query_string=query_string@entry=0x56236a8c50e0 "SELECT '{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"automatically\":{\"1\":[2,3]}}'::agtype -> '\"n\"'::agtype -> '\"1\"'::agtype;", cursorOptions=cursorOptions@entry=2048, 
    boundParams=boundParams@entry=0x0) at postgres.c:883
#20 0x000056236a3c451a in pg_plan_queries (querytrees=0x56236ab625e0, 
    query_string=query_string@entry=0x56236a8c50e0 "SELECT '{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"automatically\":{\"1\":[2,3]}}'::agtype -> '\"n\"'::agtype -> '\"1\"'::agtype;", cursorOptions=cursorOptions@entry=2048, 
    boundParams=boundParams@entry=0x0) at postgres.c:975
#21 0x000056236a3c497a in exec_simple_query (query_string=query_string@entry=0x56236a8c50e0 "SELECT '{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"automatically\":{\"1\":[2,3]}}'::agtype -> '\"n\"'::agtype -> '\"1\"'::agtype;") at postgres.c:1169
#22 0x000056236a3c68c7 in PostgresMain (dbname=<optimized out>, username=<optimized out>) at postgres.c:4598
#23 0x000056236a32b8a4 in BackendRun (port=port@entry=0x56236a8e5f80) at postmaster.c:4514
#24 0x000056236a32d8b4 in BackendStartup (port=port@entry=0x56236a8e5f80) at postmaster.c:4242
#25 0x000056236a32daed in ServerLoop () at postmaster.c:1809
#26 0x000056236a32f0c2 in PostmasterMain (argc=argc@entry=3, argv=argv@entry=0x56236a8bf5c0) at postmaster.c:1481
#27 0x000056236a27be2a in main (argc=3, argv=0x56236a8bf5c0) at main.c:202

Expected behavior
Expected ERROR to be shown or sql query to be succesfully executed

Best regards,
Egor Chindyaskin
Postgres Professional: http://postgrespro.com/

Activity

  1. added
    bug
    on Nov 9, 2023
  2. added a commit that references this issue on Nov 9, 2023
  3. added a commit that references this issue on Nov 9, 2023
  4. jrgemignani commented on Nov 9, 2023

    @jrgemignani
    Contributor

    @saygoodbyye The master now has the fix. Please verify and if this resolves the issue satisfactorily, please close the ticket.

  5. saygoodbyye commented on Nov 10, 2023

    @saygoodbyye
    Author

    Thank you!

  6. added a commit that references this issue on Dec 13, 2023
  7. added a commit that references this issue on Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions