diff --git a/pkg/sql/opt/exec/execbuilder/testdata/sql_fn b/pkg/sql/opt/exec/execbuilder/testdata/sql_fn index a303661672aa..5bed65bee121 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/sql_fn +++ b/pkg/sql/opt/exec/execbuilder/testdata/sql_fn @@ -248,3 +248,8 @@ query T SELECT addgeometrycolumn('a', 'b', 3, NULL, 2); ---- NULL + +query T +SELECT addgeometrycolumn('a', 'b', NULL::string, 'c', 9223372036854775807:::INT8, 'd', NULL::int) +---- +NULL diff --git a/pkg/sql/opt/optbuilder/sql_fn.go b/pkg/sql/opt/optbuilder/sql_fn.go index 1027e56c610b..d6981534e0ce 100644 --- a/pkg/sql/opt/optbuilder/sql_fn.go +++ b/pkg/sql/opt/optbuilder/sql_fn.go @@ -62,6 +62,9 @@ func (b *Builder) buildSQLFn( )) } exprs[i] = memo.ExtractConstDatum(info.args[i]) + if exprs[i] == tree.DNull && !info.def.Properties.NullableArgs { + return b.factory.ConstructNull(info.ResolvedType()) + } } // Get the SQL statement and parse it.