chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:32:25 +08:00
commit e014feafe1
2285 changed files with 1131979 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
# build.sh
#
# This script builds doltgres from source for this machine's OS and architecture.
# Requires a locally running docker server.
set -e
set -o pipefail
script_dir=$(dirname "$0")
cd $script_dir/..
go_version=`go version | cut -d" " -f 3 | sed -e 's|go||' | sed -e 's|\.[0-9]$||'`
os=`go version | sed "s| (.*)||" | cut -d" " -f 4 | sed "s|/.*||"`
arch=`go version | sed "s| (.*)||" | cut -d" " -f 4 | sed "s|.*/||"`
echo "os is $os"
echo "arch is $arch"
echo "go version is $go_version"
# Run the build script in docker, using the current working directory as the docker src
# directory. Packaged binaries will be placed in out/
docker run --rm \
-v `pwd`:/src \
-w /src \
golang:"$go_version"-trixie \
/src/scripts/build_binaries.sh "$os-$arch"
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
# build_all_binaries.sh
#
# This script builds doltgres from source for all supported OSes and architectures.
# Requires a locally running docker server.
#
# Used as part of automated releases. To build your current OS and architecture, use build.sh.
#
# GO_BUILD_VERSION is the major version of Go to target, e.g. 1.25. Must be set in ENV.
set -ex
set -o pipefail
script_dir=$(dirname "$0")
cd $script_dir/..
[ ! -z "$GO_BUILD_VERSION" ] || (echo "Must supply GO_BUILD_VERSION"; exit 1)
OS_ARCH_TUPLES="windows-amd64 linux-amd64 linux-arm64 darwin-amd64 darwin-arm64"
docker run --rm \
-v `pwd`:/src \
-w /src \
golang:"$GO_BUILD_VERSION"-trixie \
/src/scripts/build_binaries.sh "$OS_ARCH_TUPLES"
+95
View File
@@ -0,0 +1,95 @@
#!/bin/bash
# build_binaries.sh
#
# Builds doltgres binaries with os-arch tuples provided as arguments, e.g. windows-amd64 linux-amd64
#
# This script is intended to be run in a docker environment via build.sh or
# build_all_binaries.sh. You can also use it to build locally, but it needs to run apt-get and other
# commands which modify the system.
#
# To build doltgres for the OS / arch of this machine, use build.sh.
set -e
set -o pipefail
apt-get update && apt-get install -y p7zip-full pigz curl xz-utils mingw-w64 clang-19
mkdir -p /tmp/build-deps
pushd /tmp/build-deps
curl -o optcross.tar.xz https://dolthub-tools.s3.us-west-2.amazonaws.com/optcross/"$(uname -m)"-linux_20250327_0.0.3_trixie.tar.xz
tar Jxf optcross.tar.xz -C /
curl -o icustatic.tar.xz https://dolthub-tools.s3.us-west-2.amazonaws.com/icustatic/20250327_0.0.3_trixie.tar.xz
tar Jxf icustatic.tar.xz -C /
export PATH=/opt/cross/bin:"$PATH"
popd
OS_ARCH_TUPLES="$*"
declare -A platform_cc
platform_cc["linux-arm64"]="aarch64-linux-musl-gcc"
platform_cc["linux-amd64"]="x86_64-linux-musl-gcc"
platform_cc["darwin-arm64"]="clang-19 --target=aarch64-darwin --sysroot=/opt/cross/darwin-sysroot -mmacosx-version-min=12.0"
platform_cc["darwin-amd64"]="clang-19 --target=x86_64-darwin --sysroot=/opt/cross/darwin-sysroot -mmacosx-version-min=12.0"
platform_cc["windows-amd64"]="x86_64-w64-mingw32-gcc"
declare -A platform_cxx
platform_cxx["linux-arm64"]="aarch64-linux-musl-g++"
platform_cxx["linux-amd64"]="x86_64-linux-musl-g++"
platform_cxx["darwin-arm64"]="clang++-19 --target=aarch64-darwin --sysroot=/opt/cross/darwin-sysroot -mmacosx-version-min=12.0 --stdlib=libc++"
platform_cxx["darwin-amd64"]="clang++-19 --target=x86_64-darwin --sysroot=/opt/cross/darwin-sysroot -mmacosx-version-min=12.0 --stdlib=libc++"
platform_cxx["windows-amd64"]="x86_64-w64-mingw32-g++"
declare -A platform_as
platform_as["linux-arm64"]="aarch64-linux-musl-as"
platform_as["linux-amd64"]="x86_64-linux-musl-as"
platform_as["darwin-arm64"]="clang-19 --target=aarch64-darwin --sysroot=/opt/cross/darwin-sysroot -mmacosx-version-min=12.0"
platform_as["darwin-amd64"]="clang-19 --target=x86_64-darwin --sysroot=/opt/cross/darwin-sysroot -mmacosx-version-min=12.0"
platform_as["windows-amd64"]="x86_64-w64-mingw32-as"
declare -A platform_go_ldflags
platform_go_ldflags["linux-arm64"]="-linkmode external -s -w"
platform_go_ldflags["linux-amd64"]="-linkmode external -s -w"
platform_go_ldflags["darwin-arm64"]="-s -w -compressdwarf=false -extldflags -Wl,-platform_version,macos,12.0,14.4"
platform_go_ldflags["darwin-amd64"]="-s -w -compressdwarf=false -extldflags -Wl,-platform_version,macos,12.0,14.4"
platform_go_ldflags["windows-amd64"]="-s -w"
declare -A platform_cgo_ldflags
platform_cgo_ldflags["linux-arm64"]="-static -s"
platform_cgo_ldflags["linux-amd64"]="-static -s"
platform_cgo_ldflags["darwin-arm64"]=""
platform_cgo_ldflags["darwin-amd64"]=""
# Stack smash protection lib is built into clang for unix platforms,
# but on Windows we need to pull in the separate ssp library
platform_cgo_ldflags["windows-amd64"]="-static-libgcc -static-libstdc++ -Wl,-Bstatic -lssp"
for tuple in $OS_ARCH_TUPLES; do
os=`echo $tuple | sed 's/-.*//'`
arch=`echo $tuple | sed 's/.*-//'`
o="out/doltgresql-$os-$arch"
mkdir -p "$o/bin"
mkdir -p "$o/licenses"
cp -r ./licenses "$o/licenses"
cp LICENSE "$o/licenses"
bin="doltgres"
if [ "$os" = windows ]; then
bin="$bin.exe"
fi
echo Building "$o/bin/$bin"
CGO_ENABLED=1 \
GOOS="$os" \
GOARCH="$arch" \
CC="${platform_cc[${tuple}]}" \
CXX="${platform_cxx[${tuple}]}" \
AS="${platform_as[${tuple}]}" \
CGO_LDFLAGS="${platform_cgo_ldflags[${tuple}]}" \
go build -buildvcs=false -trimpath \
-ldflags="${platform_go_ldflags[${tuple}]}" \
-tags icu_static -o "$o/bin/$bin" \
./cmd/doltgres
if [ "$os" = windows ]; then
(cd out && 7z a "doltgresql-$os-$arch.zip" "doltgresql-$os-$arch" && 7z a "doltgresql-$os-$arch.7z" "doltgresql-$os-$arch")
else
tar cf - -C out "doltgresql-$os-$arch" | pigz -9 > "out/doltgresql-$os-$arch.tar.gz"
fi
done
+12
View File
@@ -0,0 +1,12 @@
#!/bin/bash
# This script generates an install.sh file with the $DOLTGRES_VERSION provided via ENV.
set -e
set -o pipefail
script_dir=$(dirname "$0")
cd $script_dir/..
sed 's|__DOLTGRES_VERSION__|'"$DOLTGRES_VERSION"'|' scripts/install.sh > out/install.sh
chmod 755 out/install.sh
+20
View File
@@ -0,0 +1,20 @@
#!/bin/bash
script_dir=$(dirname "$0")
cd $script_dir/../testing/bats
ERRORS_FOUND=0
for FILENAME_WITH_EXT in *.bats; do
FILENAME=${FILENAME_WITH_EXT%".bats"}
while read -r LINE; do
if [[ ! "$LINE" =~ @test[[:space:]]+[\"\']$FILENAME: ]]; then
TESTNAME=$(echo "$LINE" | grep -oP "(?<=@test\s)[\"\'][^\"\']+[\"\']")
echo -e "ERROR: test \"$TESTNAME\" in \"$FILENAME_WITH_EXT\" must start with \"$FILENAME:\" in the title"
ERRORS_FOUND=1
fi
done <<< $(grep '@test ['"'"'"]' "$FILENAME_WITH_EXT")
done
if [[ $ERRORS_FOUND -eq 1 ]]; then
exit 1
fi
exit 0
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
set -eo pipefail
script_dir=$(dirname "$0")
cd $script_dir/..
go install golang.org/x/tools/cmd/goimports
paths=`find . -maxdepth 1 -mindepth 1 ! -name ".idea" ! -name ".git" ! -name ".github" \( -name gen -prune -o -type d -print -o -type f -name '*.go' -print \)`
bad_files=$(goimports -l -local github.com/dolthub/doltgresql $paths)
if [ "$bad_files" != "" ]; then
echo "ERROR: The following files do not match goimports output:"
echo "$bad_files"
echo
echo "Please format the go code in the repository with './scripts/format_repo.sh'"
exit 1
fi
bad_files=$(find $paths -name '*.go' | while read f; do
if [[ $(awk '/import \(/{flag=1;next}/\)/{flag=0}flag' < $f | egrep -c '$^') -gt 2 ]]; then
echo $f
fi
done)
if [ "$bad_files" != "" ]; then
echo "ERROR: The following files have more than three import groups:"
echo "$bad_files"
echo
echo "Please format the go code in the repository with './scripts/format_repo.sh'"
exit 1
fi
+38
View File
@@ -0,0 +1,38 @@
#!/bin/bash
# Copyright 2023 Dolthub, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -eo pipefail
script_dir=$(dirname "$0")
cd $script_dir/..
paths=`find . -maxdepth 1 -mindepth 1 ! -name ".idea" ! -name ".git" ! -name ".github" \( -name gen -prune -o -type d -print -o -type f -name '*.go' -print \)`
goimports -w -local github.com/dolthub/doltgresql $paths
bad_files=$(find $paths -name '*.go' ! -path ".idea/*" | while read f; do
if [[ $(awk '/import \(/{flag=1;next}/\)/{flag=0}flag' < $f | egrep -c '$^') -gt 2 ]]; then
echo $f
fi
done)
if [ "$bad_files" != "" ]; then
for f in $bad_files; do
awk '/import \(/{flag=1}/\)/{flag=0}flag&&!/^$/||!flag' < "$f" > "$f.bak"
mv "$f.bak" "$f"
done
goimports -w -local github.com/dolthub/doltgresql .
fi
+126
View File
@@ -0,0 +1,126 @@
#!/bin/bash
# This script installs doltgres on your Linux or macOS computer.
# It should be run as root, and can be run directly from a GitHub
# release, for example as:
#
# curl https://github.com/dolthub/dolt/releases/download/v__DOLTGRES_VERSION__/install.sh | sudo bash
#
# All downloads occur over HTTPS from the Github releases page.
if test -z "$BASH_VERSION"; then
echo "Please run this script using bash, not sh or any other shell." >&2
exit 1
fi
_() {
set -euo pipefail
DOLTGRES_VERSION='__DOLTGRES_VERSION__'
RELEASES_BASE_URL="https://github.com/dolthub/doltgresql/releases/download/v$DOLTGRES_VERSION"
INSTALL_URL="$RELEASES_BASE_URL/install.sh"
CURL_USER_AGENT="${CURL_USER_AGENT:-dolt-installer}"
OS=
ARCH=
WORK_DIR=
PLATFORM_TUPLE=
error() {
if [ "$#" != 0 ]; then
printf '\e[0;31m%s\e[0m\n' "$*" >&2
fi
}
fail() {
local error_code="$1"
shift
echo '*** INSTALLATION FAILED ***' >&2
echo '' >&2
error "$@"
echo '' >&2
exit 1
}
assert_linux_or_macos() {
OS="$(uname)"
ARCH="$(uname -m)"
if [ "$OS" != 'Linux' ] && [ "$OS" != 'Darwin' ]; then
fail 'E_UNSUPPORTED_OS' 'doltgres install.sh only supports macOS and Linux.'
fi
# Translate aarch64 to arm64, since that's what GOARCH calls it
if [ "$ARCH" == 'aarch64' ]; then
ARCH='arm64'
fi
if [ "$ARCH-$OS" != 'x86_64-Linux' ] && [ "$ARCH-$OS" != 'x86_64-Darwin' ] && [ "$ARCH-$OS" != 'arm64-Linux' ] && [ "$ARCH-$OS" != 'arm64-Darwin' ]; then
fail 'E_UNSUPPOSED_ARCH' 'doltgres install.sh only supports installing doltgres on Linux-x86_64, Darwin-x86_64, Linux-aarch64, or Darwin-arm64.'
fi
if [ "$OS" == 'Linux' ]; then
PLATFORM_TUPLE=linux
else
PLATFORM_TUPLE=darwin
fi
if [ "$ARCH" == 'x86_64' ]; then
PLATFORM_TUPLE="$PLATFORM_TUPLE-amd64"
else
PLATFORM_TUPLE="$PLATFORM_TUPLE-arm64"
fi
}
assert_dependencies() {
type -p curl > /dev/null || fail 'E_CURL_MISSING' 'Please install curl(1).'
type -p tar > /dev/null || fail 'E_TAR_MISSING' 'Please install tar(1).'
type -p uname > /dev/null || fail 'E_UNAME_MISSING' 'Please install uname(1).'
type -p install > /dev/null || fail 'E_INSTALL_MISSING' 'Please install install(1).'
type -p mktemp > /dev/null || fail 'E_MKTEMP_MISSING' 'Please install mktemp(1).'
}
assert_uid_zero() {
uid="$(id -u)"
if [ "$uid" != 0 ]; then
fail 'E_UID_NONZERO' "doltgres install.sh must run as root; please try running with sudo or running\n\`curl $INSTALL_URL | sudo bash\`."
fi
}
create_workdir() {
WORK_DIR="$(mktemp -d -t doltgres-installer.XXXXXX)"
cleanup() {
rm -rf "$WORK_DIR"
}
trap cleanup EXIT
cd "$WORK_DIR"
}
install_binary_release() {
local FILE="doltgresql-$PLATFORM_TUPLE.tar.gz"
local URL="$RELEASES_BASE_URL/$FILE"
echo "Downloading: $URL"
curl -A "$CURL_USER_AGENT" -fsL "$URL" > "$FILE"
tar zxf "$FILE"
echo 'Installing doltgres into /usr/local/bin.'
[ ! -d /usr/local/bin ] && install -o 0 -g 0 -d /usr/local/bin
install -o 0 -g 0 "doltgresql-$PLATFORM_TUPLE/bin/doltgres" /usr/local/bin
install -o 0 -g 0 -d /usr/local/share/doc/doltgresql/
# TODO: doltgres's licenses directory needs to be reorganized for the install command below to work
# install -o 0 -g 0 -m 644 "doltgresql-$PLATFORM_TUPLE/licenses" /usr/local/share/doc/doltgresql/
}
assert_linux_or_macos
assert_dependencies
assert_uid_zero
create_workdir
install_binary_release
}
_ "$0" "$@"
+1
View File
@@ -0,0 +1 @@
sbtest
+100
View File
@@ -0,0 +1,100 @@
#!/bin/bash
#set -e
#set -o pipefail
SYSBENCH_TEST="covering_index_scan_postgres"
PPROF=0
PORT=54171
while [[ $# -gt 0 ]]; do
case "$1" in
--pprof)
PPROF=1
;;
*)
SYSBENCH_TEST="$1"
;;
esac
shift
done
mkdir -p sbtest
cd sbtest
if [ ! -d "./sysbench-lua-scripts" ]; then
git clone https://github.com/dolthub/sysbench-lua-scripts.git
fi
cp ./sysbench-lua-scripts/*.lua ./
go build -o doltgres.exe ../../../cmd/doltgres/
cat <<YAML > dolt-config.yaml
log_level: info
behavior:
read_only: false
disable_client_multi_statements: false
dolt_transaction_commit: false
user:
name: "postgres"
password: "password"
listener:
host: localhost
port: $PORT
read_timeout_millis: 28800000
write_timeout_millis: 28800000
data_dir: .
YAML
rm -rf ./.dolt
rm -rf ./postgres
./doltgres.exe -config="dolt-config.yaml" 2> prepare.log &
SERVER_PID="$!"
sleep 1
echo "----$SYSBENCH_TEST----" 1> results.log
sysbench \
--db-driver="pgsql" \
--pgsql-host="0.0.0.0" \
--pgsql-port="$PORT" \
--pgsql-user="postgres" \
--pgsql-password="password" \
--pgsql-db="postgres" \
--db-ps-mode=disable \
--table-size=10000 \
--percentile=50 \
--rand-type=uniform \
--rand-seed=1 \
"$SYSBENCH_TEST" prepare
kill -15 "$SERVER_PID"
if [ "$PPROF" -eq 1 ]; then
./doltgres.exe --prof cpu -config="dolt-config.yaml" 2> run.log &
else
./doltgres.exe -config="dolt-config.yaml" 2> run.log &
fi
SERVER_PID="$!"
sleep 1
sysbench \
--db-driver="pgsql" \
--pgsql-host="0.0.0.0" \
--pgsql-port="$PORT" \
--pgsql-user="postgres" \
--pgsql-password="password" \
--pgsql-db="postgres" \
--db-ps-mode=disable \
--table-size=10000 \
--percentile=50 \
--rand-type=uniform \
--rand-seed=1 \
--report-interval=1 \
--time=120 \
"$SYSBENCH_TEST" run 1>> results.log
sleep 1
kill -15 "$SERVER_PID"
+110
View File
@@ -0,0 +1,110 @@
#!/bin/bash
#set -e
#set -o pipefail
PORT=54171
# Set the working directory to the directory of the script's location
cd "$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
mkdir -p mini_sysbench
cd mini_sysbench
if [ ! -d "./sysbench-lua-scripts" ]; then
git clone https://github.com/dolthub/sysbench-lua-scripts.git
fi
cp ./sysbench-lua-scripts/*.lua ./
go build -o doltgres.exe ../../cmd/doltgres/
values=(
"covering_index_scan_postgres"
"groupby_scan_postgres"
"index_join_postgres"
"index_join_scan_postgres"
"index_scan_postgres"
"oltp_point_select"
"oltp_read_only"
"select_random_points"
"select_random_ranges"
"table_scan_postgres"
"types_table_scan_postgres"
"oltp_delete_insert_postgres"
"oltp_insert"
"oltp_read_write"
"oltp_update_index"
"oltp_update_non_index"
"oltp_update_non_index"
"oltp_write_only"
"types_delete_insert_postgres"
)
for value in "${values[@]}"; do
SYSBENCH_TEST="$value"
cat <<YAML > dolt-config.yaml
log_level: info
behavior:
read_only: false
disable_client_multi_statements: false
dolt_transaction_commit: false
user:
name: "postgres"
password: "password"
listener:
host: localhost
port: $PORT
read_timeout_millis: 28800000
write_timeout_millis: 28800000
data_dir: .
YAML
rm -rf ./.dolt
rm -rf ./postgres
./doltgres.exe -config="dolt-config.yaml" 2> prepare.log &
SERVER_PID="$!"
sleep 1
echo "----$SYSBENCH_TEST----"
sysbench \
--db-driver="pgsql" \
--pgsql-host="0.0.0.0" \
--pgsql-port="$PORT" \
--pgsql-user="postgres" \
--pgsql-password="password" \
--pgsql-db="postgres" \
--db-ps-mode=disable \
--table-size=10000 \
--percentile=50 \
--rand-type=uniform \
--rand-seed=1 \
"$SYSBENCH_TEST" prepare
kill -15 "$SERVER_PID"
echo "----$SYSBENCH_TEST----" 1>> results.log
./doltgres.exe -config="dolt-config.yaml" 2> run.log &
SERVER_PID="$!"
sleep 1
sysbench \
--db-driver="pgsql" \
--pgsql-host="0.0.0.0" \
--pgsql-port="$PORT" \
--pgsql-user="postgres" \
--pgsql-password="password" \
--pgsql-db="postgres" \
--db-ps-mode=disable \
--table-size=10000 \
--percentile=50 \
--rand-type=uniform \
--rand-seed=1 \
--time=15 \
"$SYSBENCH_TEST" run 1>> results.log
sleep 1
kill -15 "$SERVER_PID"
echo "----$SYSBENCH_TEST----" 1>> results.log
done
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
# Set the working directory to the directory of the script's location
cd "$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
cd ..
go run honnef.co/go/tools/cmd/staticcheck@2025.1 ./...