v20250103-0022-pg_restore-A-variable.patch
text/x-patch
Filename: v20250103-0022-pg_restore-A-variable.patch
Type: text/x-patch
Part: 0
Message:
Re: Re: proposal: schema variables
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v20250103-0022
Subject: pg_restore -A, --variable
| File | + | − |
|---|---|---|
| doc/src/sgml/ref/pg_restore.sgml | 11 | 0 |
| src/bin/pg_dump/pg_restore.c | 8 | 1 |
From e7939e726bc5031c3646d74254cecf9821347d90 Mon Sep 17 00:00:00 2001
From: "okbob@github.com" <okbob@github.com>
Date: Sun, 21 Jul 2024 17:04:41 +0200
Subject: [PATCH 22/22] pg_restore -A, --variable
possibility to restore session variable specified by name
---
doc/src/sgml/ref/pg_restore.sgml | 11 +++++++++++
src/bin/pg_dump/pg_restore.c | 9 ++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/doc/src/sgml/ref/pg_restore.sgml b/doc/src/sgml/ref/pg_restore.sgml
index b8b27e1719e..7a3a4eabe25 100644
--- a/doc/src/sgml/ref/pg_restore.sgml
+++ b/doc/src/sgml/ref/pg_restore.sgml
@@ -106,6 +106,17 @@ PostgreSQL documentation
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>-A <replaceable class="parameter">session_variable</replaceable></option></term>
+ <term><option>--variable=<replaceable class="parameter">session_variable</replaceable></option></term>
+ <listitem>
+ <para>
+ Restore a named session variable only. Multiple session variables may
+ be specified with multiple <option>-A</option> switches.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>-c</option></term>
<term><option>--clean</option></term>
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 88ae39d938a..52180c97d93 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -106,6 +106,7 @@ main(int argc, char **argv)
{"trigger", 1, NULL, 'T'},
{"use-list", 1, NULL, 'L'},
{"username", 1, NULL, 'U'},
+ {"variable", 1, NULL, 'A'},
{"verbose", 0, NULL, 'v'},
{"single-transaction", 0, NULL, '1'},
@@ -156,7 +157,7 @@ main(int argc, char **argv)
}
}
- while ((c = getopt_long(argc, argv, "acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1",
+ while ((c = getopt_long(argc, argv, "A:acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1",
cmdopts, NULL)) != -1)
{
switch (c)
@@ -164,6 +165,11 @@ main(int argc, char **argv)
case 'a': /* Dump data only */
data_only = true;
break;
+ case 'A': /* vAriable */
+ opts->selTypes = 1;
+ opts->selVariable = 1;
+ simple_string_list_append(&opts->variableNames, optarg);
+ break;
case 'c': /* clean (i.e., drop) schema prior to create */
opts->dropSchema = 1;
break;
@@ -468,6 +474,7 @@ usage(const char *progname)
printf(_("\nOptions controlling the restore:\n"));
printf(_(" -a, --data-only restore only the data, no schema\n"));
+ printf(_(" -A, --variable=NAME restore named session variable\n"));
printf(_(" -c, --clean clean (drop) database objects before recreating\n"));
printf(_(" -C, --create create the target database\n"));
printf(_(" -e, --exit-on-error exit on error, default is to continue\n"));
--
2.47.1