[PATCH v14 2/5] Simplify fill_hba_line and fill_ident_line prototypes.

Julien Rouhaud <julien.rouhaud@free.fr>

From: Julien Rouhaud <julien.rouhaud@free.fr>
To:
Date: 2022-10-26T02:52:15Z
Lists: pgsql-hackers
There's no need to pass the line number as an explicit argument as the
information is already present in the HbaLine/IdentLine.

Author: Julien Rouhaud
Reviewed-by: FIXME
Discussion: https://postgr.es/m/20220223045959.35ipdsvbxcstrhya%40jrouhaud
---
 src/backend/utils/adt/hbafuncs.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/backend/utils/adt/hbafuncs.c b/src/backend/utils/adt/hbafuncs.c
index cfdc4d8b39..f2a4f105c7 100644
--- a/src/backend/utils/adt/hbafuncs.c
+++ b/src/backend/utils/adt/hbafuncs.c
@@ -26,10 +26,10 @@
 
 static ArrayType *get_hba_options(HbaLine *hba);
 static void fill_hba_line(Tuplestorestate *tuple_store, TupleDesc tupdesc,
-						  int lineno, HbaLine *hba, const char *err_msg);
+						  HbaLine *hba, const char *err_msg);
 static void fill_hba_view(Tuplestorestate *tuple_store, TupleDesc tupdesc);
 static void fill_ident_line(Tuplestorestate *tuple_store, TupleDesc tupdesc,
-							int lineno, IdentLine *ident, const char *err_msg);
+							IdentLine *ident, const char *err_msg);
 static void fill_ident_view(Tuplestorestate *tuple_store, TupleDesc tupdesc);
 
 
@@ -165,7 +165,6 @@ get_hba_options(HbaLine *hba)
  *
  * tuple_store: where to store data
  * tupdesc: tuple descriptor for the view
- * lineno: pg_hba.conf line number (must always be valid)
  * hba: parsed line data (can be NULL, in which case err_msg should be set)
  * err_msg: error message (NULL if none)
  *
@@ -174,7 +173,7 @@ get_hba_options(HbaLine *hba)
  */
 static void
 fill_hba_line(Tuplestorestate *tuple_store, TupleDesc tupdesc,
-			  int lineno, HbaLine *hba, const char *err_msg)
+			 HbaLine *hba, const char *err_msg)
 {
 	Datum		values[NUM_PG_HBA_FILE_RULES_ATTS];
 	bool		nulls[NUM_PG_HBA_FILE_RULES_ATTS];
@@ -194,7 +193,7 @@ fill_hba_line(Tuplestorestate *tuple_store, TupleDesc tupdesc,
 	index = 0;
 
 	/* line_number */
-	values[index++] = Int32GetDatum(lineno);
+	values[index++] = Int32GetDatum(hba->linenumber);
 
 	if (hba != NULL)
 	{
@@ -393,8 +392,7 @@ fill_hba_view(Tuplestorestate *tuple_store, TupleDesc tupdesc)
 		if (tok_line->err_msg == NULL)
 			hbaline = parse_hba_line(tok_line, DEBUG3);
 
-		fill_hba_line(tuple_store, tupdesc, tok_line->line_num,
-					  hbaline, tok_line->err_msg);
+		fill_hba_line(tuple_store, tupdesc, hbaline, tok_line->err_msg);
 	}
 
 	/* Free tokenizer memory */
@@ -439,7 +437,6 @@ pg_hba_file_rules(PG_FUNCTION_ARGS)
  *
  * tuple_store: where to store data
  * tupdesc: tuple descriptor for the view
- * lineno: pg_ident.conf line number (must always be valid)
  * ident: parsed line data (can be NULL, in which case err_msg should be set)
  * err_msg: error message (NULL if none)
  *
@@ -448,7 +445,7 @@ pg_hba_file_rules(PG_FUNCTION_ARGS)
  */
 static void
 fill_ident_line(Tuplestorestate *tuple_store, TupleDesc tupdesc,
-				int lineno, IdentLine *ident, const char *err_msg)
+				IdentLine *ident, const char *err_msg)
 {
 	Datum		values[NUM_PG_IDENT_FILE_MAPPINGS_ATTS];
 	bool		nulls[NUM_PG_IDENT_FILE_MAPPINGS_ATTS];
@@ -462,7 +459,7 @@ fill_ident_line(Tuplestorestate *tuple_store, TupleDesc tupdesc,
 	index = 0;
 
 	/* line_number */
-	values[index++] = Int32GetDatum(lineno);
+	values[index++] = Int32GetDatum(ident->linenumber);
 
 	if (ident != NULL)
 	{
@@ -529,8 +526,7 @@ fill_ident_view(Tuplestorestate *tuple_store, TupleDesc tupdesc)
 		if (tok_line->err_msg == NULL)
 			identline = parse_ident_line(tok_line, DEBUG3);
 
-		fill_ident_line(tuple_store, tupdesc, tok_line->line_num, identline,
-						tok_line->err_msg);
+		fill_ident_line(tuple_store, tupdesc, identline, tok_line->err_msg);
 	}
 
 	/* Free tokenizer memory */
-- 
2.37.0


--4aj2zfv7etn2tv3k
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename="v14-0003-Add-rule_number-mapping_number-to-the-pg_hba-pg_.patch"