From c38023e5350b191fae4ea7f36d561d3b309212d2 Mon Sep 17 00:00:00 2001 From: Nathan VanBenschoten Date: Thu, 6 Jan 2022 09:37:23 -0500 Subject: [PATCH 1/2] vendor: upgrade cockroachdb/apd to v3 This commit picks up the following changes to `cockroachdb/apd`: - https://github.com/cockroachdb/apd/pull/103 - https://github.com/cockroachdb/apd/pull/104 - https://github.com/cockroachdb/apd/pull/107 - https://github.com/cockroachdb/apd/pull/108 - https://github.com/cockroachdb/apd/pull/109 - https://github.com/cockroachdb/apd/pull/110 - https://github.com/cockroachdb/apd/pull/111 Release note (performance improvement): The memory representation of DECIMAL datums has been optimized to save space, avoid heap allocations, and eliminate indirection. This increases the speed of DECIMAL arithmetic and aggregation by up to 20% on large data sets. --- DEPS.bzl | 10 ++-- go.mod | 2 +- go.sum | 4 +- pkg/ccl/changefeedccl/BUILD.bazel | 4 +- pkg/ccl/changefeedccl/avro.go | 14 +++-- pkg/ccl/changefeedccl/avro_test.go | 2 +- pkg/ccl/changefeedccl/helpers_test.go | 2 +- pkg/ccl/cliccl/BUILD.bazel | 2 +- pkg/ccl/cliccl/debug_backup.go | 2 +- pkg/ccl/importccl/BUILD.bazel | 2 +- pkg/ccl/importccl/read_import_workload.go | 2 +- pkg/cli/BUILD.bazel | 2 +- pkg/cli/doctor.go | 2 +- pkg/cmd/cmp-sql/BUILD.bazel | 2 +- pkg/cmd/cmp-sql/main.go | 2 +- pkg/cmd/cmpconn/BUILD.bazel | 4 +- pkg/cmd/cmpconn/compare.go | 6 +- pkg/cmd/cmpconn/compare_test.go | 2 +- pkg/col/coldata/BUILD.bazel | 2 +- pkg/col/coldata/native_types.go | 4 +- pkg/col/coldata/vec.eg.go | 2 +- pkg/col/coldata/vec_tmpl.go | 2 +- pkg/col/colserde/BUILD.bazel | 2 +- pkg/col/colserde/record_batch_test.go | 2 +- pkg/col/typeconv/BUILD.bazel | 2 +- pkg/col/typeconv/typeconv.go | 2 +- pkg/jobs/BUILD.bazel | 2 +- pkg/jobs/jobs_test.go | 2 +- pkg/keys/BUILD.bazel | 2 +- pkg/keys/printer_test.go | 2 +- pkg/kv/BUILD.bazel | 2 +- pkg/kv/util.go | 2 +- pkg/roachpb/BUILD.bazel | 6 +- pkg/roachpb/data.go | 2 +- pkg/roachpb/data_test.go | 2 +- pkg/server/BUILD.bazel | 2 +- pkg/server/admin.go | 2 +- pkg/sql/BUILD.bazel | 4 +- pkg/sql/as_of_test.go | 2 +- pkg/sql/colconv/vec_to_datum.eg.go | 25 -------- pkg/sql/colencoding/BUILD.bazel | 2 +- pkg/sql/colencoding/key_encoding.go | 2 +- pkg/sql/colexec/BUILD.bazel | 4 +- pkg/sql/colexec/aggregators_test.go | 2 +- pkg/sql/colexec/colexecagg/BUILD.bazel | 2 +- pkg/sql/colexec/colexecagg/aggregate_funcs.go | 2 +- .../colexecagg/any_not_null_agg_tmpl.go | 2 +- pkg/sql/colexec/colexecagg/avg_agg_tmpl.go | 2 +- .../colexecagg/hash_any_not_null_agg.eg.go | 6 +- pkg/sql/colexec/colexecagg/hash_avg_agg.eg.go | 18 +++--- .../colexec/colexecagg/hash_min_max_agg.eg.go | 10 ++-- pkg/sql/colexec/colexecagg/hash_sum_agg.eg.go | 18 +++--- .../colexec/colexecagg/hash_sum_int_agg.eg.go | 2 +- .../colexec/colexecagg/min_max_agg_tmpl.go | 2 +- .../colexecagg/ordered_any_not_null_agg.eg.go | 6 +- .../colexec/colexecagg/ordered_avg_agg.eg.go | 18 +++--- .../colexecagg/ordered_min_max_agg.eg.go | 10 ++-- .../colexec/colexecagg/ordered_sum_agg.eg.go | 18 +++--- .../colexecagg/ordered_sum_int_agg.eg.go | 2 +- pkg/sql/colexec/colexecagg/sum_agg_tmpl.go | 2 +- .../colexec/colexecagg/window_avg_agg.eg.go | 34 +++++------ .../colexecagg/window_min_max_agg.eg.go | 10 ++-- .../colexec/colexecagg/window_sum_agg.eg.go | 34 +++++------ .../colexecagg/window_sum_int_agg.eg.go | 2 +- pkg/sql/colexec/colexecbase/BUILD.bazel | 2 +- pkg/sql/colexec/colexecbase/cast.eg.go | 2 +- pkg/sql/colexec/colexecbase/cast_tmpl.go | 2 +- pkg/sql/colexec/colexecbase/const.eg.go | 2 +- pkg/sql/colexec/colexecbase/const_tmpl.go | 2 +- pkg/sql/colexec/colexecbase/distinct.eg.go | 2 +- pkg/sql/colexec/colexecjoin/BUILD.bazel | 2 +- .../colexecjoin/mergejoiner_exceptall.eg.go | 2 +- .../colexecjoin/mergejoiner_fullouter.eg.go | 2 +- .../colexecjoin/mergejoiner_inner.eg.go | 2 +- .../mergejoiner_intersectall.eg.go | 2 +- .../colexecjoin/mergejoiner_leftanti.eg.go | 2 +- .../colexecjoin/mergejoiner_leftouter.eg.go | 2 +- .../colexecjoin/mergejoiner_leftsemi.eg.go | 2 +- .../colexecjoin/mergejoiner_rightanti.eg.go | 2 +- .../colexecjoin/mergejoiner_rightouter.eg.go | 2 +- .../colexecjoin/mergejoiner_rightsemi.eg.go | 2 +- .../colexec/colexecjoin/mergejoiner_tmpl.go | 2 +- pkg/sql/colexec/colexecproj/BUILD.bazel | 2 +- .../colexecproj/proj_const_left_ops.eg.go | 2 +- .../colexecproj/proj_const_ops_tmpl.go | 2 +- .../colexecproj/proj_const_right_ops.eg.go | 2 +- pkg/sql/colexec/colexecsel/BUILD.bazel | 2 +- .../colexec/colexecsel/selection_ops.eg.go | 2 +- .../colexec/colexecsel/selection_ops_tmpl.go | 2 +- pkg/sql/colexec/colexecspan/BUILD.bazel | 2 +- pkg/sql/colexec/colexectestutils/BUILD.bazel | 2 +- pkg/sql/colexec/colexectestutils/utils.go | 2 +- pkg/sql/colexec/colexecwindow/BUILD.bazel | 4 +- .../colexecwindow/min_max_removable_agg.eg.go | 2 +- .../min_max_removable_agg_tmpl.go | 2 +- .../colexecwindow/range_offset_handler.eg.go | 2 +- .../range_offset_handler_tmpl.go | 2 +- .../colexecwindow/window_functions_test.go | 2 +- pkg/sql/colexec/execgen/BUILD.bazel | 2 +- .../execgen/cmd/execgen/distinct_gen.go | 2 +- .../execgen/cmd/execgen/overloads_base.go | 2 +- .../execgen/cmd/execgen/vec_to_datum_gen.go | 12 ++-- pkg/sql/colexec/execgen/overloads_util.go | 5 +- pkg/sql/colexec/hashjoiner_test.go | 2 +- pkg/sql/colexec/joiner_utils_test.go | 2 +- pkg/sql/colexec/rowstovec.eg.go | 2 +- pkg/sql/colexec/rowstovec_tmpl.go | 2 +- pkg/sql/colexec/select_in.eg.go | 2 +- pkg/sql/colexec/select_in_tmpl.go | 2 +- pkg/sql/colexec/sort_partitioner.eg.go | 2 +- pkg/sql/colfetcher/BUILD.bazel | 2 +- pkg/sql/colfetcher/cfetcher.go | 2 +- pkg/sql/colfetcher/index_join.go | 2 +- pkg/sql/colmem/allocator.go | 18 +++--- pkg/sql/exec_util.go | 2 +- pkg/sql/memsize/BUILD.bazel | 2 +- pkg/sql/memsize/constants.go | 2 +- pkg/sql/opt/norm/BUILD.bazel | 2 +- pkg/sql/opt/norm/general_funcs.go | 2 +- pkg/sql/pgwire/BUILD.bazel | 4 +- pkg/sql/pgwire/encoding_test.go | 2 +- pkg/sql/pgwire/types.go | 5 +- pkg/sql/physicalplan/BUILD.bazel | 1 + pkg/sql/physicalplan/aggregator_funcs_test.go | 4 +- pkg/sql/randgen/BUILD.bazel | 1 - pkg/sql/randgen/datum.go | 10 +--- pkg/sql/rowenc/BUILD.bazel | 2 +- pkg/sql/rowenc/encoded_datum_test.go | 2 +- pkg/sql/rowenc/keyside/BUILD.bazel | 2 +- pkg/sql/rowenc/keyside/decode.go | 2 +- pkg/sql/sem/builtins/BUILD.bazel | 2 +- pkg/sql/sem/builtins/aggregate_builtins.go | 60 +++++++++---------- pkg/sql/sem/builtins/math_builtins.go | 2 +- pkg/sql/sem/builtins/window_frame_builtins.go | 2 +- pkg/sql/sem/tree/BUILD.bazel | 4 +- pkg/sql/sem/tree/as_of.go | 2 +- pkg/sql/sem/tree/cast.go | 7 +-- pkg/sql/sem/tree/constant_test.go | 2 +- pkg/sql/sem/tree/datum.go | 18 ++---- pkg/sql/sem/tree/datum_alloc.go | 2 +- pkg/sql/sem/tree/decimal.go | 2 +- pkg/sql/sem/tree/eval.go | 11 ++-- pkg/sql/sem/tree/window_funcs_test.go | 2 +- pkg/sql/set_var.go | 2 +- .../sqlstatsutil/BUILD.bazel | 2 +- .../sqlstatsutil/json_impl.go | 2 +- pkg/sql/values_test.go | 2 +- pkg/util/duration/BUILD.bazel | 1 + pkg/util/duration/duration.go | 27 +++++---- pkg/util/encoding/BUILD.bazel | 4 +- pkg/util/encoding/decimal.go | 2 +- pkg/util/encoding/decimal_test.go | 2 +- pkg/util/encoding/encoding.go | 2 +- pkg/util/encoding/encoding_test.go | 2 +- pkg/util/json/BUILD.bazel | 4 +- pkg/util/json/encode.go | 2 +- pkg/util/json/encoded.go | 2 +- pkg/util/json/json.go | 5 +- pkg/util/json/json_test.go | 2 +- vendor | 2 +- 160 files changed, 334 insertions(+), 374 deletions(-) diff --git a/DEPS.bzl b/DEPS.bzl index 2da414226dae..07af1020f741 100644 --- a/DEPS.bzl +++ b/DEPS.bzl @@ -1111,13 +1111,13 @@ def go_deps(): ], ) go_repository( - name = "com_github_cockroachdb_apd_v2", + name = "com_github_cockroachdb_apd_v3", build_file_proto_mode = "disable_global", - importpath = "github.com/cockroachdb/apd/v2", - sha256 = "25204b49acbbf2f900f4f82b7f07481847f4f78452aff64dcbd05c543b21e35d", - strip_prefix = "github.com/cockroachdb/apd/v2@v2.0.2", + importpath = "github.com/cockroachdb/apd/v3", + sha256 = "c461aad0b12e37d042402e0ad2478092d846b1981b5708bb7a63fcc07a154816", + strip_prefix = "github.com/cockroachdb/apd/v3@v3.0.0", urls = [ - "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/apd/v2/com_github_cockroachdb_apd_v2-v2.0.2.zip", + "https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/apd/v3/com_github_cockroachdb_apd_v3-v3.0.0.zip", ], ) go_repository( diff --git a/go.mod b/go.mod index 53932d060eae..0eb680727017 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( github.com/bufbuild/buf v0.56.0 github.com/cenkalti/backoff v2.2.1+incompatible github.com/client9/misspell v0.3.4 - github.com/cockroachdb/apd/v2 v2.0.2 + github.com/cockroachdb/apd/v3 v3.0.0 github.com/cockroachdb/circuitbreaker v2.2.2-0.20190114160014-a614b14ccf63+incompatible github.com/cockroachdb/cmux v0.0.0-20170110192607-30d10be49292 github.com/cockroachdb/cockroach-go/v2 v2.1.1 diff --git a/go.sum b/go.sum index 5d630eac0571..25359fc16691 100644 --- a/go.sum +++ b/go.sum @@ -386,8 +386,8 @@ github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1 h1:zH8ljVhhq7yC0MIeUL/ github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= -github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= -github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= +github.com/cockroachdb/apd/v3 v3.0.0 h1:7uckTv9DQFr2/kh9tTEc2PTrPr85n9T+MWX4p5pVS/Y= +github.com/cockroachdb/apd/v3 v3.0.0/go.mod h1:6qgPBMXjATAdD/VefbRP9NoSLKjbB4LCoA7gN4LpHs4= github.com/cockroachdb/circuitbreaker v2.2.2-0.20190114160014-a614b14ccf63+incompatible h1:u3uQ4oAKM5g2eODBAsDdDSrTs7zRWXtvu+nvSDA9098= github.com/cockroachdb/circuitbreaker v2.2.2-0.20190114160014-a614b14ccf63+incompatible/go.mod h1:v3T8+rm/HmCL0D1BwDcGaHHAQDuFPW7EsnYs2nBRqUo= github.com/cockroachdb/cmux v0.0.0-20170110192607-30d10be49292 h1:dzj1/xcivGjNPwwifh/dWTczkwcuqsXXFHY1X/TZMtw= diff --git a/pkg/ccl/changefeedccl/BUILD.bazel b/pkg/ccl/changefeedccl/BUILD.bazel index dd5d3ae98e84..ff3760abd5b1 100644 --- a/pkg/ccl/changefeedccl/BUILD.bazel +++ b/pkg/ccl/changefeedccl/BUILD.bazel @@ -105,7 +105,7 @@ go_library( "//pkg/util/timeutil", "//pkg/util/tracing", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_cockroachdb_logtags//:logtags", "@com_github_google_btree//:btree", @@ -223,7 +223,7 @@ go_test( "//pkg/workload/bank", "//pkg/workload/ledger", "//pkg/workload/workloadsql", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_cockroach_go_v2//crdb", "@com_github_cockroachdb_errors//:errors", "@com_github_dustin_go_humanize//:go-humanize", diff --git a/pkg/ccl/changefeedccl/avro.go b/pkg/ccl/changefeedccl/avro.go index 4dd5598b3d6f..44c63c94214f 100644 --- a/pkg/ccl/changefeedccl/avro.go +++ b/pkg/ccl/changefeedccl/avro.go @@ -13,7 +13,7 @@ import ( "math/big" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/geo" "github.com/cockroachdb/cockroach/pkg/geo/geopb" "github.com/cockroachdb/cockroach/pkg/sql/catalog" @@ -1015,12 +1015,13 @@ func decimalToRat(dec apd.Decimal, scale int32) (big.Rat, error) { if dec.Exponent >= 0 { exp := big.NewInt(10) exp = exp.Exp(exp, big.NewInt(int64(dec.Exponent)), nil) - var coeff big.Int - r.SetFrac(coeff.Mul(&dec.Coeff, exp), big.NewInt(1)) + coeff := dec.Coeff.MathBigInt() + r.SetFrac(coeff.Mul(coeff, exp), big.NewInt(1)) } else { exp := big.NewInt(10) exp = exp.Exp(exp, big.NewInt(int64(-dec.Exponent)), nil) - r.SetFrac(&dec.Coeff, exp) + coeff := dec.Coeff.MathBigInt() + r.SetFrac(coeff, exp) } if dec.Negative { r.Mul(&r, big.NewRat(-1, 1)) @@ -1036,7 +1037,8 @@ func ratToDecimal(rat big.Rat, scale int32) apd.Decimal { exp := big.NewInt(10) exp = exp.Exp(exp, big.NewInt(int64(scale)), nil) sf := denom.Div(exp, denom) - coeff := num.Mul(num, sf) - dec := apd.NewWithBigInt(coeff, -scale) + var coeff apd.BigInt + coeff.SetMathBigInt(num.Mul(num, sf)) + dec := apd.NewWithBigInt(&coeff, -scale) return *dec } diff --git a/pkg/ccl/changefeedccl/avro_test.go b/pkg/ccl/changefeedccl/avro_test.go index 2e847336e819..a51471c71919 100644 --- a/pkg/ccl/changefeedccl/avro_test.go +++ b/pkg/ccl/changefeedccl/avro_test.go @@ -18,7 +18,7 @@ import ( "testing" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/ccl/importccl" "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/settings/cluster" diff --git a/pkg/ccl/changefeedccl/helpers_test.go b/pkg/ccl/changefeedccl/helpers_test.go index 7eff9f3f4521..ef82561d2533 100644 --- a/pkg/ccl/changefeedccl/helpers_test.go +++ b/pkg/ccl/changefeedccl/helpers_test.go @@ -22,7 +22,7 @@ import ( "testing" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/blobs" "github.com/cockroachdb/cockroach/pkg/ccl/changefeedccl/cdctest" diff --git a/pkg/ccl/cliccl/BUILD.bazel b/pkg/ccl/cliccl/BUILD.bazel index 1efb285ce8c4..5dfb4dde1d2f 100644 --- a/pkg/ccl/cliccl/BUILD.bazel +++ b/pkg/ccl/cliccl/BUILD.bazel @@ -52,7 +52,7 @@ go_library( "//pkg/util/timeutil", "//pkg/util/timeutil/pgdate", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_cockroachdb_errors//oserror", "@com_github_spf13_cobra//:cobra", diff --git a/pkg/ccl/cliccl/debug_backup.go b/pkg/ccl/cliccl/debug_backup.go index e217261541c7..0c460d31394c 100644 --- a/pkg/ccl/cliccl/debug_backup.go +++ b/pkg/ccl/cliccl/debug_backup.go @@ -22,7 +22,7 @@ import ( "strings" "time" - apd "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/blobs" "github.com/cockroachdb/cockroach/pkg/ccl/backupccl" diff --git a/pkg/ccl/importccl/BUILD.bazel b/pkg/ccl/importccl/BUILD.bazel index c70975e7f73b..338a930a6274 100644 --- a/pkg/ccl/importccl/BUILD.bazel +++ b/pkg/ccl/importccl/BUILD.bazel @@ -91,7 +91,7 @@ go_library( "//pkg/util/timeutil/pgdate", "//pkg/util/tracing", "//pkg/workload", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_cockroachdb_logtags//:logtags", "@com_github_fraugster_parquet_go//:parquet-go", diff --git a/pkg/ccl/importccl/read_import_workload.go b/pkg/ccl/importccl/read_import_workload.go index 08b226750541..35089ab507bf 100644 --- a/pkg/ccl/importccl/read_import_workload.go +++ b/pkg/ccl/importccl/read_import_workload.go @@ -17,7 +17,7 @@ import ( "sync/atomic" "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/cloud" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/roachpb" diff --git a/pkg/cli/BUILD.bazel b/pkg/cli/BUILD.bazel index 04f5cbe867b6..419db42a1281 100644 --- a/pkg/cli/BUILD.bazel +++ b/pkg/cli/BUILD.bazel @@ -208,7 +208,7 @@ go_library( "//pkg/workload/tpch", "//pkg/workload/workloadsql", "//pkg/workload/ycsb", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_cockroachdb_errors//oserror", "@com_github_cockroachdb_logtags//:logtags", diff --git a/pkg/cli/doctor.go b/pkg/cli/doctor.go index 493c1b27c37e..6da8e033e819 100644 --- a/pkg/cli/doctor.go +++ b/pkg/cli/doctor.go @@ -23,7 +23,7 @@ import ( "strings" "time" - apd "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/cli/clierror" "github.com/cockroachdb/cockroach/pkg/cli/clierrorplus" "github.com/cockroachdb/cockroach/pkg/cli/clisqlclient" diff --git a/pkg/cmd/cmp-sql/BUILD.bazel b/pkg/cmd/cmp-sql/BUILD.bazel index d6b0402d70c0..c27ffc7172e3 100644 --- a/pkg/cmd/cmp-sql/BUILD.bazel +++ b/pkg/cmd/cmp-sql/BUILD.bazel @@ -7,7 +7,7 @@ go_library( visibility = ["//visibility:private"], deps = [ "//pkg/util/randutil", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_jackc_pgtype//:pgtype", "@com_github_jackc_pgx_v4//:pgx", ], diff --git a/pkg/cmd/cmp-sql/main.go b/pkg/cmd/cmp-sql/main.go index c457a7cc21f2..caf0c61fbb78 100644 --- a/pkg/cmd/cmp-sql/main.go +++ b/pkg/cmd/cmp-sql/main.go @@ -34,7 +34,7 @@ import ( "regexp" "strings" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/util/randutil" "github.com/jackc/pgtype" "github.com/jackc/pgx/v4" diff --git a/pkg/cmd/cmpconn/BUILD.bazel b/pkg/cmd/cmpconn/BUILD.bazel index aa8e498fd01b..411dde20a5d1 100644 --- a/pkg/cmd/cmpconn/BUILD.bazel +++ b/pkg/cmd/cmpconn/BUILD.bazel @@ -12,7 +12,7 @@ go_library( "//pkg/sql/randgen", "//pkg/sql/sem/tree", "//pkg/util/duration", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_google_go_cmp//cmp", "@com_github_google_go_cmp//cmp/cmpopts", @@ -28,7 +28,7 @@ go_test( srcs = ["compare_test.go"], embed = [":cmpconn"], deps = [ - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_jackc_pgtype//:pgtype", ], ) diff --git a/pkg/cmd/cmpconn/compare.go b/pkg/cmd/cmpconn/compare.go index 07dbef3ab3b0..b82a82c33356 100644 --- a/pkg/cmd/cmpconn/compare.go +++ b/pkg/cmd/cmpconn/compare.go @@ -14,7 +14,7 @@ import ( "math/big" "strings" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/cockroach/pkg/util/duration" "github.com/cockroachdb/errors" @@ -118,7 +118,9 @@ var ( if t.NaN { v = &apd.Decimal{Form: apd.NaN} } else { - v = apd.NewWithBigInt(t.Int, t.Exp) + var coeff apd.BigInt + coeff.SetMathBigInt(t.Int) + v = apd.NewWithBigInt(&coeff, t.Exp) } } case int64: diff --git a/pkg/cmd/cmpconn/compare_test.go b/pkg/cmd/cmpconn/compare_test.go index 3acd85f99f78..24fd9fb0c96e 100644 --- a/pkg/cmd/cmpconn/compare_test.go +++ b/pkg/cmd/cmpconn/compare_test.go @@ -15,7 +15,7 @@ import ( "math/big" "testing" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/jackc/pgtype" ) diff --git a/pkg/col/coldata/BUILD.bazel b/pkg/col/coldata/BUILD.bazel index f8fe780e140b..dedd1f533e44 100644 --- a/pkg/col/coldata/BUILD.bazel +++ b/pkg/col/coldata/BUILD.bazel @@ -25,7 +25,7 @@ go_library( "//pkg/util/duration", "//pkg/util/json", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_stretchr_testify//require", ], diff --git a/pkg/col/coldata/native_types.go b/pkg/col/coldata/native_types.go index 02a901d062ec..708ab44d3825 100644 --- a/pkg/col/coldata/native_types.go +++ b/pkg/col/coldata/native_types.go @@ -13,7 +13,7 @@ package coldata import ( "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/util/duration" ) @@ -106,8 +106,6 @@ func (c Float64s) Set(idx int, val float64) { c[idx] = val } // Note that this method is usually inlined, but it isn't in case of the merge // joiner generated code (probably because of the size of the functions), so we // don't assert the inlining with the GCAssert linter. -// TODO(yuzefovich): consider whether Get and Set on Decimals should operate on -// pointers to apd.Decimal. func (c Decimals) Set(idx int, val apd.Decimal) { c[idx].Set(&val) } // Set sets the element at index idx of the vector to val. diff --git a/pkg/col/coldata/vec.eg.go b/pkg/col/coldata/vec.eg.go index 36b3b3be4655..36c9c3b887b5 100644 --- a/pkg/col/coldata/vec.eg.go +++ b/pkg/col/coldata/vec.eg.go @@ -13,7 +13,7 @@ import ( "fmt" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/typeconv" "github.com/cockroachdb/cockroach/pkg/sql/colexecerror" "github.com/cockroachdb/cockroach/pkg/sql/types" diff --git a/pkg/col/coldata/vec_tmpl.go b/pkg/col/coldata/vec_tmpl.go index 4a8cdff84052..40f9d939f951 100644 --- a/pkg/col/coldata/vec_tmpl.go +++ b/pkg/col/coldata/vec_tmpl.go @@ -24,7 +24,7 @@ package coldata import ( "fmt" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/typeconv" "github.com/cockroachdb/cockroach/pkg/sql/colexec/execgen" "github.com/cockroachdb/cockroach/pkg/sql/colexecerror" diff --git a/pkg/col/colserde/BUILD.bazel b/pkg/col/colserde/BUILD.bazel index ff118a0421da..41ba3d8eff68 100644 --- a/pkg/col/colserde/BUILD.bazel +++ b/pkg/col/colserde/BUILD.bazel @@ -58,7 +58,7 @@ go_test( "@com_github_apache_arrow_go_arrow//:arrow", "@com_github_apache_arrow_go_arrow//array", "@com_github_apache_arrow_go_arrow//memory", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_stretchr_testify//require", ], ) diff --git a/pkg/col/colserde/record_batch_test.go b/pkg/col/colserde/record_batch_test.go index 99b88850536c..58a4c1077072 100644 --- a/pkg/col/colserde/record_batch_test.go +++ b/pkg/col/colserde/record_batch_test.go @@ -23,7 +23,7 @@ import ( "github.com/apache/arrow/go/arrow" "github.com/apache/arrow/go/arrow/array" "github.com/apache/arrow/go/arrow/memory" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/colserde" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/col/typeconv/BUILD.bazel b/pkg/col/typeconv/BUILD.bazel index be0a22bce0f2..4763a3aa9778 100644 --- a/pkg/col/typeconv/BUILD.bazel +++ b/pkg/col/typeconv/BUILD.bazel @@ -9,6 +9,6 @@ go_library( "//pkg/sql/types", "//pkg/util/duration", "//pkg/util/json", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", ], ) diff --git a/pkg/col/typeconv/typeconv.go b/pkg/col/typeconv/typeconv.go index 7b507791081f..9a81a107be36 100644 --- a/pkg/col/typeconv/typeconv.go +++ b/pkg/col/typeconv/typeconv.go @@ -14,7 +14,7 @@ import ( "fmt" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/util/duration" "github.com/cockroachdb/cockroach/pkg/util/json" diff --git a/pkg/jobs/BUILD.bazel b/pkg/jobs/BUILD.bazel index ce5d3a5635e2..2ec28946eddf 100644 --- a/pkg/jobs/BUILD.bazel +++ b/pkg/jobs/BUILD.bazel @@ -130,7 +130,7 @@ go_test( "//pkg/util/timeutil", "//pkg/util/tracing", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_cockroachdb_redact//:redact", "@com_github_gogo_protobuf//types", diff --git a/pkg/jobs/jobs_test.go b/pkg/jobs/jobs_test.go index 7241e8a48cc9..6aaa0a6e6203 100644 --- a/pkg/jobs/jobs_test.go +++ b/pkg/jobs/jobs_test.go @@ -24,7 +24,7 @@ import ( "testing" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/clusterversion" "github.com/cockroachdb/cockroach/pkg/jobs" diff --git a/pkg/keys/BUILD.bazel b/pkg/keys/BUILD.bazel index 879f9bad3c56..aa6ea9d2290e 100644 --- a/pkg/keys/BUILD.bazel +++ b/pkg/keys/BUILD.bazel @@ -39,7 +39,7 @@ go_test( "//pkg/util/keysutil", "//pkg/util/leaktest", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_stretchr_testify//require", ], diff --git a/pkg/keys/printer_test.go b/pkg/keys/printer_test.go index 4a25b82428cb..4ce284200607 100644 --- a/pkg/keys/printer_test.go +++ b/pkg/keys/printer_test.go @@ -21,7 +21,7 @@ import ( "time" "unicode/utf8" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/util/bitarray" diff --git a/pkg/kv/BUILD.bazel b/pkg/kv/BUILD.bazel index 6bf800ba83cc..2100cf9da850 100644 --- a/pkg/kv/BUILD.bazel +++ b/pkg/kv/BUILD.bazel @@ -37,7 +37,7 @@ go_library( "//pkg/util/timeutil", "//pkg/util/tracing", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", ], ) diff --git a/pkg/kv/util.go b/pkg/kv/util.go index b13fbb790cb0..8d6bfb00f548 100644 --- a/pkg/kv/util.go +++ b/pkg/kv/util.go @@ -15,7 +15,7 @@ import ( "reflect" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/util/duration" "github.com/cockroachdb/cockroach/pkg/util/protoutil" diff --git a/pkg/roachpb/BUILD.bazel b/pkg/roachpb/BUILD.bazel index 6c668ee214d7..e9b733f67763 100644 --- a/pkg/roachpb/BUILD.bazel +++ b/pkg/roachpb/BUILD.bazel @@ -53,7 +53,7 @@ go_library( "//pkg/util/protoutil", "//pkg/util/timetz", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_cockroachdb_errors//errorspb", "@com_github_cockroachdb_errors//extgrpc", @@ -108,7 +108,7 @@ go_library( "//pkg/util/uuid", "@com_github_aws_aws_sdk_go//aws", "@com_github_aws_aws_sdk_go//aws/credentials", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_cockroachdb_errors//errorspb", "@com_github_cockroachdb_errors//extgrpc", @@ -176,7 +176,7 @@ go_test( "//pkg/util/randutil", "//pkg/util/timeutil", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_cockroachdb_redact//:redact", "@com_github_gogo_protobuf//proto", diff --git a/pkg/roachpb/data.go b/pkg/roachpb/data.go index 36e1fbc1877b..fb156a2fe9dd 100644 --- a/pkg/roachpb/data.go +++ b/pkg/roachpb/data.go @@ -26,7 +26,7 @@ import ( "time" "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/geo/geopb" "github.com/cockroachdb/cockroach/pkg/kv/kvserver/concurrency/lock" "github.com/cockroachdb/cockroach/pkg/storage/enginepb" diff --git a/pkg/roachpb/data_test.go b/pkg/roachpb/data_test.go index f38d012cb49c..4b71df693ad3 100644 --- a/pkg/roachpb/data_test.go +++ b/pkg/roachpb/data_test.go @@ -20,7 +20,7 @@ import ( "testing" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/cli/exit" "github.com/cockroachdb/cockroach/pkg/storage/enginepb" "github.com/cockroachdb/cockroach/pkg/testutils/zerofields" diff --git a/pkg/server/BUILD.bazel b/pkg/server/BUILD.bazel index eb49543c15f1..0a697fa1f1cb 100644 --- a/pkg/server/BUILD.bazel +++ b/pkg/server/BUILD.bazel @@ -200,7 +200,7 @@ go_library( "//pkg/util/tracing/tracingservicepb", "//pkg/util/uuid", "@com_github_cenkalti_backoff//:backoff", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_circuitbreaker//:circuitbreaker", "@com_github_cockroachdb_cmux//:cmux", "@com_github_cockroachdb_errors//:errors", diff --git a/pkg/server/admin.go b/pkg/server/admin.go index a93c950a351a..20ea644d4181 100644 --- a/pkg/server/admin.go +++ b/pkg/server/admin.go @@ -22,7 +22,7 @@ import ( "strings" "time" - apd "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/config/zonepb" "github.com/cockroachdb/cockroach/pkg/jobs/jobspb" diff --git a/pkg/sql/BUILD.bazel b/pkg/sql/BUILD.bazel index f3f8c2652a27..25d6a5df1755 100644 --- a/pkg/sql/BUILD.bazel +++ b/pkg/sql/BUILD.bazel @@ -419,7 +419,7 @@ go_library( "//pkg/util/tracing/tracingpb", "//pkg/util/uint128", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_cockroachdb_errors//hintdetail", "@com_github_cockroachdb_logtags//:logtags", @@ -667,7 +667,7 @@ go_test( "//pkg/util/tracing", "//pkg/util/tracing/tracingpb", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_cockroach_go_v2//crdb", "@com_github_cockroachdb_datadriven//:datadriven", "@com_github_cockroachdb_errors//:errors", diff --git a/pkg/sql/as_of_test.go b/pkg/sql/as_of_test.go index e87c95cd3742..fc6586fd8d8d 100644 --- a/pkg/sql/as_of_test.go +++ b/pkg/sql/as_of_test.go @@ -16,7 +16,7 @@ import ( "fmt" "testing" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/jobs/jobspb" "github.com/cockroachdb/cockroach/pkg/kv" diff --git a/pkg/sql/colconv/vec_to_datum.eg.go b/pkg/sql/colconv/vec_to_datum.eg.go index 968c49e658dc..a8e914c3b855 100644 --- a/pkg/sql/colconv/vec_to_datum.eg.go +++ b/pkg/sql/colconv/vec_to_datum.eg.go @@ -10,7 +10,6 @@ package colconv import ( - "math/big" "sync" "github.com/cockroachdb/cockroach/pkg/col/coldata" @@ -449,10 +448,6 @@ func ColVecToDatumAndDeselect( _ = true v := typedCol.Get(srcIdx) _converted := da.NewDDecimal(tree.DDecimal{Decimal: v}) - // Clear the Coeff so that the Set below allocates a new slice for the - // Coeff.abs field. - _converted.Coeff = big.Int{} - _converted.Coeff.Set(&v.Coeff) //gcassert:bce converted[destIdx] = _converted } @@ -833,10 +828,6 @@ func ColVecToDatumAndDeselect( _ = true v := typedCol.Get(srcIdx) _converted := da.NewDDecimal(tree.DDecimal{Decimal: v}) - // Clear the Coeff so that the Set below allocates a new slice for the - // Coeff.abs field. - _converted.Coeff = big.Int{} - _converted.Coeff.Set(&v.Coeff) //gcassert:bce converted[destIdx] = _converted } @@ -1224,10 +1215,6 @@ func ColVecToDatum( _ = true v := typedCol.Get(srcIdx) _converted := da.NewDDecimal(tree.DDecimal{Decimal: v}) - // Clear the Coeff so that the Set below allocates a new slice for the - // Coeff.abs field. - _converted.Coeff = big.Int{} - _converted.Coeff.Set(&v.Coeff) converted[destIdx] = _converted } } @@ -1642,10 +1629,6 @@ func ColVecToDatum( //gcassert:bce v := typedCol.Get(srcIdx) _converted := da.NewDDecimal(tree.DDecimal{Decimal: v}) - // Clear the Coeff so that the Set below allocates a new slice for the - // Coeff.abs field. - _converted.Coeff = big.Int{} - _converted.Coeff.Set(&v.Coeff) //gcassert:bce converted[destIdx] = _converted } @@ -2028,10 +2011,6 @@ func ColVecToDatum( _ = true v := typedCol.Get(srcIdx) _converted := da.NewDDecimal(tree.DDecimal{Decimal: v}) - // Clear the Coeff so that the Set below allocates a new slice for the - // Coeff.abs field. - _converted.Coeff = big.Int{} - _converted.Coeff.Set(&v.Coeff) converted[destIdx] = _converted } } @@ -2374,10 +2353,6 @@ func ColVecToDatum( //gcassert:bce v := typedCol.Get(srcIdx) _converted := da.NewDDecimal(tree.DDecimal{Decimal: v}) - // Clear the Coeff so that the Set below allocates a new slice for the - // Coeff.abs field. - _converted.Coeff = big.Int{} - _converted.Coeff.Set(&v.Coeff) //gcassert:bce converted[destIdx] = _converted } diff --git a/pkg/sql/colencoding/BUILD.bazel b/pkg/sql/colencoding/BUILD.bazel index e641795fa4b3..22ba7b207b33 100644 --- a/pkg/sql/colencoding/BUILD.bazel +++ b/pkg/sql/colencoding/BUILD.bazel @@ -21,7 +21,7 @@ go_library( "//pkg/util/encoding", "//pkg/util/log", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", ], ) diff --git a/pkg/sql/colencoding/key_encoding.go b/pkg/sql/colencoding/key_encoding.go index 8e078d753c7b..c1cffb496fee 100644 --- a/pkg/sql/colencoding/key_encoding.go +++ b/pkg/sql/colencoding/key_encoding.go @@ -13,7 +13,7 @@ package colencoding import ( "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" diff --git a/pkg/sql/colexec/BUILD.bazel b/pkg/sql/colexec/BUILD.bazel index 8586b09d9e3d..6ffb0d38fac5 100644 --- a/pkg/sql/colexec/BUILD.bazel +++ b/pkg/sql/colexec/BUILD.bazel @@ -80,7 +80,7 @@ go_library( "//pkg/util/mon", "//pkg/util/stringarena", "//pkg/util/tracing", - "@com_github_cockroachdb_apd_v2//:apd", # keep + "@com_github_cockroachdb_apd_v3//:apd", # keep "@com_github_cockroachdb_errors//:errors", "@com_github_cockroachdb_redact//:redact", "@com_github_marusama_semaphore//:semaphore", @@ -177,7 +177,7 @@ go_test( "//pkg/util/timeofday", "//pkg/util/uuid", "@com_github_apache_arrow_go_arrow//array", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_marusama_semaphore//:semaphore", "@com_github_stretchr_testify//require", diff --git a/pkg/sql/colexec/aggregators_test.go b/pkg/sql/colexec/aggregators_test.go index 59e0f1a11ac1..3f95ca0112f2 100644 --- a/pkg/sql/colexec/aggregators_test.go +++ b/pkg/sql/colexec/aggregators_test.go @@ -16,7 +16,7 @@ import ( "math" "testing" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldatatestutils" "github.com/cockroachdb/cockroach/pkg/settings/cluster" diff --git a/pkg/sql/colexec/colexecagg/BUILD.bazel b/pkg/sql/colexec/colexecagg/BUILD.bazel index 646c7c77c5b0..494219062d94 100644 --- a/pkg/sql/colexec/colexecagg/BUILD.bazel +++ b/pkg/sql/colexec/colexecagg/BUILD.bazel @@ -26,7 +26,7 @@ go_library( "//pkg/util/duration", "//pkg/util/json", # keep "//pkg/util/mon", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", ], ) diff --git a/pkg/sql/colexec/colexecagg/aggregate_funcs.go b/pkg/sql/colexec/colexecagg/aggregate_funcs.go index 0e0c394c0d48..7943eae67564 100644 --- a/pkg/sql/colexec/colexecagg/aggregate_funcs.go +++ b/pkg/sql/colexec/colexecagg/aggregate_funcs.go @@ -13,7 +13,7 @@ package colexecagg import ( "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/sql/colconv" "github.com/cockroachdb/cockroach/pkg/sql/colexecerror" diff --git a/pkg/sql/colexec/colexecagg/any_not_null_agg_tmpl.go b/pkg/sql/colexec/colexecagg/any_not_null_agg_tmpl.go index d25f393ef327..b5590c446d4a 100644 --- a/pkg/sql/colexec/colexecagg/any_not_null_agg_tmpl.go +++ b/pkg/sql/colexec/colexecagg/any_not_null_agg_tmpl.go @@ -24,7 +24,7 @@ package colexecagg import ( "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/typeconv" "github.com/cockroachdb/cockroach/pkg/sql/colexec/execgen" diff --git a/pkg/sql/colexec/colexecagg/avg_agg_tmpl.go b/pkg/sql/colexec/colexecagg/avg_agg_tmpl.go index 91c74ea9076f..22bd5a6f2869 100644 --- a/pkg/sql/colexec/colexecagg/avg_agg_tmpl.go +++ b/pkg/sql/colexec/colexecagg/avg_agg_tmpl.go @@ -24,7 +24,7 @@ package colexecagg import ( "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/sql/colexec/execgen" "github.com/cockroachdb/cockroach/pkg/sql/colexecerror" diff --git a/pkg/sql/colexec/colexecagg/hash_any_not_null_agg.eg.go b/pkg/sql/colexec/colexecagg/hash_any_not_null_agg.eg.go index f3a8b779a488..c476f0641392 100644 --- a/pkg/sql/colexec/colexecagg/hash_any_not_null_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/hash_any_not_null_agg.eg.go @@ -13,7 +13,7 @@ import ( "time" "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/typeconv" "github.com/cockroachdb/cockroach/pkg/sql/colexecerror" @@ -342,7 +342,7 @@ func (a *anyNotNullDecimalHashAgg) Compute( return } - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Decimal(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -388,7 +388,7 @@ func (a *anyNotNullDecimalHashAgg) Compute( } }, ) - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } diff --git a/pkg/sql/colexec/colexecagg/hash_avg_agg.eg.go b/pkg/sql/colexec/colexecagg/hash_avg_agg.eg.go index 75de3c0dc5f6..d4f620924faa 100644 --- a/pkg/sql/colexec/colexecagg/hash_avg_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/hash_avg_agg.eg.go @@ -12,7 +12,7 @@ package colexecagg import ( "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/sql/colexec/execgen" "github.com/cockroachdb/cockroach/pkg/sql/colexecerror" @@ -88,7 +88,7 @@ func (a *avgInt16HashAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurSumSize := tree.SizeOfDecimal(&a.curSum) + oldCurSumSize := a.curSum.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int16(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -138,7 +138,7 @@ func (a *avgInt16HashAgg) Compute( } }, ) - newCurSumSize := tree.SizeOfDecimal(&a.curSum) + newCurSumSize := a.curSum.Size() if newCurSumSize != oldCurSumSize { a.allocator.AdjustMemoryUsage(int64(newCurSumSize - oldCurSumSize)) } @@ -206,7 +206,7 @@ func (a *avgInt32HashAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurSumSize := tree.SizeOfDecimal(&a.curSum) + oldCurSumSize := a.curSum.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int32(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -256,7 +256,7 @@ func (a *avgInt32HashAgg) Compute( } }, ) - newCurSumSize := tree.SizeOfDecimal(&a.curSum) + newCurSumSize := a.curSum.Size() if newCurSumSize != oldCurSumSize { a.allocator.AdjustMemoryUsage(int64(newCurSumSize - oldCurSumSize)) } @@ -324,7 +324,7 @@ func (a *avgInt64HashAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurSumSize := tree.SizeOfDecimal(&a.curSum) + oldCurSumSize := a.curSum.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int64(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -374,7 +374,7 @@ func (a *avgInt64HashAgg) Compute( } }, ) - newCurSumSize := tree.SizeOfDecimal(&a.curSum) + newCurSumSize := a.curSum.Size() if newCurSumSize != oldCurSumSize { a.allocator.AdjustMemoryUsage(int64(newCurSumSize - oldCurSumSize)) } @@ -438,7 +438,7 @@ var _ AggregateFunc = &avgDecimalHashAgg{} func (a *avgDecimalHashAgg) Compute( vecs []coldata.Vec, inputIdxs []uint32, startIdx, endIdx int, sel []int, ) { - oldCurSumSize := tree.SizeOfDecimal(&a.curSum) + oldCurSumSize := a.curSum.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Decimal(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -486,7 +486,7 @@ func (a *avgDecimalHashAgg) Compute( } }, ) - newCurSumSize := tree.SizeOfDecimal(&a.curSum) + newCurSumSize := a.curSum.Size() if newCurSumSize != oldCurSumSize { a.allocator.AdjustMemoryUsage(int64(newCurSumSize - oldCurSumSize)) } diff --git a/pkg/sql/colexec/colexecagg/hash_min_max_agg.eg.go b/pkg/sql/colexec/colexecagg/hash_min_max_agg.eg.go index b57a08603496..5fa52970bffe 100644 --- a/pkg/sql/colexec/colexecagg/hash_min_max_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/hash_min_max_agg.eg.go @@ -15,7 +15,7 @@ import ( "time" "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" @@ -393,7 +393,7 @@ var _ AggregateFunc = &minDecimalHashAgg{} func (a *minDecimalHashAgg) Compute( vecs []coldata.Vec, inputIdxs []uint32, startIdx, endIdx int, sel []int, ) { - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Decimal(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -455,7 +455,7 @@ func (a *minDecimalHashAgg) Compute( } }, ) - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } @@ -2042,7 +2042,7 @@ var _ AggregateFunc = &maxDecimalHashAgg{} func (a *maxDecimalHashAgg) Compute( vecs []coldata.Vec, inputIdxs []uint32, startIdx, endIdx int, sel []int, ) { - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Decimal(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -2104,7 +2104,7 @@ func (a *maxDecimalHashAgg) Compute( } }, ) - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } diff --git a/pkg/sql/colexec/colexecagg/hash_sum_agg.eg.go b/pkg/sql/colexec/colexecagg/hash_sum_agg.eg.go index d437340eab20..6304f52754c0 100644 --- a/pkg/sql/colexec/colexecagg/hash_sum_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/hash_sum_agg.eg.go @@ -12,7 +12,7 @@ package colexecagg import ( "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/sql/colexec/execgen" "github.com/cockroachdb/cockroach/pkg/sql/colexecerror" @@ -87,7 +87,7 @@ func (a *sumInt16HashAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int16(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -137,7 +137,7 @@ func (a *sumInt16HashAgg) Compute( } }, ) - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } @@ -200,7 +200,7 @@ func (a *sumInt32HashAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int32(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -250,7 +250,7 @@ func (a *sumInt32HashAgg) Compute( } }, ) - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } @@ -313,7 +313,7 @@ func (a *sumInt64HashAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int64(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -363,7 +363,7 @@ func (a *sumInt64HashAgg) Compute( } }, ) - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } @@ -422,7 +422,7 @@ var _ AggregateFunc = &sumDecimalHashAgg{} func (a *sumDecimalHashAgg) Compute( vecs []coldata.Vec, inputIdxs []uint32, startIdx, endIdx int, sel []int, ) { - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Decimal(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -470,7 +470,7 @@ func (a *sumDecimalHashAgg) Compute( } }, ) - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } diff --git a/pkg/sql/colexec/colexecagg/hash_sum_int_agg.eg.go b/pkg/sql/colexec/colexecagg/hash_sum_int_agg.eg.go index 1ceffb1a41f9..c20a89e63842 100644 --- a/pkg/sql/colexec/colexecagg/hash_sum_int_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/hash_sum_int_agg.eg.go @@ -12,7 +12,7 @@ package colexecagg import ( "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/sql/colexecerror" "github.com/cockroachdb/cockroach/pkg/sql/colmem" diff --git a/pkg/sql/colexec/colexecagg/min_max_agg_tmpl.go b/pkg/sql/colexec/colexecagg/min_max_agg_tmpl.go index 3111383f2d43..4cf955fc5c57 100644 --- a/pkg/sql/colexec/colexecagg/min_max_agg_tmpl.go +++ b/pkg/sql/colexec/colexecagg/min_max_agg_tmpl.go @@ -24,7 +24,7 @@ package colexecagg import ( "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecagg/ordered_any_not_null_agg.eg.go b/pkg/sql/colexec/colexecagg/ordered_any_not_null_agg.eg.go index a73d0ba37173..ab587b5f479f 100644 --- a/pkg/sql/colexec/colexecagg/ordered_any_not_null_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/ordered_any_not_null_agg.eg.go @@ -13,7 +13,7 @@ import ( "time" "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/typeconv" "github.com/cockroachdb/cockroach/pkg/sql/colexecerror" @@ -524,7 +524,7 @@ func (a *anyNotNullDecimalOrderedAgg) Compute( vecs []coldata.Vec, inputIdxs []uint32, startIdx, endIdx int, sel []int, ) { - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Decimal(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -656,7 +656,7 @@ func (a *anyNotNullDecimalOrderedAgg) Compute( } }, ) - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } diff --git a/pkg/sql/colexec/colexecagg/ordered_avg_agg.eg.go b/pkg/sql/colexec/colexecagg/ordered_avg_agg.eg.go index 8eb43d2d5670..9524d4879d5c 100644 --- a/pkg/sql/colexec/colexecagg/ordered_avg_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/ordered_avg_agg.eg.go @@ -12,7 +12,7 @@ package colexecagg import ( "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/sql/colexec/execgen" "github.com/cockroachdb/cockroach/pkg/sql/colexecerror" @@ -95,7 +95,7 @@ func (a *avgInt16OrderedAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurSumSize := tree.SizeOfDecimal(&a.curSum) + oldCurSumSize := a.curSum.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int16(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -277,7 +277,7 @@ func (a *avgInt16OrderedAgg) Compute( } }, ) - newCurSumSize := tree.SizeOfDecimal(&a.curSum) + newCurSumSize := a.curSum.Size() if newCurSumSize != oldCurSumSize { a.allocator.AdjustMemoryUsage(int64(newCurSumSize - oldCurSumSize)) } @@ -357,7 +357,7 @@ func (a *avgInt32OrderedAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurSumSize := tree.SizeOfDecimal(&a.curSum) + oldCurSumSize := a.curSum.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int32(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -539,7 +539,7 @@ func (a *avgInt32OrderedAgg) Compute( } }, ) - newCurSumSize := tree.SizeOfDecimal(&a.curSum) + newCurSumSize := a.curSum.Size() if newCurSumSize != oldCurSumSize { a.allocator.AdjustMemoryUsage(int64(newCurSumSize - oldCurSumSize)) } @@ -619,7 +619,7 @@ func (a *avgInt64OrderedAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurSumSize := tree.SizeOfDecimal(&a.curSum) + oldCurSumSize := a.curSum.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int64(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -801,7 +801,7 @@ func (a *avgInt64OrderedAgg) Compute( } }, ) - newCurSumSize := tree.SizeOfDecimal(&a.curSum) + newCurSumSize := a.curSum.Size() if newCurSumSize != oldCurSumSize { a.allocator.AdjustMemoryUsage(int64(newCurSumSize - oldCurSumSize)) } @@ -877,7 +877,7 @@ func (a *avgDecimalOrderedAgg) SetOutput(vec coldata.Vec) { func (a *avgDecimalOrderedAgg) Compute( vecs []coldata.Vec, inputIdxs []uint32, startIdx, endIdx int, sel []int, ) { - oldCurSumSize := tree.SizeOfDecimal(&a.curSum) + oldCurSumSize := a.curSum.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Decimal(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -1055,7 +1055,7 @@ func (a *avgDecimalOrderedAgg) Compute( } }, ) - newCurSumSize := tree.SizeOfDecimal(&a.curSum) + newCurSumSize := a.curSum.Size() if newCurSumSize != oldCurSumSize { a.allocator.AdjustMemoryUsage(int64(newCurSumSize - oldCurSumSize)) } diff --git a/pkg/sql/colexec/colexecagg/ordered_min_max_agg.eg.go b/pkg/sql/colexec/colexecagg/ordered_min_max_agg.eg.go index 6399abcfa111..8049701a4b68 100644 --- a/pkg/sql/colexec/colexecagg/ordered_min_max_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/ordered_min_max_agg.eg.go @@ -15,7 +15,7 @@ import ( "time" "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" @@ -684,7 +684,7 @@ func (a *minDecimalOrderedAgg) SetOutput(vec coldata.Vec) { func (a *minDecimalOrderedAgg) Compute( vecs []coldata.Vec, inputIdxs []uint32, startIdx, endIdx int, sel []int, ) { - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Decimal(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -868,7 +868,7 @@ func (a *minDecimalOrderedAgg) Compute( } }, ) - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } @@ -4001,7 +4001,7 @@ func (a *maxDecimalOrderedAgg) SetOutput(vec coldata.Vec) { func (a *maxDecimalOrderedAgg) Compute( vecs []coldata.Vec, inputIdxs []uint32, startIdx, endIdx int, sel []int, ) { - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Decimal(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -4185,7 +4185,7 @@ func (a *maxDecimalOrderedAgg) Compute( } }, ) - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } diff --git a/pkg/sql/colexec/colexecagg/ordered_sum_agg.eg.go b/pkg/sql/colexec/colexecagg/ordered_sum_agg.eg.go index a0cade17e013..3be4db00629b 100644 --- a/pkg/sql/colexec/colexecagg/ordered_sum_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/ordered_sum_agg.eg.go @@ -12,7 +12,7 @@ package colexecagg import ( "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/sql/colexec/execgen" "github.com/cockroachdb/cockroach/pkg/sql/colexecerror" @@ -94,7 +94,7 @@ func (a *sumInt16OrderedAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int16(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -262,7 +262,7 @@ func (a *sumInt16OrderedAgg) Compute( } }, ) - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } @@ -337,7 +337,7 @@ func (a *sumInt32OrderedAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int32(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -505,7 +505,7 @@ func (a *sumInt32OrderedAgg) Compute( } }, ) - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } @@ -580,7 +580,7 @@ func (a *sumInt64OrderedAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int64(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -748,7 +748,7 @@ func (a *sumInt64OrderedAgg) Compute( } }, ) - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } @@ -819,7 +819,7 @@ func (a *sumDecimalOrderedAgg) SetOutput(vec coldata.Vec) { func (a *sumDecimalOrderedAgg) Compute( vecs []coldata.Vec, inputIdxs []uint32, startIdx, endIdx int, sel []int, ) { - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Decimal(), vec.Nulls() a.allocator.PerformOperation([]coldata.Vec{a.vec}, func() { @@ -983,7 +983,7 @@ func (a *sumDecimalOrderedAgg) Compute( } }, ) - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } diff --git a/pkg/sql/colexec/colexecagg/ordered_sum_int_agg.eg.go b/pkg/sql/colexec/colexecagg/ordered_sum_int_agg.eg.go index 8972b563e836..477f83ffe5c2 100644 --- a/pkg/sql/colexec/colexecagg/ordered_sum_int_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/ordered_sum_int_agg.eg.go @@ -12,7 +12,7 @@ package colexecagg import ( "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/sql/colexecerror" "github.com/cockroachdb/cockroach/pkg/sql/colmem" diff --git a/pkg/sql/colexec/colexecagg/sum_agg_tmpl.go b/pkg/sql/colexec/colexecagg/sum_agg_tmpl.go index 09d55011a5c4..365e0ac77e53 100644 --- a/pkg/sql/colexec/colexecagg/sum_agg_tmpl.go +++ b/pkg/sql/colexec/colexecagg/sum_agg_tmpl.go @@ -24,7 +24,7 @@ package colexecagg import ( "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/sql/colexec/execgen" "github.com/cockroachdb/cockroach/pkg/sql/colexecerror" diff --git a/pkg/sql/colexec/colexecagg/window_avg_agg.eg.go b/pkg/sql/colexec/colexecagg/window_avg_agg.eg.go index 8f455fce4d8e..6169cfc32eef 100644 --- a/pkg/sql/colexec/colexecagg/window_avg_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/window_avg_agg.eg.go @@ -12,7 +12,7 @@ package colexecagg import ( "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/sql/colexec/execgen" "github.com/cockroachdb/cockroach/pkg/sql/colexecerror" @@ -88,7 +88,7 @@ func (a *avgInt16WindowAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurSumSize := tree.SizeOfDecimal(&a.curSum) + oldCurSumSize := a.curSum.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int16(), vec.Nulls() // Unnecessary memory accounting can have significant overhead for window @@ -138,7 +138,7 @@ func (a *avgInt16WindowAgg) Compute( } } } - newCurSumSize := tree.SizeOfDecimal(&a.curSum) + newCurSumSize := a.curSum.Size() if newCurSumSize != oldCurSumSize { a.allocator.AdjustMemoryUsage(int64(newCurSumSize - oldCurSumSize)) } @@ -192,7 +192,7 @@ func (a *avgInt16WindowAgg) Remove(vecs []coldata.Vec, inputIdxs []uint32, start // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurSumSize := tree.SizeOfDecimal(&a.curSum) + oldCurSumSize := a.curSum.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int16(), vec.Nulls() _, _ = col.Get(endIdx-1), col.Get(startIdx) @@ -239,7 +239,7 @@ func (a *avgInt16WindowAgg) Remove(vecs []coldata.Vec, inputIdxs []uint32, start } } } - newCurSumSize := tree.SizeOfDecimal(&a.curSum) + newCurSumSize := a.curSum.Size() if newCurSumSize != oldCurSumSize { a.allocator.AdjustMemoryUsage(int64(newCurSumSize - oldCurSumSize)) } @@ -265,7 +265,7 @@ func (a *avgInt32WindowAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurSumSize := tree.SizeOfDecimal(&a.curSum) + oldCurSumSize := a.curSum.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int32(), vec.Nulls() // Unnecessary memory accounting can have significant overhead for window @@ -315,7 +315,7 @@ func (a *avgInt32WindowAgg) Compute( } } } - newCurSumSize := tree.SizeOfDecimal(&a.curSum) + newCurSumSize := a.curSum.Size() if newCurSumSize != oldCurSumSize { a.allocator.AdjustMemoryUsage(int64(newCurSumSize - oldCurSumSize)) } @@ -369,7 +369,7 @@ func (a *avgInt32WindowAgg) Remove(vecs []coldata.Vec, inputIdxs []uint32, start // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurSumSize := tree.SizeOfDecimal(&a.curSum) + oldCurSumSize := a.curSum.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int32(), vec.Nulls() _, _ = col.Get(endIdx-1), col.Get(startIdx) @@ -416,7 +416,7 @@ func (a *avgInt32WindowAgg) Remove(vecs []coldata.Vec, inputIdxs []uint32, start } } } - newCurSumSize := tree.SizeOfDecimal(&a.curSum) + newCurSumSize := a.curSum.Size() if newCurSumSize != oldCurSumSize { a.allocator.AdjustMemoryUsage(int64(newCurSumSize - oldCurSumSize)) } @@ -442,7 +442,7 @@ func (a *avgInt64WindowAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurSumSize := tree.SizeOfDecimal(&a.curSum) + oldCurSumSize := a.curSum.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int64(), vec.Nulls() // Unnecessary memory accounting can have significant overhead for window @@ -492,7 +492,7 @@ func (a *avgInt64WindowAgg) Compute( } } } - newCurSumSize := tree.SizeOfDecimal(&a.curSum) + newCurSumSize := a.curSum.Size() if newCurSumSize != oldCurSumSize { a.allocator.AdjustMemoryUsage(int64(newCurSumSize - oldCurSumSize)) } @@ -546,7 +546,7 @@ func (a *avgInt64WindowAgg) Remove(vecs []coldata.Vec, inputIdxs []uint32, start // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurSumSize := tree.SizeOfDecimal(&a.curSum) + oldCurSumSize := a.curSum.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int64(), vec.Nulls() _, _ = col.Get(endIdx-1), col.Get(startIdx) @@ -593,7 +593,7 @@ func (a *avgInt64WindowAgg) Remove(vecs []coldata.Vec, inputIdxs []uint32, start } } } - newCurSumSize := tree.SizeOfDecimal(&a.curSum) + newCurSumSize := a.curSum.Size() if newCurSumSize != oldCurSumSize { a.allocator.AdjustMemoryUsage(int64(newCurSumSize - oldCurSumSize)) } @@ -615,7 +615,7 @@ var _ AggregateFunc = &avgDecimalWindowAgg{} func (a *avgDecimalWindowAgg) Compute( vecs []coldata.Vec, inputIdxs []uint32, startIdx, endIdx int, sel []int, ) { - oldCurSumSize := tree.SizeOfDecimal(&a.curSum) + oldCurSumSize := a.curSum.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Decimal(), vec.Nulls() // Unnecessary memory accounting can have significant overhead for window @@ -663,7 +663,7 @@ func (a *avgDecimalWindowAgg) Compute( } } } - newCurSumSize := tree.SizeOfDecimal(&a.curSum) + newCurSumSize := a.curSum.Size() if newCurSumSize != oldCurSumSize { a.allocator.AdjustMemoryUsage(int64(newCurSumSize - oldCurSumSize)) } @@ -714,7 +714,7 @@ func (a *avgDecimalWindowAggAlloc) newAggFunc() AggregateFunc { // Remove implements the slidingWindowAggregateFunc interface (see // window_aggregator_tmpl.go). func (a *avgDecimalWindowAgg) Remove(vecs []coldata.Vec, inputIdxs []uint32, startIdx, endIdx int) { - oldCurSumSize := tree.SizeOfDecimal(&a.curSum) + oldCurSumSize := a.curSum.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Decimal(), vec.Nulls() _, _ = col.Get(endIdx-1), col.Get(startIdx) @@ -759,7 +759,7 @@ func (a *avgDecimalWindowAgg) Remove(vecs []coldata.Vec, inputIdxs []uint32, sta } } } - newCurSumSize := tree.SizeOfDecimal(&a.curSum) + newCurSumSize := a.curSum.Size() if newCurSumSize != oldCurSumSize { a.allocator.AdjustMemoryUsage(int64(newCurSumSize - oldCurSumSize)) } diff --git a/pkg/sql/colexec/colexecagg/window_min_max_agg.eg.go b/pkg/sql/colexec/colexecagg/window_min_max_agg.eg.go index 7d2a3419c29c..b561e5a9bc97 100644 --- a/pkg/sql/colexec/colexecagg/window_min_max_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/window_min_max_agg.eg.go @@ -15,7 +15,7 @@ import ( "time" "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" @@ -400,7 +400,7 @@ var _ AggregateFunc = &minDecimalWindowAgg{} func (a *minDecimalWindowAgg) Compute( vecs []coldata.Vec, inputIdxs []uint32, startIdx, endIdx int, sel []int, ) { - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Decimal(), vec.Nulls() // Unnecessary memory accounting can have significant overhead for window @@ -460,7 +460,7 @@ func (a *minDecimalWindowAgg) Compute( } } } - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } @@ -2093,7 +2093,7 @@ var _ AggregateFunc = &maxDecimalWindowAgg{} func (a *maxDecimalWindowAgg) Compute( vecs []coldata.Vec, inputIdxs []uint32, startIdx, endIdx int, sel []int, ) { - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Decimal(), vec.Nulls() // Unnecessary memory accounting can have significant overhead for window @@ -2153,7 +2153,7 @@ func (a *maxDecimalWindowAgg) Compute( } } } - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } diff --git a/pkg/sql/colexec/colexecagg/window_sum_agg.eg.go b/pkg/sql/colexec/colexecagg/window_sum_agg.eg.go index c655f6f7a1b4..78a8d0ce61cc 100644 --- a/pkg/sql/colexec/colexecagg/window_sum_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/window_sum_agg.eg.go @@ -12,7 +12,7 @@ package colexecagg import ( "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/sql/colexec/execgen" "github.com/cockroachdb/cockroach/pkg/sql/colexecerror" @@ -87,7 +87,7 @@ func (a *sumInt16WindowAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int16(), vec.Nulls() // Unnecessary memory accounting can have significant overhead for window @@ -137,7 +137,7 @@ func (a *sumInt16WindowAgg) Compute( } } } - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } @@ -189,7 +189,7 @@ func (a *sumInt16WindowAgg) Remove( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int16(), vec.Nulls() _, _ = col.Get(endIdx-1), col.Get(startIdx) @@ -236,7 +236,7 @@ func (a *sumInt16WindowAgg) Remove( } } } - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } @@ -261,7 +261,7 @@ func (a *sumInt32WindowAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int32(), vec.Nulls() // Unnecessary memory accounting can have significant overhead for window @@ -311,7 +311,7 @@ func (a *sumInt32WindowAgg) Compute( } } } - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } @@ -363,7 +363,7 @@ func (a *sumInt32WindowAgg) Remove( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int32(), vec.Nulls() _, _ = col.Get(endIdx-1), col.Get(startIdx) @@ -410,7 +410,7 @@ func (a *sumInt32WindowAgg) Remove( } } } - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } @@ -435,7 +435,7 @@ func (a *sumInt64WindowAgg) Compute( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int64(), vec.Nulls() // Unnecessary memory accounting can have significant overhead for window @@ -485,7 +485,7 @@ func (a *sumInt64WindowAgg) Compute( } } } - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } @@ -537,7 +537,7 @@ func (a *sumInt64WindowAgg) Remove( // In order to inline the templated code of overloads, we need to have a // "_overloadHelper" local variable of type "overloadHelper". _overloadHelper := a.overloadHelper - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Int64(), vec.Nulls() _, _ = col.Get(endIdx-1), col.Get(startIdx) @@ -584,7 +584,7 @@ func (a *sumInt64WindowAgg) Remove( } } } - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } @@ -605,7 +605,7 @@ var _ AggregateFunc = &sumDecimalWindowAgg{} func (a *sumDecimalWindowAgg) Compute( vecs []coldata.Vec, inputIdxs []uint32, startIdx, endIdx int, sel []int, ) { - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Decimal(), vec.Nulls() // Unnecessary memory accounting can have significant overhead for window @@ -653,7 +653,7 @@ func (a *sumDecimalWindowAgg) Compute( } } } - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } @@ -702,7 +702,7 @@ func (a *sumDecimalWindowAggAlloc) newAggFunc() AggregateFunc { func (a *sumDecimalWindowAgg) Remove( vecs []coldata.Vec, inputIdxs []uint32, startIdx, endIdx int, ) { - oldCurAggSize := tree.SizeOfDecimal(&a.curAgg) + oldCurAggSize := a.curAgg.Size() vec := vecs[inputIdxs[0]] col, nulls := vec.Decimal(), vec.Nulls() _, _ = col.Get(endIdx-1), col.Get(startIdx) @@ -747,7 +747,7 @@ func (a *sumDecimalWindowAgg) Remove( } } } - newCurAggSize := tree.SizeOfDecimal(&a.curAgg) + newCurAggSize := a.curAgg.Size() if newCurAggSize != oldCurAggSize { a.allocator.AdjustMemoryUsage(int64(newCurAggSize - oldCurAggSize)) } diff --git a/pkg/sql/colexec/colexecagg/window_sum_int_agg.eg.go b/pkg/sql/colexec/colexecagg/window_sum_int_agg.eg.go index 051508590d0b..5fb7edf555fe 100644 --- a/pkg/sql/colexec/colexecagg/window_sum_int_agg.eg.go +++ b/pkg/sql/colexec/colexecagg/window_sum_int_agg.eg.go @@ -12,7 +12,7 @@ package colexecagg import ( "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/sql/colexecerror" "github.com/cockroachdb/cockroach/pkg/sql/colmem" diff --git a/pkg/sql/colexec/colexecbase/BUILD.bazel b/pkg/sql/colexec/colexecbase/BUILD.bazel index a632b5cd3181..0e6a6c3b2d2d 100644 --- a/pkg/sql/colexec/colexecbase/BUILD.bazel +++ b/pkg/sql/colexec/colexecbase/BUILD.bazel @@ -33,7 +33,7 @@ go_library( "//pkg/util/json", # keep "//pkg/util/log", "//pkg/util/uuid", # keep - "@com_github_cockroachdb_apd_v2//:apd", # keep + "@com_github_cockroachdb_apd_v3//:apd", # keep "@com_github_cockroachdb_errors//:errors", "@com_github_lib_pq//oid", # keep ], diff --git a/pkg/sql/colexec/colexecbase/cast.eg.go b/pkg/sql/colexec/colexecbase/cast.eg.go index 690243ca7a29..76fc6692d013 100644 --- a/pkg/sql/colexec/colexecbase/cast.eg.go +++ b/pkg/sql/colexec/colexecbase/cast.eg.go @@ -17,7 +17,7 @@ import ( "strings" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/typeconv" "github.com/cockroachdb/cockroach/pkg/sql/colconv" diff --git a/pkg/sql/colexec/colexecbase/cast_tmpl.go b/pkg/sql/colexec/colexecbase/cast_tmpl.go index db2004d48a7f..b7da4781ea79 100644 --- a/pkg/sql/colexec/colexecbase/cast_tmpl.go +++ b/pkg/sql/colexec/colexecbase/cast_tmpl.go @@ -26,7 +26,7 @@ import ( "fmt" "math" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/typeconv" "github.com/cockroachdb/cockroach/pkg/sql/colconv" diff --git a/pkg/sql/colexec/colexecbase/const.eg.go b/pkg/sql/colexec/colexecbase/const.eg.go index df2b6998ee79..2af1aa9157c5 100644 --- a/pkg/sql/colexec/colexecbase/const.eg.go +++ b/pkg/sql/colexec/colexecbase/const.eg.go @@ -12,7 +12,7 @@ package colexecbase import ( "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/typeconv" "github.com/cockroachdb/cockroach/pkg/sql/colexec/colexecutils" diff --git a/pkg/sql/colexec/colexecbase/const_tmpl.go b/pkg/sql/colexec/colexecbase/const_tmpl.go index 08e1ed3113cf..fe85e32befee 100644 --- a/pkg/sql/colexec/colexecbase/const_tmpl.go +++ b/pkg/sql/colexec/colexecbase/const_tmpl.go @@ -22,7 +22,7 @@ package colexecbase import ( - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/typeconv" "github.com/cockroachdb/cockroach/pkg/sql/colexec/colexecutils" diff --git a/pkg/sql/colexec/colexecbase/distinct.eg.go b/pkg/sql/colexec/colexecbase/distinct.eg.go index 83f311027de6..e54ba21b4995 100644 --- a/pkg/sql/colexec/colexecbase/distinct.eg.go +++ b/pkg/sql/colexec/colexecbase/distinct.eg.go @@ -16,7 +16,7 @@ import ( "math" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecjoin/BUILD.bazel b/pkg/sql/colexec/colexecjoin/BUILD.bazel index 59f4c062885c..e26849e799c2 100644 --- a/pkg/sql/colexec/colexecjoin/BUILD.bazel +++ b/pkg/sql/colexec/colexecjoin/BUILD.bazel @@ -33,7 +33,7 @@ go_library( "//pkg/util/duration", # keep "//pkg/util/json", # keep "//pkg/util/mon", - "@com_github_cockroachdb_apd_v2//:apd", # keep + "@com_github_cockroachdb_apd_v3//:apd", # keep "@com_github_cockroachdb_errors//:errors", "@com_github_marusama_semaphore//:semaphore", ], diff --git a/pkg/sql/colexec/colexecjoin/mergejoiner_exceptall.eg.go b/pkg/sql/colexec/colexecjoin/mergejoiner_exceptall.eg.go index 86e91620a528..6623b4e55d34 100644 --- a/pkg/sql/colexec/colexecjoin/mergejoiner_exceptall.eg.go +++ b/pkg/sql/colexec/colexecjoin/mergejoiner_exceptall.eg.go @@ -14,7 +14,7 @@ import ( "math" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecjoin/mergejoiner_fullouter.eg.go b/pkg/sql/colexec/colexecjoin/mergejoiner_fullouter.eg.go index 0d8d1fde22d9..996be9989579 100644 --- a/pkg/sql/colexec/colexecjoin/mergejoiner_fullouter.eg.go +++ b/pkg/sql/colexec/colexecjoin/mergejoiner_fullouter.eg.go @@ -14,7 +14,7 @@ import ( "math" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecjoin/mergejoiner_inner.eg.go b/pkg/sql/colexec/colexecjoin/mergejoiner_inner.eg.go index fdd9d665d452..17ccdaf40312 100644 --- a/pkg/sql/colexec/colexecjoin/mergejoiner_inner.eg.go +++ b/pkg/sql/colexec/colexecjoin/mergejoiner_inner.eg.go @@ -14,7 +14,7 @@ import ( "math" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecjoin/mergejoiner_intersectall.eg.go b/pkg/sql/colexec/colexecjoin/mergejoiner_intersectall.eg.go index 55c13e7a4139..7aee581338ad 100644 --- a/pkg/sql/colexec/colexecjoin/mergejoiner_intersectall.eg.go +++ b/pkg/sql/colexec/colexecjoin/mergejoiner_intersectall.eg.go @@ -14,7 +14,7 @@ import ( "math" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecjoin/mergejoiner_leftanti.eg.go b/pkg/sql/colexec/colexecjoin/mergejoiner_leftanti.eg.go index dbc70f4fa95c..3e18b7bee080 100644 --- a/pkg/sql/colexec/colexecjoin/mergejoiner_leftanti.eg.go +++ b/pkg/sql/colexec/colexecjoin/mergejoiner_leftanti.eg.go @@ -14,7 +14,7 @@ import ( "math" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecjoin/mergejoiner_leftouter.eg.go b/pkg/sql/colexec/colexecjoin/mergejoiner_leftouter.eg.go index f8d6f065d6bd..9df2b39bbbb2 100644 --- a/pkg/sql/colexec/colexecjoin/mergejoiner_leftouter.eg.go +++ b/pkg/sql/colexec/colexecjoin/mergejoiner_leftouter.eg.go @@ -14,7 +14,7 @@ import ( "math" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecjoin/mergejoiner_leftsemi.eg.go b/pkg/sql/colexec/colexecjoin/mergejoiner_leftsemi.eg.go index ddab25e50f6c..c6ea41924f21 100644 --- a/pkg/sql/colexec/colexecjoin/mergejoiner_leftsemi.eg.go +++ b/pkg/sql/colexec/colexecjoin/mergejoiner_leftsemi.eg.go @@ -14,7 +14,7 @@ import ( "math" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecjoin/mergejoiner_rightanti.eg.go b/pkg/sql/colexec/colexecjoin/mergejoiner_rightanti.eg.go index d782f4429bf2..a6d1d9dca1b7 100644 --- a/pkg/sql/colexec/colexecjoin/mergejoiner_rightanti.eg.go +++ b/pkg/sql/colexec/colexecjoin/mergejoiner_rightanti.eg.go @@ -14,7 +14,7 @@ import ( "math" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecjoin/mergejoiner_rightouter.eg.go b/pkg/sql/colexec/colexecjoin/mergejoiner_rightouter.eg.go index bd6ae5db6595..582f0d59a60e 100644 --- a/pkg/sql/colexec/colexecjoin/mergejoiner_rightouter.eg.go +++ b/pkg/sql/colexec/colexecjoin/mergejoiner_rightouter.eg.go @@ -14,7 +14,7 @@ import ( "math" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecjoin/mergejoiner_rightsemi.eg.go b/pkg/sql/colexec/colexecjoin/mergejoiner_rightsemi.eg.go index d2cd18ca9289..a5d983bc8f91 100644 --- a/pkg/sql/colexec/colexecjoin/mergejoiner_rightsemi.eg.go +++ b/pkg/sql/colexec/colexecjoin/mergejoiner_rightsemi.eg.go @@ -14,7 +14,7 @@ import ( "math" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecjoin/mergejoiner_tmpl.go b/pkg/sql/colexec/colexecjoin/mergejoiner_tmpl.go index ff29ce6837f9..b145f9d805bf 100644 --- a/pkg/sql/colexec/colexecjoin/mergejoiner_tmpl.go +++ b/pkg/sql/colexec/colexecjoin/mergejoiner_tmpl.go @@ -22,7 +22,7 @@ package colexecjoin import ( - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecproj/BUILD.bazel b/pkg/sql/colexec/colexecproj/BUILD.bazel index 410386e069e2..cfbd81e259bc 100644 --- a/pkg/sql/colexec/colexecproj/BUILD.bazel +++ b/pkg/sql/colexec/colexecproj/BUILD.bazel @@ -27,7 +27,7 @@ go_library( "//pkg/sql/types", "//pkg/util/duration", # keep "//pkg/util/json", # keep - "@com_github_cockroachdb_apd_v2//:apd", # keep + "@com_github_cockroachdb_apd_v3//:apd", # keep "@com_github_cockroachdb_errors//:errors", ], ) diff --git a/pkg/sql/colexec/colexecproj/proj_const_left_ops.eg.go b/pkg/sql/colexec/colexecproj/proj_const_left_ops.eg.go index 34e68e031ea0..3b8c6a351eb5 100644 --- a/pkg/sql/colexec/colexecproj/proj_const_left_ops.eg.go +++ b/pkg/sql/colexec/colexecproj/proj_const_left_ops.eg.go @@ -14,7 +14,7 @@ import ( "time" "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecproj/proj_const_ops_tmpl.go b/pkg/sql/colexec/colexecproj/proj_const_ops_tmpl.go index 10249e3b0365..3b2edae486a2 100644 --- a/pkg/sql/colexec/colexecproj/proj_const_ops_tmpl.go +++ b/pkg/sql/colexec/colexecproj/proj_const_ops_tmpl.go @@ -22,7 +22,7 @@ package colexecproj import ( - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecproj/proj_const_right_ops.eg.go b/pkg/sql/colexec/colexecproj/proj_const_right_ops.eg.go index 0b26e3cd3b56..1069636be86e 100644 --- a/pkg/sql/colexec/colexecproj/proj_const_right_ops.eg.go +++ b/pkg/sql/colexec/colexecproj/proj_const_right_ops.eg.go @@ -15,7 +15,7 @@ import ( "time" "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecsel/BUILD.bazel b/pkg/sql/colexec/colexecsel/BUILD.bazel index 8c318da34bbe..db1a5386fd65 100644 --- a/pkg/sql/colexec/colexecsel/BUILD.bazel +++ b/pkg/sql/colexec/colexecsel/BUILD.bazel @@ -23,7 +23,7 @@ go_library( "//pkg/sql/types", # keep "//pkg/util/duration", # keep "//pkg/util/json", # keep - "@com_github_cockroachdb_apd_v2//:apd", # keep + "@com_github_cockroachdb_apd_v3//:apd", # keep "@com_github_cockroachdb_errors//:errors", ], ) diff --git a/pkg/sql/colexec/colexecsel/selection_ops.eg.go b/pkg/sql/colexec/colexecsel/selection_ops.eg.go index f038f74067e4..e5d3485d7d1c 100644 --- a/pkg/sql/colexec/colexecsel/selection_ops.eg.go +++ b/pkg/sql/colexec/colexecsel/selection_ops.eg.go @@ -14,7 +14,7 @@ import ( "math" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecsel/selection_ops_tmpl.go b/pkg/sql/colexec/colexecsel/selection_ops_tmpl.go index c5893822c943..e5c31c139175 100644 --- a/pkg/sql/colexec/colexecsel/selection_ops_tmpl.go +++ b/pkg/sql/colexec/colexecsel/selection_ops_tmpl.go @@ -22,7 +22,7 @@ package colexecsel import ( - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecspan/BUILD.bazel b/pkg/sql/colexec/colexecspan/BUILD.bazel index 940d7530a716..2083cea41cbc 100644 --- a/pkg/sql/colexec/colexecspan/BUILD.bazel +++ b/pkg/sql/colexec/colexecspan/BUILD.bazel @@ -26,7 +26,7 @@ go_library( "//pkg/util", # keep "//pkg/util/duration", # keep "//pkg/util/encoding", # keep - "@com_github_cockroachdb_apd_v2//:apd", # keep + "@com_github_cockroachdb_apd_v3//:apd", # keep "@com_github_cockroachdb_errors//:errors", # keep ], ) diff --git a/pkg/sql/colexec/colexectestutils/BUILD.bazel b/pkg/sql/colexec/colexectestutils/BUILD.bazel index 4034dc457abf..7d0bdd640134 100644 --- a/pkg/sql/colexec/colexectestutils/BUILD.bazel +++ b/pkg/sql/colexec/colexectestutils/BUILD.bazel @@ -33,7 +33,7 @@ go_library( "//pkg/util/randutil", "//pkg/util/timeofday", "//pkg/util/timeutil", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_pmezard_go_difflib//difflib", "@com_github_stretchr_testify//assert", diff --git a/pkg/sql/colexec/colexectestutils/utils.go b/pkg/sql/colexec/colexectestutils/utils.go index 4c2a364c088e..0e5c04ab9123 100644 --- a/pkg/sql/colexec/colexectestutils/utils.go +++ b/pkg/sql/colexec/colexectestutils/utils.go @@ -22,7 +22,7 @@ import ( "testing/quick" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/typeconv" "github.com/cockroachdb/cockroach/pkg/settings/cluster" diff --git a/pkg/sql/colexec/colexecwindow/BUILD.bazel b/pkg/sql/colexec/colexecwindow/BUILD.bazel index c50385e8cdb9..2c77157787e6 100644 --- a/pkg/sql/colexec/colexecwindow/BUILD.bazel +++ b/pkg/sql/colexec/colexecwindow/BUILD.bazel @@ -37,7 +37,7 @@ go_library( "//pkg/util/json", # keep "//pkg/util/mon", # keep "//pkg/util/timeutil/pgdate", # keep - "@com_github_cockroachdb_apd_v2//:apd", # keep + "@com_github_cockroachdb_apd_v3//:apd", # keep "@com_github_cockroachdb_errors//:errors", # keep "@com_github_marusama_semaphore//:semaphore", # keep ], @@ -81,7 +81,7 @@ go_test( "//pkg/util/log", "//pkg/util/mon", "//pkg/util/randutil", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_marusama_semaphore//:semaphore", "@com_github_stretchr_testify//require", diff --git a/pkg/sql/colexec/colexecwindow/min_max_removable_agg.eg.go b/pkg/sql/colexec/colexecwindow/min_max_removable_agg.eg.go index e2415fb674b2..59a9a155e4f1 100644 --- a/pkg/sql/colexec/colexecwindow/min_max_removable_agg.eg.go +++ b/pkg/sql/colexec/colexecwindow/min_max_removable_agg.eg.go @@ -15,7 +15,7 @@ import ( "math" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecwindow/min_max_removable_agg_tmpl.go b/pkg/sql/colexec/colexecwindow/min_max_removable_agg_tmpl.go index 4f466289b141..36dd5e2442d9 100644 --- a/pkg/sql/colexec/colexecwindow/min_max_removable_agg_tmpl.go +++ b/pkg/sql/colexec/colexecwindow/min_max_removable_agg_tmpl.go @@ -24,7 +24,7 @@ package colexecwindow import ( "context" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecwindow/range_offset_handler.eg.go b/pkg/sql/colexec/colexecwindow/range_offset_handler.eg.go index 63fae3893359..0ace6d83e271 100644 --- a/pkg/sql/colexec/colexecwindow/range_offset_handler.eg.go +++ b/pkg/sql/colexec/colexecwindow/range_offset_handler.eg.go @@ -14,7 +14,7 @@ import ( "math" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecwindow/range_offset_handler_tmpl.go b/pkg/sql/colexec/colexecwindow/range_offset_handler_tmpl.go index 8729d52167ce..86ae85cafd82 100644 --- a/pkg/sql/colexec/colexecwindow/range_offset_handler_tmpl.go +++ b/pkg/sql/colexec/colexecwindow/range_offset_handler_tmpl.go @@ -24,7 +24,7 @@ package colexecwindow import ( "context" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/colexecwindow/window_functions_test.go b/pkg/sql/colexec/colexecwindow/window_functions_test.go index 01740738e09e..28e8851d7ced 100644 --- a/pkg/sql/colexec/colexecwindow/window_functions_test.go +++ b/pkg/sql/colexec/colexecwindow/window_functions_test.go @@ -15,7 +15,7 @@ import ( "fmt" "testing" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/sql/colexec/colexecagg" diff --git a/pkg/sql/colexec/execgen/BUILD.bazel b/pkg/sql/colexec/execgen/BUILD.bazel index 5c594519e4de..c1df83f5f00c 100644 --- a/pkg/sql/colexec/execgen/BUILD.bazel +++ b/pkg/sql/colexec/execgen/BUILD.bazel @@ -16,7 +16,7 @@ go_library( deps = [ "//pkg/sql/colexecerror", "//pkg/sql/sem/tree", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_dave_dst//:dst", "@com_github_dave_dst//decorator", diff --git a/pkg/sql/colexec/execgen/cmd/execgen/distinct_gen.go b/pkg/sql/colexec/execgen/cmd/execgen/distinct_gen.go index 935181d8d872..d7f570d1c1ed 100644 --- a/pkg/sql/colexec/execgen/cmd/execgen/distinct_gen.go +++ b/pkg/sql/colexec/execgen/cmd/execgen/distinct_gen.go @@ -41,7 +41,7 @@ package %s import ( "context" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/execgen/cmd/execgen/overloads_base.go b/pkg/sql/colexec/execgen/cmd/execgen/overloads_base.go index 500ab1c6da1f..f8b88c126e05 100644 --- a/pkg/sql/colexec/execgen/cmd/execgen/overloads_base.go +++ b/pkg/sql/colexec/execgen/cmd/execgen/overloads_base.go @@ -575,7 +575,7 @@ if %[2]s != nil { %[1]s = %[2]s.Size() }`, target, value) case types.DecimalFamily: - return fmt.Sprintf(`%s := tree.SizeOfDecimal(&%s)`, target, value) + return fmt.Sprintf(`%s := %s.Size()`, target, value) case typeconv.DatumVecCanonicalTypeFamily: return fmt.Sprintf(` var %[1]s uintptr diff --git a/pkg/sql/colexec/execgen/cmd/execgen/vec_to_datum_gen.go b/pkg/sql/colexec/execgen/cmd/execgen/vec_to_datum_gen.go index 02ec9a27c2b2..2b40e2c377bd 100644 --- a/pkg/sql/colexec/execgen/cmd/execgen/vec_to_datum_gen.go +++ b/pkg/sql/colexec/execgen/cmd/execgen/vec_to_datum_gen.go @@ -67,14 +67,10 @@ var vecToDatumConversionTmpls = map[types.Family]string{ types.BoolFamily: `%[1]s := tree.MakeDBool(tree.DBool(%[2]s))`, // Note that currently, regardless of the integer's width, we always return // INT8, so there is a single conversion template for IntFamily. - types.IntFamily: `%[1]s := %[3]s.NewDInt(tree.DInt(%[2]s))`, - types.FloatFamily: `%[1]s := %[3]s.NewDFloat(tree.DFloat(%[2]s))`, - types.DecimalFamily: ` %[1]s := %[3]s.NewDDecimal(tree.DDecimal{Decimal: %[2]s}) - // Clear the Coeff so that the Set below allocates a new slice for the - // Coeff.abs field. - %[1]s.Coeff = big.Int{} - %[1]s.Coeff.Set(&%[2]s.Coeff)`, - types.DateFamily: `%[1]s := %[3]s.NewDDate(tree.DDate{Date: pgdate.MakeCompatibleDateFromDisk(%[2]s)})`, + types.IntFamily: `%[1]s := %[3]s.NewDInt(tree.DInt(%[2]s))`, + types.FloatFamily: `%[1]s := %[3]s.NewDFloat(tree.DFloat(%[2]s))`, + types.DecimalFamily: `%[1]s := %[3]s.NewDDecimal(tree.DDecimal{Decimal: %[2]s})`, + types.DateFamily: `%[1]s := %[3]s.NewDDate(tree.DDate{Date: pgdate.MakeCompatibleDateFromDisk(%[2]s)})`, types.BytesFamily: `// Note that there is no need for a copy since DBytes uses a string // as underlying storage, which will perform the copy for us. %[1]s := %[3]s.NewDBytes(tree.DBytes(%[2]s))`, diff --git a/pkg/sql/colexec/execgen/overloads_util.go b/pkg/sql/colexec/execgen/overloads_util.go index 26f52c351499..de16699c1b8f 100644 --- a/pkg/sql/colexec/execgen/overloads_util.go +++ b/pkg/sql/colexec/execgen/overloads_util.go @@ -11,7 +11,7 @@ package execgen import ( - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" ) @@ -23,6 +23,9 @@ import ( // `_overloadHelper` of this type must be declared before the inlined // overloaded code. type OverloadHelper struct { + // TODO(yuzefovich): remove these now that temporary apd.Decimal instances can + // be stack-allocated without any indirection to the heap. When doing so, make + // sure the stack variables don't escape by using gcassert:noescape. TmpDec1, TmpDec2 apd.Decimal BinFn tree.TwoArgFn EvalCtx *tree.EvalContext diff --git a/pkg/sql/colexec/hashjoiner_test.go b/pkg/sql/colexec/hashjoiner_test.go index ed6fc406bd2c..39bb753db92b 100644 --- a/pkg/sql/colexec/hashjoiner_test.go +++ b/pkg/sql/colexec/hashjoiner_test.go @@ -15,7 +15,7 @@ import ( "fmt" "testing" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" diff --git a/pkg/sql/colexec/joiner_utils_test.go b/pkg/sql/colexec/joiner_utils_test.go index 23ef63950bfd..dd8b1d9222d8 100644 --- a/pkg/sql/colexec/joiner_utils_test.go +++ b/pkg/sql/colexec/joiner_utils_test.go @@ -14,7 +14,7 @@ import ( "fmt" "strings" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/typeconv" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" "github.com/cockroachdb/cockroach/pkg/sql/colexec/colexectestutils" diff --git a/pkg/sql/colexec/rowstovec.eg.go b/pkg/sql/colexec/rowstovec.eg.go index 4ce1d03b7c85..ceecfbf9a60a 100644 --- a/pkg/sql/colexec/rowstovec.eg.go +++ b/pkg/sql/colexec/rowstovec.eg.go @@ -12,7 +12,7 @@ package colexec import ( "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/typeconv" "github.com/cockroachdb/cockroach/pkg/sql/colmem" diff --git a/pkg/sql/colexec/rowstovec_tmpl.go b/pkg/sql/colexec/rowstovec_tmpl.go index 7a72c5b4ddb0..b5d0ca5db908 100644 --- a/pkg/sql/colexec/rowstovec_tmpl.go +++ b/pkg/sql/colexec/rowstovec_tmpl.go @@ -22,7 +22,7 @@ package colexec import ( - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/typeconv" "github.com/cockroachdb/cockroach/pkg/sql/colmem" diff --git a/pkg/sql/colexec/select_in.eg.go b/pkg/sql/colexec/select_in.eg.go index 888980d976be..2d230b7c895e 100644 --- a/pkg/sql/colexec/select_in.eg.go +++ b/pkg/sql/colexec/select_in.eg.go @@ -14,7 +14,7 @@ import ( "math" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/select_in_tmpl.go b/pkg/sql/colexec/select_in_tmpl.go index 954547a70237..15fd9b256e9e 100644 --- a/pkg/sql/colexec/select_in_tmpl.go +++ b/pkg/sql/colexec/select_in_tmpl.go @@ -22,7 +22,7 @@ package colexec import ( - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colexec/sort_partitioner.eg.go b/pkg/sql/colexec/sort_partitioner.eg.go index 5b3c7dc2f5e8..266afff0d763 100644 --- a/pkg/sql/colexec/sort_partitioner.eg.go +++ b/pkg/sql/colexec/sort_partitioner.eg.go @@ -15,7 +15,7 @@ import ( "math" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/col/typeconv" diff --git a/pkg/sql/colfetcher/BUILD.bazel b/pkg/sql/colfetcher/BUILD.bazel index ac4553cf9db3..c30642f3f2e5 100644 --- a/pkg/sql/colfetcher/BUILD.bazel +++ b/pkg/sql/colfetcher/BUILD.bazel @@ -48,7 +48,7 @@ go_library( "//pkg/util/mon", "//pkg/util/syncutil", "//pkg/util/tracing", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", ], ) diff --git a/pkg/sql/colfetcher/cfetcher.go b/pkg/sql/colfetcher/cfetcher.go index 718bc7fe1cc1..d7b0b86f54ee 100644 --- a/pkg/sql/colfetcher/cfetcher.go +++ b/pkg/sql/colfetcher/cfetcher.go @@ -19,7 +19,7 @@ import ( "sync" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/kv" diff --git a/pkg/sql/colfetcher/index_join.go b/pkg/sql/colfetcher/index_join.go index bb2a948b9710..a17afd63057e 100644 --- a/pkg/sql/colfetcher/index_join.go +++ b/pkg/sql/colfetcher/index_join.go @@ -280,7 +280,7 @@ func (s *ColIndexJoin) getRowSize(idx int) int64 { rowSize += adjustMemEstimate(s.mem.byteLikeCols[i].ElemSize(idx)) } for i := range s.mem.decimalCols { - rowSize += adjustMemEstimate(int64(tree.SizeOfDecimal(&s.mem.decimalCols[i][idx]))) + rowSize += adjustMemEstimate(int64(s.mem.decimalCols[i][idx].Size())) } for i := range s.mem.datumCols { memEstimate := int64(s.mem.datumCols[i].Get(idx).(tree.Datum).Size()) + memsize.DatumOverhead diff --git a/pkg/sql/colmem/allocator.go b/pkg/sql/colmem/allocator.go index 747ea4f26ca6..8af904f12ec3 100644 --- a/pkg/sql/colmem/allocator.go +++ b/pkg/sql/colmem/allocator.go @@ -384,7 +384,7 @@ func sizeOfDecimals(decimals coldata.Decimals, startIdx int) int64 { // Account for the allocated memory beyond the length of the slice. size := int64(cap(decimals)-len(decimals)) * memsize.Decimal for i := startIdx; i < decimals.Len(); i++ { - size += int64(tree.SizeOfDecimal(&decimals[i])) + size += int64(decimals[i].Size()) } return size } @@ -393,10 +393,6 @@ func sizeOfDecimals(decimals coldata.Decimals, startIdx int) int64 { // coldata.BatchSize() length. var SizeOfBatchSizeSelVector = int64(coldata.BatchSize()) * memsize.Int -// decimalEstimate is our guess for how much space a single apd.Decimal element -// will take up. -const decimalEstimate = 50 - // EstimateBatchSizeBytes returns an estimated amount of bytes needed to // store a batch in memory that has column types vecTypes. // WARNING: This only is correct for fixed width types, and returns an @@ -423,8 +419,12 @@ func EstimateBatchSizeBytes(vecTypes []*types.T, batchLength int) int64 { } case types.DecimalFamily: // Similar to byte arrays, we can't tell how much space is used - // to hold the arbitrary precision decimal objects. - acc += decimalEstimate + // to hold the arbitrary precision decimal objects because they + // can contain a variable-length portion. However, most values + // (those with a coefficient which can fit in a uint128) do not + // contain any indirection and are stored entirely inline, so we + // use the flat struct size as an estimate. + acc += memsize.Decimal case types.JsonFamily: numBytesVectors++ case typeconv.DatumVecCanonicalTypeFamily: @@ -559,7 +559,7 @@ func (h *SetAccountingHelper) Init(allocator *Allocator, typs []*types.T) { h.bytesLikeVecIdxs.Add(vecIdx) case types.DecimalFamily: h.varSizeVecIdxs.Add(vecIdx) - h.varSizeEstimatePerRow += decimalEstimate + h.varSizeEstimatePerRow += memsize.Decimal numDecimalVecs++ case typeconv.DatumVecCanonicalTypeFamily: estimate, isVarlen := tree.DatumTypeSize(typ) @@ -659,7 +659,7 @@ func (h *SetAccountingHelper) AccountForSet(rowIdx int) { var newVarLengthDatumSize int64 for _, decimalVec := range h.decimalVecs { d := decimalVec.Get(rowIdx) - newVarLengthDatumSize += int64(tree.SizeOfDecimal(&d)) + newVarLengthDatumSize += int64(d.Size()) } for _, datumVec := range h.datumVecs { datumSize := datumVec.Get(rowIdx).(tree.Datum).Size() diff --git a/pkg/sql/exec_util.go b/pkg/sql/exec_util.go index 8e35c1af7cee..593302da98c0 100644 --- a/pkg/sql/exec_util.go +++ b/pkg/sql/exec_util.go @@ -25,7 +25,7 @@ import ( "strings" "time" - apd "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/clusterversion" "github.com/cockroachdb/cockroach/pkg/col/coldata" diff --git a/pkg/sql/memsize/BUILD.bazel b/pkg/sql/memsize/BUILD.bazel index d118ef52214e..74b1ef54fc79 100644 --- a/pkg/sql/memsize/BUILD.bazel +++ b/pkg/sql/memsize/BUILD.bazel @@ -8,6 +8,6 @@ go_library( deps = [ "//pkg/sql/sem/tree", "//pkg/util/duration", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", ], ) diff --git a/pkg/sql/memsize/constants.go b/pkg/sql/memsize/constants.go index 109bd43ea9ed..e7e70dcdc7ab 100644 --- a/pkg/sql/memsize/constants.go +++ b/pkg/sql/memsize/constants.go @@ -14,7 +14,7 @@ import ( "time" "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/cockroach/pkg/util/duration" ) diff --git a/pkg/sql/opt/norm/BUILD.bazel b/pkg/sql/opt/norm/BUILD.bazel index 18b456723cbd..02249b60748a 100644 --- a/pkg/sql/opt/norm/BUILD.bazel +++ b/pkg/sql/opt/norm/BUILD.bazel @@ -51,7 +51,7 @@ go_library( "//pkg/util/errorutil", "//pkg/util/json", "//pkg/util/log", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", ], ) diff --git a/pkg/sql/opt/norm/general_funcs.go b/pkg/sql/opt/norm/general_funcs.go index 3cc8942d1890..8bc9611fb469 100644 --- a/pkg/sql/opt/norm/general_funcs.go +++ b/pkg/sql/opt/norm/general_funcs.go @@ -11,7 +11,7 @@ package norm import ( - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/sql/opt" "github.com/cockroachdb/cockroach/pkg/sql/opt/cat" "github.com/cockroachdb/cockroach/pkg/sql/opt/constraint" diff --git a/pkg/sql/pgwire/BUILD.bazel b/pkg/sql/pgwire/BUILD.bazel index 5544eca765e6..a43d461f3e71 100644 --- a/pkg/sql/pgwire/BUILD.bazel +++ b/pkg/sql/pgwire/BUILD.bazel @@ -62,7 +62,7 @@ go_library( "//pkg/util/timeutil", "//pkg/util/timeutil/pgdate", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_cockroachdb_logtags//:logtags", "@com_github_cockroachdb_redact//:redact", @@ -129,7 +129,7 @@ go_test( "//pkg/util/randutil", "//pkg/util/timeutil", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_datadriven//:datadriven", "@com_github_cockroachdb_errors//:errors", "@com_github_cockroachdb_errors//stdstrings", diff --git a/pkg/sql/pgwire/encoding_test.go b/pkg/sql/pgwire/encoding_test.go index ef23ad656810..e2b3af12e9a0 100644 --- a/pkg/sql/pgwire/encoding_test.go +++ b/pkg/sql/pgwire/encoding_test.go @@ -21,7 +21,7 @@ import ( "testing" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/col/coldataext" "github.com/cockroachdb/cockroach/pkg/sql/colconv" diff --git a/pkg/sql/pgwire/types.go b/pkg/sql/pgwire/types.go index c3059f6c9687..76f965fb5a1c 100644 --- a/pkg/sql/pgwire/types.go +++ b/pkg/sql/pgwire/types.go @@ -14,13 +14,12 @@ import ( "context" "encoding/binary" "math" - "math/big" "net" "strconv" "strings" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/col/coldata" "github.com/cockroachdb/cockroach/pkg/server/telemetry" "github.com/cockroachdb/cockroach/pkg/sql/lex" @@ -418,7 +417,7 @@ func writeBinaryDecimal(b *writeBuffer, v *apd.Decimal) { alloc := struct { pgNum pgwirebase.PGNumeric - bigI big.Int + bigI apd.BigInt }{ pgNum: pgwirebase.PGNumeric{ // Since we use 2000 as the exponent limits in tree.DecimalCtx, this diff --git a/pkg/sql/physicalplan/BUILD.bazel b/pkg/sql/physicalplan/BUILD.bazel index 5f8a224e4e13..2f5bff8910d5 100644 --- a/pkg/sql/physicalplan/BUILD.bazel +++ b/pkg/sql/physicalplan/BUILD.bazel @@ -75,6 +75,7 @@ go_test( "//pkg/util/log", "//pkg/util/randutil", "//pkg/util/uuid", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", ], ) diff --git a/pkg/sql/physicalplan/aggregator_funcs_test.go b/pkg/sql/physicalplan/aggregator_funcs_test.go index a77318748c36..8e0549659681 100644 --- a/pkg/sql/physicalplan/aggregator_funcs_test.go +++ b/pkg/sql/physicalplan/aggregator_funcs_test.go @@ -14,9 +14,9 @@ import ( "context" "fmt" "math" - "math/big" "testing" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/keys" "github.com/cockroachdb/cockroach/pkg/kv" @@ -47,7 +47,7 @@ var ( // decimal calculations. diffCtx = tree.DecimalCtx.WithPrecision(0) // Use to check for 1ulp. - bigOne = big.NewInt(1) + bigOne = apd.NewBigInt(1) // floatPrecFmt is the format string with a precision of 3 (after // decimal point) specified for float comparisons. Float aggregation // operations involve unavoidable off-by-last-few-digits errors, which diff --git a/pkg/sql/randgen/BUILD.bazel b/pkg/sql/randgen/BUILD.bazel index f2e53659da24..9ac9f8484fb0 100644 --- a/pkg/sql/randgen/BUILD.bazel +++ b/pkg/sql/randgen/BUILD.bazel @@ -42,7 +42,6 @@ go_library( "//pkg/util/timeutil/pgdate", "//pkg/util/uint128", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_lib_pq//oid", ], diff --git a/pkg/sql/randgen/datum.go b/pkg/sql/randgen/datum.go index ef5cbf26884c..ae2b8cb17249 100644 --- a/pkg/sql/randgen/datum.go +++ b/pkg/sql/randgen/datum.go @@ -13,13 +13,11 @@ package randgen import ( "bytes" "math" - "math/big" "math/bits" "math/rand" "time" "unicode" - "github.com/cockroachdb/apd/v2" "github.com/cockroachdb/cockroach/pkg/geo" "github.com/cockroachdb/cockroach/pkg/geo/geogen" "github.com/cockroachdb/cockroach/pkg/geo/geopb" @@ -345,11 +343,9 @@ func RandDatumSimple(rng *rand.Rand, typ *types.T) tree.Datum { date, _ := pgdate.MakeDateFromPGEpoch(rng.Int31n(simpleRange)) datum = tree.NewDDate(date) case types.DecimalFamily: - datum = &tree.DDecimal{ - Decimal: apd.Decimal{ - Coeff: *big.NewInt(rng.Int63n(simpleRange)), - }, - } + dd := &tree.DDecimal{} + dd.SetInt64(rng.Int63n(simpleRange)) + datum = dd case types.IntFamily: datum = tree.NewDInt(tree.DInt(rng.Intn(simpleRange))) case types.IntervalFamily: diff --git a/pkg/sql/rowenc/BUILD.bazel b/pkg/sql/rowenc/BUILD.bazel index 57eca2530b0a..f2500205198e 100644 --- a/pkg/sql/rowenc/BUILD.bazel +++ b/pkg/sql/rowenc/BUILD.bazel @@ -70,7 +70,7 @@ go_test( "//pkg/util/leaktest", "//pkg/util/randutil", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_stretchr_testify//require", ], diff --git a/pkg/sql/rowenc/encoded_datum_test.go b/pkg/sql/rowenc/encoded_datum_test.go index 7aabd97add66..b8d2a3e4d837 100644 --- a/pkg/sql/rowenc/encoded_datum_test.go +++ b/pkg/sql/rowenc/encoded_datum_test.go @@ -16,7 +16,7 @@ import ( "time" "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/sql/catalog/colinfo" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" diff --git a/pkg/sql/rowenc/keyside/BUILD.bazel b/pkg/sql/rowenc/keyside/BUILD.bazel index 26a42f46c0d6..a8232dc170ab 100644 --- a/pkg/sql/rowenc/keyside/BUILD.bazel +++ b/pkg/sql/rowenc/keyside/BUILD.bazel @@ -23,7 +23,7 @@ go_library( "//pkg/util/timetz", "//pkg/util/timeutil/pgdate", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_lib_pq//oid", ], diff --git a/pkg/sql/rowenc/keyside/decode.go b/pkg/sql/rowenc/keyside/decode.go index a91b4fcdd65f..9057ddaff062 100644 --- a/pkg/sql/rowenc/keyside/decode.go +++ b/pkg/sql/rowenc/keyside/decode.go @@ -13,7 +13,7 @@ package keyside import ( "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/geo" "github.com/cockroachdb/cockroach/pkg/geo/geopb" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" diff --git a/pkg/sql/sem/builtins/BUILD.bazel b/pkg/sql/sem/builtins/BUILD.bazel index 1af522e7c177..c0478db1087e 100644 --- a/pkg/sql/sem/builtins/BUILD.bazel +++ b/pkg/sql/sem/builtins/BUILD.bazel @@ -95,7 +95,7 @@ go_library( "//pkg/util/ulid", "//pkg/util/unaccent", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_golang_geo//s1", "@com_github_knz_strtime//:strtime", diff --git a/pkg/sql/sem/builtins/aggregate_builtins.go b/pkg/sql/sem/builtins/aggregate_builtins.go index e60213e40cb5..ca347f68528e 100644 --- a/pkg/sql/sem/builtins/aggregate_builtins.go +++ b/pkg/sql/sem/builtins/aggregate_builtins.go @@ -18,7 +18,7 @@ import ( "strconv" "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/geo" "github.com/cockroachdb/cockroach/pkg/geo/geopb" "github.com/cockroachdb/cockroach/pkg/geo/geos" @@ -2004,21 +2004,21 @@ func (a *regressionAccumulatorDecimalBase) add( a.syy.Set(&a.tmpSyy) a.sxy.Set(&a.tmpSxy) - size := int64(tree.SizeOfDecimal(&a.n) + - tree.SizeOfDecimal(&a.sx) + - tree.SizeOfDecimal(&a.sxx) + - tree.SizeOfDecimal(&a.sy) + - tree.SizeOfDecimal(&a.syy) + - tree.SizeOfDecimal(&a.sxy) + - tree.SizeOfDecimal(&a.tmpX) + - tree.SizeOfDecimal(&a.tmpY) + - tree.SizeOfDecimal(&a.scale) + - tree.SizeOfDecimal(&a.tmpN) + - tree.SizeOfDecimal(&a.tmpSx) + - tree.SizeOfDecimal(&a.tmpSxx) + - tree.SizeOfDecimal(&a.tmpSy) + - tree.SizeOfDecimal(&a.tmpSyy) + - tree.SizeOfDecimal(&a.tmpSxy)) + size := int64(a.n.Size() + + a.sx.Size() + + a.sxx.Size() + + a.sy.Size() + + a.syy.Size() + + a.sxy.Size() + + a.tmpX.Size() + + a.tmpY.Size() + + a.scale.Size() + + a.tmpN.Size() + + a.tmpSx.Size() + + a.tmpSxx.Size() + + a.tmpSy.Size() + + a.tmpSyy.Size() + + a.tmpSxy.Size()) if err := a.updateMemoryUsage(ctx, size); err != nil { return err } @@ -2687,7 +2687,7 @@ func (a *intSumAggregate) Add(ctx context.Context, datum tree.Datum, _ ...tree.D if err != nil { return err } - if err := a.updateMemoryUsage(ctx, int64(tree.SizeOfDecimal(&a.decSum))); err != nil { + if err := a.updateMemoryUsage(ctx, int64(a.decSum.Size())); err != nil { return err } } @@ -2755,7 +2755,7 @@ func (a *decimalSumAggregate) Add(ctx context.Context, datum tree.Datum, _ ...tr return err } - if err := a.updateMemoryUsage(ctx, int64(tree.SizeOfDecimal(&a.sum))); err != nil { + if err := a.updateMemoryUsage(ctx, int64(a.sum.Size())); err != nil { return err } @@ -3058,11 +3058,11 @@ func (a *decimalSqrDiffAggregate) Add( a.ed.Sub(&a.tmp, d, &a.mean) a.ed.Add(&a.sqrDiff, &a.sqrDiff, a.ed.Mul(&a.delta, &a.delta, &a.tmp)) - size := int64(tree.SizeOfDecimal(&a.count) + - tree.SizeOfDecimal(&a.mean) + - tree.SizeOfDecimal(&a.sqrDiff) + - tree.SizeOfDecimal(&a.delta) + - tree.SizeOfDecimal(&a.tmp)) + size := int64(a.count.Size() + + a.mean.Size() + + a.sqrDiff.Size() + + a.delta.Size() + + a.tmp.Size()) if err := a.updateMemoryUsage(ctx, size); err != nil { return err } @@ -3257,13 +3257,13 @@ func (a *decimalSumSqrDiffsAggregate) Add( // Update running mean. a.ed.Add(&a.mean, &a.mean, &a.tmp) - size := int64(tree.SizeOfDecimal(&a.count) + - tree.SizeOfDecimal(&a.mean) + - tree.SizeOfDecimal(&a.sqrDiff) + - tree.SizeOfDecimal(&a.tmpCount) + - tree.SizeOfDecimal(&a.tmpMean) + - tree.SizeOfDecimal(&a.delta) + - tree.SizeOfDecimal(&a.tmp)) + size := int64(a.count.Size() + + a.mean.Size() + + a.sqrDiff.Size() + + a.tmpCount.Size() + + a.tmpMean.Size() + + a.delta.Size() + + a.tmp.Size()) if err := a.updateMemoryUsage(ctx, size); err != nil { return err } diff --git a/pkg/sql/sem/builtins/math_builtins.go b/pkg/sql/sem/builtins/math_builtins.go index b439a469e953..05afd4baa7cc 100644 --- a/pkg/sql/sem/builtins/math_builtins.go +++ b/pkg/sql/sem/builtins/math_builtins.go @@ -14,7 +14,7 @@ import ( "math" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" diff --git a/pkg/sql/sem/builtins/window_frame_builtins.go b/pkg/sql/sem/builtins/window_frame_builtins.go index f54138605d8c..0eff809d0bf0 100644 --- a/pkg/sql/sem/builtins/window_frame_builtins.go +++ b/pkg/sql/sem/builtins/window_frame_builtins.go @@ -15,7 +15,7 @@ import ( "fmt" "strings" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/cockroach/pkg/util/duration" "github.com/cockroachdb/cockroach/pkg/util/ring" diff --git a/pkg/sql/sem/tree/BUILD.bazel b/pkg/sql/sem/tree/BUILD.bazel index 99c7bb235364..45657231e377 100644 --- a/pkg/sql/sem/tree/BUILD.bazel +++ b/pkg/sql/sem/tree/BUILD.bazel @@ -167,7 +167,7 @@ go_library( "//pkg/util/tracing", "//pkg/util/uint128", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_cockroachdb_redact//:redact", "@com_github_google_go_cmp//cmp", @@ -256,7 +256,7 @@ go_test( "//pkg/util/timetz", "//pkg/util/timeutil", "//pkg/util/timeutil/pgdate", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_datadriven//:datadriven", "@com_github_lib_pq//oid", "@com_github_stretchr_testify//assert", diff --git a/pkg/sql/sem/tree/as_of.go b/pkg/sql/sem/tree/as_of.go index 55ee64aa7dbe..f399f410d37c 100644 --- a/pkg/sql/sem/tree/as_of.go +++ b/pkg/sql/sem/tree/as_of.go @@ -17,7 +17,7 @@ import ( "strings" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror" "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" diff --git a/pkg/sql/sem/tree/cast.go b/pkg/sql/sem/tree/cast.go index da7082315ed0..c24479603938 100644 --- a/pkg/sql/sem/tree/cast.go +++ b/pkg/sql/sem/tree/cast.go @@ -12,13 +12,12 @@ package tree import ( "math" - "math/big" "strconv" "strings" "time" "unicode/utf8" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/geo" "github.com/cockroachdb/cockroach/pkg/geo/geopb" "github.com/cockroachdb/cockroach/pkg/server/telemetry" @@ -2314,14 +2313,14 @@ func performCastWithoutPrecisionTruncation( val.SetInt64(v.Unix()) val.Mul(val, big10E6) micros := v.Nanosecond() / int(time.Microsecond) - val.Add(val, big.NewInt(int64(micros))) + val.Add(val, apd.NewBigInt(int64(micros))) dd.Exponent = -6 case *DTimestampTZ: val := &dd.Coeff val.SetInt64(v.Unix()) val.Mul(val, big10E6) micros := v.Nanosecond() / int(time.Microsecond) - val.Add(val, big.NewInt(int64(micros))) + val.Add(val, apd.NewBigInt(int64(micros))) dd.Exponent = -6 case *DInterval: v.AsBigInt(&dd.Coeff) diff --git a/pkg/sql/sem/tree/constant_test.go b/pkg/sql/sem/tree/constant_test.go index e1f9e4845fc5..bfef77c21919 100644 --- a/pkg/sql/sem/tree/constant_test.go +++ b/pkg/sql/sem/tree/constant_test.go @@ -20,7 +20,7 @@ import ( "testing" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/cockroach/pkg/sql/types" diff --git a/pkg/sql/sem/tree/datum.go b/pkg/sql/sem/tree/datum.go index 123d8c6840ae..61c59066fae0 100644 --- a/pkg/sql/sem/tree/datum.go +++ b/pkg/sql/sem/tree/datum.go @@ -15,7 +15,6 @@ import ( "encoding/hex" "fmt" "math" - "math/big" "regexp" "sort" "strconv" @@ -24,7 +23,7 @@ import ( "unicode" "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/geo" "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/sql/lex" @@ -1149,23 +1148,14 @@ func (d *DDecimal) Format(ctx *FmtCtx) { } } -// shallowDecimalSize is the size of the fixed-size part of apd.Decimal in -// bytes. -const shallowDecimalSize = unsafe.Sizeof(apd.Decimal{}) - -// SizeOfDecimal returns the size in bytes of an apd.Decimal. -func SizeOfDecimal(d *apd.Decimal) uintptr { - return shallowDecimalSize + uintptr(cap(d.Coeff.Bits()))*unsafe.Sizeof(big.Word(0)) -} - // Size implements the Datum interface. func (d *DDecimal) Size() uintptr { - return SizeOfDecimal(&d.Decimal) + return d.Decimal.Size() } var ( decimalNegativeZero = &apd.Decimal{Negative: true} - bigTen = big.NewInt(10) + bigTen = apd.NewBigInt(10) ) // IsComposite implements the CompositeDatum interface. @@ -1176,7 +1166,7 @@ func (d *DDecimal) IsComposite() bool { } // Check if d is divisible by 10. - var r big.Int + var r apd.BigInt r.Rem(&d.Decimal.Coeff, bigTen) return r.Sign() == 0 } diff --git a/pkg/sql/sem/tree/datum_alloc.go b/pkg/sql/sem/tree/datum_alloc.go index 90d64f601f1c..6027b9677dfd 100644 --- a/pkg/sql/sem/tree/datum_alloc.go +++ b/pkg/sql/sem/tree/datum_alloc.go @@ -176,7 +176,7 @@ func (a *DatumAlloc) NewDDecimal(v DDecimal) *DDecimal { *buf = make([]DDecimal, a.AllocSize) } r := &(*buf)[0] - *r = v + r.Set(&v.Decimal) *buf = (*buf)[1:] return r } diff --git a/pkg/sql/sem/tree/decimal.go b/pkg/sql/sem/tree/decimal.go index b2213f77add7..0ed19db09c65 100644 --- a/pkg/sql/sem/tree/decimal.go +++ b/pkg/sql/sem/tree/decimal.go @@ -14,7 +14,7 @@ import ( "fmt" "math" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror" ) diff --git a/pkg/sql/sem/tree/eval.go b/pkg/sql/sem/tree/eval.go index d99b075c8169..91811b2592f1 100644 --- a/pkg/sql/sem/tree/eval.go +++ b/pkg/sql/sem/tree/eval.go @@ -14,13 +14,12 @@ import ( "context" "fmt" "math" - "math/big" "regexp" "strings" "time" "unicode/utf8" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/geo" "github.com/cockroachdb/cockroach/pkg/keys" @@ -75,8 +74,8 @@ var ( // ErrShiftArgOutOfRange is reported when a shift argument is out of range. ErrShiftArgOutOfRange = pgerror.New(pgcode.InvalidParameterValue, "shift argument out of range") - big10E6 = big.NewInt(1e6) - big10E10 = big.NewInt(1e10) + big10E6 = apd.NewBigInt(1e6) + big10E10 = apd.NewBigInt(1e10) ) // NewCannotMixBitArraySizesError creates an error for the case when a bitwise @@ -3773,7 +3772,7 @@ func TimestampToDecimal(ts hlc.Timestamp) apd.Decimal { val := &res.Coeff val.SetInt64(ts.WallTime) val.Mul(val, big10E10) - val.Add(val, big.NewInt(int64(ts.Logical))) + val.Add(val, apd.NewBigInt(int64(ts.Logical))) // val must be positive. If it was set to a negative value above, // transfer the sign to res.Negative. @@ -3798,7 +3797,7 @@ func DecimalToInexactDTimestampTZ(d *DDecimal) (*DTimestampTZ, error) { } func decimalToHLC(d *DDecimal) (hlc.Timestamp, error) { - var coef big.Int + var coef apd.BigInt coef.Set(&d.Decimal.Coeff) // The physical portion of the HLC is stored shifted up by 10^10, so shift // it down and clear out the logical component. diff --git a/pkg/sql/sem/tree/window_funcs_test.go b/pkg/sql/sem/tree/window_funcs_test.go index 3b488d7eb0b1..bb06d9eef638 100644 --- a/pkg/sql/sem/tree/window_funcs_test.go +++ b/pkg/sql/sem/tree/window_funcs_test.go @@ -17,7 +17,7 @@ import ( "math/rand" "testing" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/sql/types" "github.com/cockroachdb/cockroach/pkg/util/leaktest" diff --git a/pkg/sql/set_var.go b/pkg/sql/set_var.go index 64b8f3611533..c355849a02a0 100644 --- a/pkg/sql/set_var.go +++ b/pkg/sql/set_var.go @@ -15,7 +15,7 @@ import ( "strings" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/server/telemetry" "github.com/cockroachdb/cockroach/pkg/sql/paramparse" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode" diff --git a/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil/BUILD.bazel b/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil/BUILD.bazel index ebcd42563330..8118b11235bf 100644 --- a/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil/BUILD.bazel +++ b/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil/BUILD.bazel @@ -17,7 +17,7 @@ go_library( "//pkg/util/encoding", "//pkg/util/json", "//pkg/util/timeutil", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_stretchr_testify//require", ], diff --git a/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil/json_impl.go b/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil/json_impl.go index 760044f44663..bddd7a8ce97c 100644 --- a/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil/json_impl.go +++ b/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil/json_impl.go @@ -14,7 +14,7 @@ import ( "encoding/hex" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/util/encoding" "github.com/cockroachdb/cockroach/pkg/util/json" diff --git a/pkg/sql/values_test.go b/pkg/sql/values_test.go index 557ca98df380..5f615374818e 100644 --- a/pkg/sql/values_test.go +++ b/pkg/sql/values_test.go @@ -14,7 +14,7 @@ import ( "testing" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" "github.com/cockroachdb/cockroach/pkg/sql/types" diff --git a/pkg/util/duration/BUILD.bazel b/pkg/util/duration/BUILD.bazel index 4ece483c190b..d94df65fc164 100644 --- a/pkg/util/duration/BUILD.bazel +++ b/pkg/util/duration/BUILD.bazel @@ -12,6 +12,7 @@ go_library( "//pkg/sql/pgwire/pgcode", "//pkg/sql/pgwire/pgerror", "//pkg/util/arith", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", ], ) diff --git a/pkg/util/duration/duration.go b/pkg/util/duration/duration.go index d59d263be2ed..ecdee8c3f585 100644 --- a/pkg/util/duration/duration.go +++ b/pkg/util/duration/duration.go @@ -18,6 +18,7 @@ import ( "strings" "time" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror" "github.com/cockroachdb/cockroach/pkg/util/arith" @@ -62,9 +63,9 @@ const ( ) var ( - bigDaysInMonth = big.NewInt(DaysPerMonth) - bigNanosInDay = big.NewInt(nanosInDay) - bigNanosInMonth = big.NewInt(nanosInMonth) + bigDaysInMonth = apd.NewBigInt(DaysPerMonth) + bigNanosInDay = apd.NewBigInt(nanosInDay) + bigNanosInMonth = apd.NewBigInt(nanosInMonth) ) // errEncodeOverflow is returned by Encode when the sortNanos returned would @@ -298,18 +299,18 @@ func FromFloat64(x float64) Duration { return d.normalize().round() } -// FromBigInt converts a big.Int number of nanoseconds to a duration. Inverse +// FromBigInt converts an apd.BigInt number of nanoseconds to a duration. Inverse // conversion of AsBigInt. Boolean false if the result overflows. -func FromBigInt(src *big.Int) (Duration, bool) { - var rem big.Int - var monthsDec big.Int +func FromBigInt(src *apd.BigInt) (Duration, bool) { + var rem apd.BigInt + var monthsDec apd.BigInt monthsDec.QuoRem(src, bigNanosInMonth, &rem) if !monthsDec.IsInt64() { return Duration{}, false } - var daysDec big.Int - var nanosRem big.Int + var daysDec apd.BigInt + var nanosRem apd.BigInt daysDec.QuoRem(&rem, bigNanosInDay, &nanosRem) // Note: we do not need to check for overflow of daysDec because any // excess bits were spilled into months above already. @@ -359,14 +360,14 @@ func (d Duration) AsFloat64() float64 { float64(numMonthsInYear*DaysPerMonth*SecsPerDay) } -// AsBigInt converts a duration to a big.Int with the number of nanoseconds. -func (d Duration) AsBigInt(dst *big.Int) { +// AsBigInt converts a duration to an apd.BigInt with the number of nanoseconds. +func (d Duration) AsBigInt(dst *apd.BigInt) { dst.SetInt64(d.Months) dst.Mul(dst, bigDaysInMonth) - dst.Add(dst, big.NewInt(d.Days)) + dst.Add(dst, apd.NewBigInt(d.Days)) dst.Mul(dst, bigNanosInDay) // Uses rounded instead of nanos here to remove any on-disk nanos. - dst.Add(dst, big.NewInt(d.rounded())) + dst.Add(dst, apd.NewBigInt(d.rounded())) } const ( diff --git a/pkg/util/encoding/BUILD.bazel b/pkg/util/encoding/BUILD.bazel index 9ce055044c94..cb215ecaf4c5 100644 --- a/pkg/util/encoding/BUILD.bazel +++ b/pkg/util/encoding/BUILD.bazel @@ -23,7 +23,7 @@ go_library( "//pkg/util/timetz", "//pkg/util/timeutil", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", ], ) @@ -53,7 +53,7 @@ go_test( "//pkg/util/timeutil", "//pkg/util/timeutil/pgdate", "//pkg/util/uuid", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", diff --git a/pkg/util/encoding/decimal.go b/pkg/util/encoding/decimal.go index 7ae74d8639bc..8d89acaa9401 100644 --- a/pkg/util/encoding/decimal.go +++ b/pkg/util/encoding/decimal.go @@ -21,7 +21,7 @@ import ( "math/big" "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/errors" ) diff --git a/pkg/util/encoding/decimal_test.go b/pkg/util/encoding/decimal_test.go index dfcf0814204c..520c5460a13d 100644 --- a/pkg/util/encoding/decimal_test.go +++ b/pkg/util/encoding/decimal_test.go @@ -17,7 +17,7 @@ import ( "math/rand" "testing" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/util/randutil" ) diff --git a/pkg/util/encoding/encoding.go b/pkg/util/encoding/encoding.go index 7549004f78d7..634989f3478a 100644 --- a/pkg/util/encoding/encoding.go +++ b/pkg/util/encoding/encoding.go @@ -24,7 +24,7 @@ import ( "unicode/utf8" "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/geo/geopb" "github.com/cockroachdb/cockroach/pkg/util/bitarray" "github.com/cockroachdb/cockroach/pkg/util/duration" diff --git a/pkg/util/encoding/encoding_test.go b/pkg/util/encoding/encoding_test.go index 57b5ef2893d6..926d4f2f3e93 100644 --- a/pkg/util/encoding/encoding_test.go +++ b/pkg/util/encoding/encoding_test.go @@ -20,7 +20,7 @@ import ( "testing" "time" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/geo" "github.com/cockroachdb/cockroach/pkg/geo/geopb" "github.com/cockroachdb/cockroach/pkg/util/bitarray" diff --git a/pkg/util/json/BUILD.bazel b/pkg/util/json/BUILD.bazel index 75eee6a369dd..f46173d282b0 100644 --- a/pkg/util/json/BUILD.bazel +++ b/pkg/util/json/BUILD.bazel @@ -25,7 +25,7 @@ go_library( "//pkg/util/encoding", "//pkg/util/syncutil", "//pkg/util/unique", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", ], ) @@ -47,7 +47,7 @@ go_test( "//pkg/util/randutil", "//pkg/util/timeutil", "//pkg/util/unique", - "@com_github_cockroachdb_apd_v2//:apd", + "@com_github_cockroachdb_apd_v3//:apd", "@com_github_stretchr_testify//require", ], ) diff --git a/pkg/util/json/encode.go b/pkg/util/json/encode.go index 57a36662b2a2..164b354d83a0 100644 --- a/pkg/util/json/encode.go +++ b/pkg/util/json/encode.go @@ -11,7 +11,7 @@ package json import ( - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/util/encoding" "github.com/cockroachdb/errors" ) diff --git a/pkg/util/json/encoded.go b/pkg/util/json/encoded.go index e7c3ffcca41f..c4e04dd5156e 100644 --- a/pkg/util/json/encoded.go +++ b/pkg/util/json/encoded.go @@ -17,7 +17,7 @@ import ( "strconv" "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/sql/inverted" "github.com/cockroachdb/cockroach/pkg/util/syncutil" "github.com/cockroachdb/errors" diff --git a/pkg/util/json/json.go b/pkg/util/json/json.go index 0be61bb64864..798568233f05 100644 --- a/pkg/util/json/json.go +++ b/pkg/util/json/json.go @@ -22,7 +22,7 @@ import ( "unicode/utf8" "unsafe" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/geo" "github.com/cockroachdb/cockroach/pkg/geo/geopb" "github.com/cockroachdb/cockroach/pkg/roachpb" @@ -756,8 +756,7 @@ func (jsonFalse) Size() uintptr { return 0 } func (jsonTrue) Size() uintptr { return 0 } func (j jsonNumber) Size() uintptr { - intVal := j.Coeff - return decimalSize + uintptr(cap(intVal.Bits()))*wordSize + return j.Coeff.Size() } func (j jsonString) Size() uintptr { diff --git a/pkg/util/json/json_test.go b/pkg/util/json/json_test.go index 09a571db7f81..4068ca610ade 100644 --- a/pkg/util/json/json_test.go +++ b/pkg/util/json/json_test.go @@ -19,7 +19,7 @@ import ( "strings" "testing" - "github.com/cockroachdb/apd/v2" + "github.com/cockroachdb/apd/v3" "github.com/cockroachdb/cockroach/pkg/sql/inverted" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror" "github.com/cockroachdb/cockroach/pkg/util/encoding" diff --git a/vendor b/vendor index 0fc47b89da2a..63f160db0ca9 160000 --- a/vendor +++ b/vendor @@ -1 +1 @@ -Subproject commit 0fc47b89da2abe62f421da4d44683c5096d0337d +Subproject commit 63f160db0ca9884760a006d0ba955cf003e926ab From 1c431f06daf63c9ddd9f73adac5e6809026b47a6 Mon Sep 17 00:00:00 2001 From: Nathan VanBenschoten Date: Thu, 6 Jan 2022 09:56:26 -0500 Subject: [PATCH 2/2] sql/sem: remove EvalContext.getTmpDec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `apd.Decimal` can now be entirely stack allocated during arithmetic, so there's no longer any need for this. With https://github.com/cockroachdb/apd/pull/104, this does not introduce any new heap allocations: ``` ➜ (cd pkg/sql/sem/tree && goescape . | grep moved | wc -l) 328 ``` --- pkg/sql/sem/tree/cast.go | 8 ++++---- pkg/sql/sem/tree/datum.go | 6 +++--- pkg/sql/sem/tree/eval.go | 10 +++------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/pkg/sql/sem/tree/cast.go b/pkg/sql/sem/tree/cast.go index c24479603938..025ed94d6d20 100644 --- a/pkg/sql/sem/tree/cast.go +++ b/pkg/sql/sem/tree/cast.go @@ -2755,12 +2755,12 @@ func performCastWithoutPrecisionTruncation( case *DTime: return NewDInterval(duration.MakeDuration(int64(*v)*1000, 0, 0), itm), nil case *DDecimal: - d := ctx.getTmpDec() + var d apd.Decimal dnanos := v.Decimal dnanos.Exponent += 9 // We need HighPrecisionCtx because duration values can contain // upward of 35 decimal digits and DecimalCtx only provides 25. - _, err := HighPrecisionCtx.Quantize(d, &dnanos, 0) + _, err := HighPrecisionCtx.Quantize(&d, &dnanos, 0) if err != nil { return nil, err } @@ -2921,8 +2921,8 @@ func performIntToOidCast(ctx *EvalContext, t *types.T, v DInt) (Datum, error) { } func roundDecimalToInt(ctx *EvalContext, d *apd.Decimal) (int64, error) { - newD := ctx.getTmpDec() - if _, err := DecimalCtx.RoundToIntegralValue(newD, d); err != nil { + var newD apd.Decimal + if _, err := DecimalCtx.RoundToIntegralValue(&newD, d); err != nil { return 0, err } i, err := newD.Int64() diff --git a/pkg/sql/sem/tree/datum.go b/pkg/sql/sem/tree/datum.go index 61c59066fae0..5b0a7cb23635 100644 --- a/pkg/sql/sem/tree/datum.go +++ b/pkg/sql/sem/tree/datum.go @@ -1057,10 +1057,10 @@ func (d *DDecimal) CompareError(ctx *EvalContext, other Datum) (int, error) { // NULL is less than any non-NULL value. return 1, nil } - v := ctx.getTmpDec() + var v apd.Decimal switch t := UnwrapDatum(ctx, other).(type) { case *DDecimal: - v = &t.Decimal + v.Set(&t.Decimal) case *DInt: v.SetInt64(int64(*t)) case *DFloat: @@ -1070,7 +1070,7 @@ func (d *DDecimal) CompareError(ctx *EvalContext, other Datum) (int, error) { default: return 0, makeUnsupportedComparisonMessage(d, other) } - res := CompareDecimals(&d.Decimal, v) + res := CompareDecimals(&d.Decimal, &v) return res, nil } diff --git a/pkg/sql/sem/tree/eval.go b/pkg/sql/sem/tree/eval.go index 91811b2592f1..d31bc0886074 100644 --- a/pkg/sql/sem/tree/eval.go +++ b/pkg/sql/sem/tree/eval.go @@ -1428,10 +1428,11 @@ var BinOps = map[BinaryOperatorSymbol]binOpOverload{ if rInt == 0 { return nil, ErrDivByZero } - div := ctx.getTmpDec().SetInt64(int64(rInt)) + var div apd.Decimal + div.SetInt64(int64(rInt)) dd := &DDecimal{} dd.SetInt64(int64(MustBeDInt(left))) - _, err := DecimalCtx.Quo(&dd.Decimal, &dd.Decimal, div) + _, err := DecimalCtx.Quo(&dd.Decimal, &dd.Decimal, &div) return dd, err }, Volatility: VolatilityImmutable, @@ -3601,7 +3602,6 @@ type EvalContext struct { DB *kv.DB ReCache *RegexpCache - tmpDec apd.Decimal // TODO(mjibson): remove prepareOnly in favor of a 2-step prepare-exec solution // that is also able to save the plan to skip work during the exec step. @@ -3930,10 +3930,6 @@ func (ctx *EvalContext) Ctx() context.Context { return ctx.Context } -func (ctx *EvalContext) getTmpDec() *apd.Decimal { - return &ctx.tmpDec -} - // Eval implements the TypedExpr interface. func (expr *AndExpr) Eval(ctx *EvalContext) (Datum, error) { left, err := expr.Left.(TypedExpr).Eval(ctx)