From 35c99484557157261e8f8b8841e37a6e68e31763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alja=C5=BE=20Mur=20Er=C5=BEen?= Date: Mon, 10 Feb 2025 13:23:46 +0100 Subject: [PATCH] Add default transaction configuration params --- flake.lock | 32 ++++++++++++++++---------------- src/commands/configure.rs | 12 ++++++++++++ src/commands/parser.rs | 26 ++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 16 deletions(-) diff --git a/flake.lock b/flake.lock index b1324731..7e748a45 100644 --- a/flake.lock +++ b/flake.lock @@ -35,11 +35,11 @@ ] }, "locked": { - "lastModified": 1737449923, - "narHash": "sha256-CfhtImn/809qxSduRdx6Zajf9pXLcjmyVicfLq2gSDk=", + "lastModified": 1739189006, + "narHash": "sha256-d79oc7VXVB5rQ2vhtAy9sGHW4vXRvicwsAjm8T1zAXA=", "owner": "edgedb", "repo": "packages-nix", - "rev": "890cec292b06511d138c9c414cd5e0c29ccd7b4f", + "rev": "fe563c974e14282bf8206e720a033dc7ca5521e3", "type": "github" }, "original": { @@ -56,11 +56,11 @@ "rust-analyzer-src": [] }, "locked": { - "lastModified": 1737441112, - "narHash": "sha256-p5yZA8Ckh9x0Uz9toCZeI7egrIzHBeY7LHaZvec/OTY=", + "lastModified": 1739169164, + "narHash": "sha256-2+/6/2rHsMjlrulkrjZbwthCQiQpeW2pukRFaaUMLy8=", "owner": "nix-community", "repo": "fenix", - "rev": "1a79901b0e37ca189944e24d9601c8426675de50", + "rev": "d7616af878cd0cb7f940b470440347920395be0c", "type": "github" }, "original": { @@ -74,11 +74,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1736143030, - "narHash": "sha256-+hu54pAoLDEZT9pjHlqL9DNzWz0NbUn8NEAHP7PQPzU=", + "lastModified": 1738453229, + "narHash": "sha256-7H9XgNiGLKN1G1CgRh0vUL4AheZSYzPm+zmZ7vxbJdo=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "b905f6fc23a9051a6e1b741e1438dbfc0634c6de", + "rev": "32ea77a06711b758da0ad9bd6a844c5740a87abd", "type": "github" }, "original": { @@ -89,11 +89,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1737449478, - "narHash": "sha256-gunDQgOtt8PIaHEG0yxuqt6xPHFTXkXz1auimBuroaQ=", + "lastModified": 1739188797, + "narHash": "sha256-3B9J+YAVkj90jEtkGOWM84KrFN9jPcDsmoQDyxTOVxU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "f7553c07e7db51e433a977230373e4857c8e876c", + "rev": "0fe418f71717754bd9a57956ee54d5d437c9479e", "type": "github" }, "original": { @@ -104,14 +104,14 @@ }, "nixpkgs-lib": { "locked": { - "lastModified": 1735774519, - "narHash": "sha256-CewEm1o2eVAnoqb6Ml+Qi9Gg/EfNAxbRx1lANGVyoLI=", + "lastModified": 1738452942, + "narHash": "sha256-vJzFZGaCpnmo7I6i416HaBLpC+hvcURh/BQwROcGIp8=", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/e9b51731911566bbf7e4895475a87fe06961de0b.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz" }, "original": { "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/e9b51731911566bbf7e4895475a87fe06961de0b.tar.gz" + "url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz" } }, "root": { diff --git a/src/commands/configure.rs b/src/commands/configure.rs index d644112b..08c17dbf 100644 --- a/src/commands/configure.rs +++ b/src/commands/configure.rs @@ -115,6 +115,15 @@ pub async fn configure( C::Set(Set { parameter: S::DefaultStatisticsTarget(ConfigStr { value }), }) => set(cli, "default_statistics_target", None, value).await, + C::Set(Set { + parameter: S::DefaultTransactionIsolation(ConfigStr { value }), + }) => set(cli, "default_transcation_isolation", None, value).await, + C::Set(Set { + parameter: S::DefaultTransactionDeferrable(ConfigStr { value }), + }) => set(cli, "default_transaction_deferrable", None, value).await, + C::Set(Set { + parameter: S::DefaultTransactionAccessMode(ConfigStr { value }), + }) => set(cli, "default_transaction_access_mode", None, value).await, C::Set(Set { parameter: S::EffectiveIoConcurrency(ConfigStr { value }), }) => set(cli, "effective_io_concurrency", None, value).await, @@ -223,6 +232,9 @@ pub async fn configure( C::MaintenanceWorkMem => "maintenance_work_mem", C::EffectiveCacheSize => "effective_cache_size", C::DefaultStatisticsTarget => "default_statistics_target", + C::DefaultTransactionAccessMode => "default_transaction_access_mode", + C::DefaultTransactionDeferrable => "default_transaction_deferrable", + C::DefaultTransactionIsolation => "default_transaction_isolation", C::EffectiveIoConcurrency => "effective_io_concurrency", C::SessionIdleTimeout => "session_idle_timeout", C::SessionIdleTransactionTimeout => "session_idle_transaction_timeout", diff --git a/src/commands/parser.rs b/src/commands/parser.rs index 78c66155..d89b57b5 100644 --- a/src/commands/parser.rs +++ b/src/commands/parser.rs @@ -547,6 +547,26 @@ pub enum ValueParameter { /// Corresponds to the PostgreSQL configuration parameter of the same name. DefaultStatisticsTarget(ConfigStr), + /// Controls the default isolation level of each new transaction, + /// including implicit transactions. Defaults to `Serializable`. + /// Note that changing this to a lower isolation level implies + /// that the transactions are also read-only by default regardless + /// of the value of the `default_transaction_access_mode` setting. + DefaultTransactionIsolation(ConfigStr), + + /// Controls the default deferrable status of each new transaction. + /// It currently has no effect on read-write transactions or those + /// operating at isolation levels lower than `Serializable`. + /// The default is `NotDeferrable`. + DefaultTransactionDeferrable(ConfigStr), + + // Controls the default read-only status of each new transaction, + // including implicit transactions. Defaults to `ReadWrite`. + // Note that if `default_transaction_isolation` is set to any value + // other than Serializable this parameter is implied to be + // `ReadOnly` regardless of the actual value. + DefaultTransactionAccessMode(ConfigStr), + /// Sets the number of concurrent disk I/O operations that PostgreSQL /// expects can be executed simultaneously. /// @@ -642,6 +662,12 @@ pub enum ConfigParameter { /// Reset PostgreSQL configuration parameter of the same name DefaultStatisticsTarget, /// Reset PostgreSQL configuration parameter of the same name + DefaultTransactionIsolation, + /// Reset PostgreSQL configuration parameter of the same name + DefaultTransactionDeferrable, + /// Reset PostgreSQL configuration parameter of the same name + DefaultTransactionAccessMode, + /// Reset PostgreSQL configuration parameter of the same name EffectiveIoConcurrency, /// Reset session idle timeout SessionIdleTimeout,