Commit a8434379 authored by Radu Berinde's avatar Radu Berinde

sql: remove Impure flag

Release note: None
parent 4ee72a16
......@@ -38,9 +38,6 @@ func initAggregateBuiltins() {
panic("duplicate builtin: " + k)
}
if !v.props.Impure {
panic(fmt.Sprintf("%s: aggregate functions should all be impure, found %v", k, v))
}
if v.props.Class != tree.AggregateClass {
panic(fmt.Sprintf("%s: aggregate functions should be marked with the tree.AggregateClass "+
"function class, found %v", k, v))
......@@ -61,7 +58,7 @@ func initAggregateBuiltins() {
}
func aggProps() tree.FunctionProperties {
return tree.FunctionProperties{Class: tree.AggregateClass, Impure: true}
return tree.FunctionProperties{Class: tree.AggregateClass}
}
func aggPropsNullableArgs() tree.FunctionProperties {
......
......@@ -493,7 +493,6 @@ var builtins = map[string]builtinDefinition{
"gen_random_uuid": makeBuiltin(
tree.FunctionProperties{
Category: categoryIDGeneration,
Impure: true,
},
tree.Overload{
Types: tree.ArgTypes{},
......@@ -1714,9 +1713,7 @@ CockroachDB supports the following flags:
),
"random": makeBuiltin(
tree.FunctionProperties{
Impure: true,
},
tree.FunctionProperties{},
tree.Overload{
Types: tree.ArgTypes{},
ReturnType: tree.FixedReturnType(types.Float),
......@@ -1731,7 +1728,6 @@ CockroachDB supports the following flags:
"unique_rowid": makeBuiltin(
tree.FunctionProperties{
Category: categoryIDGeneration,
Impure: true,
},
tree.Overload{
Types: tree.ArgTypes{},
......@@ -1754,7 +1750,6 @@ CockroachDB supports the following flags:
tree.FunctionProperties{
Category: categorySequences,
DistsqlBlocklist: true,
Impure: true,
HasSequenceArguments: true,
},
tree.Overload{
......@@ -1781,7 +1776,6 @@ CockroachDB supports the following flags:
tree.FunctionProperties{
Category: categorySequences,
DistsqlBlocklist: true,
Impure: true,
HasSequenceArguments: true,
},
tree.Overload{
......@@ -1807,7 +1801,6 @@ CockroachDB supports the following flags:
"lastval": makeBuiltin(
tree.FunctionProperties{
Category: categorySequences,
Impure: true,
},
tree.Overload{
Types: tree.ArgTypes{},
......@@ -1830,7 +1823,6 @@ CockroachDB supports the following flags:
tree.FunctionProperties{
Category: categorySequences,
DistsqlBlocklist: true,
Impure: true,
HasSequenceArguments: true,
},
tree.Overload{
......@@ -1999,7 +1991,7 @@ CockroachDB supports the following flags:
// https://www.postgresql.org/docs/10/static/functions-datetime.html
"age": makeBuiltin(
tree.FunctionProperties{Impure: true},
tree.FunctionProperties{},
tree.Overload{
Types: tree.ArgTypes{{"val", types.TimestampTZ}},
ReturnType: tree.FixedReturnType(types.Interval),
......@@ -2021,7 +2013,7 @@ CockroachDB supports the following flags:
),
"current_date": makeBuiltin(
tree.FunctionProperties{Impure: true},
tree.FunctionProperties{},
tree.Overload{
Types: tree.ArgTypes{},
ReturnType: tree.FixedReturnType(types.Date),
......@@ -2040,7 +2032,7 @@ CockroachDB supports the following flags:
"localtime": txnTimeWithPrecisionBuiltin(false),
"statement_timestamp": makeBuiltin(
tree.FunctionProperties{Impure: true},
tree.FunctionProperties{},
tree.Overload{
Types: tree.ArgTypes{},
ReturnType: tree.FixedReturnType(types.TimestampTZ),
......@@ -2063,7 +2055,7 @@ CockroachDB supports the following flags:
),
tree.FollowerReadTimestampFunctionName: makeBuiltin(
tree.FunctionProperties{Impure: true},
tree.FunctionProperties{},
tree.Overload{
Types: tree.ArgTypes{},
ReturnType: tree.FixedReturnType(types.TimestampTZ),
......@@ -2091,7 +2083,6 @@ return without an error.`,
"cluster_logical_timestamp": makeBuiltin(
tree.FunctionProperties{
Category: categorySystemInfo,
Impure: true,
},
tree.Overload{
Types: tree.ArgTypes{},
......@@ -2111,7 +2102,7 @@ may increase either contention or retry errors, or both.`,
),
"clock_timestamp": makeBuiltin(
tree.FunctionProperties{Impure: true},
tree.FunctionProperties{},
tree.Overload{
Types: tree.ArgTypes{},
ReturnType: tree.FixedReturnType(types.TimestampTZ),
......@@ -2134,7 +2125,7 @@ may increase either contention or retry errors, or both.`,
),
"timeofday": makeBuiltin(
tree.FunctionProperties{Category: categoryDateAndTime, Impure: true},
tree.FunctionProperties{Category: categoryDateAndTime},
tree.Overload{
Types: tree.ArgTypes{},
ReturnType: tree.FixedReturnType(types.String),
......@@ -3220,7 +3211,6 @@ may increase either contention or retry errors, or both.`,
tree.FunctionProperties{
Category: categoryMultiTenancy,
Undocumented: true,
Impure: true,
},
tree.Overload{
Types: tree.ArgTypes{
......@@ -3266,7 +3256,6 @@ may increase either contention or retry errors, or both.`,
tree.FunctionProperties{
Category: categoryMultiTenancy,
Undocumented: true,
Impure: true,
},
tree.Overload{
Types: tree.ArgTypes{
......@@ -3412,7 +3401,6 @@ may increase either contention or retry errors, or both.`,
"crdb_internal.force_error": makeBuiltin(
tree.FunctionProperties{
Category: categorySystemInfo,
Impure: true,
},
tree.Overload{
Types: tree.ArgTypes{{"errorCode", types.String}, {"msg", types.String}},
......@@ -3435,7 +3423,6 @@ may increase either contention or retry errors, or both.`,
"crdb_internal.notice": makeBuiltin(
tree.FunctionProperties{
Category: categorySystemInfo,
Impure: true,
},
tree.Overload{
Types: tree.ArgTypes{{"msg", types.String}},
......@@ -3466,7 +3453,6 @@ may increase either contention or retry errors, or both.`,
"crdb_internal.force_assertion_error": makeBuiltin(
tree.FunctionProperties{
Category: categorySystemInfo,
Impure: true,
},
tree.Overload{
Types: tree.ArgTypes{{"msg", types.String}},
......@@ -3483,7 +3469,6 @@ may increase either contention or retry errors, or both.`,
"crdb_internal.force_panic": makeBuiltin(
tree.FunctionProperties{
Category: categorySystemInfo,
Impure: true,
},
tree.Overload{
Types: tree.ArgTypes{{"msg", types.String}},
......@@ -3503,7 +3488,6 @@ may increase either contention or retry errors, or both.`,
"crdb_internal.force_log_fatal": makeBuiltin(
tree.FunctionProperties{
Category: categorySystemInfo,
Impure: true,
},
tree.Overload{
Types: tree.ArgTypes{{"msg", types.String}},
......@@ -3529,7 +3513,6 @@ may increase either contention or retry errors, or both.`,
"crdb_internal.force_retry": makeBuiltin(
tree.FunctionProperties{
Category: categorySystemInfo,
Impure: true,
},
tree.Overload{
Types: tree.ArgTypes{{"val", types.Interval}},
......@@ -3580,7 +3563,6 @@ may increase either contention or retry errors, or both.`,
"crdb_internal.no_constant_folding": makeBuiltin(
tree.FunctionProperties{
Category: categorySystemInfo,
Impure: true,
},
tree.Overload{
Types: tree.ArgTypes{{"input", types.Any}},
......@@ -3712,7 +3694,6 @@ may increase either contention or retry errors, or both.`,
"crdb_internal.set_vmodule": makeBuiltin(
tree.FunctionProperties{
Category: categorySystemInfo,
Impure: true,
},
tree.Overload{
Types: tree.ArgTypes{{"vmodule_string", types.String}},
......@@ -4194,7 +4175,6 @@ func getSubstringFromIndexOfLength(str, errMsg string, start, length int) (strin
var uuidV4Impl = makeBuiltin(
tree.FunctionProperties{
Category: categoryIDGeneration,
Impure: true,
},
tree.Overload{
Types: tree.ArgTypes{},
......@@ -4314,7 +4294,6 @@ func txnTSImplBuiltin(preferTZOverload bool) builtinDefinition {
return makeBuiltin(
tree.FunctionProperties{
Category: categoryDateAndTime,
Impure: true,
},
txnTSOverloads(preferTZOverload)...,
)
......@@ -4324,7 +4303,6 @@ func txnTSWithPrecisionImplBuiltin(preferTZOverload bool) builtinDefinition {
return makeBuiltin(
tree.FunctionProperties{
Category: categoryDateAndTime,
Impure: true,
},
txnTSWithPrecisionOverloads(preferTZOverload)...,
)
......@@ -4333,7 +4311,7 @@ func txnTSWithPrecisionImplBuiltin(preferTZOverload bool) builtinDefinition {
func txnTimeWithPrecisionBuiltin(preferTZOverload bool) builtinDefinition {
tzAdditionalDesc, noTZAdditionalDesc := getTimeAdditionalDesc(preferTZOverload)
return makeBuiltin(
tree.FunctionProperties{Impure: true},
tree.FunctionProperties{},
tree.Overload{
Types: tree.ArgTypes{},
ReturnType: tree.FixedReturnType(types.TimeTZ),
......
......@@ -43,9 +43,6 @@ func initGeneratorBuiltins() {
panic("duplicate builtin: " + k)
}
if !v.props.Impure {
panic(fmt.Sprintf("generator functions should all be impure, found %v", v))
}
if v.props.Class != tree.GeneratorClass {
panic(fmt.Sprintf("generator functions should be marked with the tree.GeneratorClass "+
"function class, found %v", v))
......@@ -57,7 +54,6 @@ func initGeneratorBuiltins() {
func genProps() tree.FunctionProperties {
return tree.FunctionProperties{
Impure: true,
Class: tree.GeneratorClass,
Category: categoryGenerator,
}
......@@ -65,7 +61,6 @@ func genProps() tree.FunctionProperties {
func genPropsWithLabels(returnLabels []string) tree.FunctionProperties {
return tree.FunctionProperties{
Impure: true,
Class: tree.GeneratorClass,
Category: categoryGenerator,
ReturnLabels: returnLabels,
......@@ -265,7 +260,6 @@ var generators = map[string]builtinDefinition{
"crdb_internal.check_consistency": makeBuiltin(
tree.FunctionProperties{
Impure: true,
Class: tree.GeneratorClass,
Category: categorySystemInfo,
},
......
......@@ -2889,7 +2889,6 @@ The calculations are done on a sphere.`,
tree.FunctionProperties{
Class: tree.SQLClass,
Category: categoryGeospatial,
Impure: true,
},
tree.Overload{
Types: tree.ArgTypes{
......
......@@ -1083,11 +1083,7 @@ SELECT description
),
"pg_sleep": makeBuiltin(
tree.FunctionProperties{
// pg_sleep is marked as impure so it doesn't get executed during
// normalization.
Impure: true,
},
tree.FunctionProperties{},
tree.Overload{
Types: tree.ArgTypes{{"seconds", types.Float}},
ReturnType: tree.FixedReturnType(types.Bool),
......@@ -1744,7 +1740,6 @@ SELECT description
tree.FunctionProperties{
Category: categorySystemInfo,
DistsqlBlocklist: true,
Impure: true,
},
tree.Overload{
Types: tree.ArgTypes{{"setting_name", types.String}, {"new_value", types.String}, {"is_local", types.Bool}},
......
......@@ -27,9 +27,6 @@ func initWindowBuiltins() {
panic("duplicate builtin: " + k)
}
if !v.props.Impure {
panic(fmt.Sprintf("%s: window functions should all be impure, found %v", k, v))
}
if v.props.Class != tree.WindowClass {
panic(fmt.Sprintf("%s: window functions should be marked with the tree.WindowClass "+
"function class, found %v", k, v))
......@@ -46,8 +43,7 @@ func initWindowBuiltins() {
func winProps() tree.FunctionProperties {
return tree.FunctionProperties{
Impure: true,
Class: tree.WindowClass,
Class: tree.WindowClass,
}
}
......
......@@ -1394,13 +1394,6 @@ func (node *FuncExpr) IsWindowFunctionApplication() bool {
return node.WindowDef != nil
}
// IsImpure returns whether the function application is impure, meaning that it
// potentially returns a different value when called in the same statement with
// the same parameters.
func (node *FuncExpr) IsImpure() bool {
return node.fnProps != nil && node.fnProps.Impure
}
// IsDistSQLBlocklist returns whether the function is not supported by DistSQL.
func (node *FuncExpr) IsDistSQLBlocklist() bool {
return node.fnProps != nil && node.fnProps.DistsqlBlocklist
......
......@@ -57,14 +57,6 @@ type FunctionProperties struct {
// be NULL and should act accordingly.
NullableArgs bool
// Impure is set to true when a function potentially returns a
// different value when called in the same statement with the same
// parameters. e.g.: random(), clock_timestamp(). Some functions
// like now() return the same value in the same statement, but
// different values in separate statements, and should not be marked
// as impure.
Impure bool
// DistsqlBlocklist is set to true when a function depends on
// members of the EvalContext that are not marshaled by DistSQL
// (e.g. planner). Currently used for DistSQL to determine if
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment