13 Commits
Author SHA1 Message Date
Parag Jain b650a1d1c9 Merged PR 1743315: [Compat] Fixing output pipeline namespace validations
### 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
[Compat] Fixing output pipeline namespace validations

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix and compatibility update.

#### PR Summary
This pull request enforces strict namespace validations for aggregation pipeline output stages by preventing writes to internal databases and system collections. It introduces a dedicated validation function for both $out and $merge stages and integrates new error codes across the codebase and mapping files.
- `oss/pg_documentdb/src/aggregation/bson_aggregation_output_pipeline.c`: Added the `ValidateTargetNameSpaceForOutputStage` function and updated calls in both the $out and $merge handlers.
- `pgmongo/src/utils/documentdb_conversion_codes.c` and `oss/pg_documentdb_core/include/utils/documentdb_errors.h`: Introduced and mapped new error codes for invalid namespace targets.
- Updated multiple error mapping files (`documentdb_errors.csv`, `error_mappings.csv`, `documentdb_codes.txt`, `external_error_mapping.csv`, and `mongo_codes.csv`) and test CSV files under `gateway/managed/Tests.Integration.Shell.Postgres` to reflect the new validations and error messages.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
2025-07-23 15:56:08 +08:00
Juan Carlos Aguilera Mendez 5428e5e4ea Merged PR 1720111: Move error to the correct 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

Move Location13103 error to documentdb_codes.txt

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix: Moving an error code definition to the correct file.

#### PR Summary
This pull request corrects the placement of the "Location13103" error by removing it from one file and adding it into the proper location.
- `pg_documentdb_gw/include/gateway_errors.txt`: Removed the "Location13103" error entry.
- `pg_documentdb_core/include/utils/documentdb_codes.txt`: Added the "Location13103" error entry.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
2025-07-09 18:56:11 +08:00
Vinod Sridharan ccc471e169 Merged PR 1703619: [Cursors] Improve stability of file based cursors
### 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 -->
2025-06-19 14:10:04 +08:00
Shuai Tian 17d4306a28 Merged PR 1422337: [pgmongo] Aggregate stage $bucketAuto implementation
### 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

This pull request adds documentation for the `$bucketAuto` aggregation stage in PostgreSQL, detailing its design, usage, and implementation.
- Adds `bucketAuto.md` with details on the `$bucketAuto` aggregation stage
- code implementation
- support all granularity types: POWERSOF2, 1-2-5, Renard numbers, E series

Related work items: #3234185
2025-06-05 10:31:32 +08:00
Vinod Sridharan c5bbda3241 Merged PR 1668237: [Livesite] Handle default_readonly_transaction more gracefully
### 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?
Yes
### ChangeLog (Refer [Template](../oss/CHANGELOG.md))

### Description

When servers have default_readonly_transaction set, the current behavior is wonky - it will cause failures in underlying queries and pollute the errors, and it will go through a bunch of work only to fail.
Additionally, background jobs like TTL will fail ungracefully.

Handle this GUC by failing write commands early with a more useful error message.
Additionally, in cases like TTL, add an opt-in way to prune rows even in the presence of this GUC if it's opted into.

----
#### AI description  (iteration 1)
#### PR Classification
This pull request is a bug fix that improves error handling for write operations attempted during default read-only transactions.

#### PR Summary
The changes introduce a unified mechanism to check and enforce read-only transaction restrictions, ensuring graceful errors when write operations are attempted while in a read-only state. Key changes include:
- **`include/commands/commands_common.h`**: Added the inline function `ThrowIfServerOrTransactionReadOnly` to validate transaction state and throw appropriate errors.
- **Test files**: New regression tests under `/oss/pg_documentdb/src/test/regress/expected/` and `/oss/pg_documentdb/src/test/regress/sql/readonly_transaction_tests.sql` validate the expected error responses under read-only conditions.
- **`ttl_index.c`**: Modified TTL job logic to handle read-only transactions, allowing jobs to commit and restart when the corresponding flag is enabled.
- **Gateway and error handling**: Updated configuration in `TenantConfigurationBase.cs`, error augmentation in `PostgresMongoResultExtensions.cs`, and error mappings (e.g., adding error code 10107 for `NotWritablePrimary`) to propagate clear error messages.
- **Command modules**: Added calls to `ThrowIfServerOrTransactionReadOnly` in several command implementations (e.g., in `insert.c`, `update.c`, `delete.c`, `create_indexes.c`) to enforce read-only restrictions uniformly.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
2025-05-29 12:12:31 +08:00
Deepak Pemmaraju cdb390d2eb Merged PR 1600780: DataPlane External Identity Provider User CRUD
### 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
New feature

#### PR Summary
This pull request introduces CRUD operations for Entra users in the DataPlane.
- `authentication.c`: Added functions to create users with external identity providers, validate identity provider info, and check if the current user is an Entra admin.
- `users.h`: Added new header file defining user CRUD functions and related structures.
- `users.c`: Updated user creation logic to handle external identity providers and added parsing for custom data.
- `api_hooks.c`: Added hooks for creating users with external identity providers and checking user privileges.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
2025-04-07 11:39:49 +08:00
Cornelius Boateng d4f127106a Merged PR 1574869: [engine][compat] BinData Conversion to/from String
### 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
Support conversion to binData from string and vice versa.
$convert to BinData
```
"$convert": {
   "input": <string>,
   "to": {
      "type": "binData",
      "subtype": <bson_subtype_t>
   },
   "format": <"base64"/"string"/"hex"/"uuid"/"base64url">
}
```

OR
```
--- subtype will default to 0
"$convert": {
   "input": <string>,
   "to": "binData",
   "format": <"base64"/"string"/"hex"/"uuid"/"base64url">
}

```

BinData $toString
```
{ $toString: <binData expression> }
```

----
#### AI description  (iteration 1)
#### PR Classification
New feature

#### PR Summary
This pull request introduces support for converting data to `BinData` using the `$convert` operator.
- `src/operators/bson_expression_type_operators.c`: Added new functions and modified existing ones to handle `BinData` conversion, including `ProcessDollarToBinData`, `GetToTypeAndSubTypeForBinDataConversion`, and `ValidateAndGetBinDataConversionSubTypeAndFormat`.
- Refactored `ParseDollarConvert` and `ApplyDollarConvert` to accommodate the new `BinData` conversion logic.
- Introduced a new struct `ConvertToTypeArguments` to manage conversion arguments.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
2025-04-07 11:39:49 +08:00
Xing Fan 5a8db3494c Merged PR 1614043: [Operator] Support extended $getfield for 8.0
### 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

### ChangeLog (Refer [Template](../oss/CHANGELOG.md))

### Description
Support new syntax of $getField

----
#### AI description  (iteration 1)
#### PR Classification
New feature

#### PR Summary
This pull request adds support for the extended `$getField` operator for version 8.0.
- Added new test file `postgresjs/expression_get_field_80_custom.js` to validate `$getField` operator behavior.
- Updated `bson_expression_object_operators.c` to handle new error codes and validation for `$getField`.
- Modified `bson_aggregation_object_operators_tests.sql` and related expected output files to include new test cases for `$getField`.
- Added new error code mappings in `documentdb_errors.csv` and `error_mappings.csv`.
- Updated `documentdb_codes.txt` and `mongo_codes.csv` to include new error codes.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
2025-03-26 12:19:42 +08:00
Deepak Bisht 58e9029fab Merged PR 1590489: top level let support with $geoNear stage
### 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))
- Support top level let variables in $geoNear stage

### Description
Support top level let variables in $geoNear stage

- Today there are 2 scenarios where `let` is used with $geoNear
1- `top level`: Any `let`  provided in the top level command such as `aggregate`, the variables used in geonear spec should result into a `constant`, so we evaluate and rewrite the geoNear spec before parsing it to replace any expressions/let variables from top level let.
2- `nested let`: This scenario occurs with lookup pipeline and let is a combination of top level let and lookup let, this case is not optimized in this PR and will still return in error

----
#### AI description  (iteration 1)
#### PR Classification
New feature

#### PR Summary
This pull request adds support for top-level `let` expressions within the `$geoNear` stage in aggregation pipelines.
- `oss/pg_documentdb/src/aggregation/bson_aggregation_pipeline.c`: Added logic to handle `let` expressions by updating the `$geoNear` specification if a `CONST let` expression is present in the context.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
2025-03-18 21:57:32 -07:00
Deepak Bisht 8199a49bc4 Merged PR 1576694: Aggregation stages limit pipeline for 1000 stages
### 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?
Yes
`documentdb.aggregation_stages_limit`- sets the max number of pipeline stages allowed in aggregations. (validates even the nested pipelines)

### ChangeLog (Refer [Template](../oss/CHANGELOG.md))
- Limit aggregation stages to 1000

### Description

Limit aggregation stages to 1000 via the GUC introduced.

This limit is enforced in newer server version > 7.1 , making it similar would have needed us to introduce api hooks as document db doesn't have server version. so we went ahead with simple GUC based approach to apply the limit, because this is rare limit to hit

----
#### AI description  (iteration 1)
#### PR Classification
New feature

#### PR Summary
This pull request introduces a limit on the number of aggregation stages in a pipeline to 1000 stages.
- `bson_aggregation_pipeline_private.h`: Added a helper function `CheckMaxAllowedAggregationStages` to enforce the stage limit.
- `bson_aggregation_pipeline.c`: Integrated the stage limit check within the `ExtractAggregationStages` function.
- `system_configs.c`: Defined a new configuration variable `aggregation_stages_limit` to set the maximum allowed stages.
- `bson_aggregation_pipeline_tests.sql` and `bson_aggregation_pipeline_tests.out`: Added tests to verify the stage limit enforcement.
- `documentdb_errors.h` and related error mapping files: Introduced a new error code for exceeding the stage limit.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
2025-02-25 22:09:25 -08:00
Vinod Sridharan 489b3fe819 Merged PR 1557887: Change error file mapping name
### 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
Rename error file mapping

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

#### PR Summary
This pull request updates the name of the error mapping file and adjusts references accordingly.
- `Makefile`: Updated references from `mongoerrors.csv` to `error_mappings.csv`.
- `docs/pgmongo/design_docs/data_plane/backend_common/error_management.md`: Updated documentation to reflect the new file name.
- `src/utils/documentdb_conversion_codes.c`: Updated comment to reference the new file name.
- Moved `oss/mongoerrors.csv` to `oss/error_mappings.csv` without code changes.
2025-01-22 22:24:35 -08:00
Siddhesh Vethe 361c56bd92 Revert "Documentdb sync 2025-01-23 (#6)" (#9)
This reverts commit 451119c809.
2025-01-22 22:21:30 -08:00
451119c809 Documentdb sync 2025-01-23 (#6)
* Merged PR 1557887: Change error file mapping name

### 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
Rename error file mapping

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

#### PR Summary
This pull request updates the name of the error mapping file and adjusts references accordingly.
- `Makefile`: Updated references from `mongoerrors.csv` to `error_mappings.csv`.
- `docs/pgmongo/design_docs/data_plane/backend_common/error_management.md`: Updated documentation to reflect the new file name.
- `src/utils/documentdb_conversion_codes.c`: Updated comment to reference the new file name.
- Moved `oss/mongoerrors.csv` to `oss/error_mappings.csv` without code changes.

* Merged PR 1555452: [OSS] Enable distributed tests in documentdb

### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactoring
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Are you introducing any new config? If yes, do you have tests with and without them being set?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

Enable distributed tests in documentdb, and clean up helio references from documentdb_distributed
Add substitution to make pg_helio_distributed tests work
Add substitution to make pgmongo/helio_compat tests work
Move udfs bson_aggregation_redact to documentdb

----
#### AI description  (iteration 1)
#### PR Classification
New feature

#### PR Summary
This pull request enables distributed tests in DocumentDB by adding a new set of regression tests for BSON aggregation comparison operators.
- Added `bson_aggregation_comparison_operators_tests.out` with extensive test cases for BSON comparison operators (`$cmp`, `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`).

* Merged PR 1555841: [OSS] fix regress sql test workflow

[OSS] fix regress sql test workflow

----
Bug fix for the SQL test workflow.
This pull request fixes the regression in the SQL test workflow by updating the GitHub Actions configuration and related scripts.
- Updated `.github/workflows/regress_tests.yml` to improve the build matrix, install dependencies, and run tests for multiple PostgreSQL versions and Ubuntu versions.
- Modified `scripts/start_oss_server.sh` to correct the help message and default directory.
- Minor cleanup in `scripts/install_setup_pg_cron.sh` to remove an unnecessary blank line.

---------

Co-authored-by: Vinod Sridharan <visridha@microsoft.com>
Co-authored-by: Zinan Ren <zinanren@microsoft.com>
2025-01-22 22:20:31 -08:00