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

Commit1dc7c79

Browse files
committed
Have pg_upgrade create its output files in the current directory, rather
than in a subdirectory of the $HOME directory, or $TMP in Windows.
1 parent99fdb4a commit1dc7c79

File tree

8 files changed

+21
-63
lines changed

8 files changed

+21
-63
lines changed

‎contrib/pg_upgrade/check.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ create_script_for_old_cluster_deletion(migratorContext *ctx,
381381
prep_status(ctx,"Creating script to delete old cluster");
382382

383383
snprintf(*deletion_script_file_name,MAXPGPATH,"%s/delete_old_cluster.%s",
384-
ctx->output_dir,EXEC_EXT);
384+
ctx->cwd,EXEC_EXT);
385385

386386
if ((script=fopen(*deletion_script_file_name,"w"))==NULL)
387387
pg_log(ctx,PG_FATAL,"Could not create necessary file: %s\n",

‎contrib/pg_upgrade/dump.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ generate_old_dump(migratorContext *ctx)
2121
exec_prog(ctx, true,
2222
SYSTEMQUOTE"\"%s/pg_dumpall\" --port %d --schema-only "
2323
"--binary-upgrade > \"%s/"ALL_DUMP_FILE"\""SYSTEMQUOTE,
24-
ctx->new.bindir,ctx->old.port,ctx->output_dir);
24+
ctx->new.bindir,ctx->old.port,ctx->cwd);
2525
check_ok(ctx);
2626
}
2727

@@ -52,13 +52,13 @@ split_old_dump(migratorContext *ctx)
5252
charfilename[MAXPGPATH];
5353
boolsuppressed_username= false;
5454

55-
snprintf(filename,sizeof(filename),"%s/%s",ctx->output_dir,ALL_DUMP_FILE);
55+
snprintf(filename,sizeof(filename),"%s/%s",ctx->cwd,ALL_DUMP_FILE);
5656
if ((all_dump=fopen(filename,"r"))==NULL)
5757
pg_log(ctx,PG_FATAL,"Cannot open dump file %s\n",filename);
58-
snprintf(filename,sizeof(filename),"%s/%s",ctx->output_dir,GLOBALS_DUMP_FILE);
58+
snprintf(filename,sizeof(filename),"%s/%s",ctx->cwd,GLOBALS_DUMP_FILE);
5959
if ((globals_dump=fopen(filename,"w"))==NULL)
6060
pg_log(ctx,PG_FATAL,"Cannot write to dump file %s\n",filename);
61-
snprintf(filename,sizeof(filename),"%s/%s",ctx->output_dir,DB_DUMP_FILE);
61+
snprintf(filename,sizeof(filename),"%s/%s",ctx->cwd,DB_DUMP_FILE);
6262
if ((db_dump=fopen(filename,"w"))==NULL)
6363
pg_log(ctx,PG_FATAL,"Cannot write to dump file %s\n",filename);
6464
current_output=globals_dump;

‎contrib/pg_upgrade/function.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ check_loadable_libraries(migratorContext *ctx)
213213
prep_status(ctx,"Checking for presence of required libraries");
214214

215215
snprintf(output_path,sizeof(output_path),"%s/loadable_libraries.txt",
216-
ctx->output_dir);
216+
ctx->cwd);
217217

218218
for (libnum=0;libnum<ctx->num_libraries;libnum++)
219219
{

‎contrib/pg_upgrade/option.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,7 @@ parseCommandLine(migratorContext *ctx, int argc, char *argv[])
8484
if (user_id==0)
8585
pg_log(ctx,PG_FATAL,"%s: cannot be run as root\n",ctx->progname);
8686

87-
#ifndefWIN32
88-
get_home_path(ctx->home_dir);
89-
#else
90-
{
91-
char*tmppath;
92-
93-
/* TMP is the best place on Windows, rather than APPDATA */
94-
if ((tmppath=getenv("TMP"))==NULL)
95-
pg_log(ctx,PG_FATAL,"TMP environment variable is not set.\n");
96-
snprintf(ctx->home_dir,MAXPGPATH,"%s",tmppath);
97-
}
98-
#endif
99-
100-
snprintf(ctx->output_dir,MAXPGPATH,"%s/"OUTPUT_SUBDIR,ctx->home_dir);
87+
getcwd(ctx->cwd,MAXPGPATH);
10188

10289
while ((option=getopt_long(argc,argv,"d:D:b:B:cgG:kl:p:P:u:v",
10390
long_options,&optindex))!=-1)

‎contrib/pg_upgrade/pg_upgrade.c

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ static void copy_clog_xlog_xid(migratorContext *ctx);
1818
staticvoidset_frozenxids(migratorContext*ctx);
1919
staticvoidsetup(migratorContext*ctx,char*argv0,boollive_check);
2020
staticvoidcleanup(migratorContext*ctx);
21-
staticvoidcreate_empty_output_directory(migratorContext*ctx);
2221

2322

2423
int
@@ -37,8 +36,6 @@ main(int argc, char **argv)
3736

3837
setup(&ctx,argv[0],live_check);
3938

40-
create_empty_output_directory(&ctx);
41-
4239
check_cluster_versions(&ctx);
4340
check_cluster_compatibility(&ctx,live_check);
4441

@@ -201,7 +198,7 @@ prepare_new_databases(migratorContext *ctx)
201198
exec_prog(ctx, true,
202199
SYSTEMQUOTE"\"%s/psql\" --set ON_ERROR_STOP=on --port %d "
203200
"-f \"%s/%s\" --dbname template1 >> \"%s\""SYSTEMQUOTE,
204-
ctx->new.bindir,ctx->new.port,ctx->output_dir,
201+
ctx->new.bindir,ctx->new.port,ctx->cwd,
205202
GLOBALS_DUMP_FILE,ctx->logfile);
206203
check_ok(ctx);
207204

@@ -223,7 +220,7 @@ create_new_objects(migratorContext *ctx)
223220
exec_prog(ctx, true,
224221
SYSTEMQUOTE"\"%s/psql\" --set ON_ERROR_STOP=on --port %d "
225222
"-f \"%s/%s\" --dbname template1 >> \"%s\""SYSTEMQUOTE,
226-
ctx->new.bindir,ctx->new.port,ctx->output_dir,
223+
ctx->new.bindir,ctx->new.port,ctx->cwd,
227224
DB_DUMP_FILE,ctx->logfile);
228225
check_ok(ctx);
229226

@@ -399,33 +396,10 @@ cleanup(migratorContext *ctx)
399396
if (ctx->debug_fd)
400397
fclose(ctx->debug_fd);
401398

402-
snprintf(filename,sizeof(filename),"%s/%s",ctx->output_dir,ALL_DUMP_FILE);
399+
snprintf(filename,sizeof(filename),"%s/%s",ctx->cwd,ALL_DUMP_FILE);
403400
unlink(filename);
404-
snprintf(filename,sizeof(filename),"%s/%s",ctx->output_dir,GLOBALS_DUMP_FILE);
401+
snprintf(filename,sizeof(filename),"%s/%s",ctx->cwd,GLOBALS_DUMP_FILE);
405402
unlink(filename);
406-
snprintf(filename,sizeof(filename),"%s/%s",ctx->output_dir,DB_DUMP_FILE);
403+
snprintf(filename,sizeof(filename),"%s/%s",ctx->cwd,DB_DUMP_FILE);
407404
unlink(filename);
408405
}
409-
410-
411-
/*
412-
* create_empty_output_directory
413-
*
414-
*Create empty directory for output files
415-
*/
416-
staticvoid
417-
create_empty_output_directory(migratorContext*ctx)
418-
{
419-
/*
420-
*rmtree() outputs a warning if the directory does not exist,
421-
*so we try to create the directory first.
422-
*/
423-
if (mkdir(ctx->output_dir,S_IRWXU)!=0)
424-
{
425-
if (errno==EEXIST)
426-
rmtree(ctx->output_dir, false);
427-
else
428-
pg_log(ctx,PG_FATAL,"Cannot create subdirectory %s: %s\n",
429-
ctx->output_dir,getErrorText(errno));
430-
}
431-
}

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
#defineOVERWRITE_MESSAGE" %-" MESSAGE_WIDTH "." MESSAGE_WIDTH "s\r"
3030
#defineGET_MAJOR_VERSION(v)((v) / 100)
3131

32-
#defineOUTPUT_SUBDIR"pg_upgrade_output"
33-
3432
#defineALL_DUMP_FILE"pg_upgrade_dump_all.sql"
3533
/* contains both global db information and CREATE DATABASE commands */
3634
#defineGLOBALS_DUMP_FILE"pg_upgrade_dump_globals.sql"
@@ -217,8 +215,7 @@ typedef struct
217215
constchar*progname;/* complete pathname for this program */
218216
char*exec_path;/* full path to my executable */
219217
char*user;/* username for clusters */
220-
charhome_dir[MAXPGPATH];/* name of user's home directory */
221-
charoutput_dir[MAXPGPATH];/* directory for pg_upgrade output */
218+
charcwd[MAXPGPATH];/* directory for pg_upgrade output */
222219
char**tablespaces;/* tablespaces */
223220
intnum_tablespaces;
224221
char**libraries;/* loadable libraries */

‎contrib/pg_upgrade/version.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ new_9_0_populate_pg_largeobject_metadata(migratorContext *ctx, bool check_mode,
2828
prep_status(ctx,"Checking for large objects");
2929

3030
snprintf(output_path,sizeof(output_path),"%s/pg_largeobject.sql",
31-
ctx->output_dir);
31+
ctx->cwd);
3232

3333
for (dbnum=0;dbnum<active_cluster->dbarr.ndbs;dbnum++)
3434
{

‎contrib/pg_upgrade/version_old_8_3.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ old_8_3_check_for_name_data_type_usage(migratorContext *ctx, Cluster whichCluste
2828
prep_status(ctx,"Checking for invalid 'name' user columns");
2929

3030
snprintf(output_path,sizeof(output_path),"%s/tables_using_name.txt",
31-
ctx->output_dir);
31+
ctx->cwd);
3232

3333
for (dbnum=0;dbnum<active_cluster->dbarr.ndbs;dbnum++)
3434
{
@@ -123,7 +123,7 @@ old_8_3_check_for_tsquery_usage(migratorContext *ctx, Cluster whichCluster)
123123
prep_status(ctx,"Checking for tsquery user columns");
124124

125125
snprintf(output_path,sizeof(output_path),"%s/tables_using_tsquery.txt",
126-
ctx->output_dir);
126+
ctx->cwd);
127127

128128
for (dbnum=0;dbnum<active_cluster->dbarr.ndbs;dbnum++)
129129
{
@@ -222,7 +222,7 @@ old_8_3_check_for_isn_and_int8_passing_mismatch(migratorContext *ctx, Cluster wh
222222
}
223223

224224
snprintf(output_path,sizeof(output_path),"%s/contrib_isn_and_int8_pass_by_value.txt",
225-
ctx->output_dir);
225+
ctx->cwd);
226226

227227
for (dbnum=0;dbnum<active_cluster->dbarr.ndbs;dbnum++)
228228
{
@@ -312,7 +312,7 @@ old_8_3_rebuild_tsvector_tables(migratorContext *ctx, bool check_mode,
312312
prep_status(ctx,"Checking for tsvector user columns");
313313

314314
snprintf(output_path,sizeof(output_path),"%s/rebuild_tsvector_tables.sql",
315-
ctx->output_dir);
315+
ctx->cwd);
316316

317317
for (dbnum=0;dbnum<active_cluster->dbarr.ndbs;dbnum++)
318318
{
@@ -457,7 +457,7 @@ old_8_3_invalidate_hash_gin_indexes(migratorContext *ctx, bool check_mode,
457457
prep_status(ctx,"Checking for hash and gin indexes");
458458

459459
snprintf(output_path,sizeof(output_path),"%s/reindex_hash_and_gin.sql",
460-
ctx->output_dir);
460+
ctx->cwd);
461461

462462
for (dbnum=0;dbnum<active_cluster->dbarr.ndbs;dbnum++)
463463
{
@@ -573,7 +573,7 @@ old_8_3_invalidate_bpchar_pattern_ops_indexes(migratorContext *ctx, bool check_m
573573
prep_status(ctx,"Checking for bpchar_pattern_ops indexes");
574574

575575
snprintf(output_path,sizeof(output_path),"%s/reindex_bpchar_ops.sql",
576-
ctx->output_dir);
576+
ctx->cwd);
577577

578578
for (dbnum=0;dbnum<active_cluster->dbarr.ndbs;dbnum++)
579579
{
@@ -705,7 +705,7 @@ old_8_3_create_sequence_script(migratorContext *ctx, Cluster whichCluster)
705705
boolfound= false;
706706
char*output_path=pg_malloc(ctx,MAXPGPATH);
707707

708-
snprintf(output_path,MAXPGPATH,"%s/adjust_sequences.sql",ctx->output_dir);
708+
snprintf(output_path,MAXPGPATH,"%s/adjust_sequences.sql",ctx->cwd);
709709

710710
prep_status(ctx,"Creating script to adjust sequences");
711711

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp