apache / age

Graph database optimized for fast analysis and real-time data processing. It is provided as an extension to PostgreSQL.
https://age.apache.org
Apache License 2.0
2.87k stars 401 forks source link

Server crashes when executing SELECT * FROM cypher('ag_graph_3'...) #1953

Closed saygoodbyye closed 3 days ago

saygoodbyye commented 2 weeks ago

Describe the bug Server 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 (PG16 branch) with PostgreSQL (REL_16_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 * FROM create_graph('ag_graph_3');
SELECT * FROM cypher('ag_graph_3', $$ RETURN delete_global_graphs('ag_graph_3')[{}][{}][{}][{}][{}] $$) AS (result agtype);

backtrace:

#0  pg_detoast_datum (datum=0x0) at fmgr.c:1805
#1  0x000056ca2ccd3682 in construct_md_array (elems=0x56ca2dfcfa98, nulls=0x56ca2dfcfae8, ndims=ndims@entry=1, dims=dims@entry=0x7fff46838f30, lbs=lbs@entry=0x7fff46838f50,
    elmtype=elmtype@entry=16452, elmlen=-1, elmbyval=false, elmalign=105 'i') at ../../../../src/include/postgres.h:314
#2  0x000056ca2cac78d3 in ExecEvalArrayExpr (state=state@entry=0x56ca2dfcf800, op=op@entry=0x56ca2dfcfd20) at execExprInterp.c:2746
#3  0x000056ca2cacaf5a in ExecInterpExpr (state=0x56ca2dfcf800, econtext=0x56ca2dfcf528, isnull=0x7fff46839067) at execExprInterp.c:1342
#4  0x000056ca2cac7230 in ExecInterpExprStillValid (state=0x56ca2dfcf800, econtext=0x56ca2dfcf528, isNull=0x7fff46839067) at execExprInterp.c:1870
#5  0x000056ca2cb04c08 in ExecEvalExprSwitchContext (state=<optimized out>, econtext=<optimized out>, isNull=<optimized out>) at ../../../src/include/executor/executor.h:355
#6  0x000056ca2cb04c4f in ExecProject (projInfo=0x56ca2dfcf7f8) at ../../../src/include/executor/executor.h:389
#7  0x000056ca2cb04def in ExecResult (pstate=<optimized out>) at nodeResult.c:136
#8  0x000056ca2cad6d70 in ExecProcNodeFirst (node=0x56ca2dfcf418) at execProcnode.c:464
#9  0x000056ca2cacec1f in ExecProcNode (node=node@entry=0x56ca2dfcf418) at ../../../src/include/executor/executor.h:273
#10 0x000056ca2cacecaf in ExecutePlan (estate=estate@entry=0x56ca2dfcf1d8, planstate=0x56ca2dfcf418, use_parallel_mode=<optimized out>, operation=operation@entry=CMD_SELECT,
    sendTuples=sendTuples@entry=true, numberTuples=numberTuples@entry=0, direction=ForwardScanDirection, dest=0x56ca2e006c10, execute_once=true) at execMain.c:1670
#11 0x000056ca2cacf9e1 in standard_ExecutorRun (queryDesc=0x56ca2e038618, direction=ForwardScanDirection, count=0, execute_once=true) at execMain.c:365
#12 0x000056ca2cacfb0a in ExecutorRun (queryDesc=queryDesc@entry=0x56ca2e038618, direction=direction@entry=ForwardScanDirection, count=count@entry=0, execute_once=<optimized out>)
    at execMain.c:309
#13 0x000056ca2cca4593 in PortalRunSelect (portal=portal@entry=0x56ca2df697f8, forward=forward@entry=true, count=0, count@entry=9223372036854775807,
    dest=dest@entry=0x56ca2e006c10) at pquery.c:924
#14 0x000056ca2cca5de3 in PortalRun (portal=portal@entry=0x56ca2df697f8, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true,
    dest=dest@entry=0x56ca2e006c10, altdest=altdest@entry=0x56ca2e006c10, qc=0x7fff46839390) at pquery.c:768
#15 0x000056ca2cca1fdd in exec_simple_query (
    query_string=query_string@entry=0x56ca2def14d8 "SELECT * FROM cypher('ag_graph_3', $$ RETURN delete_global_graphs('ag_graph_3')[{}][{}][{}][{}][{}] $$) AS (result agtype);")
    at postgres.c:1274
#16 0x000056ca2cca3e2f in PostgresMain (dbname=<optimized out>, username=<optimized out>) at postgres.c:4637
#17 0x000056ca2cc05ede in BackendRun (port=port@entry=0x56ca2df1e240) at postmaster.c:4464
#18 0x000056ca2cc07ef6 in BackendStartup (port=port@entry=0x56ca2df1e240) at postmaster.c:4192
#19 0x000056ca2cc08094 in ServerLoop () at postmaster.c:1782
#20 0x000056ca2cc095d0 in PostmasterMain (argc=argc@entry=8, argv=argv@entry=0x56ca2deab480) at postmaster.c:1466
#21 0x000056ca2cb2e205 in main (argc=8, argv=0x56ca2deab480) at main.c:198

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

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

jrgemignani commented 2 weeks ago

@saygoodbyye Hmmmm,... this is due to an issue between PG boolean and AGTYPE boolean. I can fix it superficially, but I feel like there is a better way to address this one.

jrgemignani commented 1 week ago

@saygoodbyye Resolved with PR #1959

saygoodbyye commented 3 days ago

@jrgemignani, Thank you! PR #1959 fixes this issue