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
Do not allow to INSERT into a table with row filter #7346
Conversation
@@ -405,4 +405,16 @@ public void testUpdate() | |||
assertThatThrownBy(() -> assertions.query("UPDATE orders SET totalprice = totalprice * 2 WHERE orderkey IN (10, 20, 30)")) |
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.
Typo in commit message: filterring
@@ -415,7 +415,7 @@ protected Scope visitInsert(Insert insert, Optional<Scope> scope) | |||
|
|||
for (ColumnMetadata column : columns) { | |||
if (!accessControl.getColumnMasks(session.toSecurityContext(), targetTable, column.getName(), column.getType()).isEmpty()) { | |||
throw semanticException(NOT_SUPPORTED, insert, "Insert into table with column masks"); | |||
throw semanticException(NOT_SUPPORTED, insert, "Insert into table with column masks is not supported"); |
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.
or "not allowed"
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 at least consistent with the analogous message for UPDATE
, see e.g. line 1866 and 1873
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.
kokosing@m16:~/presto$ grep -i 'not allowed' ./core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java
throw semanticException(INVALID_COLUMN_REFERENCE, reference, "LATERAL reference not allowed in %s JOIN", node.getType().name());
throw semanticException(COLUMN_NOT_FOUND, allColumns, "SELECT * not allowed from relation that has no columns");
throw semanticException(COLUMN_NOT_FOUND, allColumns, "SELECT * not allowed in queries without FROM clause");
throw semanticException(COLUMN_NOT_FOUND, allColumns, "SELECT * not allowed from relation that has no columns");
// Since RECURSIVE is specified, any reference to WITH query name is considered a recursive reference and is not allowed.
throw semanticException(INVALID_RECURSIVE_REFERENCE, recursiveReferences.get(0), "recursive reference not allowed in this context");
kokosing@m16:~/presto$ grep -i 'not supported' ./core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java
throw semanticException(NOT_SUPPORTED, node, "USE statement is not supported");
throw semanticException(NOT_SUPPORTED, insert, "Inserting into materialized views is not supported");
throw semanticException(NOT_SUPPORTED, insert, "Inserting into views is not supported");
throw semanticException(NOT_SUPPORTED, insert, "Insert into table with a row filter is not supported");
throw semanticException(NOT_SUPPORTED, insert, "Insert into table with column masks is not supported");
throw semanticException(NOT_SUPPORTED, node, "Deleting from views is not supported");
throw semanticException(NOT_SUPPORTED, node, "Analyzing views is not supported");
throw semanticException(NOT_SUPPORTED, node, "Natural join not supported");
throw semanticException(NOT_SUPPORTED, update, "Updating through views is not supported");
throw semanticException(NOT_SUPPORTED, update, "Updating a table with a row filter is not supported");
throw semanticException(NOT_SUPPORTED, update, "Updating a table with column masks is not supported");
// filter with window function is not supported yet
throw semanticException(NOT_SUPPORTED, windowFunction, "Window function with ORDER BY is not supported");
throw semanticException(NOT_SUPPORTED, allColumns, "Column aliases not supported");
throw semanticException(NOT_SUPPORTED, node.getSelect(), "SELECT * from outer scope table not supported with anonymous columns");
throw semanticException(EXPRESSION_NOT_IN_DISTINCT, expression, "Non deterministic ORDER BY expression is not supported with SELECT DISTINCT")
This is coherent with the current convention. I see your point so I created an issue for this, see: #7369
USER, | ||
new ViewExpression(USER, Optional.empty(), Optional.empty(), "nationkey < 10")); | ||
assertThatThrownBy(() -> assertions.query("INSERT INTO nation VALUES (26, 'POLAND', 0, 'No comment')")) | ||
.hasMessage("This connector does not support inserts"); |
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 looks wrong. We should be testing with a connector which does support inserts, or make a mock connector pretend it does that.
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.
Let me squash this commit then to avoid imperfect intermediate state.
@@ -407,6 +407,10 @@ protected Scope visitInsert(Insert insert, Optional<Scope> scope) | |||
} | |||
accessControl.checkCanInsertIntoTable(session.toSecurityContext(), targetTable); | |||
|
|||
if (!accessControl.getRowFilters(session.toSecurityContext(), targetTable).isEmpty()) { | |||
throw semanticException(NOT_SUPPORTED, insert, "Insert into table with a row filter is not supported"); |
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.
or "is not allowed"
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.
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.
Some nits, and more serious concerns should be a separate PR
5b656d3
to
6395ff0
Compare
Do not allow to INSERT into a table with row filter