@@ -43,8 +43,7 @@ static void vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
4343 const char * host , const char * port ,
4444 const char * username , enum trivalue prompt_password ,
4545 int concurrentCons ,
46- const char * progname , bool echo , bool quiet ,
47- char * * password );
46+ const char * progname , bool echo , bool quiet );
4847
4948static void vacuum_all_databases (vacuumingOptions * vacopts ,
5049 bool analyze_in_stages ,
@@ -276,8 +275,6 @@ main(int argc, char *argv[])
276275 }
277276 else
278277 {
279- char * password = NULL ;
280-
281278 if (dbname == NULL )
282279 {
283280 if (getenv ("PGDATABASE" ))
@@ -299,8 +296,7 @@ main(int argc, char *argv[])
299296 & tables ,
300297 host , port , username , prompt_password ,
301298 concurrentCons ,
302- progname , echo , quiet ,
303- & password );
299+ progname , echo , quiet );
304300 }
305301 }
306302 else
@@ -309,10 +305,7 @@ main(int argc, char *argv[])
309305 & tables ,
310306 host , port , username , prompt_password ,
311307 concurrentCons ,
312- progname , echo , quiet ,
313- & password );
314-
315- pg_free (password );
308+ progname , echo , quiet );
316309 }
317310
318311 exit (0 );
@@ -330,21 +323,15 @@ main(int argc, char *argv[])
330323 * If concurrentCons is > 1, multiple connections are used to vacuum tables
331324 * in parallel. In this case and if the table list is empty, we first obtain
332325 * 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.
337326 */
338327static void
339328vacuum_one_database (const char * dbname , vacuumingOptions * vacopts ,
340329 int stage ,
341330 SimpleStringList * tables ,
342331 const char * host , const char * port ,
343- const char * username ,
344- enum trivalue prompt_password ,
332+ const char * username , enum trivalue prompt_password ,
345333 int concurrentCons ,
346- const char * progname , bool echo , bool quiet ,
347- char * * password )
334+ const char * progname , bool echo , bool quiet )
348335{
349336 PQExpBufferData sql ;
350337 PGconn * conn ;
@@ -378,15 +365,8 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
378365 fflush (stdout );
379366 }
380367
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);
390370
391371 initPQExpBuffer (& sql );
392372
@@ -444,20 +424,10 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
444424 init_slot (slots , conn );
445425 if (parallel )
446426 {
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-
457427 for (i = 1 ; i < concurrentCons ; i ++ )
458428 {
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 );
461431 init_slot (slots + i , conn );
462432 }
463433 }
@@ -572,23 +542,12 @@ vacuum_all_databases(vacuumingOptions *vacopts,
572542 PGresult * result ;
573543 int stage ;
574544 int i ;
575- char * password = NULL ;
576545
577546 conn = connectMaintenanceDatabase (maintenance_db , host , port ,
578547 username , prompt_password , progname );
579-
580548 result = executeQuery (conn ,
581549 "SELECT datname FROM pg_database WHERE datallowconn ORDER BY 1;" ,
582550 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-
592551 PQfinish (conn );
593552
594553 if (analyze_in_stages )
@@ -613,8 +572,7 @@ vacuum_all_databases(vacuumingOptions *vacopts,
613572 NULL ,
614573 host , port , username , prompt_password ,
615574 concurrentCons ,
616- progname , echo , quiet ,
617- & password );
575+ progname , echo , quiet );
618576 }
619577 }
620578 }
@@ -630,13 +588,11 @@ vacuum_all_databases(vacuumingOptions *vacopts,
630588 NULL ,
631589 host , port , username , prompt_password ,
632590 concurrentCons ,
633- progname , echo , quiet ,
634- & password );
591+ progname , echo , quiet );
635592 }
636593 }
637594
638595 PQclear (result );
639- pg_free (password );
640596}
641597
642598/*
0 commit comments