Repository: GoogleCloudPlatform/pgadapter
Pull request #307 (2022-08-01 19:58:02)

feat: support pg_settings table as CTE
Automatically adds a Common Table Expression to queries that use the `pg_settings` table. This table contains the current session state for a connection, and therefore require context information that is only available in the client at this time. The client provides this information by adding it to the CTE that is generated. The CTE is then combined with the fixed values that are stored in `pg_catalog.pg_settings`. The values coming from the client take precedence above the values in `pg_catalog.pg_settings`, as these can be modified by `set setting_name to 'setting_value'`.

This means that for the following query:

```sql
select * from pg_settings
```

The query will be modified to include the following:

```sql
pg_settings_inmem_ as (
select 'DateStyle' as name, 'ISO, MDY' as setting, null as unit, 'Client Connection Defaults / Locale and Formatting' as category, null as short_desc, null as extra_desc, 'user' as context, 'string' as vartype, null as min_val, null as max_val, null::text[] as enumvals, 'ISO, MDY' as boot_val, 'ISO, MDY' as reset_val, 'configuration file' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart
union all
select 'TimeZone' as name, 'Europe/Berlin' as setting, null as unit, 'Client Connection Defaults / Locale and Formatting' as category, null as short_desc, null as extra_desc, 'user' as context, 'string' as vartype, null as min_val, null as max_val, null::text[] as enumvals, 'GMT' as boot_val, 'Europe/Berlin' as reset_val, 'configuration file' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart
union all
select 'application_name' as name, null as setting, null as unit, 'Reporting and Logging / What to Log' as category, null as short_desc, null as extra_desc, 'user' as context, 'string' as vartype, null as min_val, null as max_val, null::text[] as enumvals, '' as boot_val, null as reset_val, 'client' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart
union all
select 'bytea_output' as name, 'hex' as setting, null as unit, 'Client Connection Defaults / Statement Behavior' as category, null as short_desc, null as extra_desc, 'user' as context, 'enum' as vartype, null as min_val, null as max_val, '{"escape", "hex"}'::text[] as enumvals, 'hex' as boot_val, 'hex' as reset_val, 'default' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart
union all
select 'default_transaction_isolation' as name, 'serializable' as setting, null as unit, 'Client Connection Defaults / Statement Behavior' as category, null as short_desc, null as extra_desc, 'user' as context, 'enum' as vartype, null as min_val, null as max_val, '{"serializable", "repeatable read", "read committed", "read uncommitted"}'::text[] as enumvals, 'serializable' as boot_val, 'serializable' as reset_val, 'default' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart
union all
select 'default_transaction_read_only' as name, 'off' as setting, null as unit, 'Client Connection Defaults / Statement Behavior' as category, null as short_desc, null as extra_desc, 'user' as context, 'bool' as vartype, null as min_val, null as max_val, null::text[] as enumvals, 'off' as boot_val, 'off' as reset_val, 'default' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart
union all
select 'extra_float_digits' as name, '1' as setting, null as unit, 'Client Connection Defaults / Locale and Formatting' as category, null as short_desc, null as extra_desc, 'user' as context, 'integer' as vartype, '-15' as min_val, '3' as max_val, null::text[] as enumvals, '1' as boot_val, '1' as reset_val, 'default' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart
union all
select 'max_connections' as name, '100' as setting, null as unit, 'Connections and Authentication / Connection Settings' as category, null as short_desc, null as extra_desc, 'postmaster' as context, 'integer' as vartype, '1' as min_val, '262143' as max_val, null::text[] as enumvals, '100' as boot_val, '100' as reset_val, 'configuration file' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart
union all
select 'max_index_keys' as name, '16' as setting, null as unit, 'Preset Options' as category, null as short_desc, null as extra_desc, 'internal' as context, 'integer' as vartype, '16' as min_val, '16' as max_val, null::text[] as enumvals, '16' as boot_val, '16' as reset_val, 'default' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart
union all
select 'port' as name, '5432' as setting, null as unit, 'Connections and Authentication / Connection Settings' as category, null as short_desc, null as extra_desc, 'postmaster' as context, 'integer' as vartype, '1' as min_val, '65535' as max_val, null::text[] as enumvals, '5432' as boot_val, '5432' as reset_val, 'configuration file' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart
union all
select 'search_path' as name, 'public' as setting, null as unit, 'Client Connection Defaults / Statement Behavior' as category, null as short_desc, null as extra_desc, 'user' as context, 'string' as vartype, null as min_val, null as max_val, null::text[] as enumvals, 'public' as boot_val, 'public' as reset_val, 'default' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart
union all
select 'server_version' as name, null as setting, null as unit, 'Preset Options' as category, null as short_desc, null as extra_desc, 'internal' as context, 'string' as vartype, null as min_val, null as max_val, null::text[] as enumvals, '14.1 (Debian 14.1-1.pgdg110+1)' as boot_val, '14.1 (Debian 14.1-1.pgdg110+1)' as reset_val, 'default' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart
union all
select 'server_version_num' as name, '140001' as setting, null as unit, 'Preset Options' as category, null as short_desc, null as extra_desc, 'internal' as context, 'integer' as vartype, '140001' as min_val, '140001' as max_val, null::text[] as enumvals, '140001' as boot_val, '140001' as reset_val, 'default' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart
union all
select 'transaction_isolation' as name, 'serializable' as setting, null as unit, 'Client Connection Defaults / Statement Behavior' as category, null as short_desc, null as extra_desc, 'user' as context, 'enum' as vartype, null as min_val, null as max_val, '{"serializable", "repeatable read", "read committed", "read uncommitted"}'::text[] as enumvals, 'serializable' as boot_val, 'serializable' as reset_val, 'override' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart
union all
select 'transaction_read_only' as name, 'off' as setting, null as unit, 'Client Connection Defaults / Statement Behavior' as category, null as short_desc, null as extra_desc, 'user' as context, 'bool' as vartype, null as min_val, null as max_val, null::text[] as enumvals, 'off' as boot_val, 'off' as reset_val, 'override' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart
),
pg_settings_names_ as (
select name from pg_settings_inmem
union
select name from pg_catalog.pg_settings
),
pg_settings as (
select n.name, coalesce(s1.setting, s2.setting) as setting,coalesce(s1.unit, s2.unit) as unit,coalesce(s1.category, s2.category) as category,coalesce(s1.short_desc, s2.short_desc) as short_desc,coalesce(s1.extra_desc, s2.extra_desc) as extra_desc,coalesce(s1.context, s2.context) as context,coalesce(s1.vartype, s2.vartype) as vartype,coalesce(s1.source, s2.source) as source,coalesce(s1.min_val, s2.min_val) as min_val,coalesce(s1.max_val, s2.max_val) as max_val,coalesce(s1.enumvals, s2.enumvals) as enumvals,coalesce(s1.boot_val, s2.boot_val) as boot_val,coalesce(s1.reset_val, s2.reset_val) as reset_val,coalesce(s1.sourcefile, s2.sourcefile) as sourcefile,coalesce(s1.sourceline, s2.sourceline) as sourceline,coalesce(s1.pending_restart, s2.pending_restart) as pending_restart
from pg_settings_names n
left join pg_settings_inmem s1 using (name)
left join pg_catalog.pg_settings s2 using (name)
order by name
)
select * from pg_settings
```

codecov[bot]: # [Codecov](https://codecov.io/gh/GoogleCloudPlatform/pgadapter/pull/307?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GoogleCloudPlatform) Report
> :exclamation: No coverage uploaded for pull request base (`session-state@eb5763e`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GoogleCloudPlatform#section-missing-base-commit).
> The diff coverage is `n/a`.

```diff
@@               Coverage Diff                @@
##             session-state     #307   +/-   ##
================================================
  Coverage                 ?   82.94%           
  Complexity               ?     1432           
================================================
  Files                    ?      109           
  Lines                    ?     4989           
  Branches                 ?      641           
================================================
  Hits                     ?     4138           
  Misses                   ?      635           
  Partials                 ?      216           
```

| Flag | Coverage Δ | |
|---|---|---|
| all_tests | `82.94% <0.00%> (?)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GoogleCloudPlatform#carryforward-flags-in-the-pull-request-comment) to find out more.


Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GoogleCloudPlatform).


Patch:
diff --git a/src/main/java/com/google/cloud/spanner/pgadapter/metadata/OptionsMetadata.java b/src/main/java/com/google/cloud/spanner/pgadapter/metadata/OptionsMetadata.java
index c051ee40..73948eb1 100644
--- a/src/main/java/com/google/cloud/spanner/pgadapter/metadata/OptionsMetadata.java
+++ b/src/main/java/com/google/cloud/spanner/pgadapter/metadata/OptionsMetadata.java
@@ -775,6 +775,26 @@ public class OptionsMetadata {
     return serverVersion;
   }
 
+  public String getServerVersionNum() {
+    String[] components = serverVersion.split("\\.");
+    if (components.length >= 2) {
+      int major = tryParseInt(components[0]);
+      int minor = tryParseInt(components[1]);
+      if (major > -1 && minor > -1) {
+        return String.valueOf(major * 10000 + minor);
+      }
+    }
+    return serverVersion;
+  }
+
+  private static int tryParseInt(String value) {
+    try {
+      return Integer.parseInt(value);
+    } catch (NumberFormatException ignore) {
+      return -1;
+    }
+  }
+
   /** Returns true if the OS is Windows. */
   public boolean isWindows() {
     return osName.toLowerCase().startsWith("windows");
diff --git a/src/main/java/com/google/cloud/spanner/pgadapter/session/PGSetting.java b/src/main/java/com/google/cloud/spanner/pgadapter/session/PGSetting.java
index c4abe862..48e21f56 100644
--- a/src/main/java/com/google/cloud/spanner/pgadapter/session/PGSetting.java
+++ b/src/main/java/com/google/cloud/spanner/pgadapter/session/PGSetting.java
@@ -25,6 +25,7 @@ import com.google.common.collect.Iterables;
 import java.util.Arrays;
 import java.util.Objects;
 import java.util.Scanner;
+import java.util.stream.Collectors;
 import javax.annotation.Nonnull;
 
 /** Represents a row in the pg_settings table. */
@@ -47,6 +48,26 @@ public class PGSetting {
   private static final int SOURCEFILE_INDEX = 14;
   private static final int SOURCELINE_INDEX = 15;
   private static final int PENDING_RESTART_INDEX = 16;
+  /** The column names of the pg_settings table. */
+  private static final ImmutableList<String> COLUMN_NAMES =
+      ImmutableList.of(
+          "name",
+          "setting",
+          "unit",
+          "category",
+          "short_desc",
+          "extra_desc",
+          "context",
+          "vartype",
+          "source",
+          "min_val",
+          "max_val",
+          "enumvals",
+          "boot_val",
+          "reset_val",
+          "sourcefile",
+          "sourceline",
+          "pending_restart");
 
   private final String extension;
   private final String name;
@@ -178,6 +199,7 @@ public class PGSetting {
     this.pendingRestart = pendingRestart;
   }
 
+  /** Returns a copy of this {@link PGSetting}. */
   PGSetting copy() {
     return new PGSetting(
         extension,
@@ -200,7 +222,86 @@ public class PGSetting {
         pendingRestart);
   }
 
-  public String getKey() {
+  /** Returns this setting as a SELECT statement that can be used in a query or CTE. */
+  String getSelectStatement() {
+    return "select "
+        + toSelectExpression(getCasePreservingKey())
+        + " as name, "
+        + toSelectExpression(setting)
+        + " as setting, "
+        + toSelectExpression(unit)
+        + " as unit, "
+        + toSelectExpression(category)
+        + " as category, "
+        + toSelectExpression((String) null)
+        + " as short_desc, "
+        + toSelectExpression((String) null)
+        + " as extra_desc, "
+        + toSelectExpression(context)
+        + " as context, "
+        + toSelectExpression(vartype)
+        + " as vartype, "
+        + toSelectExpression(minVal)
+        + " as min_val, "
+        + toSelectExpression(maxVal)
+        + " as max_val, "
+        + toSelectExpression(enumVals)
+        + " as enumvals, "
+        + toSelectExpression(bootVal)
+        + " as boot_val, "
+        + toSelectExpression(resetVal)
+        + " as reset_val, "
+        + toSelectExpression(source)
+        + " as source, "
+        + toSelectExpression((String) null)
+        + " as sourcefile, "
+        + toSelectExpression((Integer) null)
+        + "::bigint as sourceline, "
+        + toSelectExpression(pendingRestart)
+        + "::boolean as pending_restart";
+  }
+
+  /** Returns the column names of the pg_settings table. */
+  static ImmutableList<String> getColumnNames() {
+    return COLUMN_NAMES;
+  }
+
+  /** Converts a string to a SQL literal expression that can be used in a select statement. */
+  String toSelectExpression(String value) {
+    return value == null ? "null" : "'" + value + "'";
+  }
+
+  /**
+   * Converts a string array to a SQL literal expression that can be used in a select statement. The
+   * expression is cast to text[].
+   */
+  String toSelectExpression(String[] value) {
+    return value == null
+        ? "null::text[]"
+        : "'{"
+            + Arrays.stream(value)
+                .map(s -> s.startsWith("\"") ? s : "\"" + s + "\"")
+                .collect(Collectors.joining(", "))
+            + "}'::text[]";
+  }
+
+  /** Converts an Integer to a SQL literal expression that can be used in a select statement. */
+  String toSelectExpression(Integer value) {
+    return value == null ? "null" : value.toString();
+  }
+
+  /** Converts a Boolean to a SQL literal expression that can be used in a select statement. */
+  String toSelectExpression(Boolean value) {
+    return value == null ? "null" : (value ? "'t'" : "'f'");
+  }
+
+  /**
+   * Returns the case-preserving key of this setting. Some settings have a key that is written in
+   * camel case (e.g. 'DateStyle') instead of snake case (e.g. 'server_version'). This key should
+   * not be used to look up a setting in the session state map, but should be used in for example
+   * the pg_settings table.
+   */
+  public String getCasePreservingKey() {
     if (extension == null) {
       return name;
     }
@@ -225,6 +326,12 @@ public class PGSetting {
     this.setting = value;
   }
 
+  /** Initializes the value of the setting at connection startup. */
+  void initConnectionValue(String value) {
+    setSetting(value);
+    this.resetVal = value;
+  }
+
   /**
    * Sets the value for this setting. Throws {@link SpannerException} if the value is not valid, or
    * if the setting is not settable.
@@ -247,7 +354,7 @@ public class PGSetting {
 
   private void checkValidContext() {
     if (!isSettable()) {
-      throw invalidContextError(getKey(), this.context);
+      throw invalidContextError(getCasePreservingKey(), this.context);
     }
   }
 
@@ -277,22 +384,22 @@ public class PGSetting {
       try {
         BooleanParser.toBoolean(value);
       } catch (IllegalArgumentException exception) {
-        throw invalidBoolError(getKey());
+        throw invalidBoolError(getCasePreservingKey());
       }
     } else if ("integer".equals(this.vartype)) {
       try {
         Integer.parseInt(value);
       } catch (NumberFormatException exception) {
-        throw invalidValueError(getKey(), value);
+        throw invalidValueError(getCasePreservingKey(), value);
       }
     } else if ("real".equals(this.vartype)) {
       try {
         Double.parseDouble(value);
       } catch (NumberFormatException exception) {
-        throw invalidValueError(getKey(), value);
+        throw invalidValueError(getCasePreservingKey(), value);
       }
     } else if (enumVals != null && !Iterables.contains(Arrays.asList(this.enumVals), value)) {
-      throw invalidValueError(getKey(), value);
+      throw invalidValueError(getCasePreservingKey(), value);
     }
   }
 
diff --git a/src/main/java/com/google/cloud/spanner/pgadapter/session/SessionState.java b/src/main/java/com/google/cloud/spanner/pgadapter/session/SessionState.java
index 4b226d6e..1d232403 100644
--- a/src/main/java/com/google/cloud/spanner/pgadapter/session/SessionState.java
+++ b/src/main/java/com/google/cloud/spanner/pgadapter/session/SessionState.java
@@ -18,7 +18,11 @@ import com.google.api.core.InternalApi;
 import com.google.cloud.spanner.ErrorCode;
 import com.google.cloud.spanner.SpannerException;
 import com.google.cloud.spanner.SpannerExceptionFactory;
+import com.google.cloud.spanner.Statement;
+import com.google.cloud.spanner.Value;
+import com.google.cloud.spanner.connection.AbstractStatementParser.ParsedStatement;
 import com.google.cloud.spanner.pgadapter.metadata.OptionsMetadata;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -27,12 +31,37 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Objects;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 /** {@link SessionState} contains all session variables for a connection. */
 @InternalApi
 public class SessionState {
+  /**
+   * This set contains the settings that show up in the pg_settings CTE. Not all settings are
+   * included in the CTE because Cloud Spanner has a limit of max 60 union all clauses in a
+   * sub-select.
+   */
+  private static final ImmutableSet<String> SUPPORTED_PG_SETTINGS_KEYS =
+      ImmutableSet.of(
+          "application_name",
+          "bytea_output",
+          "DateStyle",
+          "default_transaction_isolation",
+          "default_transaction_read_only",
+          "extra_float_digits",
+          "max_connections",
+          "max_index_keys",
+          "port",
+          "search_path",
+          "server_version",
+          "server_version_num",
+          "TimeZone",
+          "transaction_isolation",
+          "transaction_read_only");
+
   private static final Map<String, PGSetting> SERVER_SETTINGS = new HashMap<>();
 
   static {
@@ -49,8 +78,96 @@ public class SessionState {
   private Map<String, PGSetting> localSettings;
 
   public SessionState(OptionsMetadata options) {
-    this.settings = new HashMap<>(SERVER_SETTINGS);
+    this.settings = new HashMap<>(SERVER_SETTINGS.size());
+    for (Entry<String, PGSetting> entry : SERVER_SETTINGS.entrySet()) {
+      this.settings.put(entry.getKey(), entry.getValue().copy());
+    }
     this.settings.get("server_version").initSettingValue(options.getServerVersion());
+    this.settings.get("server_version_num").initSettingValue(options.getServerVersionNum());
+  }
+
+  /**
+   * Potentially add any session state to the given statement if that is needed. This can for
+   * example include a CTE for pg_settings, if the statement references that table. This method can
+   * be extended in the future to include CTEs for more tables that require session state, or that
+   * are not yet supported in pg_catalog.
+   */
+  public Statement addSessionState(ParsedStatement parsedStatement, Statement statement) {
+    if (parsedStatement.isQuery()
+        && parsedStatement.getSqlWithoutComments().contains("pg_settings")) {
+      String pgSettingsCte = generatePGSettingsCte();
+      // Check whether we can safely use the original SQL statement.
+      String sql =
+          startsWithIgnoreCase(statement.getSql(), "select")
+                  || startsWithIgnoreCase(statement.getSql(), "with")
+              ? statement.getSql()
+              : parsedStatement.getSqlWithoutComments();
+      Statement.Builder builder = null;
+      if (startsWithIgnoreCase(sql, "select")) {
+        builder = Statement.newBuilder("with ").append(pgSettingsCte).append(" ").append(sql);
+      } else if (startsWithIgnoreCase(sql, "with")) {
+        builder =
+            Statement.newBuilder("with ")
+                .append(pgSettingsCte)
+                .append(", ")
+                .append(sql.substring("with".length()));
+      }
+      if (builder != null) {
+        Map<String, Value> parameters = statement.getParameters();
+        for (Entry<String, Value> param : parameters.entrySet()) {
+          builder.bind(param.getKey()).to(param.getValue());
+        }
+        statement = builder.build();
+      }
+    }
+    return statement;
+  }
+
+  static boolean startsWithIgnoreCase(String string, String prefix) {
+    return string.substring(0, prefix.length()).equalsIgnoreCase(prefix);
+  }
+
+  /**
+   * Generates a Common Table Expression that represents the pg_settings table. Note that the
+   * generated query adds two additional CTEs that could in theory hide existing user tables. It is
+   * however strongly recommended that user tables never start with 'pg_', as all system tables in
+   * PostgreSQL start with 'pg_' and 'pg_catalog' is by design always included in the search_path
+   * and is by default the first entry on the search_path. This means that user tables that start
+   * with 'pg_' always risk being hidden by user tables, unless pg_catalog has been explicitly added
+   * to the search_path after one or more user schemas.
+   */
+  String generatePGSettingsCte() {
+    return "pg_settings_inmem_ as (\n"
+        + getAll().stream()
+            .filter(setting -> SUPPORTED_PG_SETTINGS_KEYS.contains(setting.getCasePreservingKey()))
+            .map(PGSetting::getSelectStatement)
+            .collect(Collectors.joining("\nunion all\n"))
+        + "\n),\n"
+        + "pg_settings_names_ as (\n"
+        + "select name from pg_settings_inmem_\n"
+        + "union\n"
+        + "select name from pg_catalog.pg_settings\n"
+        + "),\n"
+        + "pg_settings as (\n"
+        + "select n.name, "
+        + generatePgSettingsColumnExpressions()
+        + "\n"
+        + "from pg_settings_names_ n\n"
+        + "left join pg_settings_inmem_ s1 using (name)\n"
+        + "left join pg_catalog.pg_settings s2 using (name)\n"
+        + "order by name\n"
+        + ")\n";
+  }
+
+  /**
+   * Generates a string of `coalesce(s1.col, s2.col) as col` for all column names (except `name`) in
+   * pg_settings.
+   */
+  private static String generatePgSettingsColumnExpressions() {
+    return PGSetting.getColumnNames().stream()
+        .skip(1)
+        .map(column -> "coalesce(s1." + column + ", s2." + column + ") as " + column)
+        .collect(Collectors.joining(","));
   }
 
   private static String toKey(String extension, String name) {
@@ -59,6 +176,26 @@ public class SessionState {
         : extension.toLowerCase(Locale.ROOT) + "." + name.toLowerCase(Locale.ROOT);
   }
 
+  /** Sets the value of the specified setting at connection startup. */
+  public void setConnectionStartupValue(String extension, String name, String value) {
+    String key = toKey(extension, name);
+    PGSetting setting = this.settings.get(key);
+    if (setting == null && extension == null) {
+      // Ignore unknown settings.
+      return;
+    }
+    if (setting == null) {
+      setting = new PGSetting(extension, name);
+      this.settings.put(key, setting);
+    }
+    try {
+      setting.initConnectionValue(value);
+    } catch (Exception ignore) {
+      // ignore errors in startup values to prevent unknown or invalid settings from stopping a
+      // connection from being made.
+    }
+  }
+
   /**
    * Sets the value of the specified setting. The new value will be persisted if the current
    * transaction is committed. The value will be lost if the transaction is rolled back.
@@ -146,7 +283,7 @@ public class SessionState {
     for (String key : keys) {
       result.add(internalGet(key));
     }
-    result.sort(Comparator.comparing(PGSetting::getKey));
+    result.sort(Comparator.comparing(PGSetting::getCasePreservingKey));
     return result;
   }
 
diff --git a/src/main/java/com/google/cloud/spanner/pgadapter/statements/BackendConnection.java b/src/main/java/com/google/cloud/spanner/pgadapter/statements/BackendConnection.java
index 4870c271..aa3bc91c 100644
--- a/src/main/java/com/google/cloud/spanner/pgadapter/statements/BackendConnection.java
+++ b/src/main/java/com/google/cloud/spanner/pgadapter/statements/BackendConnection.java
@@ -48,6 +48,7 @@ import com.google.cloud.spanner.pgadapter.metadata.OptionsMetadata.DdlTransactio
 import com.google.cloud.spanner.pgadapter.session.SessionState;
 import com.google.cloud.spanner.pgadapter.statements.DdlExecutor.NotExecuted;
 import com.google.cloud.spanner.pgadapter.statements.SessionStatementParser.SessionStatement;
+import com.google.cloud.spanner.pgadapter.statements.SimpleParser.TableOrIndexName;
 import com.google.cloud.spanner.pgadapter.statements.local.LocalStatement;
 import com.google.cloud.spanner.pgadapter.utils.CopyDataReceiver;
 import com.google.cloud.spanner.pgadapter.utils.MutationWriter;
@@ -202,7 +203,10 @@ public class BackendConnection {
         } else if (parsedStatement.isDdl()) {
           result.set(ddlExecutor.execute(parsedStatement, statement));
         } else {
-          result.set(spannerConnection.execute(statement));
+          // Potentially add session state in the form of CTE(s) to the statement.
+          Statement statementWithSessionState =
+              sessionState.addSessionState(parsedStatement, statement);
+          result.set(spannerConnection.execute(statementWithSessionState));
         }
       } catch (SpannerException spannerException) {
         // Executing queries against the information schema in a transaction is unsupported.
@@ -459,6 +463,34 @@ public class BackendConnection {
     }
   }
 
+  /**
+   * Sets the initial value of a pg_settings setting for this connection. This method should only be
+   * called during startup with values that come from the connection request.
+   */
+  public void initSessionSetting(String name, String value) {
+    if ("options".equalsIgnoreCase(name)) {
+      String[] commands = value.split("-c\\s+");
+      for (String command : commands) {
+        String[] keyValue = command.split("=", 2);
+        if (keyValue.length == 2) {
+          SimpleParser parser = new SimpleParser(keyValue[0]);
+          TableOrIndexName key = parser.readTableOrIndexName();
+          if (key == null) {
+            continue;
+          }
+          this.sessionState.setConnectionStartupValue(key.schema, key.name, keyValue[1]);
+        }
+      }
+    } else {
+      SimpleParser parser = new SimpleParser(name);
+      TableOrIndexName key = parser.readTableOrIndexName();
+      if (key == null) {
+        return;
+      }
+      this.sessionState.setConnectionStartupValue(key.schema, key.name, value);
+    }
+  }
+
   /** Returns the Spanner connection used by this {@link BackendConnection}. */
   public Connection getSpannerConnection() {
     return this.spannerConnection;
diff --git a/src/main/java/com/google/cloud/spanner/pgadapter/statements/SessionStatementParser.java b/src/main/java/com/google/cloud/spanner/pgadapter/statements/SessionStatementParser.java
index 4775042b..2f87ce57 100644
--- a/src/main/java/com/google/cloud/spanner/pgadapter/statements/SessionStatementParser.java
+++ b/src/main/java/com/google/cloud/spanner/pgadapter/statements/SessionStatementParser.java
@@ -205,7 +205,7 @@ public class SessionStatementParser {
                       setting ->
                           Struct.newBuilder()
                               .set("name")
-                              .to(setting.getKey())
+                              .to(setting.getCasePreservingKey())
                               .set("setting")
                               .to(setting.getSetting())
                               .set("description")
diff --git a/src/main/java/com/google/cloud/spanner/pgadapter/wireprotocol/PasswordMessage.java b/src/main/java/com/google/cloud/spanner/pgadapter/wireprotocol/PasswordMessage.java
index 48010d5c..3753a524 100644
--- a/src/main/java/com/google/cloud/spanner/pgadapter/wireprotocol/PasswordMessage.java
+++ b/src/main/java/com/google/cloud/spanner/pgadapter/wireprotocol/PasswordMessage.java
@@ -88,7 +88,7 @@ public class PasswordMessage extends ControlMessage {
       new TerminateResponse(this.outputStream).send();
     } else {
       createConnectionAndSendStartupMessage(
-          this.connection, this.parameters.get(DATABASE_KEY), credentials);
+          this.connection, this.parameters.get(DATABASE_KEY), this.parameters, credentials);
     }
   }
 
diff --git a/src/main/java/com/google/cloud/spanner/pgadapter/wireprotocol/StartupMessage.java b/src/main/java/com/google/cloud/spanner/pgadapter/wireprotocol/StartupMessage.java
index 23826301..f5586971 100644
--- a/src/main/java/com/google/cloud/spanner/pgadapter/wireprotocol/StartupMessage.java
+++ b/src/main/java/com/google/cloud/spanner/pgadapter/wireprotocol/StartupMessage.java
@@ -24,6 +24,7 @@ import com.google.cloud.spanner.pgadapter.wireoutput.AuthenticationCleartextPass
 import java.io.IOException;
 import java.text.MessageFormat;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.annotation.Nullable;
@@ -68,16 +69,25 @@ public class StartupMessage extends BootstrapMessage {
   protected void sendPayload() throws Exception {
     if (!authenticate) {
       createConnectionAndSendStartupMessage(
-          this.connection, this.parameters.get(DATABASE_KEY), null);
+          this.connection, this.parameters.get(DATABASE_KEY), this.parameters, null);
     } else {
       new AuthenticationCleartextPasswordResponse(this.outputStream).send();
     }
   }
 
   static void createConnectionAndSendStartupMessage(
-      ConnectionHandler connection, String database, @Nullable GoogleCredentials credentials)
+      ConnectionHandler connection,
+      String database,
+      Map<String, String> parameters,
+      @Nullable GoogleCredentials credentials)
       throws Exception {
     connection.connectToSpanner(database, credentials);
+    for (Entry<String, String> parameter : parameters.entrySet()) {
+      connection
+          .getExtendedQueryProtocolHandler()
+          .getBackendConnection()
+          .initSessionSetting(parameter.getKey(), parameter.getValue());
+    }
     sendStartupMessage(
         connection.getConnectionMetadata().peekOutputStream(),
         connection.getConnectionId(),
diff --git a/src/main/resources/com/google/cloud/spanner/pgadapter/session/pg_settings.txt b/src/main/resources/com/google/cloud/spanner/pgadapter/session/pg_settings.txt
index 2b916996..d2a6fe1a 100644
--- a/src/main/resources/com/google/cloud/spanner/pgadapter/session/pg_settings.txt
+++ b/src/main/resources/com/google/cloud/spanner/pgadapter/session/pg_settings.txt
@@ -24,35 +24,40 @@ backend_flush_after	0	8kB	Resource Usage / Asynchronous Behavior	Number of pages
 backslash_quote	safe_encoding	\N	Version and Platform Compatibility / Previous PostgreSQL Versions	Sets whether "\\'" is allowed in string literals.	\N	user	enum	default	\N	\N	{safe_encoding,on,off}	safe_encoding	safe_encoding	\N	\N	f
 backtrace_functions		\N	Developer Options	Log backtrace for errors in these functions.	\N	superuser	string	default	\N	\N	\N			\N	\N	f
 bgwriter_delay	200	ms	Resource Usage / Background Writer	Background writer sleep time between rounds.	\N	sighup	integer	default	10	10000	\N	200	200	\N	\N	f
-bgwriter_flush_after	0	8kB	Resource Usage / Background Writer	Number of pages after which previously performed writes are flushed to disk.	\N	sighup	integer	default	0	256	\N	0	0	\N	\N	f
+bgwriter_flush_after	64	8kB	Resource Usage / Background Writer	Number of pages after which previously performed writes are flushed to disk.	\N	sighup	integer	default	0	256	\N	64	64	\N	\N	f
 bgwriter_lru_maxpages	100	\N	Resource Usage / Background Writer	Background writer maximum number of LRU pages to flush per round.	\N	sighup	integer	default	0	1073741823	\N	100	100	\N	\N	f
 bgwriter_lru_multiplier	2	\N	Resource Usage / Background Writer	Multiple of the average buffer usage to free per round.	\N	sighup	real	default	0	10	\N	2	2	\N	\N	f
 block_size	8192	\N	Preset Options	Shows the size of a disk block.	\N	internal	integer	default	8192	8192	\N	8192	8192	\N	\N	f
 bonjour	off	\N	Connections and Authentication / Connection Settings	Enables advertising the server via Bonjour.	\N	postmaster	bool	default	\N	\N	\N	off	off	\N	\N	f
 bonjour_name		\N	Connections and Authentication / Connection Settings	Sets the Bonjour service name.	\N	postmaster	string	default	\N	\N	\N			\N	\N	f
 bytea_output	hex	\N	Client Connection Defaults / Statement Behavior	Sets the output format for bytea.	\N	user	enum	default	\N	\N	{escape,hex}	hex	hex	\N	\N	f
-check_function_bodies	on	\N	Client Connection Defaults / Statement Behavior	Check function bodies during CREATE FUNCTION.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
-checkpoint_completion_target	0.5	\N	Write-Ahead Log / Checkpoints	Time spent flushing dirty buffers during checkpoint, as fraction of checkpoint interval.	\N	sighup	real	default	0	1	\N	0.5	0.5	\N	\N	f
-checkpoint_flush_after	0	8kB	Write-Ahead Log / Checkpoints	Number of pages after which previously performed writes are flushed to disk.	\N	sighup	integer	default	0	256	\N	0	0	\N	\N	f
+check_function_bodies	on	\N	Client Connection Defaults / Statement Behavior	Check routine bodies during CREATE FUNCTION and CREATE PROCEDURE.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
+checkpoint_completion_target	0.9	\N	Write-Ahead Log / Checkpoints	Time spent flushing dirty buffers during checkpoint, as fraction of checkpoint interval.	\N	sighup	real	default	0	1	\N	0.9	0.9	\N	\N	f
+checkpoint_flush_after	32	8kB	Write-Ahead Log / Checkpoints	Number of pages after which previously performed writes are flushed to disk.	\N	sighup	integer	default	0	256	\N	32	32	\N	\N	f
 checkpoint_timeout	300	s	Write-Ahead Log / Checkpoints	Sets the maximum time between automatic WAL checkpoints.	\N	sighup	integer	default	30	86400	\N	300	300	\N	\N	f
 checkpoint_warning	30	s	Write-Ahead Log / Checkpoints	Enables warnings if checkpoint segments are filled more frequently than this.	Write a message to the server log if checkpoints caused by the filling of checkpoint segment files happens more frequently than this number of seconds. Zero turns off the warning.	sighup	integer	default	0	2147483647	\N	30	30	\N	\N	f
+client_connection_check_interval	0	ms	Connections and Authentication / Connection Settings	Sets the time interval between checks for disconnection while running queries.	\N	user	integer	default	0	2147483647	\N	0	0	\N	\N	f
 client_encoding	UTF8	\N	Client Connection Defaults / Locale and Formatting	Sets the client's character set encoding.	\N	user	string	default	\N	\N	\N	SQL_ASCII	UTF8	\N	\N	f
 client_min_messages	notice	\N	Client Connection Defaults / Statement Behavior	Sets the message levels that are sent to the client.	Each level includes all the levels that follow it. The later the level, the fewer messages are sent.	user	enum	default	\N	\N	{debug5,debug4,debug3,debug2,debug1,log,notice,warning,error}	notice	notice	\N	\N	f
-cluster_name		\N	Process Title	Sets the name of the cluster, which is included in the process title.	\N	postmaster	string	default	\N	\N	\N			\N	\N	f
+cluster_name	14/main	\N	Reporting and Logging / Process Title	Sets the name of the cluster, which is included in the process title.	\N	postmaster	string	configuration file	\N	\N	\N		14/main	/etc/postgresql/14/main/postgresql.conf	587	f
 commit_delay	0	\N	Write-Ahead Log / Settings	Sets the delay in microseconds between transaction commit and flushing WAL to disk.	\N	superuser	integer	default	0	100000	\N	0	0	\N	\N	f
 commit_siblings	5	\N	Write-Ahead Log / Settings	Sets the minimum concurrent open transactions before performing commit_delay.	\N	user	integer	default	0	1000	\N	5	5	\N	\N	f
+compute_query_id	auto	\N	Statistics / Monitoring	Compute query identifiers.	\N	superuser	enum	default	\N	\N	{auto,on,off}	auto	auto	\N	\N	f
+config_file	/etc/postgresql/14/main/postgresql.conf	\N	File Locations	Sets the server's main configuration file.	\N	postmaster	string	override	\N	\N	\N	\N	/etc/postgresql/14/main/postgresql.conf	\N	\N	f
 constraint_exclusion	partition	\N	Query Tuning / Other Planner Options	Enables the planner to use constraints to optimize queries.	Table scans will be skipped if their constraints guarantee that no rows match the query.	user	enum	default	\N	\N	{partition,on,off}	partition	partition	\N	\N	f
 cpu_index_tuple_cost	0.005	\N	Query Tuning / Planner Cost Constants	Sets the planner's estimate of the cost of processing each index entry during an index scan.	\N	user	real	default	0	1.79769e+308	\N	0.005	0.005	\N	\N	f
 cpu_operator_cost	0.0025	\N	Query Tuning / Planner Cost Constants	Sets the planner's estimate of the cost of processing each operator or function call.	\N	user	real	default	0	1.79769e+308	\N	0.0025	0.0025	\N	\N	f
 cpu_tuple_cost	0.01	\N	Query Tuning / Planner Cost Constants	Sets the planner's estimate of the cost of processing each tuple (row).	\N	user	real	default	0	1.79769e+308	\N	0.01	0.01	\N	\N	f
 cursor_tuple_fraction	0.1	\N	Query Tuning / Other Planner Options	Sets the planner's estimate of the fraction of a cursor's rows that will be retrieved.	\N	user	real	default	0	1	\N	0.1	0.1	\N	\N	f
 data_checksums	off	\N	Preset Options	Shows whether data checksums are turned on for this cluster.	\N	internal	bool	override	\N	\N	\N	off	off	\N	\N	f
-data_directory_mode	0700	\N	Preset Options	Mode of the data directory.	The parameter value is a numeric mode specification in the form accepted by the chmod and umask system calls. (To use the customary octal format the number must start with a 0 (zero).)	internal	integer	default	0	511	\N	448	448	\N	\N	f
+data_directory	/var/lib/postgresql/14/main	\N	File Locations	Sets the server's data directory.	\N	postmaster	string	override	\N	\N	\N	\N	/var/lib/postgresql/14/main	\N	\N	f
+data_directory_mode	0700	\N	Preset Options	Shows the mode of the data directory.	The parameter value is a numeric mode specification in the form accepted by the chmod and umask system calls. (To use the customary octal format the number must start with a 0 (zero).)	internal	integer	default	0	511	\N	448	448	\N	\N	f
 data_sync_retry	off	\N	Error Handling	Whether to continue running after a failure to sync data files.	\N	postmaster	bool	default	\N	\N	\N	off	off	\N	\N	f
-DateStyle	ISO, MDY	\N	Client Connection Defaults / Locale and Formatting	Sets the display format for date and time values.	Also controls interpretation of ambiguous date inputs.	user	string	configuration file	\N	\N	\N	ISO, MDY	ISO, MDY	\N	\N	f
+DateStyle	ISO, MDY	\N	Client Connection Defaults / Locale and Formatting	Sets the display format for date and time values.	Also controls interpretation of ambiguous date inputs.	user	string	configuration file	\N	\N	\N	ISO, MDY	ISO, MDY	/etc/postgresql/14/main/postgresql.conf	694	f
 db_user_namespace	off	\N	Connections and Authentication / Authentication	Enables per-database user names.	\N	sighup	bool	default	\N	\N	\N	off	off	\N	\N	f
 deadlock_timeout	1000	ms	Lock Management	Sets the time to wait on a lock before checking for deadlock.	\N	superuser	integer	default	1	2147483647	\N	1000	1000	\N	\N	f
 debug_assertions	off	\N	Preset Options	Shows whether the running server has assertion checks enabled.	\N	internal	bool	default	\N	\N	\N	off	off	\N	\N	f
+debug_discard_caches	0	\N	Developer Options	Aggressively flush system caches for debugging purposes.	\N	superuser	integer	default	0	0	\N	0	0	\N	\N	f
 debug_pretty_print	on	\N	Reporting and Logging / What to Log	Indents parse and plan tree displays.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 debug_print_parse	off	\N	Reporting and Logging / What to Log	Logs each query's parse tree.	\N	user	bool	default	\N	\N	\N	off	off	\N	\N	f
 debug_print_plan	off	\N	Reporting and Logging / What to Log	Logs each query's execution plan.	\N	user	bool	default	\N	\N	\N	off	off	\N	\N	f
@@ -60,13 +65,16 @@ debug_print_rewritten	off	\N	Reporting and Logging / What to Log	Logs each query
 default_statistics_target	100	\N	Query Tuning / Other Planner Options	Sets the default statistics target.	This applies to table columns that have not had a column-specific target set via ALTER TABLE SET STATISTICS.	user	integer	default	1	10000	\N	100	100	\N	\N	f
 default_table_access_method	heap	\N	Client Connection Defaults / Statement Behavior	Sets the default table access method for new tables.	\N	user	string	default	\N	\N	\N	heap	heap	\N	\N	f
 default_tablespace		\N	Client Connection Defaults / Statement Behavior	Sets the default tablespace to create tables and indexes in.	An empty string selects the database's default tablespace.	user	string	default	\N	\N	\N			\N	\N	f
-default_text_search_config	pg_catalog.english	\N	Client Connection Defaults / Locale and Formatting	Sets default text search configuration.	\N	user	string	configuration file	\N	\N	\N	pg_catalog.simple	pg_catalog.english	\N	\N	f
+default_text_search_config	pg_catalog.english	\N	Client Connection Defaults / Locale and Formatting	Sets default text search configuration.	\N	user	string	configuration file	\N	\N	\N	pg_catalog.simple	pg_catalog.english	/etc/postgresql/14/main/postgresql.conf	717	f
+default_toast_compression	pglz	\N	Client Connection Defaults / Statement Behavior	Sets the default compression method for compressible values.	\N	user	enum	default	\N	\N	{pglz,lz4}	pglz	pglz	\N	\N	f
 default_transaction_deferrable	off	\N	Client Connection Defaults / Statement Behavior	Sets the default deferrable status of new transactions.	\N	user	bool	default	\N	\N	\N	off	off	\N	\N	f
-default_transaction_isolation	read committed	\N	Client Connection Defaults / Statement Behavior	Sets the transaction isolation level of each new transaction.	\N	user	enum	default	\N	\N	{serializable,"repeatable read","read committed","read uncommitted"}	read committed	read committed	\N	\N	f
+default_transaction_isolation	serializable	\N	Client Connection Defaults / Statement Behavior	Sets the transaction isolation level of each new transaction.	\N	user	enum	default	\N	\N	{serializable,"repeatable read","read committed","read uncommitted"}	serializable	serializable	\N	\N	f
 default_transaction_read_only	off	\N	Client Connection Defaults / Statement Behavior	Sets the default read-only status of new transactions.	\N	user	bool	default	\N	\N	\N	off	off	\N	\N	f
-dynamic_shared_memory_type	posix	\N	Resource Usage / Memory	Selects the dynamic shared memory implementation used.	\N	postmaster	enum	configuration file	\N	\N	{posix,sysv,mmap}	posix	posix	\N	\N	f
+dynamic_library_path	$libdir	\N	Client Connection Defaults / Other Defaults	Sets the path for dynamically loadable modules.	If a dynamically loadable module needs to be opened and the specified name does not have a directory component (i.e., the name does not contain a slash), the system will search this path for the specified file.	superuser	string	default	\N	\N	\N	$libdir	$libdir	\N	\N	f
+dynamic_shared_memory_type	posix	\N	Resource Usage / Memory	Selects the dynamic shared memory implementation used.	\N	postmaster	enum	configuration file	\N	\N	{posix,sysv,mmap}	posix	posix	/etc/postgresql/14/main/postgresql.conf	150	f
 effective_cache_size	524288	8kB	Query Tuning / Planner Cost Constants	Sets the planner's assumption about the total size of the data caches.	That is, the total size of the caches (kernel cache and shared buffers) used for PostgreSQL data files. This is measured in disk pages, which are normally 8 kB each.	user	integer	default	1	2147483647	\N	524288	524288	\N	\N	f
-effective_io_concurrency	0	\N	Resource Usage / Asynchronous Behavior	Number of simultaneous requests that can be handled efficiently by the disk subsystem.	\N	user	integer	default	0	1000	\N	0	0	\N	\N	f
+effective_io_concurrency	1	\N	Resource Usage / Asynchronous Behavior	Number of simultaneous requests that can be handled efficiently by the disk subsystem.	\N	user	integer	default	0	1000	\N	1	1	\N	\N	f
+enable_async_append	on	\N	Query Tuning / Planner Method Configuration	Enables the planner's use of async append plans.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 enable_bitmapscan	on	\N	Query Tuning / Planner Method Configuration	Enables the planner's use of bitmap-scan plans.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 enable_gathermerge	on	\N	Query Tuning / Planner Method Configuration	Enables the planner's use of gather merge plans.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 enable_hashagg	on	\N	Query Tuning / Planner Method Configuration	Enables the planner's use of hashed aggregation plans.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
@@ -75,11 +83,12 @@ enable_incremental_sort	on	\N	Query Tuning / Planner Method Configuration	Enable
 enable_indexonlyscan	on	\N	Query Tuning / Planner Method Configuration	Enables the planner's use of index-only-scan plans.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 enable_indexscan	on	\N	Query Tuning / Planner Method Configuration	Enables the planner's use of index-scan plans.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 enable_material	on	\N	Query Tuning / Planner Method Configuration	Enables the planner's use of materialization.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
+enable_memoize	on	\N	Query Tuning / Planner Method Configuration	Enables the planner's use of memoization.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 enable_mergejoin	on	\N	Query Tuning / Planner Method Configuration	Enables the planner's use of merge join plans.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 enable_nestloop	on	\N	Query Tuning / Planner Method Configuration	Enables the planner's use of nested-loop join plans.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 enable_parallel_append	on	\N	Query Tuning / Planner Method Configuration	Enables the planner's use of parallel append plans.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 enable_parallel_hash	on	\N	Query Tuning / Planner Method Configuration	Enables the planner's use of parallel hash plans.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
-enable_partition_pruning	on	\N	Query Tuning / Planner Method Configuration	Enables plan-time and run-time partition pruning.	Allows the query planner and executor to compare partition bounds to conditions in the query to determine which partitions must be scanned.	user	bool	default	\N	\N	\N	on	on	\N	\N	f
+enable_partition_pruning	on	\N	Query Tuning / Planner Method Configuration	Enables plan-time and execution-time partition pruning.	Allows the query planner and executor to compare partition bounds to conditions in the query to determine which partitions must be scanned.	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 enable_partitionwise_aggregate	off	\N	Query Tuning / Planner Method Configuration	Enables partitionwise aggregation and grouping.	\N	user	bool	default	\N	\N	\N	off	off	\N	\N	f
 enable_partitionwise_join	off	\N	Query Tuning / Planner Method Configuration	Enables partitionwise join.	\N	user	bool	default	\N	\N	\N	off	off	\N	\N	f
 enable_seqscan	on	\N	Query Tuning / Planner Method Configuration	Enables the planner's use of sequential-scan plans.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
@@ -88,8 +97,10 @@ enable_tidscan	on	\N	Query Tuning / Planner Method Configuration	Enables the pla
 escape_string_warning	on	\N	Version and Platform Compatibility / Previous PostgreSQL Versions	Warn about backslash escapes in ordinary string literals.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 event_source	PostgreSQL	\N	Reporting and Logging / Where to Log	Sets the application name used to identify PostgreSQL messages in the event log.	\N	postmaster	string	default	\N	\N	\N	PostgreSQL	PostgreSQL	\N	\N	f
 exit_on_error	off	\N	Error Handling	Terminate session on any error.	\N	user	bool	default	\N	\N	\N	off	off	\N	\N	f
+extension_destdir		\N	File Locations	Path to prepend for extension loading	This directory is prepended to paths when loading extensions (control and SQL files), and to the '$libdir' directive when loading modules that back functions. The location is made configurable to allow build-time testing of extensions that do not have been installed to their proper location yet.	superuser	string	default	\N	\N	\N			\N	\N	f
+external_pid_file	/var/run/postgresql/14-main.pid	\N	File Locations	Writes the postmaster PID to the specified file.	\N	postmaster	string	configuration file	\N	\N	\N	\N	/var/run/postgresql/14-main.pid	/etc/postgresql/14/main/postgresql.conf	50	f
 extra_float_digits	1	\N	Client Connection Defaults / Locale and Formatting	Sets the number of digits displayed for floating-point values.	This affects real, double precision, and geometric data types. A zero or negative parameter value is added to the standard number of digits (FLT_DIG or DBL_DIG as appropriate). Any value greater than zero selects precise output mode.	user	integer	default	-15	3	\N	1	1	\N	\N	f
-force_parallel_mode	off	\N	Query Tuning / Other Planner Options	Forces use of parallel query facilities.	If possible, run query using a parallel worker and with parallel restrictions.	user	enum	default	\N	\N	{off,on,regress}	off	off	\N	\N	f
+force_parallel_mode	off	\N	Developer Options	Forces use of parallel query facilities.	If possible, run query using a parallel worker and with parallel restrictions.	user	enum	default	\N	\N	{off,on,regress}	off	off	\N	\N	f
 from_collapse_limit	8	\N	Query Tuning / Other Planner Options	Sets the FROM-list size beyond which subqueries are not collapsed.	The planner will merge subqueries into upper queries if the resulting FROM list would have no more than this many items.	user	integer	default	1	2147483647	\N	8	8	\N	\N	f
 fsync	on	\N	Write-Ahead Log / Settings	Forces synchronization of updates to disk.	The server will use the fsync() system call in several places to make sure that updates are physically written to disk. This insures that a database cluster will recover to a consistent state after an operating system or hardware crash.	sighup	bool	default	\N	\N	\N	on	on	\N	\N	f
 full_page_writes	on	\N	Write-Ahead Log / Settings	Writes full pages to WAL when first modified after a checkpoint.	A page write in process during an operating system crash might be only partially written to disk.  During recovery, the row changes stored in WAL are not enough to recover.  This option writes pages when first modified after a checkpoint to WAL so full recovery is possible.	sighup	bool	default	\N	\N	\N	on	on	\N	\N	f
@@ -103,47 +114,56 @@ geqo_threshold	12	\N	Query Tuning / Genetic Query Optimizer	Sets the threshold o
 gin_fuzzy_search_limit	0	\N	Client Connection Defaults / Other Defaults	Sets the maximum allowed result for exact search by GIN.	\N	user	integer	default	0	2147483647	\N	0	0	\N	\N	f
 gin_pending_list_limit	4096	kB	Client Connection Defaults / Statement Behavior	Sets the maximum size of the pending list for GIN index.	\N	user	integer	default	64	2147483647	\N	4096	4096	\N	\N	f
 hash_mem_multiplier	1	\N	Resource Usage / Memory	Multiple of work_mem to use for hash tables.	\N	user	real	default	1	1000	\N	1	1	\N	\N	f
+hba_file	/etc/postgresql/14/main/pg_hba.conf	\N	File Locations	Sets the server's "hba" configuration file.	\N	postmaster	string	override	\N	\N	\N	\N	/etc/postgresql/14/main/pg_hba.conf	\N	\N	f
 hot_standby	on	\N	Replication / Standby Servers	Allows connections and queries during recovery.	\N	postmaster	bool	default	\N	\N	\N	on	on	\N	\N	f
 hot_standby_feedback	off	\N	Replication / Standby Servers	Allows feedback from a hot standby to the primary that will avoid query conflicts.	\N	sighup	bool	default	\N	\N	\N	off	off	\N	\N	f
+huge_page_size	0	kB	Resource Usage / Memory	The size of huge page that should be requested.	\N	postmaster	integer	default	0	2147483647	\N	0	0	\N	\N	f
 huge_pages	try	\N	Resource Usage / Memory	Use of huge pages on Linux or Windows.	\N	postmaster	enum	default	\N	\N	{off,on,try}	try	try	\N	\N	f
-idle_in_transaction_session_timeout	0	ms	Client Connection Defaults / Statement Behavior	Sets the maximum allowed duration of any idling transaction.	A value of 0 turns off the timeout.	user	integer	default	0	2147483647	\N	0	0	\N	\N	f
+ident_file	/etc/postgresql/14/main/pg_ident.conf	\N	File Locations	Sets the server's "ident" configuration file.	\N	postmaster	string	override	\N	\N	\N	\N	/etc/postgresql/14/main/pg_ident.conf	\N	\N	f
+idle_in_transaction_session_timeout	0	ms	Client Connection Defaults / Statement Behavior	Sets the maximum allowed idle time between queries, when in a transaction.	A value of 0 turns off the timeout.	user	integer	default	0	2147483647	\N	0	0	\N	\N	f
+idle_session_timeout	0	ms	Client Connection Defaults / Statement Behavior	Sets the maximum allowed idle time between queries, when not in a transaction.	A value of 0 turns off the timeout.	user	integer	default	0	2147483647	\N	0	0	\N	\N	f
 ignore_checksum_failure	off	\N	Developer Options	Continues processing after a checksum failure.	Detection of a checksum failure normally causes PostgreSQL to report an error, aborting the current transaction. Setting ignore_checksum_failure to true causes the system to ignore the failure (but still report a warning), and continue processing. This behavior could cause crashes or other serious problems. Only has an effect if checksums are enabled.	superuser	bool	default	\N	\N	\N	off	off	\N	\N	f
 ignore_invalid_pages	off	\N	Developer Options	Continues recovery after an invalid pages failure.	Detection of WAL records having references to invalid pages during recovery causes PostgreSQL to raise a PANIC-level error, aborting the recovery. Setting ignore_invalid_pages to true causes the system to ignore invalid page references in WAL records (but still report a warning), and continue recovery. This behavior may cause crashes, data loss, propagate or hide corruption, or other serious problems. Only has an effect during recovery or in standby mode.	postmaster	bool	default	\N	\N	\N	off	off	\N	\N	f
 ignore_system_indexes	off	\N	Developer Options	Disables reading from system indexes.	It does not prevent updating the indexes, so it is safe to use.  The worst consequence is slowness.	backend	bool	default	\N	\N	\N	off	off	\N	\N	f
-integer_datetimes	on	\N	Preset Options	Datetimes are integer based.	\N	internal	bool	default	\N	\N	\N	on	on	\N	\N	f
+in_hot_standby	off	\N	Preset Options	Shows whether hot standby is currently active.	\N	internal	bool	default	\N	\N	\N	off	off	\N	\N	f
+integer_datetimes	on	\N	Preset Options	Shows whether datetimes are integer based.	\N	internal	bool	default	\N	\N	\N	on	on	\N	\N	f
 IntervalStyle	postgres	\N	Client Connection Defaults / Locale and Formatting	Sets the display format for interval values.	\N	user	enum	default	\N	\N	{postgres,postgres_verbose,sql_standard,iso_8601}	postgres	postgres	\N	\N	f
 jit	on	\N	Query Tuning / Other Planner Options	Allow JIT compilation.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 jit_above_cost	100000	\N	Query Tuning / Planner Cost Constants	Perform JIT compilation if query is more expensive.	-1 disables JIT compilation.	user	real	default	-1	1.79769e+308	\N	100000	100000	\N	\N	f
-jit_debugging_support	off	\N	Developer Options	Register JIT compiled function with debugger.	\N	superuser-backend	bool	default	\N	\N	\N	off	off	\N	\N	f
+jit_debugging_support	off	\N	Developer Options	Register JIT-compiled functions with debugger.	\N	superuser-backend	bool	default	\N	\N	\N	off	off	\N	\N	f
 jit_dump_bitcode	off	\N	Developer Options	Write out LLVM bitcode to facilitate JIT debugging.	\N	superuser	bool	default	\N	\N	\N	off	off	\N	\N	f
 jit_expressions	on	\N	Developer Options	Allow JIT compilation of expressions.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 jit_inline_above_cost	500000	\N	Query Tuning / Planner Cost Constants	Perform JIT inlining if query is more expensive.	-1 disables inlining.	user	real	default	-1	1.79769e+308	\N	500000	500000	\N	\N	f
-jit_optimize_above_cost	500000	\N	Query Tuning / Planner Cost Constants	Optimize JITed functions if query is more expensive.	-1 disables optimization.	user	real	default	-1	1.79769e+308	\N	500000	500000	\N	\N	f
-jit_profiling_support	off	\N	Developer Options	Register JIT compiled function with perf profiler.	\N	superuser-backend	bool	default	\N	\N	\N	off	off	\N	\N	f
+jit_optimize_above_cost	500000	\N	Query Tuning / Planner Cost Constants	Optimize JIT-compiled functions if query is more expensive.	-1 disables optimization.	user	real	default	-1	1.79769e+308	\N	500000	500000	\N	\N	f
+jit_profiling_support	off	\N	Developer Options	Register JIT-compiled functions with perf profiler.	\N	superuser-backend	bool	default	\N	\N	\N	off	off	\N	\N	f
+jit_provider	llvmjit	\N	Client Connection Defaults / Shared Library Preloading	JIT provider to use.	\N	postmaster	string	default	\N	\N	\N	llvmjit	llvmjit	\N	\N	f
 jit_tuple_deforming	on	\N	Developer Options	Allow JIT compilation of tuple deforming.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 join_collapse_limit	8	\N	Query Tuning / Other Planner Options	Sets the FROM-list size beyond which JOIN constructs are not flattened.	The planner will flatten explicit JOIN constructs into lists of FROM items whenever a list of no more than this many items would result.	user	integer	default	1	2147483647	\N	8	8	\N	\N	f
 krb_caseins_users	off	\N	Connections and Authentication / Authentication	Sets whether Kerberos and GSSAPI user names should be treated as case-insensitive.	\N	sighup	bool	default	\N	\N	\N	off	off	\N	\N	f
-lc_collate	C	\N	Client Connection Defaults / Locale and Formatting	Shows the collation order locale.	\N	internal	string	override	\N	\N	\N	C	C	\N	\N	f
-lc_ctype	C	\N	Client Connection Defaults / Locale and Formatting	Shows the character classification and case conversion locale.	\N	internal	string	override	\N	\N	\N	C	C	\N	\N	f
-lc_messages	C	\N	Client Connection Defaults / Locale and Formatting	Sets the language in which messages are displayed.	\N	superuser	string	configuration file	\N	\N	\N		C	\N	\N	f
-lc_monetary	C	\N	Client Connection Defaults / Locale and Formatting	Sets the locale for formatting monetary amounts.	\N	user	string	configuration file	\N	\N	\N	C	C	\N	\N	f
-lc_numeric	C	\N	Client Connection Defaults / Locale and Formatting	Sets the locale for formatting numbers.	\N	user	string	configuration file	\N	\N	\N	C	C	\N	\N	f
-lc_time	C	\N	Client Connection Defaults / Locale and Formatting	Sets the locale for formatting date and time values.	\N	user	string	configuration file	\N	\N	\N	C	C	\N	\N	f
-listen_addresses	*	\N	Connections and Authentication / Connection Settings	Sets the host name or IP address(es) to listen to.	\N	postmaster	string	configuration file	\N	\N	\N	localhost	*	\N	\N	f
+krb_server_keyfile	FILE:/etc/postgresql-common/krb5.keytab	\N	Connections and Authentication / Authentication	Sets the location of the Kerberos server key file.	\N	sighup	string	default	\N	\N	\N	FILE:/etc/postgresql-common/krb5.keytab	FILE:/etc/postgresql-common/krb5.keytab	\N	\N	f
+lc_collate	en_US.UTF-8	\N	Preset Options	Shows the collation order locale.	\N	internal	string	override	\N	\N	\N	C	en_US.UTF-8	\N	\N	f
+lc_ctype	en_US.UTF-8	\N	Preset Options	Shows the character classification and case conversion locale.	\N	internal	string	override	\N	\N	\N	C	en_US.UTF-8	\N	\N	f
+lc_messages	en_US.UTF-8	\N	Client Connection Defaults / Locale and Formatting	Sets the language in which messages are displayed.	\N	superuser	string	configuration file	\N	\N	\N		en_US.UTF-8	/etc/postgresql/14/main/postgresql.conf	710	f
+lc_monetary	en_US.UTF-8	\N	Client Connection Defaults / Locale and Formatting	Sets the locale for formatting monetary amounts.	\N	user	string	configuration file	\N	\N	\N	C	en_US.UTF-8	/etc/postgresql/14/main/postgresql.conf	712	f
+lc_numeric	en_US.UTF-8	\N	Client Connection Defaults / Locale and Formatting	Sets the locale for formatting numbers.	\N	user	string	configuration file	\N	\N	\N	C	en_US.UTF-8	/etc/postgresql/14/main/postgresql.conf	713	f
+lc_time	en_US.UTF-8	\N	Client Connection Defaults / Locale and Formatting	Sets the locale for formatting date and time values.	\N	user	string	configuration file	\N	\N	\N	C	en_US.UTF-8	/etc/postgresql/14/main/postgresql.conf	714	f
+listen_addresses	localhost	\N	Connections and Authentication / Connection Settings	Sets the host name or IP address(es) to listen to.	\N	postmaster	string	default	\N	\N	\N	localhost	localhost	\N	\N	f
 lo_compat_privileges	off	\N	Version and Platform Compatibility / Previous PostgreSQL Versions	Enables backward compatibility mode for privilege checks on large objects.	Skips privilege checks when reading or modifying large objects, for compatibility with PostgreSQL releases prior to 9.0.	superuser	bool	default	\N	\N	\N	off	off	\N	\N	f
 local_preload_libraries		\N	Client Connection Defaults / Shared Library Preloading	Lists unprivileged shared libraries to preload into each backend.	\N	user	string	default	\N	\N	\N			\N	\N	f
 lock_timeout	0	ms	Client Connection Defaults / Statement Behavior	Sets the maximum allowed duration of any wait for a lock.	A value of 0 turns off the timeout.	user	integer	default	0	2147483647	\N	0	0	\N	\N	f
 log_autovacuum_min_duration	-1	ms	Reporting and Logging / What to Log	Sets the minimum execution time above which autovacuum actions will be logged.	Zero prints all actions. -1 turns autovacuum logging off.	sighup	integer	default	-1	2147483647	\N	-1	-1	\N	\N	f
 log_checkpoints	off	\N	Reporting and Logging / What to Log	Logs each checkpoint.	\N	sighup	bool	default	\N	\N	\N	off	off	\N	\N	f
 log_connections	off	\N	Reporting and Logging / What to Log	Logs each successful connection.	\N	superuser-backend	bool	default	\N	\N	\N	off	off	\N	\N	f
-log_destination	stderr	\N	Reporting and Logging / Where to Log	Sets the destination for server log output.	Valid values are combinations of "stderr", "syslog", "csvlog", and "eventlog", depending on the platform.	sighup	string	configuration file	\N	\N	\N	stderr	stderr	\N	\N	f
+log_destination	stderr	\N	Reporting and Logging / Where to Log	Sets the destination for server log output.	Valid values are combinations of "stderr", "syslog", "csvlog", and "eventlog", depending on the platform.	sighup	string	default	\N	\N	\N	stderr	stderr	\N	\N	f
+log_directory	log	\N	Reporting and Logging / Where to Log	Sets the destination directory for log files.	Can be specified as relative to the data directory or as absolute path.	sighup	string	default	\N	\N	\N	log	log	\N	\N	f
 log_disconnections	off	\N	Reporting and Logging / What to Log	Logs end of a session, including duration.	\N	superuser-backend	bool	default	\N	\N	\N	off	off	\N	\N	f
 log_duration	off	\N	Reporting and Logging / What to Log	Logs the duration of each completed SQL statement.	\N	superuser	bool	default	\N	\N	\N	off	off	\N	\N	f
 log_error_verbosity	default	\N	Reporting and Logging / What to Log	Sets the verbosity of logged messages.	\N	superuser	enum	default	\N	\N	{terse,default,verbose}	default	default	\N	\N	f
 log_executor_stats	off	\N	Statistics / Monitoring	Writes executor performance statistics to the server log.	\N	superuser	bool	default	\N	\N	\N	off	off	\N	\N	f
 log_file_mode	0600	\N	Reporting and Logging / Where to Log	Sets the file permissions for log files.	The parameter value is expected to be a numeric mode specification in the form accepted by the chmod and umask system calls. (To use the customary octal format the number must start with a 0 (zero).)	sighup	integer	default	0	511	\N	384	384	\N	\N	f
+log_filename	postgresql-%Y-%m-%d_%H%M%S.log	\N	Reporting and Logging / Where to Log	Sets the file name pattern for log files.	\N	sighup	string	default	\N	\N	\N	postgresql-%Y-%m-%d_%H%M%S.log	postgresql-%Y-%m-%d_%H%M%S.log	\N	\N	f
 log_hostname	off	\N	Reporting and Logging / What to Log	Logs the host name in the connection logs.	By default, connection logs only show the IP address of the connecting host. If you want them to show the host name you can turn this on, but depending on your host name resolution setup it might impose a non-negligible performance penalty.	sighup	bool	default	\N	\N	\N	off	off	\N	\N	f
-log_line_prefix	%m [%p] 	\N	Reporting and Logging / What to Log	Controls information prefixed to each log line.	If blank, no prefix is used.	sighup	string	default	\N	\N	\N	%m [%p] 	%m [%p] 	\N	\N	f
+log_line_prefix	%m [%p] %q%u@%d 	\N	Reporting and Logging / What to Log	Controls information prefixed to each log line.	If blank, no prefix is used.	sighup	string	configuration file	\N	\N	\N	%m [%p] 	%m [%p] %q%u@%d 	/etc/postgresql/14/main/postgresql.conf	542	f
 log_lock_waits	off	\N	Reporting and Logging / What to Log	Logs long lock waits.	\N	superuser	bool	default	\N	\N	\N	off	off	\N	\N	f
 log_min_duration_sample	-1	ms	Reporting and Logging / When to Log	Sets the minimum execution time above which a sample of statements will be logged. Sampling is determined by log_statement_sample_rate.	Zero logs a sample of all queries. -1 turns this feature off.	superuser	integer	default	-1	2147483647	\N	-1	-1	\N	\N	f
 log_min_duration_statement	-1	ms	Reporting and Logging / When to Log	Sets the minimum execution time above which all statements will be logged.	Zero prints all queries. -1 turns this feature off.	superuser	integer	default	-1	2147483647	\N	-1	-1	\N	\N	f
@@ -153,6 +173,7 @@ log_parameter_max_length	-1	B	Reporting and Logging / What to Log	When logging s
 log_parameter_max_length_on_error	0	B	Reporting and Logging / What to Log	When reporting an error, limit logged parameter values to first N bytes.	-1 to print values in full.	user	integer	default	-1	1073741823	\N	0	0	\N	\N	f
 log_parser_stats	off	\N	Statistics / Monitoring	Writes parser performance statistics to the server log.	\N	superuser	bool	default	\N	\N	\N	off	off	\N	\N	f
 log_planner_stats	off	\N	Statistics / Monitoring	Writes planner performance statistics to the server log.	\N	superuser	bool	default	\N	\N	\N	off	off	\N	\N	f
+log_recovery_conflict_waits	off	\N	Reporting and Logging / What to Log	Logs standby recovery conflict waits.	\N	sighup	bool	default	\N	\N	\N	off	off	\N	\N	f
 log_replication_commands	off	\N	Reporting and Logging / What to Log	Logs each replication command.	\N	superuser	bool	default	\N	\N	\N	off	off	\N	\N	f
 log_rotation_age	1440	min	Reporting and Logging / Where to Log	Automatic log file rotation will occur after N minutes.	\N	sighup	integer	default	0	35791394	\N	1440	1440	\N	\N	f
 log_rotation_size	10240	kB	Reporting and Logging / Where to Log	Automatic log file rotation will occur after N kilobytes.	\N	sighup	integer	default	0	2097151	\N	10240	10240	\N	\N	f
@@ -160,18 +181,18 @@ log_statement	none	\N	Reporting and Logging / What to Log	Sets the type of state
 log_statement_sample_rate	1	\N	Reporting and Logging / When to Log	Fraction of statements exceeding log_min_duration_sample to be logged.	Use a value between 0.0 (never log) and 1.0 (always log).	superuser	real	default	0	1	\N	1	1	\N	\N	f
 log_statement_stats	off	\N	Statistics / Monitoring	Writes cumulative performance statistics to the server log.	\N	superuser	bool	default	\N	\N	\N	off	off	\N	\N	f
 log_temp_files	-1	kB	Reporting and Logging / What to Log	Log the use of temporary files larger than this number of kilobytes.	Zero logs all files. The default is -1 (turning this feature off).	superuser	integer	default	-1	2147483647	\N	-1	-1	\N	\N	f
-log_timezone	Europe/Berlin	\N	Reporting and Logging / What to Log	Sets the time zone to use in log messages.	\N	sighup	string	configuration file	\N	\N	\N	GMT	Europe/Berlin	\N	\N	f
-log_transaction_sample_rate	0	\N	Reporting and Logging / When to Log	Set the fraction of transactions to log for new transactions.	Logs all statements from a fraction of transactions. Use a value between 0.0 (never log) and 1.0 (log all statements for all transactions).	superuser	real	default	0	1	\N	0	0	\N	\N	f
+log_timezone	Europe/Berlin	\N	Reporting and Logging / What to Log	Sets the time zone to use in log messages.	\N	sighup	string	configuration file	\N	\N	\N	GMT	Europe/Berlin	/etc/postgresql/14/main/postgresql.conf	580	f
+log_transaction_sample_rate	0	\N	Reporting and Logging / When to Log	Sets the fraction of transactions from which to log all statements.	Use a value between 0.0 (never log) and 1.0 (log all statements for all transactions).	superuser	real	default	0	1	\N	0	0	\N	\N	f
 log_truncate_on_rotation	off	\N	Reporting and Logging / Where to Log	Truncate existing log files of same name during log rotation.	\N	sighup	bool	default	\N	\N	\N	off	off	\N	\N	f
-logging_collector	on	\N	Reporting and Logging / Where to Log	Start a subprocess to capture stderr output and/or csvlogs into log files.	\N	postmaster	bool	configuration file	\N	\N	\N	off	on	\N	\N	f
+logging_collector	off	\N	Reporting and Logging / Where to Log	Start a subprocess to capture stderr output and/or csvlogs into log files.	\N	postmaster	bool	default	\N	\N	\N	off	off	\N	\N	f
 logical_decoding_work_mem	65536	kB	Resource Usage / Memory	Sets the maximum memory to be used for logical decoding.	This much memory can be used by each internal reorder buffer before spilling to disk.	user	integer	default	64	2147483647	\N	65536	65536	\N	\N	f
-maintenance_io_concurrency	0	\N	Resource Usage / Asynchronous Behavior	A variant of effective_io_concurrency that is used for maintenance work.	\N	user	integer	default	0	1000	\N	0	0	\N	\N	f
+maintenance_io_concurrency	10	\N	Resource Usage / Asynchronous Behavior	A variant of effective_io_concurrency that is used for maintenance work.	\N	user	integer	default	0	1000	\N	10	10	\N	\N	f
 maintenance_work_mem	65536	kB	Resource Usage / Memory	Sets the maximum memory to be used for maintenance operations.	This includes operations such as VACUUM and CREATE INDEX.	user	integer	default	1024	2147483647	\N	65536	65536	\N	\N	f
-max_connections	100	\N	Connections and Authentication / Connection Settings	Sets the maximum number of concurrent connections.	\N	postmaster	integer	configuration file	1	262143	\N	100	100	\N	\N	f
+max_connections	100	\N	Connections and Authentication / Connection Settings	Sets the maximum number of concurrent connections.	\N	postmaster	integer	configuration file	1	262143	\N	100	100	/etc/postgresql/14/main/postgresql.conf	65	f
 max_files_per_process	1000	\N	Resource Usage / Kernel Resources	Sets the maximum number of simultaneously open files for each server process.	\N	postmaster	integer	default	64	2147483647	\N	1000	1000	\N	\N	f
 max_function_args	100	\N	Preset Options	Shows the maximum number of function arguments.	\N	internal	integer	default	100	100	\N	100	100	\N	\N	f
 max_identifier_length	63	\N	Preset Options	Shows the maximum identifier length.	\N	internal	integer	default	63	63	\N	63	63	\N	\N	f
-max_index_keys	32	\N	Preset Options	Shows the maximum number of index keys.	\N	internal	integer	default	32	32	\N	32	32	\N	\N	f
+max_index_keys	16	\N	Preset Options	Shows the maximum number of index keys.	\N	internal	integer	default	16	16	\N	16	16	\N	\N	f
 max_locks_per_transaction	64	\N	Lock Management	Sets the maximum number of locks per transaction.	The shared lock table is sized on the assumption that at most max_locks_per_transaction * max_connections distinct objects will need to be locked at any one time.	postmaster	integer	default	10	2147483647	\N	64	64	\N	\N	f
 max_logical_replication_workers	4	\N	Replication / Subscribers	Maximum number of logical replication worker processes.	\N	postmaster	integer	default	0	262143	\N	4	4	\N	\N	f
 max_parallel_maintenance_workers	2	\N	Resource Usage / Asynchronous Behavior	Sets the maximum number of parallel processes per maintenance operation.	\N	user	integer	default	0	1024	\N	2	2	\N	\N	f
@@ -188,26 +209,28 @@ max_standby_archive_delay	30000	ms	Replication / Standby Servers	Sets the maximu
 max_standby_streaming_delay	30000	ms	Replication / Standby Servers	Sets the maximum delay before canceling queries when a hot standby server is processing streamed WAL data.	\N	sighup	integer	default	-1	2147483647	\N	30000	30000	\N	\N	f
 max_sync_workers_per_subscription	2	\N	Replication / Subscribers	Maximum number of table synchronization workers per subscription.	\N	sighup	integer	default	0	262143	\N	2	2	\N	\N	f
 max_wal_senders	10	\N	Replication / Sending Servers	Sets the maximum number of simultaneously running WAL sender processes.	\N	postmaster	integer	default	0	262143	\N	10	10	\N	\N	f
-max_wal_size	1024	MB	Write-Ahead Log / Checkpoints	Sets the WAL size that triggers a checkpoint.	\N	sighup	integer	configuration file	2	2147483647	\N	1024	1024	\N	\N	f
+max_wal_size	1024	MB	Write-Ahead Log / Checkpoints	Sets the WAL size that triggers a checkpoint.	\N	sighup	integer	configuration file	2	2147483647	\N	1024	1024	/etc/postgresql/14/main/postgresql.conf	240	f
 max_worker_processes	8	\N	Resource Usage / Asynchronous Behavior	Maximum number of concurrent worker processes.	\N	postmaster	integer	default	0	262143	\N	8	8	\N	\N	f
+min_dynamic_shared_memory	0	MB	Resource Usage / Memory	Amount of dynamic shared memory reserved at startup.	\N	postmaster	integer	default	0	2147483647	\N	0	0	\N	\N	f
 min_parallel_index_scan_size	64	8kB	Query Tuning / Planner Cost Constants	Sets the minimum amount of index data for a parallel scan.	If the planner estimates that it will read a number of index pages too small to reach this limit, a parallel scan will not be considered.	user	integer	default	0	715827882	\N	64	64	\N	\N	f
 min_parallel_table_scan_size	1024	8kB	Query Tuning / Planner Cost Constants	Sets the minimum amount of table data for a parallel scan.	If the planner estimates that it will read a number of table pages too small to reach this limit, a parallel scan will not be considered.	user	integer	default	0	715827882	\N	1024	1024	\N	\N	f
-min_wal_size	80	MB	Write-Ahead Log / Checkpoints	Sets the minimum size to shrink the WAL to.	\N	sighup	integer	configuration file	2	2147483647	\N	80	80	\N	\N	f
+min_wal_size	80	MB	Write-Ahead Log / Checkpoints	Sets the minimum size to shrink the WAL to.	\N	sighup	integer	configuration file	2	2147483647	\N	80	80	/etc/postgresql/14/main/postgresql.conf	241	f
 old_snapshot_threshold	-1	min	Resource Usage / Asynchronous Behavior	Time before a snapshot is too old to read pages changed after the snapshot was taken.	A value of -1 disables this feature.	postmaster	integer	default	-1	86400	\N	-1	-1	\N	\N	f
-operator_precedence_warning	off	\N	Version and Platform Compatibility / Previous PostgreSQL Versions	Emit a warning for constructs that changed meaning since PostgreSQL 9.4.	\N	user	bool	default	\N	\N	\N	off	off	\N	\N	f
-parallel_leader_participation	on	\N	Resource Usage / Asynchronous Behavior	Controls whether Gather and Gather Merge also run subplans.	Should gather nodes also run subplans, or just gather tuples?	user	bool	default	\N	\N	\N	on	on	\N	\N	f
+parallel_leader_participation	on	\N	Resource Usage / Asynchronous Behavior	Controls whether Gather and Gather Merge also run subplans.	Should gather nodes also run subplans or just gather tuples?	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 parallel_setup_cost	1000	\N	Query Tuning / Planner Cost Constants	Sets the planner's estimate of the cost of starting up worker processes for parallel query.	\N	user	real	default	0	1.79769e+308	\N	1000	1000	\N	\N	f
-parallel_tuple_cost	0.1	\N	Query Tuning / Planner Cost Constants	Sets the planner's estimate of the cost of passing each tuple (row) from worker to master backend.	\N	user	real	default	0	1.79769e+308	\N	0.1	0.1	\N	\N	f
-password_encryption	scram-sha-256	\N	Connections and Authentication / Authentication	Chooses the algorithm for encrypting passwords.	\N	user	enum	configuration file	\N	\N	{md5,scram-sha-256}	md5	scram-sha-256	\N	\N	f
+parallel_tuple_cost	0.1	\N	Query Tuning / Planner Cost Constants	Sets the planner's estimate of the cost of passing each tuple (row) from worker to leader backend.	\N	user	real	default	0	1.79769e+308	\N	0.1	0.1	\N	\N	f
+password_encryption	scram-sha-256	\N	Connections and Authentication / Authentication	Chooses the algorithm for encrypting passwords.	\N	user	enum	default	\N	\N	{md5,scram-sha-256}	scram-sha-256	scram-sha-256	\N	\N	f
 plan_cache_mode	auto	\N	Query Tuning / Other Planner Options	Controls the planner's selection of custom or generic plan.	Prepared statements can have custom and generic plans, and the planner will attempt to choose which is better.  This can be set to override the default behavior.	user	enum	default	\N	\N	{auto,force_generic_plan,force_custom_plan}	auto	auto	\N	\N	f
-port	5432	\N	Connections and Authentication / Connection Settings	Sets the TCP port the server listens on.	\N	postmaster	integer	configuration file	1	65535	\N	5432	5432	\N	\N	f
+port	5432	\N	Connections and Authentication / Connection Settings	Sets the TCP port the server listens on.	\N	postmaster	integer	configuration file	1	65535	\N	5432	5432	/etc/postgresql/14/main/postgresql.conf	64	f
 post_auth_delay	0	s	Developer Options	Waits N seconds on connection startup after authentication.	This allows attaching a debugger to the process.	backend	integer	default	0	2147	\N	0	0	\N	\N	f
 pre_auth_delay	0	s	Developer Options	Waits N seconds on connection startup before authentication.	This allows attaching a debugger to the process.	sighup	integer	default	0	60	\N	0	0	\N	\N	f
+primary_conninfo		\N	Replication / Standby Servers	Sets the connection string to be used to connect to the sending server.	\N	sighup	string	default	\N	\N	\N			\N	\N	f
 primary_slot_name		\N	Replication / Standby Servers	Sets the name of the replication slot to use on the sending server.	\N	sighup	string	default	\N	\N	\N			\N	\N	f
 promote_trigger_file		\N	Replication / Standby Servers	Specifies a file name whose presence ends recovery in the standby.	\N	sighup	string	default	\N	\N	\N			\N	\N	f
 quote_all_identifiers	off	\N	Version and Platform Compatibility / Previous PostgreSQL Versions	When generating SQL fragments, quote all identifiers.	\N	user	bool	default	\N	\N	\N	off	off	\N	\N	f
 random_page_cost	4	\N	Query Tuning / Planner Cost Constants	Sets the planner's estimate of the cost of a nonsequentially fetched disk page.	\N	user	real	default	0	1.79769e+308	\N	4	4	\N	\N	f
 recovery_end_command		\N	Write-Ahead Log / Archive Recovery	Sets the shell command that will be executed once at the end of recovery.	\N	sighup	string	default	\N	\N	\N			\N	\N	f
+recovery_init_sync_method	fsync	\N	Error Handling	Sets the method for synchronizing the data directory before crash recovery.	\N	sighup	enum	default	\N	\N	{fsync,syncfs}	fsync	fsync	\N	\N	f
 recovery_min_apply_delay	0	ms	Replication / Standby Servers	Sets the minimum delay for applying changes during recovery.	\N	sighup	integer	default	0	2147483647	\N	0	0	\N	\N	f
 recovery_target		\N	Write-Ahead Log / Recovery Target	Set to "immediate" to end recovery as soon as a consistent state is reached.	\N	postmaster	string	default	\N	\N	\N			\N	\N	f
 recovery_target_action	pause	\N	Write-Ahead Log / Recovery Target	Sets the action to perform upon reaching the recovery target.	\N	postmaster	enum	default	\N	\N	{pause,promote,shutdown}	pause	pause	\N	\N	f
@@ -217,70 +240,84 @@ recovery_target_name		\N	Write-Ahead Log / Recovery Target	Sets the named restor
 recovery_target_time		\N	Write-Ahead Log / Recovery Target	Sets the time stamp up to which recovery will proceed.	\N	postmaster	string	default	\N	\N	\N			\N	\N	f
 recovery_target_timeline	latest	\N	Write-Ahead Log / Recovery Target	Specifies the timeline to recover into.	\N	postmaster	string	default	\N	\N	\N	latest	latest	\N	\N	f
 recovery_target_xid		\N	Write-Ahead Log / Recovery Target	Sets the transaction ID up to which recovery will proceed.	\N	postmaster	string	default	\N	\N	\N			\N	\N	f
+remove_temp_files_after_crash	on	\N	Developer Options	Remove temporary files after backend crash.	\N	sighup	bool	default	\N	\N	\N	on	on	\N	\N	f
 restart_after_crash	on	\N	Error Handling	Reinitialize server after backend crash.	\N	sighup	bool	default	\N	\N	\N	on	on	\N	\N	f
-restore_command		\N	Write-Ahead Log / Archive Recovery	Sets the shell command that will be called to retrieve an archived WAL file.	\N	postmaster	string	default	\N	\N	\N			\N	\N	f
+restore_command		\N	Write-Ahead Log / Archive Recovery	Sets the shell command that will be called to retrieve an archived WAL file.	\N	sighup	string	default	\N	\N	\N			\N	\N	f
 row_security	on	\N	Client Connection Defaults / Statement Behavior	Enable row security.	When enabled, row security will be applied to all users.	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 search_path	public	\N	Client Connection Defaults / Statement Behavior	Sets the schema search order for names that are not schema-qualified.	\N	user	string	default	\N	\N	\N	public	public	\N	\N	f
 segment_size	131072	8kB	Preset Options	Shows the number of pages per disk file.	\N	internal	integer	default	131072	131072	\N	131072	131072	\N	\N	f
 seq_page_cost	1	\N	Query Tuning / Planner Cost Constants	Sets the planner's estimate of the cost of a sequentially fetched disk page.	\N	user	real	default	0	1.79769e+308	\N	1	1	\N	\N	f
-server_encoding	UTF8	\N	Client Connection Defaults / Locale and Formatting	Sets the server (database) character set encoding.	\N	internal	string	override	\N	\N	\N	SQL_ASCII	UTF8	\N	\N	f
-server_version	13.4	\N	Preset Options	Shows the server version.	\N	internal	string	default	\N	\N	\N	13.4	13.4	\N	\N	f
-server_version_num	130004	\N	Preset Options	Shows the server version as an integer.	\N	internal	integer	default	130004	130004	\N	130004	130004	\N	\N	f
+server_encoding	UTF8	\N	Preset Options	Shows the server (database) character set encoding.	\N	internal	string	override	\N	\N	\N	SQL_ASCII	UTF8	\N	\N	f
+server_version	14.1 (Debian 14.1-1.pgdg110+1)	\N	Preset Options	Shows the server version.	\N	internal	string	default	\N	\N	\N	14.1 (Debian 14.1-1.pgdg110+1)	14.1 (Debian 14.1-1.pgdg110+1)	\N	\N	f
+server_version_num	140001	\N	Preset Options	Shows the server version as an integer.	\N	internal	integer	default	140001	140001	\N	140001	140001	\N	\N	f
+session_preload_libraries		\N	Client Connection Defaults / Shared Library Preloading	Lists shared libraries to preload into each backend.	\N	superuser	string	default	\N	\N	\N			\N	\N	f
 session_replication_role	origin	\N	Client Connection Defaults / Statement Behavior	Sets the session's behavior for triggers and rewrite rules.	\N	superuser	enum	default	\N	\N	{origin,replica,local}	origin	origin	\N	\N	f
-shared_buffers	16384	8kB	Resource Usage / Memory	Sets the number of shared memory buffers used by the server.	\N	postmaster	integer	configuration file	16	1073741823	\N	1024	16384	\N	\N	f
+shared_buffers	16384	8kB	Resource Usage / Memory	Sets the number of shared memory buffers used by the server.	\N	postmaster	integer	configuration file	16	1073741823	\N	1024	16384	/etc/postgresql/14/main/postgresql.conf	127	f
 shared_memory_type	mmap	\N	Resource Usage / Memory	Selects the shared memory implementation used for the main shared memory region.	\N	postmaster	enum	default	\N	\N	{sysv,mmap}	mmap	mmap	\N	\N	f
-ssl	off	\N	Connections and Authentication / SSL	Enables SSL connections.	\N	sighup	bool	default	\N	\N	\N	off	off	\N	\N	f
+shared_preload_libraries		\N	Client Connection Defaults / Shared Library Preloading	Lists shared libraries to preload into server.	\N	postmaster	string	default	\N	\N	\N			\N	\N	f
+ssl	on	\N	Connections and Authentication / SSL	Enables SSL connections.	\N	sighup	bool	configuration file	\N	\N	\N	off	on	/etc/postgresql/14/main/postgresql.conf	105	f
 ssl_ca_file		\N	Connections and Authentication / SSL	Location of the SSL certificate authority file.	\N	sighup	string	default	\N	\N	\N			\N	\N	f
-ssl_cert_file	server.crt	\N	Connections and Authentication / SSL	Location of the SSL server certificate file.	\N	sighup	string	default	\N	\N	\N	server.crt	server.crt	\N	\N	f
+ssl_cert_file	/etc/ssl/certs/ssl-cert-snakeoil.pem	\N	Connections and Authentication / SSL	Location of the SSL server certificate file.	\N	sighup	string	configuration file	\N	\N	\N	server.crt	/etc/ssl/certs/ssl-cert-snakeoil.pem	/etc/postgresql/14/main/postgresql.conf	107	f
+ssl_ciphers	HIGH:MEDIUM:+3DES:!aNULL	\N	Connections and Authentication / SSL	Sets the list of allowed SSL ciphers.	\N	sighup	string	default	\N	\N	\N	HIGH:MEDIUM:+3DES:!aNULL	HIGH:MEDIUM:+3DES:!aNULL	\N	\N	f
+ssl_crl_dir		\N	Connections and Authentication / SSL	Location of the SSL certificate revocation list directory.	\N	sighup	string	default	\N	\N	\N			\N	\N	f
 ssl_crl_file		\N	Connections and Authentication / SSL	Location of the SSL certificate revocation list file.	\N	sighup	string	default	\N	\N	\N			\N	\N	f
-ssl_key_file	server.key	\N	Connections and Authentication / SSL	Location of the SSL server private key file.	\N	sighup	string	default	\N	\N	\N	server.key	server.key	\N	\N	f
-ssl_library	OpenSSL	\N	Preset Options	Name of the SSL library.	\N	internal	string	default	\N	\N	\N	OpenSSL	OpenSSL	\N	\N	f
+ssl_dh_params_file		\N	Connections and Authentication / SSL	Location of the SSL DH parameters file.	\N	sighup	string	default	\N	\N	\N			\N	\N	f
+ssl_ecdh_curve	prime256v1	\N	Connections and Authentication / SSL	Sets the curve to use for ECDH.	\N	sighup	string	default	\N	\N	\N	prime256v1	prime256v1	\N	\N	f
+ssl_key_file	/etc/ssl/private/ssl-cert-snakeoil.key	\N	Connections and Authentication / SSL	Location of the SSL server private key file.	\N	sighup	string	configuration file	\N	\N	\N	server.key	/etc/ssl/private/ssl-cert-snakeoil.key	/etc/postgresql/14/main/postgresql.conf	110	f
+ssl_library	OpenSSL	\N	Preset Options	Shows the name of the SSL library.	\N	internal	string	default	\N	\N	\N	OpenSSL	OpenSSL	\N	\N	f
+ssl_max_protocol_version		\N	Connections and Authentication / SSL	Sets the maximum SSL/TLS protocol version to use.	\N	sighup	enum	default	\N	\N	{"",TLSv1,TLSv1.1,TLSv1.2,TLSv1.3}			\N	\N	f
+ssl_min_protocol_version	TLSv1.2	\N	Connections and Authentication / SSL	Sets the minimum SSL/TLS protocol version to use.	\N	sighup	enum	default	\N	\N	{TLSv1,TLSv1.1,TLSv1.2,TLSv1.3}	TLSv1.2	TLSv1.2	\N	\N	f
+ssl_passphrase_command		\N	Connections and Authentication / SSL	Command to obtain passphrases for SSL.	\N	sighup	string	default	\N	\N	\N			\N	\N	f
 ssl_passphrase_command_supports_reload	off	\N	Connections and Authentication / SSL	Also use ssl_passphrase_command during server reload.	\N	sighup	bool	default	\N	\N	\N	off	off	\N	\N	f
 ssl_prefer_server_ciphers	on	\N	Connections and Authentication / SSL	Give priority to server ciphersuite order.	\N	sighup	bool	default	\N	\N	\N	on	on	\N	\N	f
 standard_conforming_strings	on	\N	Version and Platform Compatibility / Previous PostgreSQL Versions	Causes '...' strings to treat backslashes literally.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 statement_timeout	0	ms	Client Connection Defaults / Statement Behavior	Sets the maximum allowed duration of any statement.	A value of 0 turns off the timeout.	user	integer	default	0	2147483647	\N	0	0	\N	\N	f
+stats_temp_directory	/var/run/postgresql/14-main.pg_stat_tmp	\N	Statistics / Query and Index Statistics Collector	Writes temporary statistics files to the specified directory.	\N	sighup	string	configuration file	\N	\N	\N	pg_stat_tmp	/var/run/postgresql/14-main.pg_stat_tmp	/etc/postgresql/14/main/postgresql.conf	604	f
 superuser_reserved_connections	3	\N	Connections and Authentication / Connection Settings	Sets the number of connection slots reserved for superusers.	\N	postmaster	integer	default	0	262143	\N	3	3	\N	\N	f
 synchronize_seqscans	on	\N	Version and Platform Compatibility / Previous PostgreSQL Versions	Enable synchronized sequential scans.	\N	user	bool	default	\N	\N	\N	on	on	\N	\N	f
 synchronous_commit	on	\N	Write-Ahead Log / Settings	Sets the current transaction's synchronization level.	\N	user	enum	default	\N	\N	{local,remote_write,remote_apply,on,off}	on	on	\N	\N	f
-synchronous_standby_names		\N	Replication / Master Server	Number of synchronous standbys and list of names of potential synchronous ones.	\N	sighup	string	default	\N	\N	\N			\N	\N	f
+synchronous_standby_names		\N	Replication / Primary Server	Number of synchronous standbys and list of names of potential synchronous ones.	\N	sighup	string	default	\N	\N	\N			\N	\N	f
 syslog_facility	local0	\N	Reporting and Logging / Where to Log	Sets the syslog "facility" to be used when syslog enabled.	\N	sighup	enum	default	\N	\N	{local0,local1,local2,local3,local4,local5,local6,local7}	local0	local0	\N	\N	f
 syslog_ident	postgres	\N	Reporting and Logging / Where to Log	Sets the program name used to identify PostgreSQL messages in syslog.	\N	sighup	string	default	\N	\N	\N	postgres	postgres	\N	\N	f
 syslog_sequence_numbers	on	\N	Reporting and Logging / Where to Log	Add sequence number to syslog messages to avoid duplicate suppression.	\N	sighup	bool	default	\N	\N	\N	on	on	\N	\N	f
 syslog_split_messages	on	\N	Reporting and Logging / Where to Log	Split messages sent to syslog by lines and to fit into 1024 bytes.	\N	sighup	bool	default	\N	\N	\N	on	on	\N	\N	f
-tcp_keepalives_count	0	\N	Client Connection Defaults / Other Defaults	Maximum number of TCP keepalive retransmits.	This controls the number of consecutive keepalive retransmits that can be lost before a connection is considered dead. A value of 0 uses the system default.	user	integer	default	0	2147483647	\N	0	0	\N	\N	f
-tcp_keepalives_idle	0	s	Client Connection Defaults / Other Defaults	Time between issuing TCP keepalives.	A value of 0 uses the system default.	user	integer	default	0	2147483647	\N	0	0	\N	\N	f
-tcp_keepalives_interval	0	s	Client Connection Defaults / Other Defaults	Time between TCP keepalive retransmits.	A value of 0 uses the system default.	user	integer	default	0	2147483647	\N	0	0	\N	\N	f
-tcp_user_timeout	0	ms	Client Connection Defaults / Other Defaults	TCP user timeout.	A value of 0 uses the system default.	user	integer	default	0	2147483647	\N	0	0	\N	\N	f
+tcp_keepalives_count	0	\N	Connections and Authentication / Connection Settings	Maximum number of TCP keepalive retransmits.	This controls the number of consecutive keepalive retransmits that can be lost before a connection is considered dead. A value of 0 uses the system default.	user	integer	default	0	2147483647	\N	0	0	\N	\N	f
+tcp_keepalives_idle	0	s	Connections and Authentication / Connection Settings	Time between issuing TCP keepalives.	A value of 0 uses the system default.	user	integer	default	0	2147483647	\N	0	0	\N	\N	f
+tcp_keepalives_interval	0	s	Connections and Authentication / Connection Settings	Time between TCP keepalive retransmits.	A value of 0 uses the system default.	user	integer	default	0	2147483647	\N	0	0	\N	\N	f
+tcp_user_timeout	0	ms	Connections and Authentication / Connection Settings	TCP user timeout.	A value of 0 uses the system default.	user	integer	default	0	2147483647	\N	0	0	\N	\N	f
 temp_buffers	1024	8kB	Resource Usage / Memory	Sets the maximum number of temporary buffers used by each session.	\N	user	integer	default	100	1073741823	\N	1024	1024	\N	\N	f
 temp_file_limit	-1	kB	Resource Usage / Disk	Limits the total size of all temporary files used by each process.	-1 means no limit.	superuser	integer	default	-1	2147483647	\N	-1	-1	\N	\N	f
 temp_tablespaces		\N	Client Connection Defaults / Statement Behavior	Sets the tablespace(s) to use for temporary tables and sort files.	\N	user	string	default	\N	\N	\N			\N	\N	f
-TimeZone	Europe/Berlin	\N	Client Connection Defaults / Locale and Formatting	Sets the time zone for displaying and interpreting time stamps.	\N	user	string	configuration file	\N	\N	\N	GMT	Europe/Berlin	\N	\N	f
+TimeZone	Europe/Berlin	\N	Client Connection Defaults / Locale and Formatting	Sets the time zone for displaying and interpreting time stamps.	\N	user	string	configuration file	\N	\N	\N	GMT	Europe/Berlin	/etc/postgresql/14/main/postgresql.conf	696	f
 timezone_abbreviations	Default	\N	Client Connection Defaults / Locale and Formatting	Selects a file of time zone abbreviations.	\N	user	string	default	\N	\N	\N	\N	Default	\N	\N	f
 trace_notify	off	\N	Developer Options	Generates debugging output for LISTEN and NOTIFY.	\N	user	bool	default	\N	\N	\N	off	off	\N	\N	f
 trace_recovery_messages	log	\N	Developer Options	Enables logging of recovery-related debugging information.	Each level includes all the levels that follow it. The later the level, the fewer messages are sent.	sighup	enum	default	\N	\N	{debug5,debug4,debug3,debug2,debug1,log,notice,warning,error}	log	log	\N	\N	f
 trace_sort	off	\N	Developer Options	Emit information about resource usage in sorting.	\N	user	bool	default	\N	\N	\N	off	off	\N	\N	f
 track_activities	on	\N	Statistics / Query and Index Statistics Collector	Collects information about executing commands.	Enables the collection of information on the currently executing command of each session, along with the time at which that command began execution.	superuser	bool	default	\N	\N	\N	on	on	\N	\N	f
-track_activity_query_size	1024	B	Resource Usage / Memory	Sets the size reserved for pg_stat_activity.query, in bytes.	\N	postmaster	integer	default	100	1048576	\N	1024	1024	\N	\N	f
-track_commit_timestamp	off	\N	Replication	Collects transaction commit time.	\N	postmaster	bool	default	\N	\N	\N	off	off	\N	\N	f
+track_activity_query_size	1024	B	Statistics / Query and Index Statistics Collector	Sets the size reserved for pg_stat_activity.query, in bytes.	\N	postmaster	integer	default	100	1048576	\N	1024	1024	\N	\N	f
+track_commit_timestamp	off	\N	Replication / Sending Servers	Collects transaction commit time.	\N	postmaster	bool	default	\N	\N	\N	off	off	\N	\N	f
 track_counts	on	\N	Statistics / Query and Index Statistics Collector	Collects statistics on database activity.	\N	superuser	bool	default	\N	\N	\N	on	on	\N	\N	f
 track_functions	none	\N	Statistics / Query and Index Statistics Collector	Collects function-level statistics on database activity.	\N	superuser	enum	default	\N	\N	{none,pl,all}	none	none	\N	\N	f
 track_io_timing	off	\N	Statistics / Query and Index Statistics Collector	Collects timing statistics for database I/O activity.	\N	superuser	bool	default	\N	\N	\N	off	off	\N	\N	f
+track_wal_io_timing	off	\N	Statistics / Query and Index Statistics Collector	Collects timing statistics for WAL I/O activity.	\N	superuser	bool	default	\N	\N	\N	off	off	\N	\N	f
 transaction_deferrable	off	\N	Client Connection Defaults / Statement Behavior	Whether to defer a read-only serializable transaction until it can be executed with no possible serialization failures.	\N	user	bool	override	\N	\N	\N	off	off	\N	\N	f
-transaction_isolation	read committed	\N	Client Connection Defaults / Statement Behavior	Sets the current transaction's isolation level.	\N	user	enum	override	\N	\N	{serializable,"repeatable read","read committed","read uncommitted"}	read committed	read committed	\N	\N	f
+transaction_isolation	serializable	\N	Client Connection Defaults / Statement Behavior	Sets the current transaction's isolation level.	\N	user	enum	override	\N	\N	{serializable,"repeatable read","read committed","read uncommitted"}	serializable	serializable	\N	\N	f
 transaction_read_only	off	\N	Client Connection Defaults / Statement Behavior	Sets the current transaction's read-only status.	\N	user	bool	override	\N	\N	\N	off	off	\N	\N	f
 transform_null_equals	off	\N	Version and Platform Compatibility / Other Platforms and Clients	Treats "expr=NULL" as "expr IS NULL".	When turned on, expressions of the form expr = NULL (or NULL = expr) are treated as expr IS NULL, that is, they return true if expr evaluates to the null value, and false otherwise. The correct behavior of expr = NULL is to always return null (unknown).	user	bool	default	\N	\N	\N	off	off	\N	\N	f
+unix_socket_directories	/var/run/postgresql	\N	Connections and Authentication / Connection Settings	Sets the directories where Unix-domain sockets will be created.	\N	postmaster	string	configuration file	\N	\N	\N	/var/run/postgresql	/var/run/postgresql	/etc/postgresql/14/main/postgresql.conf	67	f
 unix_socket_group		\N	Connections and Authentication / Connection Settings	Sets the owning group of the Unix-domain socket.	The owning user of the socket is always the user that starts the server.	postmaster	string	default	\N	\N	\N			\N	\N	f
 unix_socket_permissions	0777	\N	Connections and Authentication / Connection Settings	Sets the access permissions of the Unix-domain socket.	Unix-domain sockets use the usual Unix file system permission set. The parameter value is expected to be a numeric mode specification in the form accepted by the chmod and umask system calls. (To use the customary octal format the number must start with a 0 (zero).)	postmaster	integer	default	0	511	\N	511	511	\N	\N	f
-update_process_title	on	\N	Process Title	Updates the process title to show the active SQL command.	Enables updating of the process title every time a new SQL command is received by the server.	superuser	bool	default	\N	\N	\N	on	on	\N	\N	f
-vacuum_cleanup_index_scale_factor	0.1	\N	Client Connection Defaults / Statement Behavior	Number of tuple inserts prior to index cleanup as a fraction of reltuples.	\N	user	real	default	0	1e+10	\N	0.1	0.1	\N	\N	f
+update_process_title	on	\N	Reporting and Logging / Process Title	Updates the process title to show the active SQL command.	Enables updating of the process title every time a new SQL command is received by the server.	superuser	bool	default	\N	\N	\N	on	on	\N	\N	f
 vacuum_cost_delay	0	ms	Resource Usage / Cost-Based Vacuum Delay	Vacuum cost delay in milliseconds.	\N	user	real	default	0	100	\N	0	0	\N	\N	f
 vacuum_cost_limit	200	\N	Resource Usage / Cost-Based Vacuum Delay	Vacuum cost amount available before napping.	\N	user	integer	default	1	10000	\N	200	200	\N	\N	f
 vacuum_cost_page_dirty	20	\N	Resource Usage / Cost-Based Vacuum Delay	Vacuum cost for a page dirtied by vacuum.	\N	user	integer	default	0	10000	\N	20	20	\N	\N	f
 vacuum_cost_page_hit	1	\N	Resource Usage / Cost-Based Vacuum Delay	Vacuum cost for a page found in the buffer cache.	\N	user	integer	default	0	10000	\N	1	1	\N	\N	f
-vacuum_cost_page_miss	10	\N	Resource Usage / Cost-Based Vacuum Delay	Vacuum cost for a page not found in the buffer cache.	\N	user	integer	default	0	10000	\N	10	10	\N	\N	f
-vacuum_defer_cleanup_age	0	\N	Replication / Master Server	Number of transactions by which VACUUM and HOT cleanup should be deferred, if any.	\N	sighup	integer	default	0	1000000	\N	0	0	\N	\N	f
+vacuum_cost_page_miss	2	\N	Resource Usage / Cost-Based Vacuum Delay	Vacuum cost for a page not found in the buffer cache.	\N	user	integer	default	0	10000	\N	2	2	\N	\N	f
+vacuum_defer_cleanup_age	0	\N	Replication / Primary Server	Number of transactions by which VACUUM and HOT cleanup should be deferred, if any.	\N	sighup	integer	default	0	1000000	\N	0	0	\N	\N	f
+vacuum_failsafe_age	1600000000	\N	Client Connection Defaults / Statement Behavior	Age at which VACUUM should trigger failsafe to avoid a wraparound outage.	\N	user	integer	default	0	2100000000	\N	1600000000	1600000000	\N	\N	f
 vacuum_freeze_min_age	50000000	\N	Client Connection Defaults / Statement Behavior	Minimum age at which VACUUM should freeze a table row.	\N	user	integer	default	0	1000000000	\N	50000000	50000000	\N	\N	f
 vacuum_freeze_table_age	150000000	\N	Client Connection Defaults / Statement Behavior	Age at which VACUUM should scan whole table to freeze tuples.	\N	user	integer	default	0	2000000000	\N	150000000	150000000	\N	\N	f
+vacuum_multixact_failsafe_age	1600000000	\N	Client Connection Defaults / Statement Behavior	Multixact age at which VACUUM should trigger failsafe to avoid a wraparound outage.	\N	user	integer	default	0	2100000000	\N	1600000000	1600000000	\N	\N	f
 vacuum_multixact_freeze_min_age	5000000	\N	Client Connection Defaults / Statement Behavior	Minimum age at which VACUUM should freeze a MultiXactId in a table row.	\N	user	integer	default	0	1000000000	\N	5000000	5000000	\N	\N	f
 vacuum_multixact_freeze_table_age	150000000	\N	Client Connection Defaults / Statement Behavior	Multixact age at which VACUUM should scan whole table to freeze tuples.	\N	user	integer	default	0	2000000000	\N	150000000	150000000	\N	\N	f
 wal_block_size	8192	\N	Preset Options	Shows the block size in the write ahead log.	\N	internal	integer	default	8192	8192	\N	8192	8192	\N	\N	f
@@ -289,7 +326,7 @@ wal_compression	off	\N	Write-Ahead Log / Settings	Compresses full-page writes wr
 wal_consistency_checking		\N	Developer Options	Sets the WAL resource managers for which WAL consistency checks are done.	Full-page images will be logged for all data blocks and cross-checked against the results of WAL replay.	superuser	string	default	\N	\N	\N			\N	\N	f
 wal_init_zero	on	\N	Write-Ahead Log / Settings	Writes zeroes to new WAL files before first use.	\N	superuser	bool	default	\N	\N	\N	on	on	\N	\N	f
 wal_keep_size	0	MB	Replication / Sending Servers	Sets the size of WAL files held for standby servers.	\N	sighup	integer	default	0	2147483647	\N	0	0	\N	\N	f
-wal_level	replica	\N	Write-Ahead Log / Settings	Set the level of information written to the WAL.	\N	postmaster	enum	default	\N	\N	{minimal,replica,logical}	replica	replica	\N	\N	f
+wal_level	replica	\N	Write-Ahead Log / Settings	Sets the level of information written to the WAL.	\N	postmaster	enum	default	\N	\N	{minimal,replica,logical}	replica	replica	\N	\N	f
 wal_log_hints	off	\N	Write-Ahead Log / Settings	Writes full pages to WAL when first modified after a checkpoint, even for a non-critical modification.	\N	postmaster	bool	default	\N	\N	\N	off	off	\N	\N	f
 wal_receiver_create_temp_slot	off	\N	Replication / Standby Servers	Sets whether a WAL receiver should create a temporary replication slot if no permanent slot is configured.	\N	sighup	bool	default	\N	\N	\N	off	off	\N	\N	f
 wal_receiver_status_interval	10	s	Replication / Standby Servers	Sets the maximum interval between WAL receiver status reports to the sending server.	\N	sighup	integer	default	0	2147483	\N	10	10	\N	\N	f
@@ -298,8 +335,8 @@ wal_recycle	on	\N	Write-Ahead Log / Settings	Recycles WAL files by renaming them
 wal_retrieve_retry_interval	5000	ms	Replication / Standby Servers	Sets the time to wait before retrying to retrieve WAL after a failed attempt.	\N	sighup	integer	default	1	2147483647	\N	5000	5000	\N	\N	f
 wal_segment_size	16777216	B	Preset Options	Shows the size of write ahead log segments.	\N	internal	integer	override	1048576	1073741824	\N	16777216	16777216	\N	\N	f
 wal_sender_timeout	60000	ms	Replication / Sending Servers	Sets the maximum time to wait for WAL replication.	\N	user	integer	default	0	2147483647	\N	60000	60000	\N	\N	f
-wal_skip_threshold	2048	kB	Write-Ahead Log / Settings	Size of new file to fsync instead of writing WAL.	\N	user	integer	default	0	2147483647	\N	2048	2048	\N	\N	f
-wal_sync_method	open_datasync	\N	Write-Ahead Log / Settings	Selects the method used for forcing WAL updates to disk.	\N	sighup	enum	default	\N	\N	{fsync,fsync_writethrough,fdatasync,open_sync,open_datasync}	open_datasync	open_datasync	\N	\N	f
+wal_skip_threshold	2048	kB	Write-Ahead Log / Settings	Minimum size of new file to fsync instead of writing WAL.	\N	user	integer	default	0	2147483647	\N	2048	2048	\N	\N	f
+wal_sync_method	fdatasync	\N	Write-Ahead Log / Settings	Selects the method used for forcing WAL updates to disk.	\N	sighup	enum	default	\N	\N	{fsync,fdatasync,open_sync,open_datasync}	fdatasync	fdatasync	\N	\N	f
 wal_writer_delay	200	ms	Write-Ahead Log / Settings	Time between WAL flushes performed in the WAL writer.	\N	sighup	integer	default	1	10000	\N	200	200	\N	\N	f
 wal_writer_flush_after	128	8kB	Write-Ahead Log / Settings	Amount of WAL written out by WAL writer that triggers a flush.	\N	sighup	integer	default	0	2147483647	\N	128	128	\N	\N	f
 work_mem	4096	kB	Resource Usage / Memory	Sets the maximum memory to be used for query workspaces.	This much memory can be used by each internal sort operation and hash table before switching to temporary disk files.	user	integer	default	64	2147483647	\N	4096	4096	\N	\N	f


Test patch:
diff --git a/src/test/java/com/google/cloud/spanner/pgadapter/ITJdbcTest.java b/src/test/java/com/google/cloud/spanner/pgadapter/ITJdbcTest.java
index 6fa3f1b4..c984dc7a 100644
--- a/src/test/java/com/google/cloud/spanner/pgadapter/ITJdbcTest.java
+++ b/src/test/java/com/google/cloud/spanner/pgadapter/ITJdbcTest.java
@@ -735,6 +735,76 @@ public class ITJdbcTest implements IntegrationTest {
     }
   }
 
+  @Test
+  public void testPGSettings() throws SQLException {
+    try (Connection connection = DriverManager.getConnection(getConnectionUrl())) {
+      // First verify the default value.
+      // JDBC sets the DateStyle to 'ISO' for every connection in the connection request.
+      try (ResultSet resultSet =
+          connection
+              .createStatement()
+              .executeQuery("select setting from pg_settings where name='DateStyle'")) {
+        assertTrue(resultSet.next());
+        assertEquals("ISO", resultSet.getString("setting"));
+        assertFalse(resultSet.next());
+      }
+      // Verify that we can also use a statement parameter to query the pg_settings table.
+      try (PreparedStatement preparedStatement =
+          connection.prepareStatement("select setting from pg_settings where name=?")) {
+        preparedStatement.setString(1, "DateStyle");
+        try (ResultSet resultSet = preparedStatement.executeQuery()) {
+          assertTrue(resultSet.next());
+          assertEquals("ISO", resultSet.getString("setting"));
+          assertFalse(resultSet.next());
+        }
+      }
+      // Change the date style and verify that it is also reflected in  pg_settings.
+      connection.createStatement().execute("set datestyle to 'iso, ymd'");
+      try (ResultSet resultSet =
+          connection
+              .createStatement()
+              .executeQuery("select setting from pg_settings where name='DateStyle'")) {
+        assertTrue(resultSet.next());
+        assertEquals("iso, ymd", resultSet.getString("setting"));
+        assertFalse(resultSet.next());
+      }
+
+      // Verify that pg_settings also respects transactions.
+      connection.setAutoCommit(false);
+      connection.createStatement().execute("set datestyle to 'iso'");
+      try (ResultSet resultSet =
+          connection
+              .createStatement()
+              .executeQuery("select setting from pg_settings where name='DateStyle'")) {
+        assertTrue(resultSet.next());
+        assertEquals("iso", resultSet.getString("setting"));
+        assertFalse(resultSet.next());
+      }
+      // This should also roll back the changes to pg_settings.
+      connection.rollback();
+      try (ResultSet resultSet =
+          connection
+              .createStatement()
+              .executeQuery("select setting from pg_settings where name='DateStyle'")) {
+        assertTrue(resultSet.next());
+        assertEquals("iso, ymd", resultSet.getString("setting"));
+        assertFalse(resultSet.next());
+      }
+
+      // Resetting the value should bring it back to the initial value.
+      connection.createStatement().execute("reset datestyle");
+      connection.commit();
+      try (ResultSet resultSet =
+          connection
+              .createStatement()
+              .executeQuery("select setting from pg_settings where name='DateStyle'")) {
+        assertTrue(resultSet.next());
+        assertEquals("ISO", resultSet.getString("setting"));
+        assertFalse(resultSet.next());
+      }
+    }
+  }
+
   private void writeExtraTestRows() {
     testEnv.write(
         database.getId().getDatabase(),
diff --git a/src/test/java/com/google/cloud/spanner/pgadapter/JdbcMockServerTest.java b/src/test/java/com/google/cloud/spanner/pgadapter/JdbcMockServerTest.java
index 2a4d6ecb..c453ff1c 100644
--- a/src/test/java/com/google/cloud/spanner/pgadapter/JdbcMockServerTest.java
+++ b/src/test/java/com/google/cloud/spanner/pgadapter/JdbcMockServerTest.java
@@ -1648,6 +1648,18 @@ public class JdbcMockServerTest extends AbstractMockServerTest {
     }
   }
 
+  @Test
+  public void testShowSettingWithStartupValue() throws SQLException {
+    try (Connection connection = DriverManager.getConnection(createUrl())) {
+      // DATESTYLE is set to 'ISO' by the JDBC driver at startup.
+      try (ResultSet resultSet = connection.createStatement().executeQuery("show DATESTYLE")) {
+        assertTrue(resultSet.next());
+        assertEquals("ISO", resultSet.getString(1));
+        assertFalse(resultSet.next());
+      }
+    }
+  }
+
   @Test
   public void testShowInvalidSetting() throws SQLException {
     try (Connection connection = DriverManager.getConnection(createUrl())) {
@@ -1724,6 +1736,33 @@ public class JdbcMockServerTest extends AbstractMockServerTest {
     }
   }
 
+  @Test
+  public void testResetSettingWithStartupValue() throws SQLException {
+    try (Connection connection = DriverManager.getConnection(createUrl())) {
+      try (ResultSet resultSet = connection.createStatement().executeQuery("show datestyle")) {
+        assertTrue(resultSet.next());
+        assertEquals("ISO", resultSet.getString(1));
+        assertFalse(resultSet.next());
+      }
+
+      connection.createStatement().execute("set datestyle to 'iso, ymd'");
+
+      try (ResultSet resultSet = connection.createStatement().executeQuery("show datestyle")) {
+        assertTrue(resultSet.next());
+        assertEquals("iso, ymd", resultSet.getString(1));
+        assertFalse(resultSet.next());
+      }
+
+      connection.createStatement().execute("reset datestyle");
+
+      try (ResultSet resultSet = connection.createStatement().executeQuery("show datestyle")) {
+        assertTrue(resultSet.next());
+        assertEquals("ISO", resultSet.getString(1));
+        assertFalse(resultSet.next());
+      }
+    }
+  }
+
   @Test
   public void testResetInvalidSetting() throws SQLException {
     try (Connection connection = DriverManager.getConnection(createUrl())) {
@@ -1967,7 +2006,7 @@ public class JdbcMockServerTest extends AbstractMockServerTest {
           }
           count++;
         }
-        assertEquals(308, count);
+        assertEquals(345, count);
       }
     }
   }
@@ -2011,6 +2050,30 @@ public class JdbcMockServerTest extends AbstractMockServerTest {
     }
   }
 
+  @Test
+  public void testSettingsAreUniqueToConnections() throws SQLException {
+    // Verify that each new connection gets a separate set of settings.
+    for (int connectionNum = 0; connectionNum < 5; connectionNum++) {
+      try (Connection connection = DriverManager.getConnection(createUrl())) {
+        // Verify that the initial value is null.
+        verifySettingIsNull(connection, "application_name");
+        connection.createStatement().execute("set application_name to \"my-application\"");
+        verifySettingValue(connection, "application_name", "my-application");
+      }
+    }
+  }
+
+  @Test
+  public void testSettingInConnectionOptions() throws SQLException {
+    try (Connection connection =
+        DriverManager.getConnection(
+            createUrl()
+                + "?options=-c%20spanner.ddl_transaction_mode=AutocommitExplicitTransaction")) {
+      verifySettingValue(
+          connection, "spanner.ddl_transaction_mode", "AutocommitExplicitTransaction");
+    }
+  }
+
   private void verifySettingIsNull(Connection connection, String setting) throws SQLException {
     try (ResultSet resultSet =
         connection.createStatement().executeQuery(String.format("show %s", setting))) {
diff --git a/src/test/java/com/google/cloud/spanner/pgadapter/session/SessionStateTest.java b/src/test/java/com/google/cloud/spanner/pgadapter/session/SessionStateTest.java
index 95ad3bc8..f5647bea 100644
--- a/src/test/java/com/google/cloud/spanner/pgadapter/session/SessionStateTest.java
+++ b/src/test/java/com/google/cloud/spanner/pgadapter/session/SessionStateTest.java
@@ -16,10 +16,15 @@ package com.google.cloud.spanner.pgadapter.session;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertThrows;
 import static org.mockito.Mockito.mock;
 
+import com.google.cloud.spanner.Dialect;
 import com.google.cloud.spanner.SpannerException;
+import com.google.cloud.spanner.Statement;
+import com.google.cloud.spanner.connection.AbstractStatementParser;
+import com.google.cloud.spanner.connection.AbstractStatementParser.ParsedStatement;
 import com.google.cloud.spanner.pgadapter.metadata.OptionsMetadata;
 import java.util.List;
 import org.junit.Test;
@@ -146,7 +151,7 @@ public class SessionStateTest {
   public void testGetAll() {
     SessionState state = new SessionState(mock(OptionsMetadata.class));
     List<PGSetting> allSettings = state.getAll();
-    assertEquals(308, allSettings.size());
+    assertEquals(345, allSettings.size());
   }
 
   @Test
@@ -184,7 +189,7 @@ public class SessionStateTest {
     state.setLocal("spanner", "custom_local_setting", "value2");
 
     List<PGSetting> allSettings = state.getAll();
-    assertEquals(310, allSettings.size());
+    assertEquals(347, allSettings.size());
 
     PGSetting applicationName =
         allSettings.stream()
@@ -386,4 +391,143 @@ public class SessionStateTest {
         "INVALID_ARGUMENT: parameter \"post_auth_delay\" cannot be set after connection start",
         exception.getMessage());
   }
+
+  static String getDefaultSessionStateExpression() {
+    return "pg_settings_inmem_ as (\n"
+        + "select 'DateStyle' as name, 'ISO, MDY' as setting, null as unit, 'Client Connection Defaults / Locale and Formatting' as category, null as short_desc, null as extra_desc, 'user' as context, 'string' as vartype, null as min_val, null as max_val, null::text[] as enumvals, 'ISO, MDY' as boot_val, 'ISO, MDY' as reset_val, 'configuration file' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart\n"
+        + "union all\n"
+        + "select 'TimeZone' as name, 'Europe/Berlin' as setting, null as unit, 'Client Connection Defaults / Locale and Formatting' as category, null as short_desc, null as extra_desc, 'user' as context, 'string' as vartype, null as min_val, null as max_val, null::text[] as enumvals, 'GMT' as boot_val, 'Europe/Berlin' as reset_val, 'configuration file' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart\n"
+        + "union all\n"
+        + "select 'application_name' as name, null as setting, null as unit, 'Reporting and Logging / What to Log' as category, null as short_desc, null as extra_desc, 'user' as context, 'string' as vartype, null as min_val, null as max_val, null::text[] as enumvals, '' as boot_val, null as reset_val, 'client' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart\n"
+        + "union all\n"
+        + "select 'bytea_output' as name, 'hex' as setting, null as unit, 'Client Connection Defaults / Statement Behavior' as category, null as short_desc, null as extra_desc, 'user' as context, 'enum' as vartype, null as min_val, null as max_val, '{\"escape\", \"hex\"}'::text[] as enumvals, 'hex' as boot_val, 'hex' as reset_val, 'default' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart\n"
+        + "union all\n"
+        + "select 'default_transaction_isolation' as name, 'serializable' as setting, null as unit, 'Client Connection Defaults / Statement Behavior' as category, null as short_desc, null as extra_desc, 'user' as context, 'enum' as vartype, null as min_val, null as max_val, '{\"serializable\", \"repeatable read\", \"read committed\", \"read uncommitted\"}'::text[] as enumvals, 'serializable' as boot_val, 'serializable' as reset_val, 'default' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart\n"
+        + "union all\n"
+        + "select 'default_transaction_read_only' as name, 'off' as setting, null as unit, 'Client Connection Defaults / Statement Behavior' as category, null as short_desc, null as extra_desc, 'user' as context, 'bool' as vartype, null as min_val, null as max_val, null::text[] as enumvals, 'off' as boot_val, 'off' as reset_val, 'default' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart\n"
+        + "union all\n"
+        + "select 'extra_float_digits' as name, '1' as setting, null as unit, 'Client Connection Defaults / Locale and Formatting' as category, null as short_desc, null as extra_desc, 'user' as context, 'integer' as vartype, '-15' as min_val, '3' as max_val, null::text[] as enumvals, '1' as boot_val, '1' as reset_val, 'default' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart\n"
+        + "union all\n"
+        + "select 'max_connections' as name, '100' as setting, null as unit, 'Connections and Authentication / Connection Settings' as category, null as short_desc, null as extra_desc, 'postmaster' as context, 'integer' as vartype, '1' as min_val, '262143' as max_val, null::text[] as enumvals, '100' as boot_val, '100' as reset_val, 'configuration file' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart\n"
+        + "union all\n"
+        + "select 'max_index_keys' as name, '16' as setting, null as unit, 'Preset Options' as category, null as short_desc, null as extra_desc, 'internal' as context, 'integer' as vartype, '16' as min_val, '16' as max_val, null::text[] as enumvals, '16' as boot_val, '16' as reset_val, 'default' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart\n"
+        + "union all\n"
+        + "select 'port' as name, '5432' as setting, null as unit, 'Connections and Authentication / Connection Settings' as category, null as short_desc, null as extra_desc, 'postmaster' as context, 'integer' as vartype, '1' as min_val, '65535' as max_val, null::text[] as enumvals, '5432' as boot_val, '5432' as reset_val, 'configuration file' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart\n"
+        + "union all\n"
+        + "select 'search_path' as name, 'public' as setting, null as unit, 'Client Connection Defaults / Statement Behavior' as category, null as short_desc, null as extra_desc, 'user' as context, 'string' as vartype, null as min_val, null as max_val, null::text[] as enumvals, 'public' as boot_val, 'public' as reset_val, 'default' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart\n"
+        + "union all\n"
+        + "select 'server_version' as name, null as setting, null as unit, 'Preset Options' as category, null as short_desc, null as extra_desc, 'internal' as context, 'string' as vartype, null as min_val, null as max_val, null::text[] as enumvals, '14.1 (Debian 14.1-1.pgdg110+1)' as boot_val, '14.1 (Debian 14.1-1.pgdg110+1)' as reset_val, 'default' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart\n"
+        + "union all\n"
+        + "select 'server_version_num' as name, null as setting, null as unit, 'Preset Options' as category, null as short_desc, null as extra_desc, 'internal' as context, 'integer' as vartype, '140001' as min_val, '140001' as max_val, null::text[] as enumvals, '140001' as boot_val, '140001' as reset_val, 'default' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart\n"
+        + "union all\n"
+        + "select 'transaction_isolation' as name, 'serializable' as setting, null as unit, 'Client Connection Defaults / Statement Behavior' as category, null as short_desc, null as extra_desc, 'user' as context, 'enum' as vartype, null as min_val, null as max_val, '{\"serializable\", \"repeatable read\", \"read committed\", \"read uncommitted\"}'::text[] as enumvals, 'serializable' as boot_val, 'serializable' as reset_val, 'override' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart\n"
+        + "union all\n"
+        + "select 'transaction_read_only' as name, 'off' as setting, null as unit, 'Client Connection Defaults / Statement Behavior' as category, null as short_desc, null as extra_desc, 'user' as context, 'bool' as vartype, null as min_val, null as max_val, null::text[] as enumvals, 'off' as boot_val, 'off' as reset_val, 'override' as source, null as sourcefile, null::bigint as sourceline, 'f'::boolean as pending_restart\n"
+        + "),\n"
+        + "pg_settings_names_ as (\n"
+        + "select name from pg_settings_inmem_\n"
+        + "union\n"
+        + "select name from pg_catalog.pg_settings\n"
+        + "),\n"
+        + "pg_settings as (\n"
+        + "select n.name, coalesce(s1.setting, s2.setting) as setting,coalesce(s1.unit, s2.unit) as unit,coalesce(s1.category, s2.category) as category,coalesce(s1.short_desc, s2.short_desc) as short_desc,coalesce(s1.extra_desc, s2.extra_desc) as extra_desc,coalesce(s1.context, s2.context) as context,coalesce(s1.vartype, s2.vartype) as vartype,coalesce(s1.source, s2.source) as source,coalesce(s1.min_val, s2.min_val) as min_val,coalesce(s1.max_val, s2.max_val) as max_val,coalesce(s1.enumvals, s2.enumvals) as enumvals,coalesce(s1.boot_val, s2.boot_val) as boot_val,coalesce(s1.reset_val, s2.reset_val) as reset_val,coalesce(s1.sourcefile, s2.sourcefile) as sourcefile,coalesce(s1.sourceline, s2.sourceline) as sourceline,coalesce(s1.pending_restart, s2.pending_restart) as pending_restart\n"
+        + "from pg_settings_names_ n\n"
+        + "left join pg_settings_inmem_ s1 using (name)\n"
+        + "left join pg_catalog.pg_settings s2 using (name)\n"
+        + "order by name\n"
+        + ")\n";
+  }
+
+  @Test
+  public void testGeneratePGSettingsCte() {
+    SessionState state = new SessionState(mock(OptionsMetadata.class));
+
+    String cte = state.generatePGSettingsCte();
+
+    assertEquals(getDefaultSessionStateExpression(), cte);
+  }
+
+  @Test
+  public void testAddSessionState() {
+    SessionState state = new SessionState(mock(OptionsMetadata.class));
+    Statement statement = Statement.of("select * from pg_settings");
+    ParsedStatement parsedStatement =
+        AbstractStatementParser.getInstance(Dialect.POSTGRESQL).parse(statement);
+
+    Statement withSessionState = state.addSessionState(parsedStatement, statement);
+
+    assertEquals(
+        "with " + getDefaultSessionStateExpression() + " " + statement.getSql(),
+        withSessionState.getSql());
+  }
+
+  @Test
+  public void testAddSessionStateWithParameters() {
+    SessionState state = new SessionState(mock(OptionsMetadata.class));
+    Statement statement =
+        Statement.newBuilder("select * from pg_settings where name=$1")
+            .bind("p1")
+            .to("some-name")
+            .build();
+    ParsedStatement parsedStatement =
+        AbstractStatementParser.getInstance(Dialect.POSTGRESQL).parse(statement);
+
+    Statement withSessionState = state.addSessionState(parsedStatement, statement);
+
+    assertEquals(
+        Statement.newBuilder(
+                "with " + getDefaultSessionStateExpression() + " " + statement.getSql())
+            .bind("p1")
+            .to("some-name")
+            .build(),
+        withSessionState);
+  }
+
+  @Test
+  public void testAddSessionStateWithoutPgSettings() {
+    SessionState state = new SessionState(mock(OptionsMetadata.class));
+    Statement statement = Statement.of("select * from some_table");
+    ParsedStatement parsedStatement =
+        AbstractStatementParser.getInstance(Dialect.POSTGRESQL).parse(statement);
+
+    Statement withSessionState = state.addSessionState(parsedStatement, statement);
+
+    assertSame(statement, withSessionState);
+  }
+
+  @Test
+  public void testAddSessionStateWithComments() {
+    SessionState state = new SessionState(mock(OptionsMetadata.class));
+    Statement statement =
+        Statement.of("/* This comment is not preserved */ select * from pg_settings");
+    ParsedStatement parsedStatement =
+        AbstractStatementParser.getInstance(Dialect.POSTGRESQL).parse(statement);
+
+    Statement withSessionState = state.addSessionState(parsedStatement, statement);
+
+    assertEquals(
+        "with "
+            + getDefaultSessionStateExpression()
+            + " "
+            + parsedStatement.getSqlWithoutComments(),
+        withSessionState.getSql());
+  }
+
+  @Test
+  public void testAddSessionStateWithExistingCte() {
+    SessionState state = new SessionState(mock(OptionsMetadata.class));
+    Statement statement =
+        Statement.of(
+            "with my_cte as (select col1, col2 from foo) select * from pg_settings inner join my_cte on my_cte.col1=pg_settings.name");
+    ParsedStatement parsedStatement =
+        AbstractStatementParser.getInstance(Dialect.POSTGRESQL).parse(statement);
+
+    Statement withSessionState = state.addSessionState(parsedStatement, statement);
+
+    assertEquals(
+        "with "
+            + getDefaultSessionStateExpression()
+            + ",  my_cte as (select col1, col2 from foo) select * from pg_settings inner join my_cte on my_cte.col1=pg_settings.name",
+        withSessionState.getSql());
+  }
 }
diff --git a/src/test/java/com/google/cloud/spanner/pgadapter/wireprotocol/ProtocolTest.java b/src/test/java/com/google/cloud/spanner/pgadapter/wireprotocol/ProtocolTest.java
index beffe2ef..cf60cf95 100644
--- a/src/test/java/com/google/cloud/spanner/pgadapter/wireprotocol/ProtocolTest.java
+++ b/src/test/java/com/google/cloud/spanner/pgadapter/wireprotocol/ProtocolTest.java
@@ -1518,6 +1518,9 @@ public class ProtocolTest {
     when(connectionHandler.getConnectionMetadata()).thenReturn(connectionMetadata);
     when(connectionHandler.getServer()).thenReturn(server);
     when(connectionHandler.getConnectionId()).thenReturn(1);
+    when(connectionHandler.getExtendedQueryProtocolHandler())
+        .thenReturn(extendedQueryProtocolHandler);
+    when(extendedQueryProtocolHandler.getBackendConnection()).thenReturn(backendConnection);
     when(server.getOptions()).thenReturn(options);
     when(options.getServerVersion()).thenReturn("13.4");
     when(options.shouldAuthenticate()).thenReturn(false);