mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 11:49:53 -05:00
### 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)) ### Description On Update with Upsert, convert the final insert to INSERT ON CONFLICT UPDATE This is to handle a race condition where two threads do SELECT for update -> don't find the doc -> one does the insert, and the other will get a unique conflict when it should just succeed. ---- #### AI description (iteration 1) #### PR Classification New feature #### PR Summary This pull request introduces a new feature to handle upserts by converting the final insert to `INSERT ON CONFLICT UPDATE`. - `oss/pg_helio_api/src/commands/insert.c`: Added `InsertOrUpdateDocument` function to handle upserts. - `oss/pg_helio_api/src/commands/update.c`: Updated functions to use `InsertOrUpdateDocument` for upsert operations. - `oss/pg_helio_api/include/commands/insert.h`: Declared the new `InsertOrUpdateDocument` function. - `oss/internal/pg_helio_distributed/src/test/regress/expected/commands_update.out` and `pgmongo/src/test/helio_compat/expected/commands_update.out`: Added tests for the new upsert behavior. - `oss/internal/pg_helio_distributed/src/test/regress/sql/commands_update.sql`: Added SQL tests for upsert functionality.