Skip to content

Commit 387efd3

Browse files
committed
Make pg_hba parsing report all errors in the file before aborting the load,
instead of just reporting the first one. Selena Deckelmann
1 parent 54fd95b commit 387efd3

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/backend/libpq/hba.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.182 2009/03/04 18:43:38 mha Exp $
13+
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.183 2009/03/07 21:28:00 mha Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -1304,6 +1304,7 @@ load_hba(void)
13041304
List *hba_line_nums = NIL;
13051305
ListCell *line, *line_num;
13061306
List *new_parsed_lines = NIL;
1307+
bool ok = true;
13071308

13081309
file = AllocateFile(HbaFileName, "r");
13091310
if (file == NULL)
@@ -1332,17 +1333,29 @@ load_hba(void)
13321333

13331334
if (!parse_hba_line(lfirst(line), lfirst_int(line_num), newline))
13341335
{
1335-
/* Parse error in the file, so bail out */
1336+
/* Parse error in the file, so indicate there's a problem */
13361337
free_hba_record(newline);
13371338
pfree(newline);
1338-
clean_hba_list(new_parsed_lines);
1339-
/* Error has already been reported in the parsing function */
1340-
return false;
1339+
1340+
/*
1341+
* Keep parsing the rest of the file so we can report errors
1342+
* on more than the first row. Error has already been reported
1343+
* in the parsing function, so no need to log it here.
1344+
*/
1345+
ok = false;
1346+
continue;
13411347
}
13421348

13431349
new_parsed_lines = lappend(new_parsed_lines, newline);
13441350
}
13451351

1352+
if (!ok)
1353+
{
1354+
/* Parsing failed at one or more rows, so bail out */
1355+
clean_hba_list(new_parsed_lines);
1356+
return false;
1357+
}
1358+
13461359
/* Loaded new file successfully, replace the one we use */
13471360
clean_hba_list(parsed_hba_lines);
13481361
parsed_hba_lines = new_parsed_lines;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy