From 4f4ae9b976e6db4e65b0d0b4986063c2a8463a8a Mon Sep 17 00:00:00 2001 From: jkaczman Date: Thu, 17 Sep 2026 06:10:43 -0400 Subject: [PATCH 1/2] Re-writes for transaction start time. New config key. --- docs/configuration/pgdog.toml/rewrite.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/configuration/pgdog.toml/rewrite.md b/docs/configuration/pgdog.toml/rewrite.md index 45352c76..9b029aa5 100644 --- a/docs/configuration/pgdog.toml/rewrite.md +++ b/docs/configuration/pgdog.toml/rewrite.md @@ -22,7 +22,7 @@ The `rewrite` section controls PgDog's automatic SQL rewrites for sharded databa shardKey: "error" splitInserts: "error" primaryKey: "ignore" - omniNonDeterministicFunctions: "ignore" + nonDeterministicFunctions: "ignore" ``` | Setting | Description | Default | @@ -31,7 +31,7 @@ The `rewrite` section controls PgDog's automatic SQL rewrites for sharded databa | `shard_key` | Behavior when an `UPDATE` changes a sharding key: `error` rejects the statement,
`rewrite` migrates the row between shards,
`ignore` forwards it unchanged. | `"error"` | | `split_inserts` | Behavior when a sharded table receives a multi-row `INSERT`: `error` rejects the statement, `rewrite` fans the rows out to their shards, `ignore` forwards it unchanged. | `"error"` | | `primary_key` | Behavior when an `INSERT` is missing a `BIGINT` primary key: `error` rejects the statement,
`rewrite` auto-injects `pgdog.unique_id()` for missing keys,
`ignore` allows the INSERT without modification. | `"ignore"` | -| `omni_non_deterministic_functions` | Behavior when an `INSERT` is headed to an omnisharded table using a function (such as date-time functions) that will not be consistent when performing the functions separately on each shard. Thus, it re-writes all such functions before performing the `INSERT` with constant values to maintain consistency. Example: `NOW()` is re-written to `2026-09-15 18:14:09.123456-05` (or whatever the current time is) before performing the individual `INSERT` operations. This applies to both `DEFAULT` table schema and functions called within a VALUES list of an `INSERT`. `ignore` allows the `INSERT` without modification. | `"ignore"` | +| `non_deterministic_functions` | Behavior when an `INSERT` is headed to an omnisharded table using a function (such as date-time functions) that will not be consistent when performing the functions separately on each shard. Thus, it re-writes all such functions before performing the `INSERT` with constant values to maintain consistency. It also handles re-writing `NOW()` (and other funtions that rely on transaction start time) to be consistent within a transaction. This is especially important when we write such a function to multiple Shards in a singular transaction. Example: `NOW()` is re-written to `2026-09-15 18:14:09.123456-05` (or whatever the current time is) before performing the individual `INSERT` operations. This applies to both `DEFAULT` table schema and functions called within a VALUES list of an `INSERT`. `ignore` allows the `INSERT` without modification. | `"ignore"` | !!! note "Two-phase commit" Consider enabling [two-phase commit](../../features/sharding/2pc/index.md) when either feature is set to `rewrite`. Without it, rewrites are committed shard-by-shard and can leave partial changes if a transaction fails. From 7fe6e18ac257ce3688f57795975dbb841a318976 Mon Sep 17 00:00:00 2001 From: John Kaczman Date: Thu, 17 Sep 2026 06:15:15 -0400 Subject: [PATCH 2/2] Update docs/configuration/pgdog.toml/rewrite.md Co-authored-by: Lev Kokotov --- docs/configuration/pgdog.toml/rewrite.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration/pgdog.toml/rewrite.md b/docs/configuration/pgdog.toml/rewrite.md index 9b029aa5..50aa4419 100644 --- a/docs/configuration/pgdog.toml/rewrite.md +++ b/docs/configuration/pgdog.toml/rewrite.md @@ -31,7 +31,7 @@ The `rewrite` section controls PgDog's automatic SQL rewrites for sharded databa | `shard_key` | Behavior when an `UPDATE` changes a sharding key: `error` rejects the statement,
`rewrite` migrates the row between shards,
`ignore` forwards it unchanged. | `"error"` | | `split_inserts` | Behavior when a sharded table receives a multi-row `INSERT`: `error` rejects the statement, `rewrite` fans the rows out to their shards, `ignore` forwards it unchanged. | `"error"` | | `primary_key` | Behavior when an `INSERT` is missing a `BIGINT` primary key: `error` rejects the statement,
`rewrite` auto-injects `pgdog.unique_id()` for missing keys,
`ignore` allows the INSERT without modification. | `"ignore"` | -| `non_deterministic_functions` | Behavior when an `INSERT` is headed to an omnisharded table using a function (such as date-time functions) that will not be consistent when performing the functions separately on each shard. Thus, it re-writes all such functions before performing the `INSERT` with constant values to maintain consistency. It also handles re-writing `NOW()` (and other funtions that rely on transaction start time) to be consistent within a transaction. This is especially important when we write such a function to multiple Shards in a singular transaction. Example: `NOW()` is re-written to `2026-09-15 18:14:09.123456-05` (or whatever the current time is) before performing the individual `INSERT` operations. This applies to both `DEFAULT` table schema and functions called within a VALUES list of an `INSERT`. `ignore` allows the `INSERT` without modification. | `"ignore"` | +| `non_deterministic_functions` | Behavior when an `INSERT` is headed to an omnisharded table using a function (such as date-time functions) that will not be consistent when performing the functions separately on each shard. Thus, it re-writes all such functions before performing the `INSERT` with constant values to maintain consistency. It also handles re-writing `NOW()` (and other functions that rely on transaction start time) to be consistent within a transaction. This is especially important when we write such a function to multiple shards in a singular transaction. Example: `NOW()` is re-written to `2026-09-15 18:14:09.123456-05` (or whatever the current time is) before performing the individual `INSERT` operations. This applies to both `DEFAULT` table schema and functions called within a VALUES list of an `INSERT`. `ignore` allows the `INSERT` without modification. | `"ignore"` | !!! note "Two-phase commit" Consider enabling [two-phase commit](../../features/sharding/2pc/index.md) when either feature is set to `rewrite`. Without it, rewrites are committed shard-by-shard and can leave partial changes if a transaction fails.