Files
documentdb/scripts/validate_headers.sh
T
Vinod Sridharan dcf5344190 Merged PR 1538375: [OSS] Initial setup for documentdb
### Does this PR have any customer impact?
No

### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactor

### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
Not yet

### 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
Initial setup for documentdb extensions.
Create Makefiles and set up build scripts around documentdb.

This does not yet touch the actual code or make anything deployable.

----
#### AI description  (iteration 1)
#### PR Classification
Initial setup for DocumentDB integration.

#### PR Summary
This pull request sets up the initial structure and configuration for DocumentDB integration.
- Added `documentdb_errors.h` for defining DocumentDB-specific error codes.
- Created `Makefile` for `pg_documentdb`, `pg_documentdb_core`, and `pg_documentdb_distributed` to handle build configurations.
- Updated `validate_helio_extension_state.sh` and `validate_headers.sh` scripts to include checks for DocumentDB.
- Modified `bson_aggregation_nested_pipeline.c`, `bson_aggregation_vector_search.c`, and other source files to replace references from Helio to DocumentDB.
- Added control files for `pg_documentdb`, `pg_documentdb_core`, and `pg_documentdb_distributed` extensions.
2025-01-15 07:48:39 +00:00

120 lines
3.8 KiB
Bash
Executable File

#!/bin/bash
# fail if trying to reference a variable that is not set.
set -e
source="${BASH_SOURCE[0]}"
while [[ -h $source ]]; do
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
source="$(readlink "$source")"
# if $source was a relative symlink, we need to resolve it relative to the path where the
# symlink file was located
[[ $source != /* ]] && source="$scriptroot/$source"
done
repoScriptDir="$( cd -P "$( dirname "$source" )" && pwd )"
declare -A headerMap;
# Ensure unique headers between OSS extensions
echo "Checking helio_core"
for f in `find $repoScriptDir/../pg_helio_core/include/ -name *.h`; do
subPath=${f#$repoScriptDir/../pg_helio_core/include/}
if [ "${headerMap[$subPath]}" != "" ]; then
echo "Duplicate header path found at $subPath. Header files must be unique across the extensions";
exit 1;
fi
headerMap[$subPath]=1;
done;
echo "Checking helio_api"
for f in `find $repoScriptDir/../pg_helio_api/include/ -name *.h`; do
subPath=${f#$repoScriptDir/../pg_helio_api/include/}
if [ "${headerMap[$subPath]}" != "" ]; then
echo "Duplicate header path found at $subPath. Header files must be unique across the extensions";
exit 1;
fi
headerMap[$subPath]=1;
done;
echo "Checking pg_documentdb_core"
for f in `find $repoScriptDir/../pg_documentdb_core/include/ -name *.h`; do
subPath=${f#$repoScriptDir/../pg_documentdb_core/include/}
if [ "${headerMap[$subPath]}" != "" ]; then
echo "Duplicate header path found at $subPath. Header files must be unique across the extensions";
exit 1;
fi
headerMap[$subPath]=1;
done;
echo "Checking pg_documentdb"
for f in `find $repoScriptDir/../pg_documentdb/include/ -name *.h`; do
subPath=${f#$repoScriptDir/../pg_documentdb/include/}
if [ "${headerMap[$subPath]}" != "" ]; then
echo "Duplicate header path found at $subPath. Header files must be unique across the extensions";
exit 1;
fi
headerMap[$subPath]=1;
done;
echo "Checking pg_helio_distributed"
for f in `find $repoScriptDir/../internal/pg_helio_distributed/include/ -name *.h`; do
subPath=${f#$repoScriptDir/../internal/pg_helio_distributed/include/}
if [ "${headerMap[$subPath]}" != "" ]; then
echo "Duplicate header path found at $subPath. Header files must be unique across the extensions";
exit 1;
fi
headerMap[$subPath]=1;
done;
echo "Checking pg_documentdb_distributed"
for f in `find $repoScriptDir/../internal/pg_documentdb_distributed/include/ -name *.h`; do
subPath=${f#$repoScriptDir/../internal/pg_documentdb_distributed/include/}
if [ "${headerMap[$subPath]}" != "" ]; then
echo "Duplicate header path found at $subPath. Header files must be unique across the extensions";
exit 1;
fi
headerMap[$subPath]=1;
done;
# Now check they don't duplicate with postgres's headers.
pg_include_dir=$(pg_config --includedir)
pg_include_dir_server=$(pg_config --includedir-server)
for f in ${!example_array[@]}
do
if [ -f "$pg_include_dir/$f"]; then
echo "Duplicate header path found at $f. Header files must not collide with postgres headers";
exit 1;
fi
if [ -f "$pg_include_dir_server/$f"]; then
echo "Duplicate header path found at $f. Header files must not collide with postgres server headers";
exit 1;
fi
done
hasInvalidHeaders="0"
for f in $(grep -R "include <server" --include \*.h --include \*.c oss)
do
echo "Invalid header file found $f do not reference header files via 'server'"
hasInvalidHeaders="1"
done
for f in $(grep -R "include \"server" --include \*.h --include \*.c oss)
do
echo "Invalid header file found $f do not reference header files via 'server'"
hasInvalidHeaders="1"
done
if [ "$hasInvalidHeaders" == "1" ]; then
exit 1;
fi
echo "Total headers checked ${#headerMap[@]}"