From 68355af110dca2654703821cc41d67a4729942a6 Mon Sep 17 00:00:00 2001 From: Ricky Stewart Date: Wed, 16 Mar 2022 13:32:25 -0500 Subject: [PATCH 1/6] build: integrate new cross toolchains w/ Bazel 1. Add new toolchains that run on ARM hosts. 2. Add new toolchains that target M1 Mac's. Release note: None --- .bazelrc | 6 +- WORKSPACE | 14 +- build/toolchains/BUILD.bazel | 197 +++++++++++++++++- build/toolchains/REPOSITORIES.bzl | 42 +++- build/toolchains/crosstool-ng/BUILD.tmpl | 2 +- .../crosstool-ng/cc_toolchain_config.bzl.tmpl | 2 +- build/toolchains/crosstool-ng/toolchain.bzl | 13 +- build/toolchains/darwin-x86_64/toolchain.bzl | 28 --- .../{darwin-x86_64 => darwin}/BUILD.tmpl | 20 +- .../cc_toolchain_config.bzl.tmpl | 30 +-- build/toolchains/darwin/toolchain.bzl | 58 ++++++ c-deps/BUILD.bazel | 50 +++-- 12 files changed, 372 insertions(+), 90 deletions(-) delete mode 100644 build/toolchains/darwin-x86_64/toolchain.bzl rename build/toolchains/{darwin-x86_64 => darwin}/BUILD.tmpl (69%) rename build/toolchains/{darwin-x86_64 => darwin}/cc_toolchain_config.bzl.tmpl (85%) create mode 100644 build/toolchains/darwin/toolchain.bzl diff --git a/.bazelrc b/.bazelrc index 08fda85a2beb..20817443f7b9 100644 --- a/.bazelrc +++ b/.bazelrc @@ -58,10 +58,14 @@ build:crosswindows '--workspace_status_command=./build/bazelutil/stamp.sh x86_64 build:crosswindows --config=crosswindowsbase build:crosswindowsbase --platforms=//build/toolchains:cross_windows build:crosswindowsbase --config=cross -build:crossmacos '--workspace_status_command=./build/bazelutil/stamp.sh x86_64-apple-darwin19' +build:crossmacos '--workspace_status_command=./build/bazelutil/stamp.sh x86_64-apple-darwin21.2' build:crossmacos --config=crossmacosbase build:crossmacosbase --platforms=//build/toolchains:cross_macos build:crossmacosbase --config=cross +build:crossmacosarm '--workspace_status_command=./build/bazelutil/stamp.sh aarch64-apple-darwin21.2' +build:crossmacosarm --config=crossmacosarmbase +build:crossmacosarmbase --platforms=//build/toolchains:cross_macos_arm +build:crossmacosarmbase --config=cross build:crosslinuxarm '--workspace_status_command=./build/bazelutil/stamp.sh aarch64-unknown-linux-gnu' build:crosslinuxarm --config=crosslinuxarmbase build:crosslinuxarmbase --platforms=//build/toolchains:cross_linux_arm diff --git a/WORKSPACE b/WORKSPACE index 7ffc54c22492..03b75070f83c 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -390,10 +390,16 @@ load("//build/toolchains:REPOSITORIES.bzl", "toolchain_dependencies") toolchain_dependencies() register_toolchains( - "//build/toolchains:cross_linux_toolchain", - "//build/toolchains:cross_linux_arm_toolchain", - "//build/toolchains:cross_macos_toolchain", - "//build/toolchains:cross_windows_toolchain", + "//build/toolchains:cross_x86_64_linux_toolchain", + "//build/toolchains:cross_x86_64_linux_arm_toolchain", + "//build/toolchains:cross_x86_64_macos_toolchain", + "//build/toolchains:cross_x86_64_macos_arm_toolchain", + "//build/toolchains:cross_x86_64_windows_toolchain", + "//build/toolchains:cross_arm64_linux_toolchain", + "//build/toolchains:cross_arm64_linux_arm_toolchain", + "//build/toolchains:cross_arm64_windows_toolchain", + "//build/toolchains:cross_arm64_macos_toolchain", + "//build/toolchains:cross_arm64_macos_arm_toolchain", "//build/toolchains:dev_darwin_x86_64_toolchain", ) diff --git a/build/toolchains/BUILD.bazel b/build/toolchains/BUILD.bazel index f6857021a6d4..c77956684ce6 100644 --- a/build/toolchains/BUILD.bazel +++ b/build/toolchains/BUILD.bazel @@ -1,7 +1,14 @@ load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") +# We define a number of toolchains, each of which has a name of the form: +# cross_HOST_TARGET_toolchain +# The "HOST" is either x86_64 or arm64. The TARGET is either linux, windows, +# macos, s390x, linux_arm, or macos_arm. (As you might expect, the targets +# are x86_64 in general unless they end with "_arm".) You can enable any of +# these toolchains with `--config crossTARGET` (see .bazelrc). + toolchain( - name = "cross_linux_toolchain", + name = "cross_x86_64_linux_toolchain", exec_compatible_with = [ "@platforms//os:linux", "@platforms//cpu:x86_64", @@ -26,7 +33,7 @@ platform( ) toolchain( - name = "cross_windows_toolchain", + name = "cross_x86_64_windows_toolchain", exec_compatible_with = [ "@platforms//os:linux", "@platforms//cpu:x86_64", @@ -51,7 +58,7 @@ platform( ) toolchain( - name = "cross_macos_toolchain", + name = "cross_x86_64_macos_toolchain", exec_compatible_with = [ "@platforms//os:linux", "@platforms//cpu:x86_64", @@ -63,7 +70,7 @@ toolchain( target_settings = [ ":cross", ], - toolchain = "@toolchain_cross_x86_64-apple-darwin19//:toolchain", + toolchain = "@cross_x86_64_macos_toolchain//:toolchain", toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", ) @@ -76,7 +83,32 @@ platform( ) toolchain( - name = "cross_linux_arm_toolchain", + name = "cross_x86_64_macos_arm_toolchain", + exec_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + ], + target_compatible_with = [ + "@platforms//os:macos", + "@platforms//cpu:arm64", + ], + target_settings = [ + ":cross", + ], + toolchain = "@cross_x86_64_macos_arm_toolchain//:toolchain", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + +platform( + name = "cross_macos_arm", + constraint_values = [ + "@platforms//os:macos", + "@platforms//cpu:arm64", + ], +) + +toolchain( + name = "cross_x86_64_linux_arm_toolchain", exec_compatible_with = [ "@platforms//os:linux", "@platforms//cpu:x86_64", @@ -100,6 +132,136 @@ platform( ], ) +platform( + name = "cross_linux_s390x", + constraint_values = [ + "@platforms//os:linux", + "@platforms//cpu:s390x", + ], +) + +toolchain( + name = "cross_x86_64_s390x_toolchain", + exec_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + ], + target_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:s390x", + ], + target_settings = [ + ":cross", + ], + toolchain = "@toolchain_cross_s390x-ibm-linux-gnu//:toolchain", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + +toolchain( + name = "cross_arm64_linux_toolchain", + exec_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:arm64", + ], + target_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + ], + target_settings = [ + ":cross", + ], + toolchain = "@armtoolchain_cross_x86_64-unknown-linux-gnu//:toolchain", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + +toolchain( + name = "cross_arm64_windows_toolchain", + exec_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:arm64", + ], + target_compatible_with = [ + "@platforms//os:windows", + "@platforms//cpu:x86_64", + ], + target_settings = [ + ":cross", + ], + toolchain = "@armtoolchain_cross_x86_64-w64-mingw32//:toolchain", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + +toolchain( + name = "cross_arm64_linux_arm_toolchain", + exec_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:arm64", + ], + target_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:arm64", + ], + target_settings = [ + ":cross", + ], + toolchain = "@armtoolchain_cross_aarch64-unknown-linux-gnu//:toolchain", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + +toolchain( + name = "cross_arm64_s390x_toolchain", + exec_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + ], + target_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:s390x", + ], + target_settings = [ + ":cross", + ], + toolchain = "@armtoolchain_cross_s390x-ibm-linux-gnu//:toolchain", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + +toolchain( + name = "cross_arm64_macos_toolchain", + exec_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:arm64", + ], + target_compatible_with = [ + "@platforms//os:macos", + "@platforms//cpu:x86_64", + ], + target_settings = [ + ":cross", + ], + toolchain = "@cross_arm64_macos_toolchain//:toolchain", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + +toolchain( + name = "cross_arm64_macos_arm_toolchain", + exec_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:arm64", + ], + target_compatible_with = [ + "@platforms//os:macos", + "@platforms//cpu:arm64", + ], + target_settings = [ + ":cross", + ], + toolchain = "@cross_arm64_macos_arm_toolchain//:toolchain", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + +# This is the dev macOS toolchain which uses the same version of Clang that we +# use in CI. We don't have a dev macOS toolchain for ARM yet because Clang +# doesn't publish compilers that run on M1 Macs. toolchain( name = "dev_darwin_x86_64_toolchain", exec_compatible_with = [ @@ -125,6 +287,9 @@ platform( ], ) +# There are aliases for each of these flags defined in .bazelrc; for example, +# --crdb_test instead of --//build/toolchains:crdb_test_flag. + bool_flag( name = "crdb_test_flag", build_setting_default = False, @@ -185,6 +350,28 @@ config_setting( }, ) +config_setting( + name = "is_cross_macos_x86_64", + constraint_values = [ + "@io_bazel_rules_go//go/toolchain:darwin", + "@platforms//cpu:x86_64", + ], + flag_values = { + ":cross_flag": "true", + }, +) + +config_setting( + name = "is_cross_macos_arm64", + constraint_values = [ + "@io_bazel_rules_go//go/toolchain:darwin", + "@platforms//cpu:arm64", + ], + flag_values = { + ":cross_flag": "true", + }, +) + config_setting( name = "is_cross_linux", constraint_values = [ diff --git a/build/toolchains/REPOSITORIES.bzl b/build/toolchains/REPOSITORIES.bzl index 5c4f7713a69e..8038baddf041 100644 --- a/build/toolchains/REPOSITORIES.bzl +++ b/build/toolchains/REPOSITORIES.bzl @@ -7,30 +7,58 @@ load( _crosstool_toolchain_repo = "crosstool_toolchain_repo", ) load( - "//build/toolchains:darwin-x86_64/toolchain.bzl", - _macos_toolchain_repo = "macos_toolchain_repo", + "//build/toolchains:darwin/toolchain.bzl", + _macos_toolchain_repos = "macos_toolchain_repos", ) def toolchain_dependencies(): _dev_darwin_x86_repo(name = "toolchain_dev_darwin_x86-64") _crosstool_toolchain_repo( name = "toolchain_cross_aarch64-unknown-linux-gnu", + host = "x86_64", target = "aarch64-unknown-linux-gnu", - tarball_sha256 = "ed7ebe618794c0a64aec742d1bf9274302f86a8a81505758c97dc99dab5fd6ab", + tarball_sha256 = "76efd6ee539a0a358c03a6405c95c2f758935bbe70572e030fad86fb328b7d7b", ) _crosstool_toolchain_repo( name = "toolchain_cross_s390x-ibm-linux-gnu", + host = "x86_64", target = "s390x-ibm-linux-gnu", - tarball_sha256 = "93c34d3111e38882fd88f38df33243c52466f703d78e7dd8ac0260c9e1ca35c6", + tarball_sha256 = "3917b7ba50b30d4907d05a3060e79e931e541cb7096913285e4fc0b06ccc98fe", ) _crosstool_toolchain_repo( name = "toolchain_cross_x86_64-unknown-linux-gnu", + host = "x86_64", target = "x86_64-unknown-linux-gnu", - tarball_sha256 = "38f06a929fcc3d1405fe229aa8bc30e57ca78312f4e07e10a68cd3568a64412e", + tarball_sha256 = "267331e9c9cefdcb079a1487b346014f956e6b95332286fadb43d41b6cdd8ce0", ) _crosstool_toolchain_repo( name = "toolchain_cross_x86_64-w64-mingw32", + host = "x86_64", target = "x86_64-w64-mingw32", - tarball_sha256 = "6900b96f7bbd86ba96c4c9704eab6fcb2241fdb5df0a8b9cb3416505a6ef19f7", + tarball_sha256 = "6b2a41d551f91d43b00ce086c60bb589e0ae95da2b14cc3fc6e2f2bf4494b21d", ) - _macos_toolchain_repo(name = "toolchain_cross_x86_64-apple-darwin19") + _crosstool_toolchain_repo( + name = "armtoolchain_cross_aarch64-unknown-linux-gnu", + host = "aarch64", + target = "aarch64-unknown-linux-gnu", + tarball_sha256 = "8e8455a9f5cec46aa6f8a7ffa53b6fb470f98ae169c49a8fe65ed2fbeb83e82f", + ) + _crosstool_toolchain_repo( + name = "armtoolchain_cross_s390x-ibm-linux-gnu", + host = "aarch64", + target = "s390x-ibm-linux-gnu", + tarball_sha256 = "013e7ad3294b7f77b4937e988e0766bd0eb02186876c9e12f51314af38a43597", + ) + _crosstool_toolchain_repo( + name = "armtoolchain_cross_x86_64-unknown-linux-gnu", + host = "aarch64", + target = "x86_64-unknown-linux-gnu", + tarball_sha256 = "a74aa2fb685b23e32a099f4c0bd32618640fc6f1070237edfd3f0c7f613ea983", + ) + _crosstool_toolchain_repo( + name = "armtoolchain_cross_x86_64-w64-mingw32", + host = "aarch64", + target = "x86_64-w64-mingw32", + tarball_sha256 = "6baff5e7658215aabfbc6d37374f4fcdd1b62269828d55ebef841248a99373cc", + ) + _macos_toolchain_repos() diff --git a/build/toolchains/crosstool-ng/BUILD.tmpl b/build/toolchains/crosstool-ng/BUILD.tmpl index 487e09f3c8e0..58164b4ed1f9 100644 --- a/build/toolchains/crosstool-ng/BUILD.tmpl +++ b/build/toolchains/crosstool-ng/BUILD.tmpl @@ -5,7 +5,7 @@ load(":cc_toolchain_config.bzl", "cc_toolchain_config") cc_toolchain_suite( name = "suite", toolchains = { - "k8": ":toolchain", + "%{host}": ":toolchain", }, ) diff --git a/build/toolchains/crosstool-ng/cc_toolchain_config.bzl.tmpl b/build/toolchains/crosstool-ng/cc_toolchain_config.bzl.tmpl index d5ec0041380f..23968c771e7d 100644 --- a/build/toolchains/crosstool-ng/cc_toolchain_config.bzl.tmpl +++ b/build/toolchains/crosstool-ng/cc_toolchain_config.bzl.tmpl @@ -168,7 +168,7 @@ def _impl(ctx): ctx = ctx, features = features, toolchain_identifier = "%{target}-cross-toolchain", - host_system_name = "%{target}", + host_system_name = "%{host}", target_system_name = "%{target}", target_cpu = "%{target}", target_libc = "glibc-2.14", diff --git a/build/toolchains/crosstool-ng/toolchain.bzl b/build/toolchains/crosstool-ng/toolchain.bzl index 92875e77118c..7436eb69187d 100644 --- a/build/toolchains/crosstool-ng/toolchain.bzl +++ b/build/toolchains/crosstool-ng/toolchain.bzl @@ -1,10 +1,10 @@ def _impl(rctx): + if rctx.attr.host == "x86_64": + url = "https://storage.googleapis.com/public-bazel-artifacts/toolchains/crosstool-ng/{}/20220317-191459/{}.tar.gz".format(rctx.attr.host, rctx.attr.target) + elif rctx.attr.host == "aarch64": + url = "https://storage.googleapis.com/public-bazel-artifacts/toolchains/crosstool-ng/{}/20220316-165237/{}.tar.gz".format(rctx.attr.host, rctx.attr.target) rctx.download_and_extract( - url = [ - "https://storage.googleapis.com/public-bazel-artifacts/toolchains/crosstool-ng/20210601-231954/{}.tar.gz".format( - rctx.attr.target, - ), - ], + url = [url], sha256 = rctx.attr.tarball_sha256, stripPrefix = "x-tools/{}/".format(rctx.attr.target), ) @@ -15,6 +15,7 @@ def _impl(rctx): "BUILD", Label("@cockroach//build:toolchains/crosstool-ng/BUILD.tmpl"), substitutions = { + "%{host}": rctx.attr.host, "%{target}": rctx.attr.target, }, executable = False, @@ -24,6 +25,7 @@ def _impl(rctx): Label("@cockroach//build:toolchains/crosstool-ng/cc_toolchain_config.bzl.tmpl"), substitutions = { "%{target}": rctx.attr.target, + "%{host}": rctx.attr.host, "%{repo_path}": repo_path, }, executable = False, @@ -32,6 +34,7 @@ def _impl(rctx): crosstool_toolchain_repo = repository_rule( implementation = _impl, attrs = { + "host": attr.string(mandatory = True), "target": attr.string(mandatory = True), "tarball_sha256": attr.string(mandatory = True), }, diff --git a/build/toolchains/darwin-x86_64/toolchain.bzl b/build/toolchains/darwin-x86_64/toolchain.bzl deleted file mode 100644 index 54ab88ab8383..000000000000 --- a/build/toolchains/darwin-x86_64/toolchain.bzl +++ /dev/null @@ -1,28 +0,0 @@ -def _impl(rctx): - rctx.download_and_extract( - url = [ - "https://storage.googleapis.com/public-bazel-artifacts/toolchains/crosstool-ng/20210601-231954/x86_64-apple-darwin19.tar.gz", - ], - sha256 = "79ecc64d57f05cc4eccb3e57ce19fe016a3ba24c00fbe2435650f58168df8937", - stripPrefix = "x-tools/x86_64-apple-darwin19/", - ) - - repo_path = str(rctx.path("")) - - rctx.template( - "BUILD", - Label("@cockroach//build:toolchains/darwin-x86_64/BUILD.tmpl"), - executable = False, - ) - rctx.template( - "cc_toolchain_config.bzl", - Label("@cockroach//build:toolchains/darwin-x86_64/cc_toolchain_config.bzl.tmpl"), - substitutions = { - "%{repo_path}": repo_path, - }, - executable = False, - ) - -macos_toolchain_repo = repository_rule( - implementation = _impl, -) diff --git a/build/toolchains/darwin-x86_64/BUILD.tmpl b/build/toolchains/darwin/BUILD.tmpl similarity index 69% rename from build/toolchains/darwin-x86_64/BUILD.tmpl rename to build/toolchains/darwin/BUILD.tmpl index 8888b5bf461b..fb9cff09767a 100644 --- a/build/toolchains/darwin-x86_64/BUILD.tmpl +++ b/build/toolchains/darwin/BUILD.tmpl @@ -3,14 +3,14 @@ package(default_visibility = ["//visibility:public"]) load(":cc_toolchain_config.bzl", "cc_toolchain_config") exports_files([ - "bin/x86_64-apple-darwin19-install_name_tool", - "bin/x86_64-apple-darwin19-otool", + "bin/%{target}-apple-darwin21.2-install_name_tool", + "bin/%{target}-apple-darwin21.2-otool", ]) cc_toolchain_suite( name = "suite", toolchains = { - "k8": ":toolchain", + "%{host}": ":toolchain", }, ) @@ -31,22 +31,22 @@ filegroup( filegroup( name = "compiler_files", srcs = [ - "bin/x86_64-apple-darwin19-cc", - "bin/x86_64-apple-darwin19-c++", + "bin/%{target}-apple-darwin21.2-cc", + "bin/%{target}-apple-darwin21.2-c++", ], ) filegroup( name = "ar_files", srcs = [ - "bin/x86_64-apple-darwin19-ar", + "bin/%{target}-apple-darwin21.2-ar", ], ) filegroup( name = "linker_files", srcs = [ - "bin/x86_64-apple-darwin19-cc", + "bin/%{target}-apple-darwin21.2-cc", "bin/xcrun", ], ) @@ -54,20 +54,20 @@ filegroup( filegroup( name = "objcopy_files", srcs = [ - "bin/x86_64-apple-darwin19-objcopy", + "bin/%{target}-apple-darwin21.2-objcopy", ], ) filegroup( name = "strip_files", srcs = [ - "bin/x86_64-apple-darwin19-strip", + "bin/%{target}-apple-darwin21.2-strip", ], ) cc_toolchain( name = "toolchain", - toolchain_identifier = "x86_64-apple-darwin19-cross-toolchain", + toolchain_identifier = "%{target}-apple-darwin21.2-cross-toolchain", toolchain_config = ":toolchain_config", all_files = ":all_files", ar_files = ":ar_files", diff --git a/build/toolchains/darwin-x86_64/cc_toolchain_config.bzl.tmpl b/build/toolchains/darwin/cc_toolchain_config.bzl.tmpl similarity index 85% rename from build/toolchains/darwin-x86_64/cc_toolchain_config.bzl.tmpl rename to build/toolchains/darwin/cc_toolchain_config.bzl.tmpl index 49cb777d4b41..b5b53c8f54d3 100644 --- a/build/toolchains/darwin-x86_64/cc_toolchain_config.bzl.tmpl +++ b/build/toolchains/darwin/cc_toolchain_config.bzl.tmpl @@ -34,35 +34,35 @@ def _impl(ctx): tool_paths = [ tool_path( name = "gcc", - path = "bin/x86_64-apple-darwin19-cc", + path = "bin/%{target}-apple-darwin21.2-cc", ), tool_path( name = "ld", - path = "bin/x86_64-apple-darwin19-ld", + path = "bin/%{target}-apple-darwin21.2-ld", ), tool_path( name = "cpp", - path = "bin/x86_64-apple-darwin19-c++", + path = "bin/%{target}-apple-darwin21.2-c++", ), tool_path( name = "gcov", - path = "bin/x86_64-apple-darwin19-gcov", + path = "bin/%{target}-apple-darwin21.2-gcov", ), tool_path( name = "nm", - path = "bin/x86_64-apple-darwin19-nm", + path = "bin/%{target}-apple-darwin21.2-nm", ), tool_path( name = "objdump", - path = "bin/x86_64-apple-darwin19-objdump", + path = "bin/%{target}-apple-darwin21.2-objdump", ), tool_path( name = "strip", - path = "bin/x86_64-apple-darwin19-strip", + path = "bin/%{target}-apple-darwin21.2-strip", ), tool_path( name = "ar", - path = "bin/x86_64-apple-darwin19-ar", + path = "bin/%{target}-apple-darwin21.2-ar", ), ] @@ -112,7 +112,7 @@ def _impl(ctx): flags = [ "-g1", "-Wall", - "-I%{repo_path}/SDK/MacOSX10.15.sdk/usr/include/c++/v1", + "-I%{repo_path}/SDK/MacOSX12.1.sdk/usr/include/c++/v1", ], ), ]), @@ -191,20 +191,20 @@ def _impl(ctx): return cc_common.create_cc_toolchain_config_info( ctx = ctx, features = features, - toolchain_identifier = "x86_64-apple-darwin19-cross-toolchain", - host_system_name = "x86_64-apple-darwin19", - target_system_name = "x86_64-apple-darwin19", - target_cpu = "x86_64-apple-darwin19", + toolchain_identifier = "%{target}-apple-darwin21.2-cross-toolchain", + host_system_name = "{host}-apple-darwin21.2", + target_system_name = "%{target}-apple-darwin21.2", + target_cpu = "%{target}-apple-darwin21.2", target_libc = "glibc-2.14", compiler = "clang", abi_version = "clang-10.0.0", - abi_libc_version = "x86_64-apple-darwin19", + abi_libc_version = "%{target}-apple-darwin21.2", tool_paths = tool_paths, cxx_builtin_include_directories = [ "%sysroot%/usr/include", "/usr/lib/llvm-10/lib/clang/10.0.0/include", ], - builtin_sysroot = "%{repo_path}/SDK/MacOSX10.15.sdk", + builtin_sysroot = "%{repo_path}/SDK/MacOSX12.1.sdk", ) cc_toolchain_config = rule( diff --git a/build/toolchains/darwin/toolchain.bzl b/build/toolchains/darwin/toolchain.bzl new file mode 100644 index 000000000000..4601aeebdd40 --- /dev/null +++ b/build/toolchains/darwin/toolchain.bzl @@ -0,0 +1,58 @@ +def _impl(rctx): + if rctx.attr.host == "arm64": + url = "https://storage.googleapis.com/public-bazel-artifacts/toolchains/osxcross/aarch64/20220317-160719/x86_64-apple-darwin21.2.tar.gz" + sha256 = "a0fda00934d9f6f17cdd62ce685d0a12751c34686df14085b72e40d5803e93a6" + elif rctx.attr.host == "x86_64": + url = "https://storage.googleapis.com/public-bazel-artifacts/toolchains/osxcross/x86_64/20220317-165434/x86_64-apple-darwin21.2.tar.gz" + sha256 = "751365dbfb5db66fe8e9f47fcf82cbbd7d1c176b79112ab91945d1be1d160dd5" + rctx.download_and_extract( + url = [url], + sha256 = sha256, + stripPrefix = "x-tools/x86_64-apple-darwin21.2/", + ) + + repo_path = str(rctx.path("")) + + rctx.template( + "BUILD", + Label("@cockroach//build:toolchains/darwin/BUILD.tmpl"), + substitutions = { + "%{host}": rctx.attr.host, + "%{target}": rctx.attr.target, + }, + executable = False, + ) + rctx.template( + "cc_toolchain_config.bzl", + Label("@cockroach//build:toolchains/darwin/cc_toolchain_config.bzl.tmpl"), + substitutions = { + "%{host}": rctx.attr.host, + "%{repo_path}": repo_path, + "%{target}": rctx.attr.target, + }, + executable = False, + ) + +macos_toolchain_repo = repository_rule( + implementation = _impl, + attrs = { + "host": attr.string(mandatory = True), + "target": attr.string(mandatory = True), + }, +) + +def macos_toolchain_repos_for_host(host): + macos_toolchain_repo( + name = "cross_{}_macos_arm_toolchain".format(host), + host = host, + target = 'arm64', + ) + macos_toolchain_repo( + name = "cross_{}_macos_toolchain".format(host), + host = host, + target = 'x86_64', + ) + +def macos_toolchain_repos(): + macos_toolchain_repos_for_host('arm64') + macos_toolchain_repos_for_host('x86_64') diff --git a/c-deps/BUILD.bazel b/c-deps/BUILD.bazel index 7b48794119e7..778c92d5c922 100644 --- a/c-deps/BUILD.bazel +++ b/c-deps/BUILD.bazel @@ -11,8 +11,13 @@ configure_make( "--enable-prof", ] + select({ "@io_bazel_rules_go//go/platform:windows": ["--host=x86_64-w64-mingw32"], - "@io_bazel_rules_go//go/platform:darwin_amd64": ["--host=x86_64-apple-darwin19"], - "@io_bazel_rules_go//go/platform:darwin_arm64": ["--host=aarch64-apple-darwin19"], + "@io_bazel_rules_go//go/platform:darwin_amd64": ["--host=x86_64-apple-darwin21.2"], + "@io_bazel_rules_go//go/platform:darwin_arm64": [ + "--host=aarch64-apple-darwin21.2", + "--with-lg-page=16", + ], + "@io_bazel_rules_go//go/platform:linux_amd64": ["--host=x86_64-unknown-linux-gnu"], + "@io_bazel_rules_go//go/platform:linux_arm64": ["--host=aarch64-unknown-linux-gnu"], # NB: Normally host detection is handled by configure, but the version # of jemalloc we have vendored is pretty ancient and can't handle some # of the newer M1 Macs. This arm of the select() can probably be deleted @@ -21,7 +26,6 @@ configure_make( "--host=aarch64-apple-darwin19", "--build=aarch64-apple-darwin19", ], - "@io_bazel_rules_go//go/platform:linux_arm64": ["--host=aarch64-unknown-linux-gnu"], "//conditions:default": [], }), env = select({ @@ -92,16 +96,24 @@ cmake( }, }), data = select({ - "//build/toolchains:is_cross_macos": [ - "@toolchain_cross_x86_64-apple-darwin19//:bin/x86_64-apple-darwin19-install_name_tool", - "@toolchain_cross_x86_64-apple-darwin19//:bin/x86_64-apple-darwin19-otool", + "//build/toolchains:is_cross_macos_x86_64": [ + "@cross_x86_64_macos_toolchain//:bin/x86_64-apple-darwin21.2-install_name_tool", + "@cross_x86_64_macos_toolchain//:bin/x86_64-apple-darwin21.2-otool", + ], + "//build/toolchains:is_cross_macos_arm64": [ + "@cross_arm64_macos_toolchain//:bin/arm64-apple-darwin21.2-install_name_tool", + "@cross_arm64_macos_toolchain//:bin/arm64-apple-darwin21.2-otool", ], "//conditions:default": [], }), env = select({ - "//build/toolchains:is_cross_macos": { - "CMAKE_INSTALL_NAME_TOOL": "$(execpath @toolchain_cross_x86_64-apple-darwin19//:bin/x86_64-apple-darwin19-install_name_tool)", - "OTOOL": "$(execpath @toolchain_cross_x86_64-apple-darwin19//:bin/x86_64-apple-darwin19-otool)", + "//build/toolchains:is_cross_macos_x86_64": { + "CMAKE_INSTALL_NAME_TOOL": "$(execpath @cross_x86_64_macos_toolchain//:bin/x86_64-apple-darwin21.2-install_name_tool)", + "OTOOL": "$(execpath @cross_x86_64_macos_toolchain//:bin/x86_64-apple-darwin21.2-otool)", + }, + "//build/toolchains:is_cross_macos_arm64": { + "CMAKE_INSTALL_NAME_TOOL": "$(execpath @cross_arm64_macos_toolchain//:bin/arm64-apple-darwin21.2-install_name_tool)", + "OTOOL": "$(execpath @cross_arm64_macos_toolchain//:bin/arm64-apple-darwin21.2-otool)", }, "//conditions:default": {}, }), @@ -160,13 +172,25 @@ configure_make( configure_options = [ "--enable-static", "--disable-shared", - ], + ] + select({ + "@io_bazel_rules_go//go/platform:linux_amd64": ["--host=x86_64-unknown-linux-gnu"], + "@io_bazel_rules_go//go/platform:linux_arm64": ["--host=aarch64-unknown-linux-gnu"], + "//conditions:default": [], + }), # We specify -fcommon to get around duplicate definition errors in recent gcc. copts = ["-fcommon"], data = [":autom4te"], - env = { - "AUTOM4TE": "$(execpath :autom4te)", - }, + env = select({ + "//build/toolchains:cross": { + "AUTOM4TE": "$(execpath :autom4te)", + "krb5_cv_attr_constructor_destructor": "yes", + "ac_cv_func_regcomp": "yes", + "ac_cv_printf_positional": "yes", + }, + "//conditions:default": { + "AUTOM4TE": "$(execpath :autom4te)", + }, + }), lib_source = "@krb5//:all", out_static_libs = [ "libgssapi_krb5.a", From 572988258381f7ec030ffaf866c9c98313821d9b Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Wed, 6 Apr 2022 12:23:10 -0400 Subject: [PATCH 2/6] roachtest: fix permissions in typeorm testt Release note: None --- pkg/cmd/roachtest/tests/typeorm.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/roachtest/tests/typeorm.go b/pkg/cmd/roachtest/tests/typeorm.go index 58a4446a4634..649f7316fea5 100644 --- a/pkg/cmd/roachtest/tests/typeorm.go +++ b/pkg/cmd/roachtest/tests/typeorm.go @@ -89,7 +89,7 @@ func registerTypeORM(r registry.Registry) { c, node, "add nodesource repository", - `sudo apt install ca-certificates && curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -`, + `sudo apt install ca-certificates && curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -`, ); err != nil { t.Fatal(err) } @@ -154,14 +154,14 @@ func registerTypeORM(r registry.Registry) { c, node, "building TypeORM", - `cd /mnt/data1/typeorm/ && sudo npm install --unsafe-perm=true --allow-root`, + `cd /mnt/data1/typeorm/ && npm install`, ); err != nil { t.Fatal(err) } t.Status("running TypeORM test suite - approx 12 mins") result, err := c.RunWithDetailsSingleNode(ctx, t.L(), node, - `cd /mnt/data1/typeorm/ && sudo npm test --unsafe-perm=true --allow-root`, + `cd /mnt/data1/typeorm/ && npm test`, ) rawResults := result.Stdout + result.Stderr t.L().Printf("Test Results: %s", rawResults) From c3c68bff9818dd2be35cc795a105b87dfc6e6689 Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Fri, 1 Apr 2022 16:19:24 -0400 Subject: [PATCH 3/6] roachtest: update ORMs under test - typeorm - sqlalchemy - pgjdbc (required updating expected failures) - pgx Release note: None --- pkg/cmd/roachtest/tests/libpq.go | 4 +- pkg/cmd/roachtest/tests/pgjdbc.go | 2 +- pkg/cmd/roachtest/tests/pgjdbc_blocklist.go | 110 +++++++++++++++++++- pkg/cmd/roachtest/tests/pgx.go | 2 +- pkg/cmd/roachtest/tests/sqlalchemy.go | 2 +- pkg/cmd/roachtest/tests/typeorm.go | 2 +- 6 files changed, 112 insertions(+), 10 deletions(-) diff --git a/pkg/cmd/roachtest/tests/libpq.go b/pkg/cmd/roachtest/tests/libpq.go index b591bbf10203..3cd44c30bd15 100644 --- a/pkg/cmd/roachtest/tests/libpq.go +++ b/pkg/cmd/roachtest/tests/libpq.go @@ -25,7 +25,7 @@ import ( ) var libPQReleaseTagRegex = regexp.MustCompile(`^v(?P\d+)\.(?P\d+)\.(?P\d+)$`) -var libPQSupportedTag = "v1.10.0" +var libPQSupportedTag = "v1.10.4" func registerLibPQ(r registry.Registry) { runLibPQ := func(ctx context.Context, t test.Test, c cluster.Cluster) { @@ -134,7 +134,7 @@ func registerLibPQ(r registry.Registry) { parseAndSummarizeJavaORMTestsResults( ctx, t, c, node, "lib/pq" /* ormName */, []byte(resultsPath), - blocklistName, expectedFailures, ignoreList, version, latestTag, + blocklistName, expectedFailures, ignoreList, version, libPQSupportedTag, ) } diff --git a/pkg/cmd/roachtest/tests/pgjdbc.go b/pkg/cmd/roachtest/tests/pgjdbc.go index 32dfc956898b..be0c283fbfbc 100644 --- a/pkg/cmd/roachtest/tests/pgjdbc.go +++ b/pkg/cmd/roachtest/tests/pgjdbc.go @@ -23,7 +23,7 @@ import ( ) var pgjdbcReleaseTagRegex = regexp.MustCompile(`^REL(?P\d+)\.(?P\d+)\.(?P\d+)$`) -var supportedPGJDBCTag = "REL42.2.19" +var supportedPGJDBCTag = "REL42.3.3" // This test runs pgjdbc's full test suite against a single cockroach node. diff --git a/pkg/cmd/roachtest/tests/pgjdbc_blocklist.go b/pkg/cmd/roachtest/tests/pgjdbc_blocklist.go index 07eb3c1f3e36..2f2ac6a4617b 100644 --- a/pkg/cmd/roachtest/tests/pgjdbc_blocklist.go +++ b/pkg/cmd/roachtest/tests/pgjdbc_blocklist.go @@ -21,6 +21,35 @@ var pgjdbcBlocklists = blocklistsForVersion{ // After a failed run, an updated version of this blocklist should be available // in the test log. var pgjdbcBlockList22_1 = blocklist{ + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=BOX, oidValue=603]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=CIDR, oidValue=650]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=CIRCLE, oidValue=718]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=JSON, oidValue=114]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=JSON_ARRAY, oidValue=199]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=LINE, oidValue=628]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=LSEG, oidValue=601]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=MACADDR, oidValue=829]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=MACADDR8, oidValue=774]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=MONEY, oidValue=790]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=MONEY_ARRAY, oidValue=791]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=PATH, oidValue=602]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=POINT, oidValue=600]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=POINT_ARRAY, oidValue=1,017]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=POLYGON, oidValue=604]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=REF_CURSOR, oidValue=1,790]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=REF_CURSOR_ARRAY, oidValue=2,201]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=TSQUERY, oidValue=3,615]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=TSVECTOR, oidValue=3,614]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=XML, oidValue=142]": "unknown", + "org.postgresql.core.OidValuesCorrectnessTest.testValue[oidName=XML_ARRAY, oidValue=143]": "unknown", + "org.postgresql.jdbc.BitFieldTest.TestGetObjectForBitFields": "unknown", + "org.postgresql.jdbc.BitFieldTest.TestSetBitParameter": "unknown", + "org.postgresql.jdbc.LargeObjectManagerTest.testOpenWithErrorAndSubsequentParameterStatusMessageShouldLeaveConnectionInUsableStateAndUpdateParameterStatus()": "unknown", + "org.postgresql.jdbc.ScramTest.[1] null, The server requested SCRAM-based authentication, but no password was provided.": "unknown", + "org.postgresql.jdbc.ScramTest.[2] , The server requested SCRAM-based authentication, but the password is an empty string.": "unknown", + "org.postgresql.test.core.LogServerMessagePropertyTest.testBatchExplicitlyEnabled": "unknown", + "org.postgresql.test.core.LogServerMessagePropertyTest.testBatchWithDefaults": "unknown", + "org.postgresql.test.core.LogServerMessagePropertyTest.testBatchWithLogServerErrorDetailDisabled": "unknown", "org.postgresql.test.jdbc2.ArrayTest.testEscaping[binary = FORCE]": "32552", "org.postgresql.test.jdbc2.ArrayTest.testEscaping[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.ArrayTest.testIndexAccess[binary = FORCE]": "32552", @@ -109,6 +138,7 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc2.ConnectionTest.testTypeMaps": "41578", "org.postgresql.test.jdbc2.ConnectionTest.testWarnings": "41578", "org.postgresql.test.jdbc2.CopyTest.testChangeDateStyle": "41608", + "org.postgresql.test.jdbc2.CopyTest.testCopyMultiApi": "unknown", "org.postgresql.test.jdbc2.CopyTest.testCopyOut": "41608", "org.postgresql.test.jdbc2.CopyTest.testCopyOutByRow": "41608", "org.postgresql.test.jdbc2.CopyTest.testCopyQuery": "41608", @@ -116,6 +146,7 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc2.CursorFetchTest.testMultistatement[binary = FORCE]": "40195", "org.postgresql.test.jdbc2.CursorFetchTest.testMultistatement[binary = REGULAR]": "40195", "org.postgresql.test.jdbc2.DatabaseEncodingTest.testEncoding": "41771", + "org.postgresql.test.jdbc2.DatabaseMetaDataCacheTest.testGetSQLTypeQueryCache": "unknown", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testArrayInt4DoubleDim[binary = FORCE]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testArrayInt4DoubleDim[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testArrayTypeInfo[binary = FORCE]": "32552", @@ -158,6 +189,8 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testFuncWithoutNames[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testFunctionColumns[binary = FORCE]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testFunctionColumns[binary = REGULAR]": "32552", + "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testGeneratedColumns[binary = FORCE]": "32552", + "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testGeneratedColumns[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testGetSQLKeywords[binary = FORCE]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testGetSQLKeywords[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testGetUDT1[binary = FORCE]": "32552", @@ -172,20 +205,28 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testGetUDTQualified[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testIdentityColumns[binary = FORCE]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testIdentityColumns[binary = REGULAR]": "32552", + "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testIndexInfoColumnCase[binary = FORCE]": "32552", + "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testIndexInfoColumnCase[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testIndexInfoColumnOrder[binary = FORCE]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testIndexInfoColumnOrder[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testIndexInfo[binary = FORCE]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testIndexInfo[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testInformationAboutArrayTypes[binary = FORCE]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testInformationAboutArrayTypes[binary = REGULAR]": "32552", + "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testMaterializedViewPrivileges[binary = FORCE]": "32552", + "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testMaterializedViewPrivileges[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testMultiColumnForeignKeys[binary = FORCE]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testMultiColumnForeignKeys[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testNoTablePrivileges[binary = FORCE]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testNoTablePrivileges[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testNotNullDomainColumn[binary = FORCE]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testNotNullDomainColumn[binary = REGULAR]": "32552", + "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testNumericPrecision[binary = FORCE]": "32552", + "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testNumericPrecision[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testPartialIndexInfo[binary = FORCE]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testPartialIndexInfo[binary = REGULAR]": "32552", + "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testPartionedTablesIndex[binary = FORCE]": "32552", + "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testPartionedTablesIndex[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testPartitionedTables[binary = FORCE]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testPartitionedTables[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testPrimaryKeys[binary = FORCE]": "32552", @@ -216,6 +257,8 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testTypeInfoSigned[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testTypes[binary = FORCE]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testTypes[binary = REGULAR]": "32552", + "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testUpperCaseMetaDataLabels[binary = FORCE]": "32552", + "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testUpperCaseMetaDataLabels[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testVersionColumns[binary = FORCE]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testVersionColumns[binary = REGULAR]": "32552", "org.postgresql.test.jdbc2.DatabaseMetaDataTest.testViewPrivileges[binary = FORCE]": "32552", @@ -250,6 +293,27 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc2.NotifyTest.testNotify": "41522", "org.postgresql.test.jdbc2.NotifyTest.testNotifyArgument": "41522", "org.postgresql.test.jdbc2.NumericTransferTest.receive100000[binary = REGULAR]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest.sendReceive100000[binary = REGULAR]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = FORCE, value = -1]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = FORCE, value = 0.1]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = FORCE, value = 0]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = FORCE, value = 1,000,000]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = FORCE, value = 1.1]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = FORCE, value = 10,000,000,000,000,000,000,000,000,000,000,000,000]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = FORCE, value = 1]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = FORCE, value = 20,000]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = FORCE, value = 40,000]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = FORCE, value = 9,990,000]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = REGULAR, value = -1]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = REGULAR, value = 0.1]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = REGULAR, value = 0]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = REGULAR, value = 1,000,000]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = REGULAR, value = 1.1]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = REGULAR, value = 10,000,000,000,000,000,000,000,000,000,000,000,000]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = REGULAR, value = 1]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = REGULAR, value = 20,000]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = REGULAR, value = 40,000]": "unknown", + "org.postgresql.test.jdbc2.NumericTransferTest2.sendReceiveValue[binary = REGULAR, value = 9,990,000]": "unknown", "org.postgresql.test.jdbc2.PGObjectGetTest.getAsPGobjectSubtype[binary = FORCE, sql = null::box, type = class org.postgresql.geometric.PGbox]": "21286", "org.postgresql.test.jdbc2.PGObjectGetTest.getAsPGobjectSubtype[binary = FORCE, sql = null::circle, type = class org.postgresql.geometric.PGcircle]": "21286", "org.postgresql.test.jdbc2.PGObjectGetTest.getAsPGobjectSubtype[binary = FORCE, sql = null::line, type = class org.postgresql.geometric.PGline]": "21286", @@ -340,6 +404,9 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc2.PreparedStatementTest.testTrailingSpaces[binary = REGULAR]": "unknown", "org.postgresql.test.jdbc2.PreparedStatementTest.testUnknownSetObject[binary = FORCE]": "41779", "org.postgresql.test.jdbc2.PreparedStatementTest.testUnknownSetObject[binary = REGULAR]": "41779", + "org.postgresql.test.jdbc2.RefCursorFetchTest.testRefCursorWithFetchSize": "unknown", + "org.postgresql.test.jdbc2.RefCursorFetchTest.testRefCursorWithFetchSizeNoTransaction": "unknown", + "org.postgresql.test.jdbc2.RefCursorFetchTest.testRefCursorWithOutFetchSize": "unknown", "org.postgresql.test.jdbc2.RefCursorTest.testEmptyResult[typeName = OTHER, cursorType = 1,111]": "17511", "org.postgresql.test.jdbc2.RefCursorTest.testEmptyResult[typeName = REF_CURSOR, cursorType = 2,012]": "17511", "org.postgresql.test.jdbc2.RefCursorTest.testMetaData[typeName = OTHER, cursorType = 1,111]": "17511", @@ -408,8 +475,10 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc2.ResultSetMetaDataTest.testUnexecutedStatement[databaseMetadataCacheFields = 0, databaseMetadataCacheFieldsMib = null]": "32565", "org.postgresql.test.jdbc2.ResultSetMetaDataTest.testUnexecutedStatement[databaseMetadataCacheFields = null, databaseMetadataCacheFieldsMib = 0]": "32565", "org.postgresql.test.jdbc2.ResultSetMetaDataTest.testUnexecutedStatement[databaseMetadataCacheFields = null, databaseMetadataCacheFieldsMib = null]": "32565", - "org.postgresql.test.jdbc2.ResultSetTest.testRowResultPositioning": "unknown", - "org.postgresql.test.jdbc2.ResultSetTest.testgetBadBoolean": "32552", + "org.postgresql.test.jdbc2.ResultSetTest.testRowResultPositioning[binary = FORCE]": "unknown", + "org.postgresql.test.jdbc2.ResultSetTest.testRowResultPositioning[binary = REGULAR]": "unknown", + "org.postgresql.test.jdbc2.ResultSetTest.testgetBadBoolean[binary = FORCE]": "unknown", + "org.postgresql.test.jdbc2.ResultSetTest.testgetBadBoolean[binary = REGULAR]": "unknown", "org.postgresql.test.jdbc2.SearchPathLookupTest.testSearchPathNormalLookup": "unknown", "org.postgresql.test.jdbc2.ServerCursorTest.testBinaryFetch": "41412", "org.postgresql.test.jdbc2.ServerErrorTest.testCheckConstraint": "27796", @@ -476,6 +545,7 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc2.TimezoneTest.testSetTime": "41776", "org.postgresql.test.jdbc2.TimezoneTest.testSetTimestamp": "41776", "org.postgresql.test.jdbc2.UpdateableResultTest.simpleAndUpdateableSameQuery": "unknown", + "org.postgresql.test.jdbc2.UpdateableResultTest.test2193": "unknown", "org.postgresql.test.jdbc2.UpdateableResultTest.testArray": "26925", "org.postgresql.test.jdbc2.UpdateableResultTest.testBadColumnIndexes": "unknown", "org.postgresql.test.jdbc2.UpdateableResultTest.testCancelRowUpdates": "unknown", @@ -483,10 +553,19 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc2.UpdateableResultTest.testInsertRowIllegalMethods": "unknown", "org.postgresql.test.jdbc2.UpdateableResultTest.testMultiColumnUpdate": "unknown", "org.postgresql.test.jdbc2.UpdateableResultTest.testMultiColumnUpdateWithoutAllColumns": "unknown", + "org.postgresql.test.jdbc2.UpdateableResultTest.testMultiColumnUpdateWithoutPrimaryKey": "unknown", + "org.postgresql.test.jdbc2.UpdateableResultTest.testNoUniqueNotUpdateable": "unknown", "org.postgresql.test.jdbc2.UpdateableResultTest.testOidUpdatable": "unknown", "org.postgresql.test.jdbc2.UpdateableResultTest.testPositioning": "unknown", + "org.postgresql.test.jdbc2.UpdateableResultTest.testPrimaryAndUniqueUpdateableByPrimary": "unknown", + "org.postgresql.test.jdbc2.UpdateableResultTest.testPrimaryAndUniqueUpdateableByUnique": "unknown", "org.postgresql.test.jdbc2.UpdateableResultTest.testReturnSerial": "unknown", + "org.postgresql.test.jdbc2.UpdateableResultTest.testUniqueWithNotNullableColumnUpdateable": "unknown", + "org.postgresql.test.jdbc2.UpdateableResultTest.testUniqueWithNullAndNotNullableColumnUpdateable": "unknown", + "org.postgresql.test.jdbc2.UpdateableResultTest.testUniqueWithNullableColumnNotUpdateable": "unknown", + "org.postgresql.test.jdbc2.UpdateableResultTest.testUniqueWithNullableColumnsNotUpdatable": "unknown", "org.postgresql.test.jdbc2.UpdateableResultTest.testUpdateBoolean": "unknown", + "org.postgresql.test.jdbc2.UpdateableResultTest.testUpdateDate": "unknown", "org.postgresql.test.jdbc2.UpdateableResultTest.testUpdateReadOnlyResultSet": "unknown", "org.postgresql.test.jdbc2.UpdateableResultTest.testUpdateSelectOnly": "unknown", "org.postgresql.test.jdbc2.UpdateableResultTest.testUpdateStreams": "unknown", @@ -543,7 +622,10 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc3.Jdbc3CallableStatementTest.testAllInOut": "17511", "org.postgresql.test.jdbc3.Jdbc3CallableStatementTest.testFunctionNoParametersWithParentheses": "17511", "org.postgresql.test.jdbc3.Jdbc3CallableStatementTest.testFunctionNoParametersWithoutParentheses": "17511", + "org.postgresql.test.jdbc3.Jdbc3CallableStatementTest.testGetBit1WithoutArg": "unknown", + "org.postgresql.test.jdbc3.Jdbc3CallableStatementTest.testGetBit2WithoutArg": "unknown", "org.postgresql.test.jdbc3.Jdbc3CallableStatementTest.testGetBoolean01": "17511", + "org.postgresql.test.jdbc3.Jdbc3CallableStatementTest.testGetBooleanWithoutArg": "unknown", "org.postgresql.test.jdbc3.Jdbc3CallableStatementTest.testGetByte01": "17511", "org.postgresql.test.jdbc3.Jdbc3CallableStatementTest.testGetBytes01": "17511", "org.postgresql.test.jdbc3.Jdbc3CallableStatementTest.testGetBytes02": "17511", @@ -591,6 +673,16 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc3.StringTypeParameterTest.testVarcharAsEnum[stringType = null]": "27793", "org.postgresql.test.jdbc3.StringTypeParameterTest.testVarcharAsEnum[stringType = unspecified]": "27793", "org.postgresql.test.jdbc3.StringTypeParameterTest.testVarcharAsEnum[stringType = varchar]": "27793", + "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = ID, quoteReturning = false]": "unknown", + "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = ID, quoteReturning = true]": "unknown", + "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = Id, quoteReturning = false]": "unknown", + "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = Id, quoteReturning = true]": "unknown", + "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = NO, quoteReturning = false]": "unknown", + "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = NO, quoteReturning = true]": "unknown", + "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = QUOTED, quoteReturning = false]": "unknown", + "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = QUOTED, quoteReturning = true]": "unknown", + "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = id, quoteReturning = false]": "unknown", + "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = id, quoteReturning = true]": "unknown", "org.postgresql.test.jdbc3.TypesTest.testCallableBoolean": "17511", "org.postgresql.test.jdbc3.TypesTest.testPreparedBoolean": "17511", "org.postgresql.test.jdbc3.TypesTest.testPreparedByte": "17511", @@ -637,6 +729,8 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc4.ArrayTest.testEvilCasing[binary = REGULAR]": "32552", "org.postgresql.test.jdbc4.ArrayTest.testGetArrayOfComposites[binary = FORCE]": "32552", "org.postgresql.test.jdbc4.ArrayTest.testGetArrayOfComposites[binary = REGULAR]": "32552", + "org.postgresql.test.jdbc4.ArrayTest.testJsonbArray[binary = FORCE]": "unknown", + "org.postgresql.test.jdbc4.ArrayTest.testJsonbArray[binary = REGULAR]": "unknown", "org.postgresql.test.jdbc4.ArrayTest.testSetObjectFromJavaArray[binary = FORCE]": "32552", "org.postgresql.test.jdbc4.ArrayTest.testSetObjectFromJavaArray[binary = REGULAR]": "32552", "org.postgresql.test.jdbc4.ArrayTest.testToString[binary = FORCE]": "32552", @@ -659,8 +753,6 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc4.DatabaseMetaDataTest.testGetSchemas": "17511", "org.postgresql.test.jdbc4.DatabaseMetaDataTest.testSortedDataTypes": "17511", "org.postgresql.test.jdbc4.IsValidTest.testIsValidRemoteClose": "35897", - "org.postgresql.test.jdbc4.JsonbTest.jsonArray[binary = FORCE]": "23468", - "org.postgresql.test.jdbc4.JsonbTest.jsonArray[binary = REGULAR]": "23468", "org.postgresql.test.jdbc4.PGCopyInputStreamTest.testCopyAPI": "41608", "org.postgresql.test.jdbc4.PGCopyInputStreamTest.testMixedAPI": "41608", "org.postgresql.test.jdbc4.PGCopyInputStreamTest.testReadBytesCorrectlyHandlesEof": "41608", @@ -716,6 +808,12 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc4.jdbc41.SchemaTest.testSearchPathPreparedStatementAutoCommitFalse": "unknown", "org.postgresql.test.jdbc4.jdbc41.SchemaTest.testSearchPathPreparedStatementAutoCommitTrue": "unknown", "org.postgresql.test.jdbc42.DatabaseMetaDataTest.testGetColumnsForNullScale": "unknown", + "org.postgresql.test.jdbc42.DatabaseMetaDataTest.testGetCorrectSQLTypeForOffPathTypes": "unknown", + "org.postgresql.test.jdbc42.DatabaseMetaDataTest.testGetCorrectSQLTypeForShadowedTypes": "unknown", + "org.postgresql.test.jdbc42.DatabaseMetaDataTest.testLargeOidIsHandledCorrectly": "unknown", + "org.postgresql.test.jdbc42.DatabaseMetaDataTest.testOidConversion": "unknown", + "org.postgresql.test.jdbc42.DatabaseMetaDataTest.testOidConversionThrowsForNegativeLongValues": "unknown", + "org.postgresql.test.jdbc42.DatabaseMetaDataTest.testOidConversionThrowsForTooLargeLongValues": "unknown", "org.postgresql.test.jdbc42.GetObject310InfinityTests.test[binary = FORCE, expr = -infinity, pgType = timestamp with time zone, klass = class java.time.OffsetDateTime]": "41786", "org.postgresql.test.jdbc42.GetObject310InfinityTests.test[binary = FORCE, expr = -infinity, pgType = timestamp, klass = class java.time.LocalDateTime]": "41786", "org.postgresql.test.jdbc42.GetObject310InfinityTests.test[binary = FORCE, expr = -infinity, pgType = timestamp, klass = class java.time.OffsetDateTime]": "41786", @@ -730,11 +828,15 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc42.GetObject310InfinityTests.test[binary = REGULAR, expr = infinity, pgType = timestamp, klass = class java.time.OffsetDateTime]": "41786", "org.postgresql.test.jdbc42.Jdbc42CallableStatementTest.testGetResultSetWithoutArg": "17511", "org.postgresql.test.jdbc42.Jdbc42CallableStatementTest.testGetResultSetWithoutArgUnsupportedConversion": "17511", + "org.postgresql.test.jdbc42.Jdbc42CallableStatementTest.testRegisterInoutParameter": "unknown", "org.postgresql.test.jdbc42.Jdbc42CallableStatementTest.testRegisterOutParameter": "17511", "org.postgresql.test.jdbc42.SetObject310InfinityTests.testTimestamp[binary = FORCE]": "41564", "org.postgresql.test.jdbc42.SetObject310InfinityTests.testTimestamp[binary = REGULAR]": "41564", "org.postgresql.test.jdbc42.SetObject310InfinityTests.testTimestamptz[binary = FORCE]": "41564", "org.postgresql.test.jdbc42.SetObject310InfinityTests.testTimestamptz[binary = REGULAR]": "41564", + "org.postgresql.test.plugin.AuthenticationPluginTest.testAuthPluginMD5": "unknown", + "org.postgresql.test.plugin.AuthenticationPluginTest.testAuthPluginSASL": "unknown", + "org.postgresql.test.util.ObjectFactoryTest.testInvalidAuthenticationPlugin()": "unknown", "org.postgresql.test.xa.XADataSourceTest.testAutoCommit": "22329", "org.postgresql.test.xa.XADataSourceTest.testCloseBeforeCommit": "22329", "org.postgresql.test.xa.XADataSourceTest.testCommitByDifferentConnection": "22329", diff --git a/pkg/cmd/roachtest/tests/pgx.go b/pkg/cmd/roachtest/tests/pgx.go index 6c5b63266ed3..9f81b2ac2c11 100644 --- a/pkg/cmd/roachtest/tests/pgx.go +++ b/pkg/cmd/roachtest/tests/pgx.go @@ -24,7 +24,7 @@ import ( ) var pgxReleaseTagRegex = regexp.MustCompile(`^v(?P\d+)\.(?P\d+)\.(?P\d+)$`) -var supportedPGXTag = "v4.11.0" +var supportedPGXTag = "v4.15.0" // This test runs pgx's full test suite against a single cockroach node. diff --git a/pkg/cmd/roachtest/tests/sqlalchemy.go b/pkg/cmd/roachtest/tests/sqlalchemy.go index 9e05ff517bd6..4838f2e8d309 100644 --- a/pkg/cmd/roachtest/tests/sqlalchemy.go +++ b/pkg/cmd/roachtest/tests/sqlalchemy.go @@ -31,7 +31,7 @@ var sqlAlchemyReleaseTagRegex = regexp.MustCompile(`^rel_(?P\d+)_(?P\d+)\.(?P\d+)\.(?P\d+)$`) -var supportedTypeORMRelease = "0.2.32" +var supportedTypeORMRelease = "0.3.5" // This test runs TypeORM's full test suite against a single cockroach node. func registerTypeORM(r registry.Registry) { From 0ea82832dcb0aee8eece3b968ce039f49ccbd4bb Mon Sep 17 00:00:00 2001 From: Ricky Stewart Date: Thu, 31 Mar 2022 13:11:57 -0500 Subject: [PATCH 4/6] dev: add support for `dev generate cgo` The contents of these files here is basically cargo-culted from the `Makefile`. I have verified that I can get a build working via the following steps: ./dev generate go cgo ./dev go -- build ./pkg/cmd/cockroach-short We don't exactly mirror the previous contents of the `zcgo_flags.go` files that `make` would create. One difference is that we don't populate the `zcgo_flags` files in `go-libedit` to configure how the C sources are built and linked, so we get the default behavior, which is fine, but means the `go build`-built binary and the Bazel-built binary will be using a different compiled archive (maybe compiled with different flags/ a different configuration/etc.) for the `libedit` sources. With `make`, we address this by putting a `zcgo_flags_extra.go` file in the sources for `go-libedit` right in `vendor`. Post-Bazel we have no reason for `vendor` and have no plans to keep it in the long-term so this is not really suitable. I'm punting on this for now -- the default behavior will probably be "good enough" for most people. Closes #77170. Release note: None --- Makefile | 3 ++ dev | 2 +- pkg/cmd/dev/generate.go | 74 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 44dd7d93c7a9..c3113cf9833f 100644 --- a/Makefile +++ b/Makefile @@ -549,6 +549,9 @@ native-tag := $(subst -,_,$(TARGET_TRIPLE))$(if $(use-stdmalloc),_stdmalloc) # encounters a given native tag or when the build signature changes (see # build/defs.mk.sig). These tags are unset when building with the Go toolchain # directly, so these files are only compiled when building with Make. +# +# NB: If you update the zcgo_flags.go generation below, make sure to make the +# corresponding changes to `dev generate cgo`. CGO_PKGS := \ pkg/cli \ pkg/cli/clisqlshell \ diff --git a/dev b/dev index 26b02ca7c4c0..5dc93f1d92f5 100755 --- a/dev +++ b/dev @@ -3,7 +3,7 @@ set -euo pipefail # Bump this counter to force rebuilding `dev` on all machines. -DEV_VERSION=27 +DEV_VERSION=28 THIS_DIR=$(cd "$(dirname "$0")" && pwd) BINARY_DIR=$THIS_DIR/bin/dev-versions diff --git a/pkg/cmd/dev/generate.go b/pkg/cmd/dev/generate.go index ec3060a26365..0c775c3ef21f 100644 --- a/pkg/cmd/dev/generate.go +++ b/pkg/cmd/dev/generate.go @@ -15,6 +15,8 @@ import ( "fmt" "os" "path/filepath" + "runtime" + "text/template" "github.com/spf13/cobra" ) @@ -29,13 +31,21 @@ func makeGenerateCmd(runE func(cmd *cobra.Command, args []string) error) *cobra. Use: "generate [target..]", Aliases: []string{"gen"}, Short: `Generate the specified files`, - Long: `Generate the specified files.`, + Long: `Generate the specified files. +` + "`dev generate bazel`" + ` updates BUILD.bazel files and other Bazel files like DEPS.bzl. +Use the --mirror option if vendoring a new dependency that needs to be mirrored. +` + "`dev generate go`" + ` populates the workspace with generated code. +` + "`dev generate docs`" + ` updates generated documentation. +` + "`dev generate go+docs`" + ` does the same as ` + "`dev generate go docs`" + `, but slightly faster. +` + "`dev generate cgo`" + ` populates the workspace with a few zcgo_flags.go files that can prepare non-Bazel build systems to link in our C dependencies. +` + "`dev generate protobuf`" + ` generates a subset of the code that ` + "`dev generate go`" + ` does, specifically the .pb.go files.`, Example: ` dev generate dev generate bazel dev generate docs dev generate go dev generate protobuf + dev generate cgo dev generate go+docs `, Args: cobra.MinimumNArgs(0), @@ -52,6 +62,7 @@ func makeGenerateCmd(runE func(cmd *cobra.Command, args []string) error) *cobra. func (d *dev) generate(cmd *cobra.Command, targets []string) error { var generatorTargetMapping = map[string]func(cmd *cobra.Command) error{ "bazel": d.generateBazel, + "cgo": d.generateCgo, "docs": d.generateDocs, "go": d.generateGo, "protobuf": d.generateProtobuf, @@ -149,3 +160,64 @@ func (d *dev) generateRedactSafe(ctx context.Context) error { filepath.Join(workspace, "docs", "generated", "redact_safe.md"), string(output), ) } + +func (d *dev) generateCgo(cmd *cobra.Command) error { + ctx := cmd.Context() + args := []string{"build", "//c-deps:libjemalloc", "//c-deps:libproj", "//c-deps:libgeos"} + if runtime.GOOS == "linux" { + args = append(args, "//c-deps:libkrb5") + } + logCommand("bazel", args...) + if err := d.exec.CommandContextInheritingStdStreams(ctx, "bazel", args...); err != nil { + return err + } + bazelBin, err := d.getBazelBin(ctx) + if err != nil { + return err + } + workspace, err := d.getWorkspace(ctx) + if err != nil { + return err + } + const cgoTmpl = `// GENERATED FILE DO NOT EDIT + +package {{ .Package }} + +// #cgo CPPFLAGS: {{ .CPPFlags }} +// #cgo LDFLAGS: {{ .LDFlags }} +import "C" +` + + tpl := template.Must(template.New("source").Parse(cgoTmpl)) + cppFlags := fmt.Sprintf("-I%s", filepath.Join(bazelBin, "c-deps/libjemalloc/include")) + ldFlags := fmt.Sprintf("-L%s -L%s", filepath.Join(bazelBin, "c-deps/libjemalloc/lib"), filepath.Join(bazelBin, "c-deps/libproj/lib")) + if runtime.GOOS == "linux" { + cppFlags += fmt.Sprintf(" -I%s", filepath.Join(bazelBin, "c-deps/libkrb5/include")) + ldFlags += fmt.Sprintf(" -L%s", filepath.Join(bazelBin, "c-deps/libkrb5/lib")) + } + + cgoPkgs := []string{ + "pkg/cli", + "pkg/cli/clisqlshell", + "pkg/server/status", + "pkg/ccl/gssapiccl", + "pkg/geo/geoproj", + } + + for _, cgoPkg := range cgoPkgs { + out, err := os.Create(filepath.Join(workspace, cgoPkg, "zcgo_flags.go")) + if err != nil { + return err + } + err = tpl.Execute(out, struct { + Package string + CPPFlags string + LDFlags string + }{Package: filepath.Base(cgoPkg), CPPFlags: cppFlags, LDFlags: ldFlags}) + if err != nil { + return err + } + } + + return nil +} From 6147b3179d61215eccb83c8bb07a333804eb3a7e Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Mon, 4 Apr 2022 13:58:31 -0400 Subject: [PATCH 5/6] pgwire: use InvalidPassword error code when appropriate Release note (sql change): Use the InvalidPassword error code when authenticating if the password is invalid or the user does not exist. --- pkg/security/auth.go | 27 ++++++++++++++++++- pkg/sql/pgwire/auth.go | 12 +++++++-- pkg/sql/pgwire/testdata/auth/conn_log | 10 +++---- pkg/sql/pgwire/testdata/auth/empty_hba | 14 +++++----- .../testdata/auth/hba_default_equivalence | 12 ++++----- pkg/sql/pgwire/testdata/auth/identity_map | 2 +- pkg/sql/pgwire/testdata/auth/insecure | 2 +- pkg/sql/pgwire/testdata/auth/password_change | 16 +++++------ pkg/sql/pgwire/testdata/auth/scram | 8 +++--- pkg/sql/pgwire/testdata/auth/secure_non_tls | 6 ++--- pkg/sql/pgwire/testdata/auth/special_cases | 6 ++--- pkg/sql/pgwire/testdata/auth/trust_reject | 2 +- 12 files changed, 75 insertions(+), 42 deletions(-) diff --git a/pkg/security/auth.go b/pkg/security/auth.go index 592472377d93..0e38efdb3e7a 100644 --- a/pkg/security/auth.go +++ b/pkg/security/auth.go @@ -14,6 +14,7 @@ import ( "context" "crypto/tls" "crypto/x509" + "fmt" "strings" "github.com/cockroachdb/cockroach/pkg/util/syncutil" @@ -193,5 +194,29 @@ func UserAuthPasswordHook( // failed password authentication for a user. It should be used when // the password is incorrect or the user does not exist. func NewErrPasswordUserAuthFailed(username SQLUsername) error { - return errors.Newf("password authentication failed for user %s", username) + return &PasswordUserAuthError{errors.Newf("password authentication failed for user %s", username)} +} + +// PasswordUserAuthError indicates that an error was encountered +// during the initial set-up of a SQL connection. +type PasswordUserAuthError struct { + err error +} + +// Error implements the error interface. +func (i *PasswordUserAuthError) Error() string { return i.err.Error() } + +// Cause implements causer for compatibility with pkg/errors. +// NB: this is obsolete. Use Unwrap() instead. +func (i *PasswordUserAuthError) Cause() error { return i.err } + +// Unwrap implements errors.Wrapper. +func (i *PasswordUserAuthError) Unwrap() error { return i.err } + +// Format implements fmt.Formatter. +func (i *PasswordUserAuthError) Format(s fmt.State, verb rune) { errors.FormatError(i, s, verb) } + +// FormatError implements errors.Formatter. +func (i *PasswordUserAuthError) FormatError(p errors.Printer) error { + return i.err } diff --git a/pkg/sql/pgwire/auth.go b/pkg/sql/pgwire/auth.go index 32401321a715..c228e275f62e 100644 --- a/pkg/sql/pgwire/auth.go +++ b/pkg/sql/pgwire/auth.go @@ -157,7 +157,10 @@ func (c *conn) handleAuthentication( if !exists { ac.LogAuthFailed(ctx, eventpb.AuthFailReason_USER_NOT_FOUND, nil) - return connClose, c.sendError(ctx, execCfg, pgerror.WithCandidateCode(security.NewErrPasswordUserAuthFailed(dbUser), pgcode.InvalidAuthorizationSpecification)) + // If the user does not exist, we show the same error used for invalid + // passwords, to make it harder for an attacker to determine if a user + // exists. + return connClose, c.sendError(ctx, execCfg, pgerror.WithCandidateCode(security.NewErrPasswordUserAuthFailed(dbUser), pgcode.InvalidPassword)) } if !canLoginSQL { @@ -170,7 +173,12 @@ func (c *conn) handleAuthentication( // implementation to complete the authentication. if err := behaviors.Authenticate(ctx, systemIdentity, true /* public */, pwRetrievalFn); err != nil { ac.LogAuthFailed(ctx, eventpb.AuthFailReason_CREDENTIALS_INVALID, err) - return connClose, c.sendError(ctx, execCfg, pgerror.WithCandidateCode(err, pgcode.InvalidAuthorizationSpecification)) + if pErr := (*security.PasswordUserAuthError)(nil); errors.As(err, &pErr) { + err = pgerror.WithCandidateCode(err, pgcode.InvalidPassword) + } else { + err = pgerror.WithCandidateCode(err, pgcode.InvalidAuthorizationSpecification) + } + return connClose, c.sendError(ctx, execCfg, err) } // Add all the defaults to this session's defaults. If there is an diff --git a/pkg/sql/pgwire/testdata/auth/conn_log b/pkg/sql/pgwire/testdata/auth/conn_log index 118f0e3123cf..f4b8318a1222 100644 --- a/pkg/sql/pgwire/testdata/auth/conn_log +++ b/pkg/sql/pgwire/testdata/auth/conn_log @@ -78,7 +78,7 @@ authlog 7 connect user=root password=badpass sslmode=require sslcert= sslkey= ---- -ERROR: password authentication failed for user root (SQLSTATE 28000) +ERROR: password authentication failed for user root (SQLSTATE 28P01) authlog 8 .*client_connection_end @@ -131,7 +131,7 @@ authlog 7 connect user=userpw password=badpass ---- -ERROR: password authentication failed for user userpw (SQLSTATE 28000) +ERROR: password authentication failed for user userpw (SQLSTATE 28P01) authlog 8 .*client_connection_end @@ -151,7 +151,7 @@ subtest conn_tls/no_password connect user=usernopw ---- -ERROR: password authentication failed for user usernopw (SQLSTATE 28000) +ERROR: password authentication failed for user usernopw (SQLSTATE 28P01) authlog 8 .*client_connection_end @@ -190,7 +190,7 @@ authlog 5 connect_unix user=root password=badpass ---- -ERROR: password authentication failed for user root (SQLSTATE 28000) +ERROR: password authentication failed for user root (SQLSTATE 28P01) authlog 5 .*client_connection_end @@ -238,7 +238,7 @@ authlog 5 connect_unix user=userpw password=badpass ---- -ERROR: password authentication failed for user userpw (SQLSTATE 28000) +ERROR: password authentication failed for user userpw (SQLSTATE 28P01) authlog 5 .*client_connection_end diff --git a/pkg/sql/pgwire/testdata/auth/empty_hba b/pkg/sql/pgwire/testdata/auth/empty_hba index ff20fd117674..4a685fe7fc40 100644 --- a/pkg/sql/pgwire/testdata/auth/empty_hba +++ b/pkg/sql/pgwire/testdata/auth/empty_hba @@ -42,13 +42,13 @@ ok defaultdb # because it does not have a password. connect_unix user=root ---- -ERROR: password authentication failed for user root (SQLSTATE 28000) +ERROR: password authentication failed for user root (SQLSTATE 28P01) # When no client cert is presented, the server would otherwise require # password auth. However, root does not have a password. connect user=root password=foo sslmode=verify-ca sslcert= ---- -ERROR: password authentication failed for user root (SQLSTATE 28000) +ERROR: password authentication failed for user root (SQLSTATE 28P01) subtest end root @@ -64,7 +64,7 @@ ok defaultdb # present a cert so auth fails. connect_unix user=testuser ---- -ERROR: password authentication failed for user testuser (SQLSTATE 28000) +ERROR: password authentication failed for user testuser (SQLSTATE 28P01) # Make the user need a password. sql @@ -80,7 +80,7 @@ ok defaultdb # If we don't present the client certificate, the password is required. connect user=testuser password=invalid sslmode=verify-ca sslcert= ---- -ERROR: password authentication failed for user testuser (SQLSTATE 28000) +ERROR: password authentication failed for user testuser (SQLSTATE 28P01) connect user=testuser password=pass sslmode=verify-ca sslcert= ---- @@ -110,13 +110,13 @@ ok # and password auth becomes required. connect user=testuser_nocert ---- -ERROR: password authentication failed for user testuser_nocert (SQLSTATE 28000) +ERROR: password authentication failed for user testuser_nocert (SQLSTATE 28P01) # Even though the user has no password, trying to present the # empty password fails. The user simply cannot log in. connect user=testuser_nocert password= ---- -ERROR: password authentication failed for user testuser_nocert (SQLSTATE 28000) +ERROR: password authentication failed for user testuser_nocert (SQLSTATE 28P01) sql DROP USER testuser_nocert @@ -147,7 +147,7 @@ ok defaultdb # connect user=(Ὀδυσσεύς) password= ---- -ERROR: password authentication failed for user ὀδυσσεύς (SQLSTATE 28000) +ERROR: password authentication failed for user ὀδυσσεύς (SQLSTATE 28P01) # The unicode password succeeds, with user normalization. connect user=(Ὀδυσσεύς) password=(蟑♫螂) diff --git a/pkg/sql/pgwire/testdata/auth/hba_default_equivalence b/pkg/sql/pgwire/testdata/auth/hba_default_equivalence index 2a755905c3e9..16a2f8373340 100644 --- a/pkg/sql/pgwire/testdata/auth/hba_default_equivalence +++ b/pkg/sql/pgwire/testdata/auth/hba_default_equivalence @@ -37,13 +37,13 @@ ok defaultdb # they do not have a password by default. connect_unix user=root ---- -ERROR: password authentication failed for user root (SQLSTATE 28000) +ERROR: password authentication failed for user root (SQLSTATE 28P01) # When no client cert is presented, the server would otherwise require # password auth. However, root does not have a password. connect user=root password=foo sslmode=verify-ca sslcert= ---- -ERROR: password authentication failed for user root (SQLSTATE 28000) +ERROR: password authentication failed for user root (SQLSTATE 28P01) subtest end root @@ -58,7 +58,7 @@ ok defaultdb # present a cert so auth fails. connect_unix user=testuser ---- -ERROR: password authentication failed for user testuser (SQLSTATE 28000) +ERROR: password authentication failed for user testuser (SQLSTATE 28P01) # Make the user need a password. sql @@ -78,7 +78,7 @@ ok defaultdb # If we don't present the client certificate, the password is required. connect user=testuser password=invalid sslmode=verify-ca sslcert= ---- -ERROR: password authentication failed for user testuser (SQLSTATE 28000) +ERROR: password authentication failed for user testuser (SQLSTATE 28P01) connect user=testuser password=pass sslmode=verify-ca sslcert= ---- @@ -104,13 +104,13 @@ ok # and password auth becomes required. connect user=testuser_nocert ---- -ERROR: password authentication failed for user testuser_nocert (SQLSTATE 28000) +ERROR: password authentication failed for user testuser_nocert (SQLSTATE 28P01) # Even though the user has no password, trying to present the # empty password fails. The user simply cannot log in. connect user=testuser_nocert password= ---- -ERROR: password authentication failed for user testuser_nocert (SQLSTATE 28000) +ERROR: password authentication failed for user testuser_nocert (SQLSTATE 28P01) sql DROP USER testuser_nocert diff --git a/pkg/sql/pgwire/testdata/auth/identity_map b/pkg/sql/pgwire/testdata/auth/identity_map index 3fc42da699aa..45be8b7147bd 100644 --- a/pkg/sql/pgwire/testdata/auth/identity_map +++ b/pkg/sql/pgwire/testdata/auth/identity_map @@ -86,7 +86,7 @@ subtest password_evaluated_before_remapping connect user=carl@cockroachlabs.com database=mydb password=doggo ---- -ERROR: password authentication failed for user carl@cockroachlabs.com (SQLSTATE 28000) +ERROR: password authentication failed for user carl@cockroachlabs.com (SQLSTATE 28P01) # Since we're evaluating before remapping, the password extraction will fail # for user carl@cockroachlabs.com and we don't even get information about diff --git a/pkg/sql/pgwire/testdata/auth/insecure b/pkg/sql/pgwire/testdata/auth/insecure index 0e9d2855a188..301bd4439f17 100644 --- a/pkg/sql/pgwire/testdata/auth/insecure +++ b/pkg/sql/pgwire/testdata/auth/insecure @@ -52,6 +52,6 @@ subtest user_does_not_exist connect user=nonexistent sslmode=disable ---- -ERROR: password authentication failed for user nonexistent (SQLSTATE 28000) +ERROR: password authentication failed for user nonexistent (SQLSTATE 28P01) subtest end diff --git a/pkg/sql/pgwire/testdata/auth/password_change b/pkg/sql/pgwire/testdata/auth/password_change index 34ad5dc6070b..d8bd8f55d968 100644 --- a/pkg/sql/pgwire/testdata/auth/password_change +++ b/pkg/sql/pgwire/testdata/auth/password_change @@ -28,7 +28,7 @@ ok # sanity check: without a password, auth is denied. connect user=userpw ---- -ERROR: password authentication failed for user userpw (SQLSTATE 28000) +ERROR: password authentication failed for user userpw (SQLSTATE 28P01) # with the proper pass, auth succeeds. connect user=userpw password=pass @@ -45,7 +45,7 @@ ok connect user=userpw password=pass ---- -ERROR: password authentication failed for user userpw (SQLSTATE 28000) +ERROR: password authentication failed for user userpw (SQLSTATE 28P01) connect user=userpw password=pass2 ---- @@ -74,7 +74,7 @@ ok # sanity check: without a password, auth is denied. connect user=userpw ---- -ERROR: password authentication failed for user userpw (SQLSTATE 28000) +ERROR: password authentication failed for user userpw (SQLSTATE 28P01) # with the proper pass, auth succeeds. connect user=userpw password=pass @@ -91,7 +91,7 @@ ok connect user=userpw password=pass ---- -ERROR: password authentication failed for user userpw (SQLSTATE 28000) +ERROR: password authentication failed for user userpw (SQLSTATE 28P01) connect user=userpw password=pass2 ---- @@ -111,11 +111,11 @@ ok connect user=userpw password=pass2 ---- -ERROR: password authentication failed for user userpw (SQLSTATE 28000) +ERROR: password authentication failed for user userpw (SQLSTATE 28P01) connect user=userpw ---- -ERROR: password authentication failed for user userpw (SQLSTATE 28000) +ERROR: password authentication failed for user userpw (SQLSTATE 28P01) subtest end @@ -211,11 +211,11 @@ subtest root_pw # By default root cannot log in with a password. connect user=root sslmode=require sslcert= sslkey= ---- -ERROR: password authentication failed for user root (SQLSTATE 28000) +ERROR: password authentication failed for user root (SQLSTATE 28P01) connect_unix user=root ---- -ERROR: password authentication failed for user root (SQLSTATE 28000) +ERROR: password authentication failed for user root (SQLSTATE 28P01) # However if we give them a password, they can log in with password. diff --git a/pkg/sql/pgwire/testdata/auth/scram b/pkg/sql/pgwire/testdata/auth/scram index 462cbd467124..93e648dc5711 100644 --- a/pkg/sql/pgwire/testdata/auth/scram +++ b/pkg/sql/pgwire/testdata/auth/scram @@ -60,7 +60,7 @@ host all abc2 all password # Expect authn error. connect user=abc password=mistake ---- -ERROR: password authentication failed for user abc (SQLSTATE 28000) +ERROR: password authentication failed for user abc (SQLSTATE 28P01) authlog 5 .*client_connection_end @@ -125,7 +125,7 @@ subtest only_scram/conn_scram # For now (testing), foo does not have SCRAM credentials. connect user=foo password=abc ---- -ERROR: password authentication failed for user foo (SQLSTATE 28000) +ERROR: password authentication failed for user foo (SQLSTATE 28P01) authlog 7 .*client_connection_end @@ -142,7 +142,7 @@ authlog 7 # Expect authn error. connect user=abc password=mistake ---- -ERROR: password authentication failed for user abc (SQLSTATE 28000) +ERROR: password authentication failed for user abc (SQLSTATE 28P01) authlog 6 .*client_connection_end @@ -215,7 +215,7 @@ subtest scram_cert/scram connect user=foo password=abc ---- -ERROR: password authentication failed for user foo (SQLSTATE 28000) +ERROR: password authentication failed for user foo (SQLSTATE 28P01) connect user=abc password=abc diff --git a/pkg/sql/pgwire/testdata/auth/secure_non_tls b/pkg/sql/pgwire/testdata/auth/secure_non_tls index dae0b0f958d2..b9b57b90f159 100644 --- a/pkg/sql/pgwire/testdata/auth/secure_non_tls +++ b/pkg/sql/pgwire/testdata/auth/secure_non_tls @@ -20,11 +20,11 @@ accept_sql_without_tls connect user=root sslmode=disable ---- -ERROR: password authentication failed for user root (SQLSTATE 28000) +ERROR: password authentication failed for user root (SQLSTATE 28P01) connect user=testuser sslmode=disable ---- -ERROR: password authentication failed for user testuser (SQLSTATE 28000) +ERROR: password authentication failed for user testuser (SQLSTATE 28P01) # set the password for testuser. sql @@ -42,7 +42,7 @@ ok defaultdb connect password=wrongpass user=testuser sslmode=disable ---- -ERROR: password authentication failed for user testuser (SQLSTATE 28000) +ERROR: password authentication failed for user testuser (SQLSTATE 28P01) # Now disable all non-TLS conns via HBA. set_hba diff --git a/pkg/sql/pgwire/testdata/auth/special_cases b/pkg/sql/pgwire/testdata/auth/special_cases index 96852c041b2d..6d726f9ef302 100644 --- a/pkg/sql/pgwire/testdata/auth/special_cases +++ b/pkg/sql/pgwire/testdata/auth/special_cases @@ -29,7 +29,7 @@ host all root 0.0.0.0/0 password connect user=root password=abc sslmode=verify-ca sslcert= ---- -ERROR: password authentication failed for user root (SQLSTATE 28000) +ERROR: password authentication failed for user root (SQLSTATE 28P01) subtest end root_user_cannot_use_password @@ -82,7 +82,7 @@ host all testuser 0.0.0.0/0 password connect user=testuser ---- -ERROR: password authentication failed for user testuser (SQLSTATE 28000) +ERROR: password authentication failed for user testuser (SQLSTATE 28P01) subtest end user_has_both_cert_and_passwd/only_password_implies_reject_cert @@ -121,6 +121,6 @@ host all nopassword 0.0.0.0/0 password connect user=nopassword ---- -ERROR: password authentication failed for user nopassword (SQLSTATE 28000) +ERROR: password authentication failed for user nopassword (SQLSTATE 28P01) subtest end user_has_null_hashed_password_column diff --git a/pkg/sql/pgwire/testdata/auth/trust_reject b/pkg/sql/pgwire/testdata/auth/trust_reject index 2b1de62f080d..c8fc47372066 100644 --- a/pkg/sql/pgwire/testdata/auth/trust_reject +++ b/pkg/sql/pgwire/testdata/auth/trust_reject @@ -76,7 +76,7 @@ ok connect user=nocert sslcert= sslmode=require ---- -ERROR: password authentication failed for user nocert (SQLSTATE 28000) +ERROR: password authentication failed for user nocert (SQLSTATE 28P01) subtest end From fc0c874e28cb9d849bf320595d6c4f2eee9d50df Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Sun, 3 Apr 2022 22:18:53 -0400 Subject: [PATCH 6/6] roachtest: use secure mode for pgjdbc test This lets us test SCRAM functionality. Additionally, update the config so more tests pass. Release note: None --- pkg/cmd/roachtest/tests/pgjdbc.go | 29 ++++++++++++++--- pkg/cmd/roachtest/tests/pgjdbc_blocklist.go | 36 --------------------- pkg/sql/set_var.go | 5 ++- pkg/sql/vars.go | 7 ++++ 4 files changed, 35 insertions(+), 42 deletions(-) diff --git a/pkg/cmd/roachtest/tests/pgjdbc.go b/pkg/cmd/roachtest/tests/pgjdbc.go index be0c283fbfbc..e621c8fc8e27 100644 --- a/pkg/cmd/roachtest/tests/pgjdbc.go +++ b/pkg/cmd/roachtest/tests/pgjdbc.go @@ -39,7 +39,7 @@ func registerPgjdbc(r registry.Registry) { node := c.Node(1) t.Status("setting up cockroach") c.Put(ctx, t.Cockroach(), "./cockroach", c.All()) - c.Start(ctx, t.L(), option.DefaultStartOpts(), install.MakeClusterSettings(), c.All()) + c.Start(ctx, t.L(), option.DefaultStartOpts(), install.MakeClusterSettings(install.SecureOption(true)), c.All()) version, err := fetchCockroachVersion(ctx, t.L(), c, node[0]) if err != nil { @@ -50,6 +50,25 @@ func registerPgjdbc(r registry.Registry) { t.Fatal(err) } + t.Status("create admin user for tests") + db, err := c.ConnE(ctx, t.L(), node[0]) + if err != nil { + t.Fatal(err) + } + defer db.Close() + stmts := []string{ + "CREATE USER test_admin WITH PASSWORD 'testpw'", + "GRANT admin TO test_admin", + "ALTER ROLE ALL SET serial_normalization = 'sql_sequence_cached'", + "ALTER ROLE ALL SET statement_timeout = '60s'", + } + for _, stmt := range stmts { + _, err = db.ExecContext(ctx, stmt) + if err != nil { + t.Fatal(err) + } + } + t.Status("cloning pgjdbc and installing prerequisites") // Report the latest tag, but do not use it. The newest versions produces output that breaks our xml parser, // and we want to pin to the working version for now. @@ -210,10 +229,10 @@ secondaryPort=5433 secondaryServer2=localhost secondaryServerPort2=5434 database=defaultdb -username=root -password= -privilegedUser=root -privilegedPassword= +username=test_admin +password=testpw +privilegedUser=test_admin +privilegedPassword=testpw sspiusername=testsspi preparethreshold=5 loggerLevel=DEBUG diff --git a/pkg/cmd/roachtest/tests/pgjdbc_blocklist.go b/pkg/cmd/roachtest/tests/pgjdbc_blocklist.go index 2f2ac6a4617b..831bab33587d 100644 --- a/pkg/cmd/roachtest/tests/pgjdbc_blocklist.go +++ b/pkg/cmd/roachtest/tests/pgjdbc_blocklist.go @@ -45,8 +45,6 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.jdbc.BitFieldTest.TestGetObjectForBitFields": "unknown", "org.postgresql.jdbc.BitFieldTest.TestSetBitParameter": "unknown", "org.postgresql.jdbc.LargeObjectManagerTest.testOpenWithErrorAndSubsequentParameterStatusMessageShouldLeaveConnectionInUsableStateAndUpdateParameterStatus()": "unknown", - "org.postgresql.jdbc.ScramTest.[1] null, The server requested SCRAM-based authentication, but no password was provided.": "unknown", - "org.postgresql.jdbc.ScramTest.[2] , The server requested SCRAM-based authentication, but the password is an empty string.": "unknown", "org.postgresql.test.core.LogServerMessagePropertyTest.testBatchExplicitlyEnabled": "unknown", "org.postgresql.test.core.LogServerMessagePropertyTest.testBatchWithDefaults": "unknown", "org.postgresql.test.core.LogServerMessagePropertyTest.testBatchWithLogServerErrorDetailDisabled": "unknown", @@ -591,22 +589,6 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc3.EscapeSyntaxCallModeSelectTest.testInvokeFunction": "17511", "org.postgresql.test.jdbc3.EscapeSyntaxCallModeSelectTest.testInvokeFunctionHavingReturnParameter": "17511", "org.postgresql.test.jdbc3.EscapeSyntaxCallModeSelectTest.testInvokeProcedure": "17511", - "org.postgresql.test.jdbc3.GeneratedKeysTest.testBatchGeneratedKeys[returningInQuery = A, binary = FORCE]": "26925", - "org.postgresql.test.jdbc3.GeneratedKeysTest.testBatchGeneratedKeys[returningInQuery = A, binary = REGULAR]": "26925", - "org.postgresql.test.jdbc3.GeneratedKeysTest.testBatchGeneratedKeys[returningInQuery = AB, binary = FORCE]": "26925", - "org.postgresql.test.jdbc3.GeneratedKeysTest.testBatchGeneratedKeys[returningInQuery = AB, binary = REGULAR]": "26925", - "org.postgresql.test.jdbc3.GeneratedKeysTest.testBatchGeneratedKeys[returningInQuery = NO, binary = FORCE]": "26925", - "org.postgresql.test.jdbc3.GeneratedKeysTest.testBatchGeneratedKeys[returningInQuery = NO, binary = REGULAR]": "26925", - "org.postgresql.test.jdbc3.GeneratedKeysTest.testBatchGeneratedKeys[returningInQuery = STAR, binary = FORCE]": "26925", - "org.postgresql.test.jdbc3.GeneratedKeysTest.testBatchGeneratedKeys[returningInQuery = STAR, binary = REGULAR]": "26925", - "org.postgresql.test.jdbc3.GeneratedKeysTest.testSerialWorks[returningInQuery = A, binary = FORCE]": "26925", - "org.postgresql.test.jdbc3.GeneratedKeysTest.testSerialWorks[returningInQuery = A, binary = REGULAR]": "26925", - "org.postgresql.test.jdbc3.GeneratedKeysTest.testSerialWorks[returningInQuery = AB, binary = FORCE]": "26925", - "org.postgresql.test.jdbc3.GeneratedKeysTest.testSerialWorks[returningInQuery = AB, binary = REGULAR]": "26925", - "org.postgresql.test.jdbc3.GeneratedKeysTest.testSerialWorks[returningInQuery = NO, binary = FORCE]": "26925", - "org.postgresql.test.jdbc3.GeneratedKeysTest.testSerialWorks[returningInQuery = NO, binary = REGULAR]": "26925", - "org.postgresql.test.jdbc3.GeneratedKeysTest.testSerialWorks[returningInQuery = STAR, binary = FORCE]": "26925", - "org.postgresql.test.jdbc3.GeneratedKeysTest.testSerialWorks[returningInQuery = STAR, binary = REGULAR]": "26925", "org.postgresql.test.jdbc3.Jdbc3BlobTest.test1Byte": "26725", "org.postgresql.test.jdbc3.Jdbc3BlobTest.test1ByteOffset": "26725", "org.postgresql.test.jdbc3.Jdbc3BlobTest.test1ByteOffsetStream": "26725", @@ -673,16 +655,6 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc3.StringTypeParameterTest.testVarcharAsEnum[stringType = null]": "27793", "org.postgresql.test.jdbc3.StringTypeParameterTest.testVarcharAsEnum[stringType = unspecified]": "27793", "org.postgresql.test.jdbc3.StringTypeParameterTest.testVarcharAsEnum[stringType = varchar]": "27793", - "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = ID, quoteReturning = false]": "unknown", - "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = ID, quoteReturning = true]": "unknown", - "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = Id, quoteReturning = false]": "unknown", - "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = Id, quoteReturning = true]": "unknown", - "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = NO, quoteReturning = false]": "unknown", - "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = NO, quoteReturning = true]": "unknown", - "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = QUOTED, quoteReturning = false]": "unknown", - "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = QUOTED, quoteReturning = true]": "unknown", - "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = id, quoteReturning = false]": "unknown", - "org.postgresql.test.jdbc3.TestReturning.testMixedCase[returningInQuery = id, quoteReturning = true]": "unknown", "org.postgresql.test.jdbc3.TypesTest.testCallableBoolean": "17511", "org.postgresql.test.jdbc3.TypesTest.testPreparedBoolean": "17511", "org.postgresql.test.jdbc3.TypesTest.testPreparedByte": "17511", @@ -835,8 +807,6 @@ var pgjdbcBlockList22_1 = blocklist{ "org.postgresql.test.jdbc42.SetObject310InfinityTests.testTimestamptz[binary = FORCE]": "41564", "org.postgresql.test.jdbc42.SetObject310InfinityTests.testTimestamptz[binary = REGULAR]": "41564", "org.postgresql.test.plugin.AuthenticationPluginTest.testAuthPluginMD5": "unknown", - "org.postgresql.test.plugin.AuthenticationPluginTest.testAuthPluginSASL": "unknown", - "org.postgresql.test.util.ObjectFactoryTest.testInvalidAuthenticationPlugin()": "unknown", "org.postgresql.test.xa.XADataSourceTest.testAutoCommit": "22329", "org.postgresql.test.xa.XADataSourceTest.testCloseBeforeCommit": "22329", "org.postgresql.test.xa.XADataSourceTest.testCommitByDifferentConnection": "22329", @@ -3388,12 +3358,6 @@ var pgjdbcIgnoreList20_2 = blocklist{ "org.postgresql.jdbc.PgSQLXMLTest.testGetSourceXxeSAXSource": "43355", "org.postgresql.jdbc.PgSQLXMLTest.testGetSourceXxeStAXSource": "43355", "org.postgresql.jdbc.PgSQLXMLTest.testLegacyXxe": "43355", - "org.postgresql.jdbc.ScramTest.[1] My Space": "42519", - "org.postgresql.jdbc.ScramTest.[2] $ec ret": "42519", - "org.postgresql.jdbc.ScramTest.[3] rover june spelling ": "42519", - "org.postgresql.jdbc.ScramTest.[3] rover june spelling": "42519", - "org.postgresql.jdbc.ScramTest.[4] !zj5hs*k5 STj@DaRUy": "42519", - "org.postgresql.jdbc.ScramTest.[5] q\u00A0w\u2000e\u2003r\u2009t\u3000y": "42519", "org.postgresql.replication.CopyBothResponseTest.testKeedAliveContaintCorrectLSN": "uses pg replication", "org.postgresql.replication.CopyBothResponseTest.testOpenConnectByReplicationProtocol": "uses pg replication", "org.postgresql.replication.CopyBothResponseTest.testReceiveKeepAliveMessage": "uses pg replication", diff --git a/pkg/sql/set_var.go b/pkg/sql/set_var.go index 98d9a6b7d257..7271072505c4 100644 --- a/pkg/sql/set_var.go +++ b/pkg/sql/set_var.go @@ -207,11 +207,14 @@ func (n *resetAllNode) startExec(params runParams) error { if varName == "role" { continue } - _, defVal := getSessionVarDefaultString( + hasDefault, defVal := getSessionVarDefaultString( varName, v, params.p.sessionDataMutatorIterator.sessionDataMutatorBase, ) + if !hasDefault { + continue + } if err := params.p.SetSessionVar(params.ctx, varName, defVal, false /* isLocal */); err != nil { return err } diff --git a/pkg/sql/vars.go b/pkg/sql/vars.go index fddcdc4eaaaa..242dabf510c9 100644 --- a/pkg/sql/vars.go +++ b/pkg/sql/vars.go @@ -1310,6 +1310,13 @@ var varGen = map[string]sessionVar{ Get: func(evalCtx *extendedEvalContext) (string, error) { return security.GetConfiguredPasswordHashMethod(evalCtx.Ctx(), &evalCtx.Settings.SV).String(), nil }, + SetWithPlanner: func(ctx context.Context, p *planner, local bool, val string) error { + method := security.GetConfiguredPasswordHashMethod(ctx, &p.ExecCfg().Settings.SV) + if val != method.String() { + return newCannotChangeParameterError("password_encryption") + } + return nil + }, }, // Supported for PG compatibility only.