@@ -160,11 +160,6 @@ parseCommandLine(int argc, char *argv[])
160
160
}
161
161
break ;
162
162
163
- /*
164
- * Someday, the port number option could be removed and passed
165
- * using -o/-O, but that requires postmaster -C to be
166
- * supported on all old/new versions (added in PG 9.2).
167
- */
168
163
case 'p' :
169
164
if ((old_cluster .port = atoi (optarg )) <= 0 )
170
165
pg_fatal ("invalid old port number\n" );
@@ -187,12 +182,6 @@ parseCommandLine(int argc, char *argv[])
187
182
pg_free (os_info .user );
188
183
os_info .user = pg_strdup (optarg );
189
184
os_info .user_specified = true;
190
-
191
- /*
192
- * Push the user name into the environment so pre-9.1
193
- * pg_ctl/libpq uses it.
194
- */
195
- setenv ("PGUSER" , os_info .user , 1 );
196
185
break ;
197
186
198
187
case 'v' :
@@ -469,67 +458,51 @@ void
469
458
get_sock_dir (ClusterInfo * cluster , bool live_check )
470
459
{
471
460
#if defined(HAVE_UNIX_SOCKETS ) && !defined(WIN32 )
472
-
473
- /*
474
- * sockdir and port were added to postmaster.pid in PG 9.1. Pre-9.1 cannot
475
- * process pg_ctl -w for sockets in non-default locations.
476
- */
477
- if (GET_MAJOR_VERSION (cluster -> major_version ) >= 901 )
461
+ if (!live_check )
462
+ cluster -> sockdir = user_opts .socketdir ;
463
+ else
478
464
{
479
- if (!live_check )
480
- cluster -> sockdir = user_opts .socketdir ;
481
- else
465
+ /*
466
+ * If we are doing a live check, we will use the old cluster's Unix
467
+ * domain socket directory so we can connect to the live server.
468
+ */
469
+ unsigned short orig_port = cluster -> port ;
470
+ char filename [MAXPGPATH ],
471
+ line [MAXPGPATH ];
472
+ FILE * fp ;
473
+ int lineno ;
474
+
475
+ snprintf (filename , sizeof (filename ), "%s/postmaster.pid" ,
476
+ cluster -> pgdata );
477
+ if ((fp = fopen (filename , "r" )) == NULL )
478
+ pg_fatal ("could not open file \"%s\": %s\n" ,
479
+ filename , strerror (errno ));
480
+
481
+ for (lineno = 1 ;
482
+ lineno <= Max (LOCK_FILE_LINE_PORT , LOCK_FILE_LINE_SOCKET_DIR );
483
+ lineno ++ )
482
484
{
483
- /*
484
- * If we are doing a live check, we will use the old cluster's
485
- * Unix domain socket directory so we can connect to the live
486
- * server.
487
- */
488
- unsigned short orig_port = cluster -> port ;
489
- char filename [MAXPGPATH ],
490
- line [MAXPGPATH ];
491
- FILE * fp ;
492
- int lineno ;
493
-
494
- snprintf (filename , sizeof (filename ), "%s/postmaster.pid" ,
495
- cluster -> pgdata );
496
- if ((fp = fopen (filename , "r" )) == NULL )
497
- pg_fatal ("could not open file \"%s\": %s\n" ,
498
- filename , strerror (errno ));
499
-
500
- for (lineno = 1 ;
501
- lineno <= Max (LOCK_FILE_LINE_PORT , LOCK_FILE_LINE_SOCKET_DIR );
502
- lineno ++ )
485
+ if (fgets (line , sizeof (line ), fp ) == NULL )
486
+ pg_fatal ("could not read line %d from file \"%s\": %s\n" ,
487
+ lineno , filename , strerror (errno ));
488
+
489
+ /* potentially overwrite user-supplied value */
490
+ if (lineno == LOCK_FILE_LINE_PORT )
491
+ sscanf (line , "%hu" , & old_cluster .port );
492
+ if (lineno == LOCK_FILE_LINE_SOCKET_DIR )
503
493
{
504
- if (fgets (line , sizeof (line ), fp ) == NULL )
505
- pg_fatal ("could not read line %d from file \"%s\": %s\n" ,
506
- lineno , filename , strerror (errno ));
507
-
508
- /* potentially overwrite user-supplied value */
509
- if (lineno == LOCK_FILE_LINE_PORT )
510
- sscanf (line , "%hu" , & old_cluster .port );
511
- if (lineno == LOCK_FILE_LINE_SOCKET_DIR )
512
- {
513
- /* strip trailing newline and carriage return */
514
- cluster -> sockdir = pg_strdup (line );
515
- (void ) pg_strip_crlf (cluster -> sockdir );
516
- }
494
+ /* strip trailing newline and carriage return */
495
+ cluster -> sockdir = pg_strdup (line );
496
+ (void ) pg_strip_crlf (cluster -> sockdir );
517
497
}
518
- fclose (fp );
519
-
520
- /* warn of port number correction */
521
- if (orig_port != DEF_PGUPORT && old_cluster .port != orig_port )
522
- pg_log (PG_WARNING , "user-supplied old port number %hu corrected to %hu\n" ,
523
- orig_port , cluster -> port );
524
498
}
525
- }
526
- else
499
+ fclose (fp );
527
500
528
- /*
529
- * Can't get sockdir and pg_ctl -w can't use a non-default, use
530
- * default
531
- */
532
- cluster -> sockdir = NULL ;
501
+ /* warn of port number correction */
502
+ if ( orig_port != DEF_PGUPORT && old_cluster . port != orig_port )
503
+ pg_log ( PG_WARNING , "user-supplied old port number %hu corrected to %hu\n" ,
504
+ orig_port , cluster -> port );
505
+ }
533
506
#else /* !HAVE_UNIX_SOCKETS || WIN32 */
534
507
cluster -> sockdir = NULL ;
535
508
#endif
0 commit comments