mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 11:49:53 -05:00
### 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 source files under new directory. ---- #### AI description (iteration 1) #### PR Classification Code reorganization #### PR Summary This pull request moves the `helio_api` and `helio_distributed` sources under the `documentdb` directory, updating references and initialization logic accordingly. - Added `pg_documentdb.c` for initializing the `pg_documentdb` extension. - Added `documentdb_distributed.c` for initializing the `pg_documentdb_distributed` extension. - Updated `validate_helio_extension_state.sh` to include new checks for `documentdb`. - Moved `helio_api_extension_version.c` to `documentdb_extension_version.c` without code changes. - Updated various `Makefile` configurations to reflect the new directory structure and dependencies.
95 lines
2.2 KiB
C
95 lines
2.2 KiB
C
/*-------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
*
|
|
* include/commands/update.h
|
|
*
|
|
* Exports related to implementation of a single-document update.
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef UPDATE_H
|
|
#define UPDATE_H
|
|
|
|
#include <postgres.h>
|
|
|
|
#include "metadata/collection.h"
|
|
#include "operators/bson_expr_eval.h"
|
|
|
|
|
|
/*
|
|
* UpdateReturnValue specifies whether an update should return
|
|
* no document, the old document, or the new document.
|
|
*/
|
|
typedef enum
|
|
{
|
|
UPDATE_RETURNS_NONE,
|
|
UPDATE_RETURNS_OLD,
|
|
UPDATE_RETURNS_NEW
|
|
} UpdateReturnValue;
|
|
|
|
/*
|
|
* UpdateOneParams describes update operation for a single document.
|
|
*/
|
|
typedef struct
|
|
{
|
|
/* update only documents matching this query */
|
|
pgbson *query;
|
|
|
|
/* apply this update */
|
|
pgbson *update;
|
|
|
|
/* whether to use upsert if no documents match */
|
|
int isUpsert;
|
|
|
|
/* sort order to use when selecting 1 row */
|
|
pgbson *sort;
|
|
|
|
/* whether to return a document */
|
|
UpdateReturnValue returnDocument;
|
|
|
|
/* fields to return if returning a document */
|
|
pgbson *returnFields;
|
|
|
|
/* array filters specified in the update */
|
|
pgbson *arrayFilters;
|
|
|
|
/* whether to bypass document validation */
|
|
bool bypassDocumentValidation;
|
|
} UpdateOneParams;
|
|
|
|
|
|
/*
|
|
* UpdateOneResult reflects the result of a single-row update
|
|
* on a single shard, which may be a delete.
|
|
*/
|
|
typedef struct
|
|
{
|
|
/* whether one row matched the query and was updated */
|
|
bool isRowUpdated;
|
|
|
|
/* whether we found a document but it was not affected by the update spec */
|
|
bool updateSkipped;
|
|
|
|
/* update result came from a retry record */
|
|
bool isRetry;
|
|
|
|
/* shard key value changed, reinsertDocument document needs to be inserted */
|
|
pgbson *reinsertDocument;
|
|
|
|
/*
|
|
* Value of the (maybe projected) original or new document, if requested
|
|
* and matched any.
|
|
*/
|
|
pgbson *resultDocument;
|
|
|
|
/* upserted document ID */
|
|
pgbson *upsertedObjectId;
|
|
} UpdateOneResult;
|
|
|
|
|
|
void UpdateOne(MongoCollection *collection, UpdateOneParams *updateOneParams,
|
|
int64 shardKeyHash, text *transactionId, UpdateOneResult *result,
|
|
bool forceInlineWrites, ExprEvalState *state);
|
|
|
|
#endif
|