-
Notifications
You must be signed in to change notification settings - Fork 11
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
Reporting CTE Materialized clause and Sql body in Function #2165
Changes from all commits
15b4e98
a9ab725
06108b6
3c0fee2
c3f291d
3058bf7
304b991
e89e77a
9a358df
012cdb9
72b73d8
fc1b227
1eb486e
f52074c
1659133
3ec1447
f252657
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -603,6 +603,25 @@ func (v *ViewIssueDetector) DetectIssues(obj queryparser.DDLObject) ([]QueryIssu | |
return issues, nil | ||
} | ||
|
||
// ================FUNCTION ISSUE DETECTOR ================== | ||
|
||
type FunctionIssueDetector struct{} | ||
|
||
func (v *FunctionIssueDetector) DetectIssues(obj queryparser.DDLObject) ([]QueryIssue, error) { | ||
function, ok := obj.(*queryparser.Function) | ||
if !ok { | ||
return nil, fmt.Errorf("invalid object type: expected View") | ||
} | ||
var issues []QueryIssue | ||
|
||
if function.HasSqlBody { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
yes BEGIN can also start a function block
No only There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, but will There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, this |
||
//https://www.postgresql.org/docs/15/sql-createfunction.html#:~:text=a%20new%20session.-,sql_body,-The%20body%20of | ||
issues = append(issues, NewSqlBodyInFunctionIssue(function.GetObjectType(), function.GetObjectName(), "")) | ||
} | ||
|
||
return issues, nil | ||
} | ||
|
||
// ==============MVIEW ISSUE DETECTOR ====================== | ||
|
||
type MViewIssueDetector struct{} | ||
|
@@ -667,6 +686,8 @@ func (p *ParserIssueDetector) GetDDLDetector(obj queryparser.DDLObject) (DDLIssu | |
return &ViewIssueDetector{}, nil | ||
case *queryparser.MView: | ||
return &MViewIssueDetector{}, nil | ||
case *queryparser.Function: | ||
return &FunctionIssueDetector{}, nil | ||
case *queryparser.Collation: | ||
return &CollationIssueDetector{}, nil | ||
default: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -563,6 +563,20 @@ func NewForeignKeyReferencesPartitionedTableIssue(objectType string, objectName | |
return newQueryIssue(foreignKeyReferencesPartitionedTableIssue, objectType, objectName, SqlStatement, details) | ||
} | ||
|
||
var sqlBodyInFunctionIssue = issue.Issue{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please define a Description for each issue moving forward. |
||
Type: SQL_BODY_IN_FUNCTION, | ||
Name: SQL_BODY_IN_FUNCTION_NAME, | ||
Impact: constants.IMPACT_LEVEL_1, | ||
Description: "SQL Body for sql languages in function statement is not supported in YugabyteDB", | ||
Suggestion: "No workaround available", | ||
GH: "https://github.com/yugabyte/yugabyte-db/issues/25575", | ||
DocsLink: "https://docs.yugabyte.com/preview/yugabyte-voyager/known-issues/postgresql/#postgresql-12-and-later-features", | ||
} | ||
|
||
func NewSqlBodyInFunctionIssue(objectType string, objectName string, SqlStatement string) QueryIssue { | ||
return newQueryIssue(sqlBodyInFunctionIssue, objectType, objectName, SqlStatement, map[string]interface{}{}) | ||
} | ||
|
||
var uniqueNullsNotDistinctIssue = issue.Issue{ | ||
Type: UNIQUE_NULLS_NOT_DISTINCT, | ||
Name: UNIQUE_NULLS_NOT_DISTINCT_NAME, | ||
|
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 you add a comment here explaining that both MATERIALIZED, NOT MATERIALIZED flags were not supported..