New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on create continuous aggregate with data #2389
Conversation
006f140
to
29db351
Compare
Codecov Report
@@ Coverage Diff @@
## master #2389 +/- ##
==========================================
+ Coverage 88.51% 88.53% +0.01%
==========================================
Files 212 212
Lines 34924 34928 +4
==========================================
+ Hits 30912 30922 +10
+ Misses 4012 4006 -6
Continue to review full report at Codecov.
|
FROM conditions | ||
GROUP BY 1,2 WITH DATA; | ||
END $$; | ||
ERROR: CREATE MATERIALIZED VIEW ... WITH DATA cannot be executed from a function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is slightly odd message, why we had to wrap it into the DO statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, but it's the standard message that PreventInTransactionBlock
prints. It digs out the context itself, and uses the format %s cannot be ....
.
\set ON_ERROR_STOP 0 | ||
DO | ||
LANGUAGE PLPGSQL | ||
$$ DECLARE ts_version TEXT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this DECLARE do? Seem like a copy-paste leftover.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
-- This should fail since we do not allow refreshing inside a | ||
-- transaction, not even as part of CREATE MATERIALIZED VIEW. | ||
\set ON_ERROR_STOP 0 | ||
DO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just do a regular BEGIN--- COMMIT; transaction block instead of creating a function block. At least it would be good to test that case as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And it will likely change the error message as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done that as well.
-- aggregate. | ||
DO | ||
LANGUAGE PLPGSQL | ||
$$ DECLARE ts_version TEXT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another declare block and variable that is never used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
If a continuous aggregate is created using `CREATE MATERIALIZED VIEW` using the `WITH DATA` option, it will fail with a segmentation fault if executed inside a transaction or block. This is because starting a new transaction in the middle of the statement will reset the SPI stack. This commit fixes this by raising an error if `CREATE MATERIALIZED VIEW` is not executed on top-level and `WITH DATA` is used either directly or indirectly. Closes timescale#2371
29db351
to
dc625a2
Compare
If a continuous aggregate is created using
CREATE MATERIALIZED VIEW
using the
WITH DATA
option, it will fail with a segmentation fault ifexecuted inside a transaction or block. This is because starting a new
transaction in the middle of the statement will reset the SPI stack.
This commit fixes this by raising an error if
CREATE MATERIALIZED VIEW
is not executed on top-level andWITH DATA
is used eitherdirectly or indirectly.
Closes #2371