Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0dc3f57

Browse files
committed
In pg_upgrade, add -o/-O options to pass parameters to the servers, and
document its use for config-only directory installs.
1 parentc0f03aa commit0dc3f57

File tree

4 files changed

+52
-18
lines changed

4 files changed

+52
-18
lines changed

‎contrib/pg_upgrade/option.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ parseCommandLine(int argc, char *argv[])
3939
{"new-datadir",required_argument,NULL,'D'},
4040
{"old-bindir",required_argument,NULL,'b'},
4141
{"new-bindir",required_argument,NULL,'B'},
42+
{"old-options",required_argument,NULL,'o'},
43+
{"new-options",required_argument,NULL,'O'},
4244
{"old-port",required_argument,NULL,'p'},
4345
{"new-port",required_argument,NULL,'P'},
4446

@@ -93,7 +95,7 @@ parseCommandLine(int argc, char *argv[])
9395

9496
getcwd(os_info.cwd,MAXPGPATH);
9597

96-
while ((option=getopt_long(argc,argv,"d:D:b:B:cgG:kl:p:P:u:v",
98+
while ((option=getopt_long(argc,argv,"d:D:b:B:cgG:kl:o:O:p:P:u:v",
9799
long_options,&optindex))!=-1)
98100
{
99101
switch (option)
@@ -141,6 +143,19 @@ parseCommandLine(int argc, char *argv[])
141143
log_opts.filename=pg_strdup(optarg);
142144
break;
143145

146+
case'o':
147+
old_cluster.pgopts=pg_strdup(optarg);
148+
break;
149+
150+
case'O':
151+
new_cluster.pgopts=pg_strdup(optarg);
152+
break;
153+
154+
/*
155+
* Someday, the port number option could be removed and
156+
* passed using -o/-O, but that requires postmaster -C
157+
* to be supported on all old/new versions.
158+
*/
144159
case'p':
145160
if ((old_cluster.port=atoi(optarg)) <=0)
146161
{
@@ -242,6 +257,8 @@ Options:\n\
242257
-G, --debugfile=FILENAME output debugging activity to file\n\
243258
-k, --link link instead of copying files to new cluster\n\
244259
-l, --logfile=FILENAME log session activity to file\n\
260+
-o, --old-options=OPTIONS old cluster options to pass to the server\n\
261+
-O, --new-options=OPTIONS new cluster options to pass to the server\n\
245262
-p, --old-port=OLDPORT old cluster port number (default %d)\n\
246263
-P, --new-port=NEWPORT new cluster port number (default %d)\n\
247264
-u, --user=NAME clusters superuser (default \"%s\")\n\

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ typedef struct
189189
char*pgdata;/* pathname for cluster's $PGDATA directory */
190190
char*pgconfig;/* pathname for cluster's config file directory */
191191
char*bindir;/* pathname for cluster's executable directory */
192+
char*pgopts;/* options to pass to the server, like pg_ctl -o */
192193
unsigned shortport;/* port number where postmaster is waiting */
193194
uint32major_version;/* PG_VERSION of cluster */
194195
charmajor_version_str[64];/* string PG_VERSION of cluster */

‎contrib/pg_upgrade/server.c

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ start_postmaster(ClusterInfo *cluster)
168168
*/
169169
snprintf(cmd,sizeof(cmd),
170170
SYSTEMQUOTE"\"%s/pg_ctl\" -w -l \"%s\" -D \"%s\" "
171-
"-o \"-p %d %s\" start >> \"%s\" 2>&1"SYSTEMQUOTE,
171+
"-o \"-p %d %s %s\" start >> \"%s\" 2>&1"SYSTEMQUOTE,
172172
cluster->bindir,log_opts.filename2,cluster->pgconfig,cluster->port,
173173
(cluster->controldata.cat_ver >=
174174
BINARY_UPGRADE_SERVER_FLAG_CAT_VER) ?"-b" :
175175
"-c autovacuum=off -c autovacuum_freeze_max_age=2000000000",
176-
log_opts.filename2);
176+
cluster->pgopts ?cluster->pgopts :"",log_opts.filename2);
177177

178178
/*
179179
* Don't throw an error right away, let connecting throw the error because
@@ -207,27 +207,21 @@ void
207207
stop_postmaster(boolfast)
208208
{
209209
charcmd[MAXPGPATH];
210-
constchar*bindir;
211-
constchar*configdir;
210+
ClusterInfo*cluster;
212211

213212
if (os_info.running_cluster==&old_cluster)
214-
{
215-
bindir=old_cluster.bindir;
216-
configdir=old_cluster.pgconfig;
217-
}
213+
cluster=&old_cluster;
218214
elseif (os_info.running_cluster==&new_cluster)
219-
{
220-
bindir=new_cluster.bindir;
221-
configdir=new_cluster.pgconfig;
222-
}
215+
cluster=&new_cluster;
223216
else
224-
return;/* no cluster running */
217+
return;/* no cluster running */
225218

226219
snprintf(cmd,sizeof(cmd),
227-
SYSTEMQUOTE"\"%s/pg_ctl\" -w -l \"%s\" -D \"%s\" %s stop >> "
228-
"\"%s\" 2>&1"SYSTEMQUOTE,
229-
bindir,log_opts.filename2,configdir,fast ?"-m fast" :"",
230-
log_opts.filename2);
220+
SYSTEMQUOTE"\"%s/pg_ctl\" -w -l \"%s\" -D \"%s\" -o \"%s\" "
221+
"%s stop >> \"%s\" 2>&1"SYSTEMQUOTE,
222+
cluster->bindir,log_opts.filename2,cluster->pgconfig,
223+
cluster->pgopts ?cluster->pgopts :"",
224+
fast ?"-m fast" :"",log_opts.filename2);
231225

232226
exec_prog(fast ? false : true,"%s",cmd);
233227

‎doc/src/sgml/pgupgrade.sgml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,20 @@
114114
<listitem><para>log session activity to file</para></listitem>
115115
</varlistentry>
116116

117+
<varlistentry>
118+
<term><option>-o</option> <replaceable class="parameter">options</replaceable></term>
119+
<term><option>--old-options</option> <replaceable class="parameter">options</replaceable></term>
120+
<listitem><para>options to be passed directly to the
121+
old <command>postgres</command> command</para></listitem>
122+
</varlistentry>
123+
124+
<varlistentry>
125+
<term><option>-O</option> <replaceable class="parameter">options</replaceable></term>
126+
<term><option>--new-options</option> <replaceable class="parameter">options</replaceable></term>
127+
<listitem><para>options to be passed directly to the
128+
new <command>postgres</command> command</para></listitem>
129+
</varlistentry>
130+
117131
<varlistentry>
118132
<term><option>-p</option> <replaceable>old_port_number</></term>
119133
<term><option>--old-port=</option><replaceable>old_portnum</></term>
@@ -559,6 +573,14 @@ psql --username postgres --file script.sql postgres
559573
insert dummy data, and upgrade that.
560574
</para>
561575

576+
<para>
577+
If you are upgrading a pre-<productname>PostgreSQL</> 9.2 cluster
578+
that uses a configuration-file-only directory, you must pass the
579+
real data directory location to <application>pg_upgrade</>, and
580+
pass the configuration directory location to the server, e.g.
581+
<literal>-d /real-data-directory -o '-D /configuration-directory'</>.
582+
</para>
583+
562584
<para>
563585
If you want to use link mode and you don't want your old cluster
564586
to be modified when the new cluster is started, make a copy of the

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp