@@ -43,8 +43,7 @@ static void vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
43
43
const char * host , const char * port ,
44
44
const char * username , enum trivalue prompt_password ,
45
45
int concurrentCons ,
46
- const char * progname , bool echo , bool quiet ,
47
- char * * password );
46
+ const char * progname , bool echo , bool quiet );
48
47
49
48
static void vacuum_all_databases (vacuumingOptions * vacopts ,
50
49
bool analyze_in_stages ,
@@ -276,8 +275,6 @@ main(int argc, char *argv[])
276
275
}
277
276
else
278
277
{
279
- char * password = NULL ;
280
-
281
278
if (dbname == NULL )
282
279
{
283
280
if (getenv ("PGDATABASE" ))
@@ -299,8 +296,7 @@ main(int argc, char *argv[])
299
296
& tables ,
300
297
host , port , username , prompt_password ,
301
298
concurrentCons ,
302
- progname , echo , quiet ,
303
- & password );
299
+ progname , echo , quiet );
304
300
}
305
301
}
306
302
else
@@ -309,10 +305,7 @@ main(int argc, char *argv[])
309
305
& tables ,
310
306
host , port , username , prompt_password ,
311
307
concurrentCons ,
312
- progname , echo , quiet ,
313
- & password );
314
-
315
- pg_free (password );
308
+ progname , echo , quiet );
316
309
}
317
310
318
311
exit (0 );
@@ -330,21 +323,15 @@ main(int argc, char *argv[])
330
323
* If concurrentCons is > 1, multiple connections are used to vacuum tables
331
324
* in parallel. In this case and if the table list is empty, we first obtain
332
325
* a list of tables from the database.
333
- *
334
- * 'password' is both an input and output parameter. If one is not passed,
335
- * then whatever is used in a connection is returned so that caller can
336
- * reuse it in future connections.
337
326
*/
338
327
static void
339
328
vacuum_one_database (const char * dbname , vacuumingOptions * vacopts ,
340
329
int stage ,
341
330
SimpleStringList * tables ,
342
331
const char * host , const char * port ,
343
- const char * username ,
344
- enum trivalue prompt_password ,
332
+ const char * username , enum trivalue prompt_password ,
345
333
int concurrentCons ,
346
- const char * progname , bool echo , bool quiet ,
347
- char * * password )
334
+ const char * progname , bool echo , bool quiet )
348
335
{
349
336
PQExpBufferData sql ;
350
337
PGconn * conn ;
@@ -378,15 +365,8 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
378
365
fflush (stdout );
379
366
}
380
367
381
- conn = connectDatabase (dbname , host , port , username , * password ,
382
- prompt_password , progname , false);
383
-
384
- /*
385
- * If no password was not specified by caller and the connection required
386
- * one, remember it; this suppresses further password prompts.
387
- */
388
- if (PQconnectionUsedPassword (conn ) && * password == NULL )
389
- * password = pg_strdup (PQpass (conn ));
368
+ conn = connectDatabase (dbname , host , port , username , prompt_password ,
369
+ progname , false, true);
390
370
391
371
initPQExpBuffer (& sql );
392
372
@@ -444,20 +424,10 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
444
424
init_slot (slots , conn );
445
425
if (parallel )
446
426
{
447
- const char * pqpass ;
448
-
449
- /*
450
- * If a password was supplied for the initial connection, use it for
451
- * subsequent ones too. (Note that since we're connecting to the same
452
- * database with the same user, there's no need to update the stored
453
- * password any further.)
454
- */
455
- pqpass = PQpass (conn );
456
-
457
427
for (i = 1 ; i < concurrentCons ; i ++ )
458
428
{
459
- conn = connectDatabase (dbname , host , port , username , pqpass ,
460
- prompt_password , progname , false);
429
+ conn = connectDatabase (dbname , host , port , username , prompt_password ,
430
+ progname , false, true );
461
431
init_slot (slots + i , conn );
462
432
}
463
433
}
@@ -572,23 +542,12 @@ vacuum_all_databases(vacuumingOptions *vacopts,
572
542
PGresult * result ;
573
543
int stage ;
574
544
int i ;
575
- char * password = NULL ;
576
545
577
546
conn = connectMaintenanceDatabase (maintenance_db , host , port ,
578
547
username , prompt_password , progname );
579
-
580
548
result = executeQuery (conn ,
581
549
"SELECT datname FROM pg_database WHERE datallowconn ORDER BY 1;" ,
582
550
progname , echo );
583
-
584
- /*
585
- * Remember the password for further connections. If no password was
586
- * required for the maintenance db connection, this gets updated for the
587
- * first connection that does.
588
- */
589
- if (PQconnectionUsedPassword (conn ))
590
- password = pg_strdup (PQpass (conn ));
591
-
592
551
PQfinish (conn );
593
552
594
553
if (analyze_in_stages )
@@ -613,8 +572,7 @@ vacuum_all_databases(vacuumingOptions *vacopts,
613
572
NULL ,
614
573
host , port , username , prompt_password ,
615
574
concurrentCons ,
616
- progname , echo , quiet ,
617
- & password );
575
+ progname , echo , quiet );
618
576
}
619
577
}
620
578
}
@@ -630,13 +588,11 @@ vacuum_all_databases(vacuumingOptions *vacopts,
630
588
NULL ,
631
589
host , port , username , prompt_password ,
632
590
concurrentCons ,
633
- progname , echo , quiet ,
634
- & password );
591
+ progname , echo , quiet );
635
592
}
636
593
}
637
594
638
595
PQclear (result );
639
- pg_free (password );
640
596
}
641
597
642
598
/*
0 commit comments