sraoss / pgsql-ivm

IVM (Incremental View Maintenance) development for PostgreSQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

segfault with subquery in target list

benny-medflyt opened this issue · comments

CREATE TABLE foo(
  id SERIAL PRIMARY KEY,
  val INT
);

CREATE INCREMENTAL MATERIALIZED VIEW foo_x AS
SELECT
    foo.id,
    foo.val,
    EXISTS (SELECT 1 FROM foo f where f.id = foo.id) AS x
FROM
    foo;

server crashes with:

2021-10-03 10:12:08.152 EDT [53819] LOG:  server process (PID 54278) was terminated by signal 11: Segmentation fault
2021-10-03 10:12:08.152 EDT [53819] DETAIL:  Failed process was running: CREATE INCREMENTAL MATERIALIZED VIEW foo_x AS
        SELECT
            foo.id,
            foo.val,
            EXISTS (SELECT 1 FROM foo f where f.id = foo.id) AS x
        FROM
            foo

2021-10-03 10:12:08.153 EDT [53819] LOG:  terminating any other active server processes
2021-10-03 10:12:08.153 EDT [53819] LOG:  all server processes terminated; reinitializing
2021-10-03 10:12:08.166 EDT [54281] LOG:  database system was interrupted; last known up at 2021-10-03 10:10:59 EDT
2021-10-03 10:12:08.228 EDT [54281] LOG:  database system was not properly shut down; automatic recovery in progress
2021-10-03 10:12:08.233 EDT [54281] LOG:  redo starts at 0/14E3E08
2021-10-03 10:12:08.233 EDT [54281] LOG:  invalid record length at 0/14E3E40: wanted 24, got 0
2021-10-03 10:12:08.233 EDT [54281] LOG:  redo done at 0/14E3E08 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s
2021-10-03 10:12:08.269 EDT [53819] LOG:  database system is ready to accept connections

Thank you for your reporting it.
I could reproduce it. In IVM, EXISTS clause is not supported in target list. I will fix it so that an error occurs.

Cool, even better if this could be supported and work 🤞

Sorry. I fix to cause an error in this case.
In the future, I hope and improve subquery is supported in target list.

This bug is fixed.