(gdb) bt #0 toast_decompress_datum (attr=0x12572e0) at tuptoaster.c:2291 #1 toast_decompress_datum (attr=0x12572e0) at tuptoaster.c:2277 #2 0x00000000004c3b08 in heap_tuple_untoast_attr_slice (attr=, sliceoffset=0, slicelength=-1) at tuptoaster.c:315 #3 0x000000000085c1e5 in pg_detoast_datum_slice (datum=, first=, count=) at fmgr.c:1767 #4 0x0000000000833b7a in text_substring (str=133761519127512, start=0, length=, length_not_specified=) at varlena.c:956 #5 0x0000000000600a5b in ExecInterpExpr (state=0x12549c8, econtext=0x1253728, isnull=) at execExprInterp.c:649 #6 0x000000000061511f in ExecEvalExprSwitchContext (isNull=0x7ffc45db755f, econtext=, state=) at ../../../src/include/executor/executor.h:307 #7 advance_aggregates (aggstate=0x1253500, aggstate=0x1253500) at nodeAgg.c:679 #8 agg_retrieve_direct (aggstate=0x1253500) at nodeAgg.c:1847 #9 ExecAgg (pstate=0x1253500) at nodeAgg.c:1572 #10 0x000000000060371b in ExecProcNode (node=0x1253500) at ../../../src/include/executor/executor.h:239 #11 ExecutePlan (execute_once=, dest=0x12595b8, direction=, numberTuples=0, sendTuples=, operation=CMD_SELECT, use_parallel_mode=, planstate=0x1253500, estate=0x12532c0) at execMain.c:1648 #12 standard_ExecutorRun (queryDesc=0x11be580, direction=, count=0, execute_once=) at execMain.c:365 #13 0x0000000000748b2b in PortalRunSelect (portal=portal@entry=0x12043a0, forward=forward@entry=true, count=0, count@entry=9223372036854775807, dest=dest@entry=0x12595b8) at pquery.c:929 #14 0x0000000000749f00 in PortalRun (portal=portal@entry=0x12043a0, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x12595b8, altdest=altdest@entry=0x12595b8, completionTag=0x7ffc45db77e0 "") at pquery.c:770 #15 0x000000000074611f in exec_simple_query (query_string=0x119c820 "select sum(length(substr(a,0))) from t;") at postgres.c:1215 #16 0x000000000074783e in PostgresMain (argc=, argv=argv@entry=0x11c84d0, dbname=, username=) at postgres.c:4249 #17 0x00000000006d75d9 in BackendRun (port=0x11c09e0, port=0x11c09e0) at postmaster.c:4431 #18 BackendStartup (port=0x11c09e0) at postmaster.c:4122 #19 ServerLoop () at postmaster.c:1704 #20 0x00000000006d840c in PostmasterMain (argc=argc@entry=3, argv=argv@entry=0x11963e0) at postmaster.c:1377