sraoss / pgsql-ivm

IVM (Incremental View Maintenance) development for PostgreSQL
Other
129 stars 12 forks source link

segfault with subquery in target list #134

Closed benny-medflyt closed 2 years ago

benny-medflyt commented 3 years ago
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
thoshiai commented 3 years ago

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.

benny-medflyt commented 3 years ago

Cool, even better if this could be supported and work :crossed_fingers:

thoshiai commented 3 years ago

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

yugo-n commented 2 years ago

This bug is fixed.