### 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))
NA
### Description
remove legacy errors completely
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request removes legacy MongoDB error handling code and all related references.
- Deleted `mongo_errors.h`.
- Removed `CheckNoMongoErrorCodeHeader` function and related calls from `scripts/validate_helio_extension_state.sh`.
- Updated `error_utils.c` to remove legacy MongoDB error handling logic.
- Deleted deprecated functions from `helio_distributed_test_helpers.sql` and `pgmongo_test_helpers.sql`.
- Updated expected test outputs in `helio_distributed_test_helpers.out` and `pgmongo_test_helpers.out` to reflect the removal of deprecated functions.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Enable $out stage GUC
----
#### AI description (iteration 1)
#### PR Classification
New feature
#### PR Summary
This pull request enables the `$out` aggregation stage by default in the system.
- Modified `oss/pg_helio_api/src/helio_api_init.c` to set `DEFAULT_ENABLE_OUT_STAGE` to `true`.
- Updated test files `oss/internal/pg_helio_distributed/src/test/regress/expected/bson_aggregation_stage_out_tests_2.out`, `oss/internal/pg_helio_distributed/src/test/regress/sql/bson_aggregation_stage_out_tests_2.sql`, and `pgmongo/src/test/helio_compat/expected/bson_aggregation_stage_out_tests_2.out` to remove GUC enablement steps and error checks.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
We do not support apiVersion, so apiStrict and apiDeprecationErrors can be ignored for now.
----
#### AI description (iteration 1)
#### PR Classification
Code update to support or ignore specific API parameters.
#### PR Summary
This pull request updates the code to include `apiStrict` and `apiDeprecationErrors` in the list of ignored specification fields, addressing the requirements of the linked work item.
- `commands_common.c`: Added `apiStrict` and `apiDeprecationErrors` to the `IgnoredCommonSpecFields` array.
Related work items: #3463178
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
Yes
### 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
Start up fixes to support add node and rebalancing
- the cluster_data table didn't have a primary key - add it
- the index specs type was mismatched between current nodes and new nodes. Make them matched and handle back compat
With this at least new nodes can be added and rebalanced. After which new tables can be created.
We still cannot create tables after add node (this scenario is still broken at this point).
----
#### AI description (iteration 1)
#### PR Classification
Schema update to support node rebalancing.
#### PR Summary
This pull request updates the schema to facilitate node rebalancing in the cluster.
- `cluster_operations.c`: Added logic to conditionally alter types and re-add primary keys based on version checks.
- `start_postgres_server.sh` and `utils.sh`: Introduced `skipRegisterWorkerNode` flag and related functions to handle inactive nodes and shard management.
- `pgmongo--1.22-0--1.23-0.sql`: Added primary key to `pgmongo_cluster_data` and conditionally altered `index_spec_type_internal`.
- `collection_indexes_metadata--1.23-0.sql`: Added new attributes to `index_spec_type_internal`.
- `pg_helio_api--1.22-0--1.23-0.sql` and `pg_helio_distributed--1.22-0--1.23-0.sql`: Included schema changes and primary key addition.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
update jstest passrate
----
#### AI description (iteration 1)
#### PR Classification
Bug fix and enhancement for the `$derivative` stage aggregation operator.
#### PR Summary
This pull request addresses a bug and enhances the `$derivative` stage aggregation operator by handling `BSON_TYPE_DATE_TIME` and preventing division by zero errors.
- `bson_aggregation_statistics.c`: Added handling for `BSON_TYPE_DATE_TIME` in `yValueElement` and checks to prevent division by zero.
- `60_postgres_10260.csv` and `70_postgres_10260.csv`: Updated test results for `comprehensive_parse.js` from Fail to Pass.
Related work items: #2151582
### Does this PR have any customer impact?
no
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Comments
### 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))
na
### Description
update comments for setwindowfields JStests
----
#### AI description (iteration 1)
#### PR Classification
Documentation update for JStests related to `setWindowFields`.
#### PR Summary
This pull request updates comments and error messages for JStests related to `setWindowFields` to provide more accurate descriptions of the failures.
- `/gateway/managed/Tests.Integration.Shell.Postgres/60_postgres_10260.csv`: Updated failure reasons for various `setWindowFields` tests.
- `/oss/pg_helio_api/src/commands/coll_stats.c`: Added validation to ensure `$collStats.count` is an empty object.
- `/oss/mongoerrors.csv`, `/oss/pg_helio_core/include/utils/helio_errors.h`, `/oss/pg_helio_core/include/utils/helio_codes.txt`: Added new error code `Location31170`.
- `/oss/pg_helio_api/src/commands/commands_common.c`: Added `apiStrict` to ignored common spec fields.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Migrating 22 tests to Oss. So those tests run in both.
----
#### AI description (iteration 1)
#### PR Classification
Test migration
#### PR Summary
This pull request removes SQL test files related to BSON aggregation and order aggregates as part of the test migration process.
- Deleted `bson_aggregation_trigonometric_operators_tests.sql` containing tests for various BSON trigonometric operators.
- Deleted `bson_order_aggregates_tests.sql` containing tests for BSON order aggregates and related functions.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
version update to start 1.22 release
----
#### AI description (iteration 1)
#### PR Classification
Version update to start the 1.23 release.
#### PR Summary
This pull request updates the project version to 1.23 and includes necessary changes to support the new release.
- Added release notes for version 1.23 in `docs/release_notes/pgmongo_1.23.md`.
- Updated version numbers in control files: `pg_helio_distributed.control`, `pg_helio_api.control`, `pg_helio_core.control`, and `pgmongo.control`.
- Added SQL migration scripts for version updates in `pg_helio_distributed`, `pg_helio_api`, `pg_helio_core`, and `pgmongo`.
- Updated SHA1 checksums for SQL scripts in `pgmongo/sql/sha1/`.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Test Migration PART-2
----
#### AI description (iteration 1)
#### PR Classification
Test migration.
#### PR Summary
This pull request removes test cases related to BSON aggregation arithmetic operators and expression variables as part of the test migration process.
- Removed all test cases from `pgmongo/src/test/regress/sql/bson_aggregation_arithmetic_operators_tests.sql`.
- Removed all expected output from `pgmongo/src/test/regress/expected/bson_aggregation_expression_variable_tests.out`.
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfixes
### 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?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Cleanup for internal errors
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup to handle internal errors more effectively in production.
#### PR Summary
This pull request enhances error handling by adding specific checks for out-of-memory errors and refining existing error messages.
- `src/commands/diagnostic_commands_common.c`: Added handling for out-of-memory errors and refined error checks for recovery conflicts.
- `PostgresClient.cs`: Added specific handling for `OutOfMemoryException`.
- `PostgresMongoResultExtensions.cs`: Added new error messages for vector dimension constraints and refined existing error messages.
### Does this PR have any customer impact?
yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
bugfix
### 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))
na
### Description
fix TopologyException internal error while segmentizing the query for better index scans
----
#### AI description (iteration 1)
#### PR Classification
Bug fix for handling self-intersection errors in geospatial segmentize queries.
#### PR Summary
This pull request addresses an internal error caused by self-intersections in geospatial segmentize queries by incorporating the `ST_MAKEVALID` function.
- `/oss/pg_helio_api/src/opclass/bson_gist_geospatial.c`: Updated `BaseGeoSubdivideQuery` to use `ST_MAKEVALID` with `ST_SEGMENTIZE` to ensure valid geometries.
- `/pgmongo/src/test/regress/expected/geospatial_extract_2d_geometries.out` and `/pgmongo/src/test/regress/sql/geospatial_extract_2d_geometries.sql`: Added tests to validate the fix, demonstrating the use of `ST_MAKEVALID` to correct invalid geometries created by `ST_SEGMENTIZE`.
Related work items: #3494552
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
[OSS] Test Migration PART-1
----
#### AI description (iteration 1)
#### PR Classification
Test migration.
#### PR Summary
This pull request adds new test cases for BSON aggregation comparison operators.
- Added extensive test cases in `pgmongo/src/test/helio_compat/expected/bson_aggregation_comparison_operators_tests.out` for `$cmp`, `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, and `$lte` operators.
Related work items: #3494537
### Does this PR have any customer impact?
no
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
feature
### 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))
min and max supported in $setwindowFields
### Description
Use the existing bsonmax and bsonmin aggregate functions for window operations in setwindowfields
----
#### AI description (iteration 1)
#### PR Classification
New feature: Added min and max window operators in `setWindowFields`.
#### PR Summary
This pull request introduces the `$min` and `$max` window operators to the `setWindowFields` aggregation stage.
- `oss/pg_helio_api/src/aggregation/bson_aggregation_window_operators.c`: Added handlers for `$min` and `$max` window operators.
- `pgmongo/src/test/regress/sql/bson_aggregation_pipeline_stage_setWindowFields.sql`: Added tests for `$min` and `$max` window operators.
- `pgmongo/src/test/regress/expected/bson_aggregation_pipeline_stage_setWindowFields.out`: Updated expected output for new tests.
- `gateway/managed/Tests.Integration.Shell.Postgres/60_postgres_10260.csv`: Updated test results to reflect support for new window operators.
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
Yes
### 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
----
#### AI description (iteration 1)
#### PR Classification
New feature implementation for the `$setWindowFields` stage.
#### PR Summary
This pull request implements the `$first(N)` and `$last(N)` aggregation functions for the `$setWindowFields` stage.
- Added new aggregate functions in `oss/pg_helio_api/sql/udfs/aggregation/group_aggregates--1.21-0.sql` for `BSONFIRST`, `BSONLAST`, `BSONFIRSTN`, `BSONLASTN`, and their sorted variants.
Related work items: #2151585, #2151587
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Default configuration change
### 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 new configs
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Enable background index builds by default
----
#### AI description (iteration 1)
#### PR Classification
Configuration change to enable background index builds by default.
#### PR Summary
This pull request enables background index builds by default to improve performance and reduce downtime during index creation.
- `TenantConfigurationBase.cs`: Changed `EnableIndexBuildBackground` default value to `true`.
- `helio_api_init.c`: Changed `DEFAULT_ENABLE_INDEX_BUILD_BACKGROUND` default value to `true`.
This PR includes two parts:
1. The design doc of $fill
2. The implementation of $fill using `rewrite` way. Refer design doc [here](https://msdata.visualstudio.com/CosmosDB/_git/pgmongo/pullrequest/1423500?_a=files&path=/docs/pgmongo/design_docs/data_plane/aggregation_stages/fill.md).
3. Extract bson_expression_partition_by_fields_get() as a common method. So that, some related changes are:
a. densify's parse stage is changed
b. densify's unit tests is changed due to method name change
c. densify's original method for partitionByFields is removed
**Noticed:**
This implementation is based on the impl of `$linearFill` and `$locf`.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
----
#### AI description (iteration 1)
#### PR Classification
New feature: Adds support for `$maxN` and `$minN` operators in the `setWindowFields` stage.
#### PR Summary
This pull request introduces the `$maxN` and `$minN` window aggregation operators, including their syntax validation and handling.
- `oss/pg_helio_api/src/aggregation/bson_aggregation_window_operators.c`: Added functions to handle `$maxN` and `$minN` operators, including syntax validation.
- `pgmongo/src/test/regress/sql/bson_aggregation_pipeline_stage_setWindowFields.sql`: Added tests for `$maxN` and `$minN` operators with various window configurations.
- `pgmongo/src/test/regress/expected/setwindowfields_and_group_compliance.out`: Updated compliance tests to reflect support for `$maxN` and `$minN` in `setWindowFields`.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Before 1.20 release join condition we were not pushing down to index so in join function itself we use to validate `on` field values and compare target with source. but In 1.20 we have introduced index index push down for join condition where we are using support function for `bson_dollar_merge_join` so we validate on fields values in source projection itself using `bson_dollar_extract_merge_filter`.
So now as part of this PR we are at 1.20+ so removed older code bits which we are not going to use.
this was the PR where we have introduced index pushdown
https://msdata.visualstudio.com/CosmosDB/_git/pgmongo/pullrequest/1425893
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Testing
### 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
----
#### AI description (iteration 1)
#### PR Classification
New feature and code improvement.
#### PR Summary
This pull request implements the `$derivative` stage aggregation operator and refines error handling in the integral operator.
- `bson_aggregation_window_operators.c`: Improved error handling and calculation of time units for the integral operator.
- `bson_aggregation_statistics.c`: Updated error code for internal errors in handling integral and derivative operations.
Related work items: #2151582
### 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)
yes
### 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))
na
### Description
1. Move all legacy errors to new helio errors
2. Remove all refs to mongo_errors.h excluding error_utils.c , there is function which needs backword compatibility
3. Update `scripts/validate_helio_extension_state.sh` to enforce all validations on oss/pg_helio_api parent directory instead of individual sub directories
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup and deprecation.
#### PR Summary
This pull request moves all error handling to `helio_errors` and removes references to `mongo_errors.h`, deprecating certain functions.
- `error_utils.c`: Deprecated `command_throw_mongo_error` and `command_convert_mongo_error_to_postgres` functions.
- `mongo_errors.h`: Removed Mongo error handling code and redefined error code checks.
- `validate_helio_extension_state.sh`: Updated validation script to remove checks for `mongo_errors.h`.
- Added new SQL functions for database commands in `kill_op--1.22-0.sql`, `get_shard_key_value--1.22-0.sql`, and `reindex--1.22-0.sql`.
- Updated test files to reflect deprecation changes in error handling functions.
### Does this PR have any customer impact?
No, but setting to true was
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
N/A
### 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))
N/A
### Description
Setting enableCollation to false by default
----
#### AI description (iteration 1)
#### PR Classification
Configuration change to set `enableCollation` to false by default.
#### PR Summary
This pull request modifies the default setting for collation support in the BSON initialization code.
- `oss/pg_helio_core/src/bson_init.c`: Changed `DEFAULT_ENABLE_COLLATION` from `true` to `false`.
Add automated script for extension packaging.
The script enables packaging and testing for all combinations of
`[Debian 12, Debian 11, Ubuntu 24.04, Ubuntu 22.04, Ubuntu 20.04] x [PG
16, PG 15]`
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
[OSS] Port more errors to oss (M of N)
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup and error handling improvement.
#### PR Summary
This pull request ports more error codes to the OSS (Open Source Software) version, replacing existing error codes with `ERRCODE_HELIO_*` equivalents and improving error detail logging.
- `bson_aggregation_output_pipeline.c`: Replaced various `Mongo*` error codes with `ERRCODE_HELIO_*` equivalents and updated error messages to use `errdetail_log`.
- `bson_aggregation_pipeline.c`: Updated error handling to use `ERRCODE_HELIO_*` equivalents and improved error detail logging.
- `bson_aggregation_nested_pipeline.c`: Replaced `Mongo*` error codes with `ERRCODE_HELIO_*` equivalents and enhanced error detail logging.
- `bson_project_operator.c`: Updated positional projection error handling to use `ERRCODE_HELIO_*` equivalents.
- `commands_update.out`: Updated expected error codes in test outputs to match new `ERRCODE_HELIO_*` values.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
We cannot reuse the logic of firstN in the sort stag because the sort by key of the sort stage is a field, and the input and N of maxN are both expressions. maxN needs to sort the entire input expression.
for example :
input can be a expression:

N also can be a expression:

before the transition function, we need to evaluate input and n.
In the new implementation, we maintain a binaryHeap, the top of heap is maximum/minimum value.
For maxN:
**In transition funciton** :we need to maintain a small root heap and compare the current value with the top of the heap (minimum value). If the current value is greater than the top of the heap (minimum value), then we will pop the top of the heap and insert the current value.
**In the combine function,** each value of the left heap needs to be compared with the top of the right heap. If the conditions are met, the top of the right heap is popped out and the value is inserted. Each time, it is popped out from the left heap until the left heap is empty.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Perf
### 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
Migrate `$rand` and `$meta` to the new aggregation framework.
$rand does not need to exploit caching random constant values
----
#### AI description (iteration 1)
#### PR Classification
Performance improvement for miscellaneous aggregation operations.
#### PR Summary
This pull request optimizes and refactors various aggregation operations to enhance performance.
- Added and reordered function declarations in `include/operators/bson_expression_operators.h` for better organization.
- Implemented `ParseDollarRand` and `HandlePreParsedDollarRand` functions in `src/operators/bson_expression_miscellaneous_operators.c` to handle `$rand` expressions.
- Added `ParseDollarMeta` and `HandlePreParsedDollarMeta` functions in `src/operators/bson_expression_miscellaneous_operators.c` to handle `$meta` expressions.
- Updated `src/operators/bson_expression.c` to integrate new parsing and handling functions for `$rand` and `$meta` expressions.
Related work items: #3458675
### 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)
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))
NA
### Description
Port to new errors in operators, planners, query, schema_validation directories
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup to port to new error handling in specific directories.
#### PR Summary
This pull request updates error handling mechanisms in the `operators`, `planners`, `query`, and `schema_validation` directories.
- Modified `pgmongo/src/test/regress/expected/bson_query_operator_tests_index.out` to update error messages and hints for various BSON query operators.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request focuses on cleaning up error code handling related to MongoDB errors.
- Removed MongoDB-specific error handling from `oss/pg_helio_api/include/utils/mongo_errors.h`.
- Moved MongoDB error handling logic to `oss/pg_helio_core/include/utils/error_utils.h`.
- Updated various source files to include `utils/helio_errors.h` instead of `utils/mongo_errors.h`.
- Modified `scripts/validate_helio_extension_state.sh` to check for MongoDB error codes in additional directories.
### Does this PR have any customer impact?
no
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
cleanup
### 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))
na
### Description
Cleanup - Remove vCore referrence from OSS code
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup to remove references to vCore from the OSS code.
#### PR Summary
This pull request removes references to vCore from the OSS codebase and updates error messages accordingly.
- `bson_aggregation_window_operators.c`: Updated error messages to remove vCore version references and replaced them with generic "not supported yet" messages.
- `bson_aggregation_window_operators.c`: Changed error codes for unsupported commands to `ERRCODE_HELIO_COMMANDNOTSUPPORTED`.
- `bson_aggregation_window_operators.c`: Updated comments to replace "vCore specific options" with "helio specific options".
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix
### 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
fix memory corruption
----
#### AI description (iteration 1)
#### PR Classification
Bug fix to address memory corruption in the `$integral` window operator.
#### PR Summary
This pull request fixes a memory corruption issue in the `$integral` window operator by modifying how string memory is allocated and managed.
- `oss/pg_helio_api/src/aggregation/bson_aggregation_window_operators.c`: Replaced manual string allocation and copying with `StringInfo` for safer memory handling.
Related work items: #2151586
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
----
#### AI description (iteration 1)
#### PR Classification
New feature: Adds support for window functions `StdDevPop` and `StdDevSamp`.
#### PR Summary
This pull request introduces support for the `StdDevPop` and `StdDevSamp` window functions in the aggregation framework.
- `oss/pg_helio_api/src/aggregation/bson_aggregation_window_operators.c`: Added handlers for `$stdDevPop` and `$stdDevSamp` window aggregation operators.
- `gateway/managed/Tests.Integration.Shell.Postgres/60_postgres_10260.csv` and `70_postgres_10260.csv`: Updated test results to reflect the support for the new window functions.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
mongo_errors.h should not be part of oss.
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request updates the validation script and replaces `mongo_errors.h` with `helio_errors.h` in various source files.
- `/scripts/validate_helio_extension_state.sh`: Added header file validation and updated `CheckNoMongoErrorCodes` function to include a header validation flag.
- Replaced `#include "utils/mongo_errors.h"` with `#include "utils/helio_errors.h"` in multiple source files including `shard_colocation.c`, `cluster_operations.c`, `distributed_hooks.c`, `sharding.c`, and several files in the `vector` directory.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
[OSS] Port more error codes to OSS
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request ports error codes from MongoDB-specific codes to Helio-specific codes in the OSS project.
- `bson_json_schema_tree.c`: Replaced `Mongo` error codes with `ERRCODE_HELIO` equivalents.
- `bson_json_schema_validator.c`: Updated error code references to `ERRCODE_HELIO`.
- `collection.c`, `index.c`, `bson_gin_core.c`, `bson_gin_entrypoint.c`, `bson_gist_geospatial.c`, `bson_hashed_gin.c`, `bson_text_gin.c`, `gin_index_term.c`, `index_support.c`, `rum_exclusion.c`: Changed error code includes from `mongo_errors.h` to `helio_errors.h`.
- Removed `mongo_errors.h` include from `bson_gin_elemmatch.c`.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
adding check for changing error code
----
#### AI description (iteration 1)
#### PR Classification
Bug fix to correct the error code returned by the `findAndModify` operation.
#### PR Summary
This pull request addresses the issue where the `findAndModify` operation returns the wrong error code.
- `oss/pg_helio_api/src/update/bson_update_operators_workflow.c`: Changed the error code from `ERRCODE_HELIO_BADVALUE` to `MongoPathNotViable` when a field creation fails.
Related work items: #3463166
### 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)
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))
NA
### Description
Port errors for geospatial, command, index_am folders
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request updates error codes and messages in the geospatial, command, and index_am folders to use the new `ERRCODE_HELIO` format.
- `src/geospatial/bson_geospatial_geonear.c`: Replaced `MongoTypeMismatch` and `MongoBadValue` with `ERRCODE_HELIO_TYPEMISMATCH` and `ERRCODE_HELIO_BADVALUE`.
- `src/commands/create_indexes.c`: Updated various error codes to `ERRCODE_HELIO_*` equivalents.
- `src/commands/find_and_modify.c`: Changed error codes to `ERRCODE_HELIO_FAILEDTOPARSE`.
- `src/commands/create_collection_view.c`: Replaced `MongoInvalidNamespace` and `MongoInvalidOptions` with `ERRCODE_HELIO_*` equivalents.
- `include/geospatial/bson_geospatial_private.h`: Updated include from `utils/mongo_errors.h` to `utils/helio_errors.h`.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Enabling merge across DB
Now we have Citus 12.1.5 in the prod which has the fix to support merge across DB so enabling it.
----
#### AI description (iteration 1)
#### PR Classification
Configuration change to enable a feature.
#### PR Summary
This pull request enables the merge across databases feature by default.
- `oss/pg_helio_api/src/helio_api_init.c`: Changed `DEFAULT_ENABLE_MERGE_ACROSS_DB` from `false` to `true`.
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
UDF
### 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
add a window operator, $integral
----
#### AI description (iteration 1)
#### PR Classification
New feature: Adds a new window operator `$integral` for aggregation.
#### PR Summary
This pull request introduces the `$integral` window operator to compute integrals using the trapezoidal rule in BSON aggregation.
- Added `BsonIntegralAggState` structure and related functions in `bson_aggregates.c` to handle integral calculations.
- Implemented `HandleDollarIntegralWindowOperator` in `bson_aggregation_window_operators.c` to process the new `$integral` operator.
- Updated SQL UDFs in `group_aggregates_support--latest.sql` and `group_aggregates--latest.sql` to include the new `bson_integral_transition` and `bson_integral_final` functions.
- Added `BsonIntegralAggregateFunctionOid` in `metadata_cache.c` and `metadata_cache.h` for function OID retrieval.
- Exposed `GetDecimal128FromInt64` in `decimal128.c` and `decimal128.h` for converting integers to BSON decimal128 format.
Related work items: #3343290
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
Yes
### Are you introducing any new config? If yes, do you have tests with and without them being set?
Yes
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
$densify stage is implemented with all 3 modes
- range
- partition
- full
All 7 functional tests are passing, few tests which are explain specific will be pass in next PR with the changes

----
#### AI description (iteration 1)
#### PR Classification
New feature: Adds a new `$densify` aggregation stage.
#### PR Summary
Introduces the `$densify` aggregation stage to create new documents where certain field values are missing.
- Added detailed documentation for `$densify` in `docs/pgmongo/design_docs/data_plane/aggregation_stages/densify.md`.
- Implemented core aggregation logic in `oss/pg_helio_api/src/aggregation/bson_densify.c`.
- Created SQL functions and aggregates for densify operations in `oss/pg_helio_api/sql/udfs/aggregation/bson_densify_aggregates--1.21-0.sql` and `oss/pg_helio_api/sql/udfs/aggregation/bson_densify_aggregates--latest.sql`.
- Updated versioning and inclusion of new SQL files in `oss/pg_helio_api/sql/pg_helio_api--1.20-0--1.21-0.sql` and `pgmongo/sql/pgmongo--1.20-0--1.21-0.sql`.
Related work items: #3436236
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
Yes
### 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
$top, $topN, $bottom, $bottomN implementation for $group and $setWindowFields
----
#### AI description (iteration 1)
#### PR Classification
New feature: Added support for `$topN` and `$bottomN` group expression operators.
#### PR Summary
This pull request introduces the `$topN` and `$bottomN` group expression operators to the aggregation pipeline.
- `bson_aggregation_pipeline.c`: Added `ParseInputDocumentForTopAndBottom` function to parse input documents for `$topN` and `$bottomN` operators, and integrated it into the existing aggregation handling logic.
- `mongo_errors.h`: Defined new error codes for handling errors related to the new operators.
Related work items: #2151574, #2151576, #2151596, #2151597, #2988406, #2988407, #2988413, #2988415
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
Fix IsNan and IsInfinity for decimal128
----
#### AI description (iteration 1)
#### PR Classification
Bug fix for handling `IsNan` and `IsInfinity` functions for `decimal128` type.
#### PR Summary
This pull request fixes the `IsNan` and `IsInfinity` functions to correctly handle `decimal128` values.
- `oss/pg_helio_core/src/query/bson_compare.c`: Updated `IsBsonValueNaN` and `IsBsonValueInfinity` to use specific checks for `decimal128`.
- `oss/pg_helio_core/src/types/decimal128.c`: Modified `IsDecimal128Infinity` to return the sign of infinity.
- `oss/pg_helio_core/include/types/decimal128.h`: Updated function signature for `IsDecimal128Infinity` to include a boolean for positive infinity.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
----
#### AI description (iteration 1)
#### PR Classification
New feature: Added support for `$shift` operator in `$setWindowFields`.
#### PR Summary
This pull request introduces the `$shift` operator for window functions in BSON aggregation, along with additional rank-based window functions.
- Added `HandleDollarShiftWindowOperator` and related functions in `bson_aggregation_window_operators.c` to handle the `$shift` operator.
- Implemented `bson_rank`, `bson_dense_rank`, and `bson_shift` functions in `bson_aggregation_window_functions.c`.
- Added integration tests for rank-based window functions in `custom_rank.js`.
- Updated `bson_aggregation_pipeline_stage_setWindowFields.sql` with tests for `$rank` and `$denseRank` accumulators.
- Added OID lookup functions for new BSON window functions in `metadata_cache.c`.
### Does this PR have any customer impact?
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
### Are you introducing any new config? If yes, do you have tests with and without them being set?
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))
### Description
https://www.mongodb.com/docs/manual/reference/operator/aggregation/toHashedIndexKey/
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature
### 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
support for $out aggregation stage in aggregation pipeline
what we not support :
1. On Mult coordinator setup source and target can not be same
----
#### AI description (iteration 1)
#### PR Classification
New feature
#### PR Summary
This pull request introduces the `$out` aggregation stage to the aggregation pipeline.
- `oss/pg_helio_api/src/aggregation/bson_aggregation_output_pipeline.c`: Added `HandleOut` function to handle the `$out` stage, including parsing, validation, and query mutation for outputting results to a specified collection.
Related work items: #1798580
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature
### 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
1. Introduces a backend process level collator cache so that we open a collator for a specific collation string once per backend process
2. Uses collation-based sort key generation for string for supporting $in which uses Hashmap for membership check. We wanted the keys of the HashMap to be collation-aware for UTF8 keys.
----
#### AI description (iteration 1)
#### PR Classification
Code enhancement to improve collation handling in string comparison.
#### PR Summary
This pull request refines the string comparison logic using ICU collation in the `bson_compare.c` file.
- `bson_compare.c`: Replaced custom ICU collator creation with `ucol_open` and added error handling for unsupported collations. Closed the collator after use to prevent resource leaks.
- `bson_compare.c`: Added a reference to the ICU documentation for better clarity.
Related work items: #3412412, #3431062, #3456172
### Does this PR have any customer impact?
It fix a bug when using $setWindowFields with range window for shard collection.
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Bugfix
### 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))
N/A
### Description
Fix a bug that range window is not processed correctly when using $setWindowFields.
#### How to reproduce
See this case to reproduce it:
```
SELECT mongo_api_v1.insert_one('db', 'collShard', '{ "_id":1, "y": 1, "v": 1}', NULL);
SELECT mongo_api_v1.insert_one('db', 'collShard', '{ "_id":2, "y": 3, "v": 1}', NULL);
SELECT mongo_api_v1.shard_collection('db', 'collShard', '{ "_id": "hashed" }', false);
SELECT document FROM mongo_catalog.bson_aggregation_pipeline('db', '{ "aggregate": "collShard", "pipeline": [ { "$setWindowFields": {"sortBy": { "y": 1 }, "output": { "count": { "$count": {}, "window": { "range": [ -1, 0 ] } } } } }, { "$unset": "_id" } ]}');
```
Result:
```
postgres=# SELECT document FROM mongo_catalog.bson_aggregation_pipeline('db', '{ "aggregate": "collShard", "pipeline": [ { "$setWindowFields": {"sortBy": { "y": 1 }, "output": { "count": { "$count": {}, "window": { "range": [ -1, 0 ] } } } } }, { "$unset": "_id" } ]}');
document
--------------------------------------------------------------------------------------------------
{ "y" : { "$numberInt" : "1" }, "v" : { "$numberInt" : "1" }, "count" : { "$numberInt" : "0" } }
{ "y" : { "$numberInt" : "3" }, "v" : { "$numberInt" : "1" }, "count" : { "$numberInt" : "0" } }
(2 rows)
```
#### How to fix
In above case, the result for $count is not correct. It is becuase the WindowClause's parameter `isRangeAsc` is `false` by default.
In unshard collection, the `isRangeAsc` will be set during `transformWindowDefinitions()`. But for shard collection, it does not.
And on the other hand, for $setWindowFields, if a range window is applied, only ASC order is allowed. Thus, we can set `windowClasue->isRangeAsc` to `true` when processing range window cases.
#### After fix

----
#### AI description (iteration 1)
#### PR Classification
Bug fix to correct the range window for shard collection.
#### PR Summary
This pull request fixes a bug where the range window was not correctly set for shard collections.
- `oss/pg_helio_api/src/aggregation/bson_aggregation_window_operators.c`: Ensured range-based bounds require an ascending `sortBy` by setting `inRangeAsc` and `inRangeNullsFirst` to true.
- `pgmongo/src/test/regress/sql/bson_ag...
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Other
### 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))
NA
### Description
Add Number divide API.
----
#### AI description (iteration 1)
#### PR Classification
New feature
#### PR Summary
Introduces a new API for dividing BSON values, handling both decimal and double types, and ensuring division by zero is properly managed.
- Added `DivideBsonValueNumbers` function in `oss/pg_helio_core/src/io/pgbson_utils.c` to perform division on BSON values.
- Updated `oss/pg_helio_core/include/io/bsonvalue_utils.h` to declare the new `DivideBsonValueNumbers` function.
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Feature
### 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
Enable $setWindowFields stage by default
----
#### AI description (iteration 1)
#### PR Classification
Enable `$setWindowFields` stage by default for version 1.22.
#### PR Summary
This pull request enables the `$setWindowFields` stage by default in the configuration for version 1.22.
- Modified `scripts/utils.sh` to remove the manual enabling of `helio_api.enableStageSetWindowFields`.
- Updated `oss/internal/pg_helio_distributed/src/test/regress/postgresql.conf` and `pgmongo/src/test/regress/postgresql.conf` to remove redundant enabling of `helio_api.enableStageSetWindowFields`.
- Changed `oss/pg_helio_api/src/helio_api_init.c` to set `DEFAULT_ENABLE_STAGE_SET_WINDOW_FIELDS` to `true` by default.
### 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)
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
- Port more error codes to OSS
- Disallow new backend tests in pgmongo
----
#### AI description (iteration 1)
#### PR Classification
Porting additional error codes to the open-source version.
#### PR Summary
This pull request ports more error codes to the open-source version and updates related test cases and error handling.
- Added multiple SQL test files in `/pgmongo/src/test/regress/pgmongo_test_baseline`.
- Updated error codes in `commands_create_index_geospatial.out` and `and3.out` test files.
- Modified error handling in `oss/pg_helio_api/src/collation/collation.c` to use new error codes.
- Adjusted error logging in `oss/pg_helio_api/src/commands/insert.c` to include SQL state.
### Does this PR have any customer impact?
No.
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Testing/Bugfix.
### 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
Adding tests for index truncation on missing bson types.
Bugfixes:
1- Off by one error when truncating nested documents.
2- Missing bson type code truncation logic for nested entries.
----
#### AI description (iteration 1)
#### PR Classification
New feature: Added tests for BSON index truncation.
#### PR Summary
This pull request introduces new tests to verify BSON index truncation behavior for various BSON data types.
- Added `bson_index_truncation_binary_tests.sql` to test binary BSON data.
- Added `bson_index_truncation_code_tests.sql` to test code BSON data.
- Added `bson_index_truncation_symbol_tests.sql` to test symbol BSON data.
- Modified `gin_index_term.c` to adjust term truncation logic.
- Updated `bson_schedule` to include new test files.
Related work items: #3412472
### 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)
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
Port more errors to helio for more folders.
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup to port error codes to Helio-specific error codes.
#### PR Summary
This pull request updates various error codes from Mongo-specific to Helio-specific error codes across multiple files.
- `vector_index_kind_impl.c`: Replaced `MongoBadValue` and `MongoFailedToParse` with `ERRCODE_HELIO_BADVALUE` and `ERRCODE_HELIO_FAILEDTOPARSE`.
- `shard_colocation.c`: Updated error codes from `MongoCommandNotSupported`, `MongoBadValue`, and `MongoFailedToParse` to Helio-specific equivalents.
- `bson_update_operators.c`: Changed error codes like `MongoTypeMismatch` and `MongoBadValue` to `ERRCODE_HELIO_TYPEMISMATCH` and `ERRCODE_HELIO_BADVALUE`.
- `parse_error.h`: Replaced `MongoTypeMismatch` with `ERRCODE_HELIO_TYPEMISMATCH`.
- `collection.c`: Updated error codes from `MongoBadValue` and `MongoInvalidNamespace` to Helio-specific equivalents.
### 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)
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
Move to helio error codes in pg-helio-core
Enforce hygiene in helio core
Move to helio errors
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup
#### PR Summary
This pull request refactors error handling by replacing Mongo-specific error codes with Helio-specific error codes and updates error messages accordingly.
- Added `CheckNoMongoErrorCodes` function in `/scripts/validate_helio_extension_state.sh` to ensure no Mongo-specific error codes are used.
- Updated error codes and messages in `oss/pg_helio_core/src/query/bson_compare.c` to use Helio-specific codes.
- Modified error handling in `oss/pg_helio_core/src/types/pcre_regex.c` to replace Mongo error codes with Helio error codes.
- Replaced Mongo error codes with Helio error codes in `oss/pg_helio_core/src/io/pgbsonsequence.c`.
- Updated error codes in `oss/pg_helio_core/src/types/decimal128.c` to use Helio-specific codes.