SQL Expressions: Add setting to limit length of query (#110165)
sql_expression_query_length_limit Set the maximum length of a SQL query that can be used in a SQL expression. Default is 10000 characters. A setting of 0 means no limit.
This commit is contained in:
@@ -389,3 +389,23 @@ func MakeColumnNotFoundError(refID string, err error) CategorizedError {
|
||||
|
||||
return &ErrorWithCategory{category: ErrCategoryColumnNotFound, err: ColumnNotFoundError.Build(data)}
|
||||
}
|
||||
|
||||
const ErrCategoryQueryTooLong = "query_too_long"
|
||||
|
||||
var queryTooLongStr = `sql expression [{{.Public.refId}}] was not run because the SQL query exceeded the configured limit of {{ .Public.queryLengthLimit }} characters`
|
||||
|
||||
var QueryTooLongError = errutil.NewBase(
|
||||
errutil.StatusBadRequest, sseErrBase+ErrCategoryQueryTooLong).MustTemplate(
|
||||
queryTooLongStr,
|
||||
errutil.WithPublic(queryTooLongStr))
|
||||
|
||||
func MakeQueryTooLongError(refID string, queryLengthLimit int64) CategorizedError {
|
||||
data := errutil.TemplateData{
|
||||
Public: map[string]interface{}{
|
||||
"refId": refID,
|
||||
"queryLengthLimit": queryLengthLimit,
|
||||
},
|
||||
}
|
||||
|
||||
return &ErrorWithCategory{category: ErrCategoryQueryTooLong, err: QueryTooLongError.Build(data)}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user