Files
documentdb/scripts/utils.sh
T
Zinan Ren 8e7bd960bf Merged PR 1540262: [OSS] Remove helio references from sources of documentdb_core
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactoring
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Are you introducing any new config? If yes, do you have tests with and without them being set?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Remove helio from file name
Remove helio references from source content except schema reference
Start local documentdb server with the documentdb extension
Regression tests using the documentdb  extension

----
#### AI description  (iteration 1)
#### PR Classification
Code cleanup

#### PR Summary
This pull request removes references to "helio" from the `documentdb_core` source code.
- `scripts/utils.sh`: Renamed variables from `preloadExtensions` to `preloadLibraries`.
- `pg_documentdb_core/include/utils/error_utils.h`: Updated function and macro names to replace "Helio" with "DocumentDB".
- `pg_documentdb_core/include/io/helio_bson_core.h` and `pg_documentdb_core/include/query/helio_bson_compare.h`: Moved to `pg_documentdb_core/include/io/bson_core.h` and `pg_documentdb_core/include/query/bson_compare.h`.
- `pg_documentdb_core/src/collation/collation.c` and `pg_documentdb_core/src/io/pgbson.c`: Replaced error codes and messages to use "DocumentDB" instead of "Helio".
- `scripts/validate_helio_extension_state.sh`: Added exceptions for certain files to skip validation for "helio" references.
2025-01-15 07:48:40 +00:00

111 lines
2.8 KiB
Bash
Executable File

#!/bin/bash
# fail if trying to reference a variable that is not set.
set -u
# exit immediately if a command exits with a non-zero status
set -e
# trap to print line number on error
error() {
local parent_lineno="$1"
local message="${2:-x}"
local code="${3:-1}"
if [[ -n "$message" ]] ; then
echo "Error on or near line ${parent_lineno}: ${message}; exiting with status ${code}"
else
echo "Error on or near line ${parent_lineno}; exiting with status ${code}"
fi
exit "${code}"
}
trap 'error ${LINENO}' ERR
function GetPostgresPath()
{
local pgVersion=$1
local osVersion=$(cat /etc/os-release | grep "^ID=");
if [[ "$osVersion" == "ID=ubuntu" || "$osVersion" == "ID=debian"|| "$osVersion" == "ID=mariner" ]]; then
echo "/usr/lib/postgresql/$pgVersion/bin"
else
echo "/usr/pgsql-$pgVersion/bin"
fi
}
function GetPGCTL()
{
local pgVersion=${PG_VERSION:-16}
echo ${pgctlPath:-$(GetPostgresPath $pgVersion)/pg_ctl}
}
function GetInitDB()
{
local pgVersion=${PG_VERSION:-16}
echo $(GetPostgresPath $pgVersion)/initdb
}
function StopServer()
{
local _directory=$1
local _extraOptions=${2:-""}
$(GetPGCTL) stop -D $_directory $_extraOptions || true;
echo "Stopped all PG instances on $_directory";
}
function StartServer()
{
local _directory=$1
local _port=$2
local _logPath=${3:-$_directory/pglog.log}
local _pgctlPath=$(GetPGCTL)
echo "Starting postgres in $_directory"
echo "Calling: $_pgctlPath start -D $_directory -o \"-p $_port -l $_logPath\""
$_pgctlPath start -D $_directory -o "-p $_port" -l $_logPath
}
function SetupPostgresServerExtensions()
{
local user=$1
local port=$2
local extensionName=$3
local extensionVersion=${4:-}
local versionString="";
if [ "$extensionVersion" != "" ]; then
versionString="WITH VERSION '${extensionVersion}'";
fi
echo "create extension $extensionName on port $port with version '${extensionVersion:-latest}'."
psql -p $port -U $user -d postgres -c "CREATE EXTENSION $extensionName $versionString CASCADE;"
psql -p $port -U $user -d postgres -c "SELECT * FROM pg_extension WHERE extname = '$extensionName';"
}
function InitDatabaseExtended()
{
local _directory=$1
local _preloadLibraries=$2
echo "Deleting directory $_directory"
rm -rf $_directory
mkdir -p $_directory
echo "Calling initdb for $_directory"
$(GetInitDB) -D $_directory
SetupPostgresConfigurations $_directory "$_preloadLibraries"
}
function SetupPostgresConfigurations()
{
local installdir=$1;
local preloadLibraries=$2;
requiredLibraries="pg_cron, ${preloadLibraries}";
echo shared_preload_libraries = \'$requiredLibraries\' | tee -a $installdir/postgresql.conf
echo cron.database_name = \'postgres\' | tee -a $installdir/postgresql.conf
echo ssl = off | tee -a $installdir/postgresql.conf
}