Skip to content

Assert failure when using CTAS USING iceberg in PL/pgSQL #215

@sfc-gh-mslot

Description

@sfc-gh-mslot

The following triggers an assert failure in SPI:

CREATE OR REPLACE FUNCTION test_ctas_iceberg()
  RETURNS void
  LANGUAGE plpgsql
  AS $$
  BEGIN
      EXECUTE 'CREATE TABLE test_iceberg USING iceberg AS SELECT 1 AS id';
  END;
  $$;
select test_ctas_iceberg();
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
The connection to the server was lost. Attempting reset: Failed.
Time: 523.348 ms

In the log:

TRAP: failed Assert("ctastmt->if_not_exists || ctastmt->into->skipData"), File: "spi.c", Line: 2750, PID: 51995
0   postgres                            0x00000001005fb070 ExceptionalCondition + 108
1   postgres                            0x00000001003331ec _SPI_execute_plan + 2004
2   postgres                            0x00000001003332f0 SPI_execute_extended + 188
3   plpgsql.dylib                       0x0000000101afe95c exec_stmts + 2012
4   plpgsql.dylib                       0x0000000101afda94 exec_stmt_block + 912
5   plpgsql.dylib                       0x0000000101afb760 plpgsql_exec_function + 608
6   plpgsql.dylib                       0x0000000101b0d66c plpgsql_call_handler + 320
7   postgres                            0x00000001002ef5cc ExecInterpExpr + 1472
8   postgres                            0x000000010032879c ExecResult + 324
9   postgres                            0x00000001002f7b48 standard_ExecutorRun + 292
10  pg_stat_statements.dylib            0x000000010103133c pgss_ExecutorRun + 184
11  pgaudit.dylib                       0x0000000105ee6170 pgaudit_ExecutorRun_hook + 36
12  postgres                            0x00000001004cc538 PortalRunSelect + 232
13  postgres                            0x00000001004cc164 PortalRun + 492
14  postgres                            0x00000001004cb138 exec_simple_query + 1396
15  postgres                            0x00000001004c8d38 PostgresMain + 3496
16  postgres                            0x00000001004c42a4 BackendInitialize + 0
17  postgres                            0x00000001004292b0 PgArchShmemSize + 0
18  postgres                            0x000000010042d818 ServerLoop + 7312
19  postgres                            0x000000010042b300 InitProcessGlobals + 0
20  postgres                            0x000000010034b6dc help + 0
21  dyld                                0x000000018a3c9d54 start + 7184

looks somewhat like a Postgres bug, but does get triggered by our AST manipulation

Metadata

Metadata

Assignees

No one assigned

    Labels

    backportbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions