2057880- INSERT to very large table fails with 'stack overflow' and error 3626 "transaction was aborted because it used too much stack space" - SAP ASE

Symptom

Table in question is very large (4TB in this instance)

INSERT to table is simple:

insert into mytable select * from #my_temp_table

INSERT fails with error 3626:

Msg 3626, Level 17, State 1: Server 'SYBASE', Line 1: The transaction was aborted because it used too much stack space. Either use sp_configure to increase the stack size, or break the query into smaller pieces. spid: %d, suid: %d, hostname: %.*s, application name: %.*s

Error 3626 is followed by a stack overflow error:

stack_tracer: stack overflow last chance handler. Task 107807543 has completely exhausted stack at line 664 in file ... Cleanup is no longer possible and task will be killed

Stack trace may include modules such as stack_abort(), stack_oflow(), pg__clean_oam(), pg__insertoam()