finish cleanning up of densify .c .sql
----
#### AI description (iteration 1)
#### PR Classification
Code cleanup and refactoring.
#### PR Summary
This PR cleans up naming and comments in the densify module to enhance clarity and consistency by replacing Mongo-specific terminology with generic collection terminology.
- In `oss/pg_documentdb/src/aggregation/bson_densify.c`, renamed the variable from `isMongoDataTable` to `isCollectionDataTable` and updated its usage.
- In the same file, updated comments to remove outdated Mongo references and clarify functionality.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
update tests
### Does this PR have any customer impact?
No
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
comments
----
#### AI description (iteration 1)
#### PR Classification
This pull request performs code cleanup by revising comment texts.
#### PR Summary
The changes update comments in `bson_expression_type_operators.c` to replace references to "native mongo" with "protocol," ensuring the comments accurately reflect protocol behavior.
- `bson_expression_type_operators.c`: Updated comments in ValidateStringIsNotHexBase, ProcessDollarType, and ProcessDollarToDate to clarify protocol-specific behavior regarding hexadecimal validation, missing field paths, and unsupported int32 to date conversions.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
cleanup OSS scripts
### Does this PR have any customer impact?
No
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
update decimal128 tests
----
#### AI description (iteration 1)
#### PR Classification
This pull request is a test cleanup that updates decimal128 expected outputs and SQL test queries.
#### PR Summary
The changes standardize decimal128 representations by updating numerical values and error messages in test output files and SQL queries. This improves consistency with protocol‐defined behavior for Decimal128 arithmetic operations.
- `oss/internal/pg_documentdb_distributed/src/test/regress/expected/bson_decimal128.out`: Updated expected numeric outputs for various Decimal128 operations.
- `pgmongo/src/test/docdb_compat/expected/bson_decimal128.out`: Revised expected Decimal128 values to align with new protocol behavior.
- `oss/internal/pg_documentdb_distributed/src/test/regress/sql/bson_decimal128.sql`: Modified SQL test cases and inserted data values for Decimal128, including minor comment cleanups.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### Does this PR have any customer impact?
No
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
expMovingAvg maxN minN topN bottomN .sql and .out
### Does this PR have any customer impact?
No
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
related test cases
----
#### AI description (iteration 1)
#### PR Classification
This PR is a test cleanup focused on updating regex-related tests.
#### PR Summary
The changes refactor the test cases by replacing document fields "sku" and "description" with "address" and "comment," and by updating the corresponding regex query filters and expected output files.
- `oss/internal/pg_documentdb_distributed/src/test/regress/expected/bson_dollar_ops_basic_text_ops_tests_index.out` and `.../tests_runtime.out`: Modified inserted document fields and regex query conditions.
- `pgmongo/src/test/docdb_compat/expected/bson_dollar_ops_basic_text_ops_tests_index.out` and `.../tests_runtime.out`: Applied consistent field and query updates across compatibility tests.
- `oss/internal/pg_documentdb_distributed/src/test/regress/sql/bson_dollar_ops_basic_text_ops_tests_core.sql`: Updated document insert statements and query filters to use the new field names.
- `oss/internal/pg_documentdb_distributed/src/test/regress/expected/bson_dollar_ops_basic_text_ops_tests_explain_index.out` and `.../tests_explain_runtime.out`: Adjusted minor formatting in the QUERY PLAN output.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Cleanup as per new change guideline, part -3
----
#### AI description (iteration 1)
#### PR Classification
This pull request is a code cleanup that standardizes and clarifies inline comments across multiple command files.
#### PR Summary
The changes update comment wording and remove redundant explanations to align with new guidelines, improving overall code clarity and consistency. Key changes include:
- Updates in `coll_mod.c` to clarify lock acquisition and index TTL constraints.
- Revised comments in `coll_stats.c` and `db_stats.c` to standardize responses and scale conversion details.
- Simplified comment phrasing in `current_op.c` and `delete.c` by removing unnecessary Mongo-specific references.
- Cleaned up prevalidation explanations in `drop_indexes.c` and support option comments in `commands_common.c`.
- Removed redundant commentary in `find_and_modify.c` regarding field casing.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
[oss] Cleanup as per new change guideline
----
#### AI description (iteration 1)
#### PR Classification
This pull request is a test cleanup update designed to standardize test collection names and expected outputs in both aggregation pipeline and set operator tests.
#### PR Summary
The changes update and rename test data to comply with new guidelines. Key modifications include:
- Updated expected output files for BSON aggregation “merge objects” tests in `/oss/internal/pg_documentdb_distributed/src/test/regress/expected/` and `/pgmongo/src/test/docdb_compat/expected/` by renaming collections (e.g. from `objColl1` to `mergeObjectsGroupColl`) and adjusting document content.
- Modified SQL test files in `/oss/pg_documentdb/src/test/regress/sql/` and `/oss/internal/pg_documentdb_distributed/src/test/regress/sql/` to reflect new collection names and query parameters.
- Revised BSON aggregation set operators tests to update date values (switching from 2019 timestamps to 2013 values) and associated expected outputs.
- Updated drop and shard collection commands accordingly to maintain consistency across tests.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### Does this PR have any customer impact?
No
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
clean up bson_aggregation_pipeline comments
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
[OSS] Cleanup test files, aggregation and insert one
----
#### AI description (iteration 1)
#### PR Classification
Test cleanup and expected output update for aggregation pipelines and insert commands.
### 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Aligning to contributing guideline for geospatial module
----
#### AI description (iteration 1)
#### PR Classification
This pull request performs a code cleanup in the geospatial module to improve clarity and consistency across comments, error messages, and test outputs.
#### PR Summary
The changes refine inline documentation and output messages to accurately describe the intended behavior of geospatial operators—especially for the $geoWithin operator—and standardize legacy processing with Postgis expectations.
### Does this PR have any customer impact?
No
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
percentil_medianl sql and out file
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Code cleanup as per new codiing guideline
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Cleanup aggregation operator tests part 2
----
#### AI description (iteration 1)
#### PR Classification
This pull request is a comprehensive test cleanup that updates expected outputs for BSON aggregation operator tests.
### 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Fix up some more documentation and comments around the code.
----
#### AI description (iteration 1)
#### PR Classification
This PR performs a code and documentation cleanup by refactoring naming conventions and removing deprecated staging functions to align with the contributing guide.
#### PR Summary
The pull request removes obsolete C wrappers for staging collection operations and standardizes internal API naming from "MongoCatalog" to "ApiCatalog" while refining inline comments for clarity and consistency.
- **`src/metadata/collection.c` & `include/metadata/collection.h`**: Removed unused functions for handling staging collections during $out operations.
- **`src/metadata/metadata_cache.c` & `include/metadata/metadata_cache.h`**: Renamed functions and variables from "MongoCatalog" to "ApiCatalog" to standardize internal identifiers.
- **`src/aggregation/bson_aggregation_config_queries.c` & `src/aggregation/bson_aggregation_metadata_queries.c`**: Updated BSON aggregation queries to reference the new API naming.
- **`src/infrastructure/cursor_store.c`**: Enhanced documentation by updating comments and adding a shared memory structure for cursor tracking.
- **`src/metadata/index.c` & `src/index_am/rum.c`**: Applied minor comment corrections and removed outdated TODO notes for clarity.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
There were cases where we would generate a server side nonce that included the '=' character. '=' is a "reserved" character since the response payload schema is "r={},s={},i={}" so during SASL continue, the incoming nonce would not match the nonce from SASL start, for example:
**Client sasl start nonce:** abcdefghijk12345.
**Server generated nonce:** abcdefghijk12345=1
**Client sasl continue nonce:** abcdefghijk12345
**Expected nonce:** abcdefghijk12345=1
This change ensures the generated nonce doesn't include '='
----
#### AI description (iteration 1)
#### PR Classification
Bug fix to ensure the generated nonce never includes '=' characters.
#### PR Summary
This pull request refactors the nonce generation logic to explicitly avoid '=' by introducing a custom random string generator and updates test configurations accordingly.
- `src/auth.rs`: Added `generate_random_string()` using a restricted charset and replaced the old nonce generation method in `handle_sasl_start`.
- `tests/common/mod.rs`: Updated imports and modified the call to `run_server` by specifying `<DocumentDBDataClient>`.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### Does this PR have any customer impact?
Fixes a bug hit in production
### 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
TODO
### Description
1. Fix facet internal error on multiple facet.
2. Fix a minor potential bug on facet where alias name of a facet stage can conflict
3. Adds a faq on how the repro query was achieved
----
#### AI description (iteration 1)
#### PR Classification
Bug fix addressing an internal error in facet query planning.
#### PR Summary
This pull request fixes an internal error ("could not find plan for CTE 'facet_base_0'") by updating the Common Table Expressions (CTE) naming scheme and related query construction in facet aggregation pipelines.
- `oss/pg_documentdb/src/aggregation/bson_aggregation_nested_pipeline.c` now builds CTE names using both stage number and nested pipeline level, and the query creation call is adjusted accordingly.
- Test expectation files under `oss/internal/pg_documentdb_distributed/src/test/regress/expected/` and `pgmongo/src/test/docdb_compat/expected/` are updated to reflect the new CTE naming (e.g. from `facet_base_0` to `facet_base_0_0`).
- Additional test queries and SQL scripts in `oss/internal/pg_documentdb_distributed/src/test/regress/sql/` are added with the corrected CTE names.
- Documentation (`docs/faqs.md`) is updated with refined instructions for debugging queries with prepared statements.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
Related work items: #3741094
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Aggregation operator tests part 1 cleanup for coding guidelines
----
#### AI description (iteration 1)
#### PR Classification
This PR is a test cleanup update that standardizes aggregation operator tests to adhere to coding guidelines.
#### PR Summary
This pull request refactors multiple aggregation tests by updating query formatting, test data, and expected outputs for clarity and consistency.
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Code cleanup and documentation updates to match contribution guidelines
----
#### AI description (iteration 1)
#### PR Classification
This pull request is a code cleanup and documentation update.
#### PR Summary
The updates refine inline comments and documentation across update, error handling, and collation components to improve clarity and consistency, while replacing obsolete Mongo references with DocumentDB terminology. Key changes include:
- **`oss/pg_documentdb/src/update/bson_update_operators.c`**: Revised comments for update operators (e.g., `$currentDate`, `$push`, `$mul`) to clarify behavior and update examples.
- **`oss/pg_documentdb/src/utils/error_utils.c`**: Updated documentation to reference DocumentDB errors instead of Mongo errors.
- **`oss/pg_documentdb/src/update/bson_update.c` and `oss/pg_documentdb/src/update/bson_update_aggregation.c`**: Improved inline comment wording to accurately describe update specifications and error conditions.
- **`oss/pg_documentdb_core/src/collation/collation.c`**: Cleaned up collation conversion comments and locale handling explanations.
- **Test files under `oss/internal/pg_documentdb_distributed/src/test` and `pgmongo/src/test/docdb_compat/expected`**: Updated expected output comments to align with the revised error message tests.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Fix up docs across some files to match contributing guidelines.
----
#### AI description (iteration 1)
#### PR Classification
This PR focuses on documentation improvements and in-code comment cleanup to comply with contributing guidelines.
#### PR Summary
The pull request refines comment texts and error messages across several source files, removes unused code documentation, and updates internal clarifications.
- `oss/pg_documentdb/src/aggregation/bson_aggregates.c`: Removed the unused `BsonOutAggregateState` typedef and updated aggregation comments (e.g., changing "HASHTBL" to "HASHCTL") while eliminating redundant code comments.
- `oss/pg_documentdb/src/commands/create_collection_view.c`: Removed several unused fields from the `CreateSpec` structure and updated header comments to reflect the correct file path.
- `oss/pg_documentdb/src/aggregation/bson_aggregation_pipeline.c`: Revised comment formatting and error messages in aggregation and query generation functions to ensure consistent terminology.
- `oss/pg_documentdb/src/auth/scram256.c` & `oss/pg_documentdb/src/commands/update.c`: Updated documentation comments for authentication responses and update error handling for improved clarity.
- Other files in `/oss/pg_documentdb/src/opclass/` and `/oss/pg_documentdb_core/`: Corrected typographical errors and adjusted error code references to align with the project’s guidelines.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
One NodeJS test cases was failing when running against the rust GW since we were not handling the case where the index is too long.
----
#### AI description (iteration 1)
#### PR Classification
Bug fix addressing error handling during index creation.
#### PR Summary
The pull request improves how over-sized index creation errors are handled by introducing explicit checks and returning a clearer error message.
- In `src/responses/pg.rs`: Added a conditional branch that detects when the error message contains "index row size" and "exceeds maximum" to return a specific error code with the message "Index key is too large."
- In `src/error.rs`: Introduced a new error variant `CannotBuildIndexKeys` with code 201 to support the enhanced error handling.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
3 c files
----
#### AI description (iteration 1)
#### PR Classification
This pull request focuses on code cleanup and documentation updates.
#### PR Summary
The changes standardize and simplify documentation comments and examples across several operator implementations, removing obsolete references and unnecessary details.
- `oss/pg_documentdb/src/aggregation/bson_aggregation_output_pipeline.c`: Updated doc examples for `$merge` and `$out` to use generic placeholders and removed temporary test-related comments.
- `oss/pg_documentdb/src/query/bson_dollar_operators.c`: Cleaned up comments for multiple BSON dollar operators by eliminating "Mongo's" references and redundant test notes.
- `oss/pg_documentdb_core/src/types/pcre_regex.c`: Refined regex compile option comments and removed legacy test reference lines.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
When using mongodb-driver-sync 4.0.6, and performing a query, the namespace in the request looks like "<db>.$cmd" compared to other version where it is "admin.$cmd". To accommodate this version, we just check if the collection name equals $cmd which is similar to what we do in the other Gateway
----
#### AI description (iteration 1)
#### PR Classification
This PR implements an API update and bug fix to correctly handle OP_QUERY messages for Java driver 4.0.6.
#### PR Summary
The pull request refines the query parsing logic by extracting the collection name from the namespace instead of using the full collection path, ensuring that command queries are accurately identified and unsupported queries are logged.
- In `oss/pg_documentdb_gw/src/protocol/reader.rs`, the code now extracts a tuple (_db, collection_name) from the namespace.
- The condition to detect command messages is simplified to check if `collection_name` equals "$cmd".
- An informational log is added to print the collection name when OP_QUERY is unsupported.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### Does this PR have any customer impact?
no
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
parity
### 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
1. Implement unshardCollection command
2. Do the logical separation inside the `process.rs`
Related work items: #4306635
### Does this PR have any customer impact?
yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
feature + 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Finish the work on the query processing logic separation. This pull request is a design and architectural enhancement that finalizes query processing separation in the Rust gateway.
**For more details see the author comment.**
Related work items: #3666511
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Performance
### 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?
Yes
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Currently, each round of the sproc that does create indexes does exactly 1 index build and bails. This means if a single client request queues 4 indexes and the job runs every 2 seconds, it'll take 8 seconds to build all 4 indexes. This is wasteful since we know all 4 indexes up front.
Add a loop to the index build process so that multiple indexes can be built without waiting the 2 seconds.
As part of this, there were a few places allocating in memory contexts that are unstable across executions. Fix this.
Additionally there was a loop that could cause index builds to starve for ~20 mins if it picked the wrong index. Fix this loop too.
Finally, Noticed that the version cache does not cache properly if the Major version is 0. Fix this (which can cause perf regressions in DocumentDB).
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
[OSS] fix 0.104-1 hotfix upgrade scripts
----
#### AI description (iteration 1)
#### PR Classification
Hotfix update to upgrade SQL upgrade scripts correcting version references.
#### PR Summary
This pull request updates SQL upgrade scripts to use the correct UDF and documentdb version numbers.
- In `pgmongo/sql/pgmongo--1.103-0--1.103-1.sql`, the include directive was updated from version 0.105-0 to 0.104-1.
- In `oss/pg_documentdb/sql/documentdb--0.104-0--0.104-1.sql`, the UDF include reference was changed to use version 0.104-1.
- The file `oss/pg_documentdb/sql/documentdb--0.104-0--0.105-0.sql` was moved to `oss/pg_documentdb/sql/documentdb--0.104-1--0.105-0.sql` with no code changes.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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, the API schema
### Are you introducing any new config? If yes, do you have tests with and without them being set?
No
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
1.05
### Description
We are adding support for the Connection Status command, which exists in native Mongo, and allows users to see their authenticated user, authenticated roles, and user privileges. For more information, visit connectionStatus.md.
This PR is the second of three PRs for this feature. The first one added extensible role privileges to our `users_info` command, allowing users to retrieve role privileges with `showPrivileges: true`. This second PR adds a callable `connection_status` command to our API, that utilizes the role privileges. The last PR will add a gateway change that calls this `connection_status` command.
Related work items: #4287246
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
----
#### AI description (iteration 1)
#### PR Classification
Enhancement and bug fix to improve the stability and management of file-based cursors.
#### PR Summary
This pull request refactors and bolsters file-based cursor management by introducing shared memory support, improved cleanup, error handling, and configuration changes. It also adds new API endpoints and logging for better cursor lifecycle control.
- **`cursor_store.c` and related files:** Added shared memory functions (e.g., `FileCursorShmemSize`, `InitializeFileCursorShmem`), cursor count regulation (with `IncrementCursorCount`/`DecrementCursorCount`), and cleanup routines to ensure stable cursor file operations.
- **Test and expected output files:** Updated regression tests and expected outputs to cover scenarios like duplicate cursor creation, cursor deletion limits, and error reporting when the file cursor capacity is reached.
- **API enhancements:** Introduced new UDFs (e.g., `command_delete_cursors`) and tenant client methods for killing and deleting cursors, improving session management.
- **Configuration updates:** Renamed and added GUC parameters (e.g., `MaxAllowedCursorIntermediateFileSizeMB`, `MaxCursorFileCount`, and cursor expiry settings) to control file-based cursor behavior.
- **Logging and metrics improvements:** Enhanced logging in `mdsd_logger.c` to report current cursor counts and related metrics for operational insight.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### Does this PR have any customer impact?
Yes
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Constraint
### 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Change streams does not support rebalancing at the moment
Related work items: #4116549
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
update changelog
----
#### AI description (iteration 1)
#### PR Classification
This pull request is a documentation update focused on revising changelog entries to reflect the latest documentdb release.
#### PR Summary
The changes update two changelog files to record the new release details and feature updates.
- `oss/packaging/debian_files/changelog`: Adjusted the documentdb version to v0.104-0 with updated urgency, revised the bullet list with new features, bug fixes, and performance enhancements, and added a historical section for v0.103-0.
- `oss/CHANGELOG.md`: Updated the documentdb v0.104-0 header from "Unreleased" to a released version with the date June 09, 2025.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Define common interface for all user-related pg queries to be executed as part of the PgDataClient trait
Related work items: #3666511
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Removing unnecessary in/out from bson_update_document which were preset eariler due to older change_stream implementation.
1. For now moving udf to helio_api_internal and same time removing useless in/out params
TODO:
In next release will modify this for oss with updating test and minimal c changes will update --latest files also.
----
#### AI description (iteration 1)
#### PR Classification
This pull request is a code cleanup and update to simplify the integration of the `bson_update_document` function into OSS.
#### PR Summary
The PR introduces a new C-based SQL function for `bson_update_document` with streamlined parameters, updates the main SQL script to include this new file, and refreshes the API schema output to reflect the change.
- `pgmongo/sql/udfs/crud/bson_update_document--1.105-0.sql`: Adds the new function definition with cleaned-up parameter handling.
- `pgmongo/sql/pgmongo--1.104-0--1.105-0.sql`: Updates the script to include the newly added UDF file.
- `pgmongo/src/test/regress/expected/public_api_schema.out`: Modifies the schema output to include the new function entry.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
setting guc enableDataTableWithoutCreationTime to on so that all the new tables will not have creation_time column
----
#### AI description (iteration 1)
#### PR Classification
This pull request is a new feature change that enables omitting the creation_time field from query results.
#### PR Summary
The PR updates the behavior of the system by setting the GUC flag enableDataTableWithoutCreationTime to true, so that output from various commands no longer includes the creation_time column.
- In `configs/feature_flag_configs.c`, the default for enableDataTableWithoutCreationTime is switched to true.
- Expected output files in multiple test folders (`oss/pg_documentdb`, `oss/internal/pg_documentdb_distributed`, and `pgmongo`) have been revised to remove the creation_time field.
- Test SQL scripts have been updated to set the flag as needed, ensuring consistency between the new behavior and test expectations.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
Add support of altrernate index handler in 1.103
### 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
`deleteOne` requires `_id` or shard key value filter. If only `_id` is used, we query for the minimum shard key value and use it.
The querying for that shard key must be able to use the `variableSpec`.
----
#### AI description (iteration 1)
#### PR Classification
API change to enable proper handling of deleteOne commands on sharded collections using only an _id filter by incorporating variable specification support.
#### PR Summary
This pull request enhances deleteOne functionality by integrating a variableSpec (let variable) into query construction for sharded collections, ensuring that _id-only filters are handled correctly. The changes update core command functions, test expectations, and configuration flags to support the new behavior.
- **`commands_common.c`**: Revised the `FindShardKeyValueForDocumentId` function to accept a new variableSpec parameter and conditionally modify the query.
- **`delete.c` and `update.c`**: Updated deletion and update operations to process the variableSpec for write commands.
- **Test and Configuration Files**: Renamed and updated GUC flags (from enableLet... to enableVariablesAndCollationSupportForQueryMatch) and adjusted expected outputs to reflect the new deleteOne behavior.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
----
#### AI description (iteration 1)
#### PR Classification
This pull request implements a new feature that enhances explain plan output and composite index functionality by adding order‑by pushdown and related index option validations.
#### PR Summary
The changes add new metrics in explain plans and strengthen composite index handling for order-by pushdown across the system. Key changes include:
- **`/gateway/managed/Mongo.Service.Postgres/Helpers/PostgresExplainHelper.cs` & `/oss/pg_documentdb_gw/src/explain/mod.rs`** – Added fields like `sortKeysCount`, `sortKey`, `presortedKey(s)`, and `hasOrderBy` to enhance explain output.
- **`/oss/pg_documentdb/src/metadata/index.c` and related index management files** – Implemented improved composite index option checks and support functions such as `CompositeIndexSupportsOrderByPushdown` and equality-range predicate validation.
- **UDF and operator files (e.g., `bson_dollar_comparison--*.sql`, `/oss/pg_documentdb/src/query/bson_dollar_operators.c`)** – Introduced new functions like `bson_dollar_fullscan` to support full scan pushdowns in combination with composite indexes.
- **`/pgmongo_rum/src/rumget.c`** – Enhanced ordered scan handling and duplicate management for multi-key indexes.
- **Pipeline and configuration files (e.g., `.pipelines/templates/single_node_tests.yml`)** – Updated test scripts and experimental configuration parameters to enable the new composite opclass and order‑by pushdown features.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
[DocumentDB issus 178](https://github.com/microsoft/documentdb/issues/178)
When the document size exceeds 2000, the tuple is toasted. We need to detoast the datum before converting it to pgbson.
----
#### AI description (iteration 1)
#### PR Classification
Bug fix addressing improper detoasting of pgbson values.
#### PR Summary
This pull request replaces direct pointer extraction and SPI_datumTransfer calls with dedicated DatumGetPgBson macros to ensure both toasted and non-toasted bson documents are correctly handled. It also enhances test coverage for find-and-modify operations on large documents.
- `commands_find_and_modify.out` and SQL test files: Added new queries for deleting large (toasted) and non-toasted documents.
- `retryable_writes.c`, `delete.c`, metadata, index, and query operator files: Replaced manual SPI_datumTransfer and DatumGetPointer calls with DatumGetPgBson (and DatumGetPgBson_MAYBE_NULL) to properly detoast and copy pgbson objects.
- `pgbson.h` and `bson_io.c`: Introduced and integrated new macros to streamline detoasting of pgbson data.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
### 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?
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
### Description
This change allows us to swap between C# and Rust gateways by setting the pgmongo.use_rust_native_gateway GUC on and off without depending on Flex "outside" restarts and trigger the restart at runtime.
We read the value of the GUC and if it doesn't match the running gateway, we gracefully shut it down. Upon restart by Docker, C# flow will be executed and StartupHost.sh will be executed. Since the GUC, pgmongo.use_rust_native_gateway, will also be set in a config file, and that will mandate the gateway to actually start up.
This change was validated against a dev cluster by setting the GUC on and off
----
#### AI description (iteration 1)
#### PR Classification
This pull request introduces a new mechanism for runtime gateway switching, enabling a graceful shutdown of the C# gateway to transition to a Rust gateway.
#### PR Summary
The changes implement a unified shutdown mechanism that allows the service to detect a configuration flag for using the Rust native gateway and to trigger a graceful shutdown accordingly.
- **`Compute.Host/HostShutdown.cs`**: Added a new static class that provides a shutdown task and trigger method.
- **`Compute.Host/HostServiceContainer.cs`**: Introduced a configuration check for the "use_rust_native_gateway" flag that triggers shutdown via the new mechanism.
- **`Host.Postgres.Linux/PostgresMongoServiceHost.cs`**: Updated shutdown and signal handling to use the new HostShutdown mechanism, replacing the previous ctrl-break task approach.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->