From 4562fa498437b885a7fffc9bc88b8050eff5772a Mon Sep 17 00:00:00 2001
From: Peter Smith <peter.b.smith@fujitsu.com>
Date: Thu, 12 Sep 2024 10:23:28 +1000
Subject: [PATCH v1] Remove some shadowed declarations

---
 src/bin/pg_basebackup/pg_createsubscriber.c |  64 ++++-----
 src/bin/psql/tab-complete.c                 | 212 ++++++++++++++--------------
 src/interfaces/ecpg/ecpglib/execute.c       |  18 +--
 src/interfaces/ecpg/ecpglib/prepare.c       |  38 ++---
 src/interfaces/ecpg/preproc/c_keywords.c    |   8 +-
 5 files changed, 170 insertions(+), 170 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index e804b2a..f3866d5 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -111,14 +111,14 @@ static void drop_existing_subscriptions(PGconn *conn, const char *subname,
 #define	USEC_PER_SEC	1000000
 #define	WAIT_INTERVAL	1		/* 1 second */
 
-static const char *progname;
+static const char *prog_name;
 
 static char *primary_slot_name = NULL;
 static bool dry_run = false;
 
 static bool success = false;
 
-static struct LogicalRepInfo *dbinfo;
+static struct LogicalRepInfo *db_info;
 static int	num_dbs = 0;		/* number of specified databases */
 static int	num_pubs = 0;		/* number of specified publications */
 static int	num_subs = 0;		/* number of specified subscriptions */
@@ -173,17 +173,17 @@ cleanup_objects_atexit(void)
 
 	for (int i = 0; i < num_dbs; i++)
 	{
-		if (dbinfo[i].made_publication || dbinfo[i].made_replslot)
+		if (db_info[i].made_publication || db_info[i].made_replslot)
 		{
 			PGconn	   *conn;
 
-			conn = connect_database(dbinfo[i].pubconninfo, false);
+			conn = connect_database(db_info[i].pubconninfo, false);
 			if (conn != NULL)
 			{
-				if (dbinfo[i].made_publication)
-					drop_publication(conn, &dbinfo[i]);
-				if (dbinfo[i].made_replslot)
-					drop_replication_slot(conn, &dbinfo[i], dbinfo[i].replslotname);
+				if (db_info[i].made_publication)
+					drop_publication(conn, &db_info[i]);
+				if (db_info[i].made_replslot)
+					drop_replication_slot(conn, &db_info[i], db_info[i].replslotname);
 				disconnect_database(conn, false);
 			}
 			else
@@ -193,16 +193,16 @@ cleanup_objects_atexit(void)
 				 * that some objects were left on primary and should be
 				 * removed before trying again.
 				 */
-				if (dbinfo[i].made_publication)
+				if (db_info[i].made_publication)
 				{
 					pg_log_warning("publication \"%s\" created in database \"%s\" on primary was left behind",
-								   dbinfo[i].pubname, dbinfo[i].dbname);
+								   db_info[i].pubname, db_info[i].dbname);
 					pg_log_warning_hint("Drop this publication before trying again.");
 				}
-				if (dbinfo[i].made_replslot)
+				if (db_info[i].made_replslot)
 				{
 					pg_log_warning("replication slot \"%s\" created in database \"%s\" on primary was left behind",
-								   dbinfo[i].replslotname, dbinfo[i].dbname);
+								   db_info[i].replslotname, db_info[i].dbname);
 					pg_log_warning_hint("Drop this replication slot soon to avoid retention of WAL files.");
 				}
 			}
@@ -217,9 +217,9 @@ static void
 usage(void)
 {
 	printf(_("%s creates a new logical replica from a standby server.\n\n"),
-		   progname);
+		   prog_name);
 	printf(_("Usage:\n"));
-	printf(_("  %s [OPTION]...\n"), progname);
+	printf(_("  %s [OPTION]...\n"), prog_name);
 	printf(_("\nOptions:\n"));
 	printf(_("  -d, --database=DBNAME           database in which to create a subscription\n"));
 	printf(_("  -D, --pgdata=DATADIR            location for the subscriber data directory\n"));
@@ -323,7 +323,7 @@ get_sub_conninfo(const struct CreateSubscriberOptions *opt)
 #endif
 	if (opt->sub_username != NULL)
 		appendConnStrItem(buf, "user", opt->sub_username);
-	appendConnStrItem(buf, "fallback_application_name", progname);
+	appendConnStrItem(buf, "fallback_application_name", prog_name);
 
 	ret = pg_strdup(buf->data);
 
@@ -1903,7 +1903,7 @@ main(int argc, char **argv)
 
 	pg_logging_init(argv[0]);
 	pg_logging_set_level(PG_LOG_WARNING);
-	progname = get_progname(argv[0]);
+	prog_name = get_progname(argv[0]);
 	set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_basebackup"));
 
 	if (argc > 1)
@@ -1943,7 +1943,7 @@ main(int argc, char **argv)
 	{
 		pg_log_error("cannot be executed by \"root\"");
 		pg_log_error_hint("You must run %s as the PostgreSQL superuser.",
-						  progname);
+						  prog_name);
 		exit(1);
 	}
 #endif
@@ -2034,7 +2034,7 @@ main(int argc, char **argv)
 				break;
 			default:
 				/* getopt_long already emitted a complaint */
-				pg_log_error_hint("Try \"%s --help\" for more information.", progname);
+				pg_log_error_hint("Try \"%s --help\" for more information.", prog_name);
 				exit(1);
 		}
 	}
@@ -2044,7 +2044,7 @@ main(int argc, char **argv)
 	{
 		pg_log_error("too many command-line arguments (first is \"%s\")",
 					 argv[optind]);
-		pg_log_error_hint("Try \"%s --help\" for more information.", progname);
+		pg_log_error_hint("Try \"%s --help\" for more information.", prog_name);
 		exit(1);
 	}
 
@@ -2052,7 +2052,7 @@ main(int argc, char **argv)
 	if (subscriber_dir == NULL)
 	{
 		pg_log_error("no subscriber data directory specified");
-		pg_log_error_hint("Try \"%s --help\" for more information.", progname);
+		pg_log_error_hint("Try \"%s --help\" for more information.", prog_name);
 		exit(1);
 	}
 
@@ -2080,7 +2080,7 @@ main(int argc, char **argv)
 		 * not, we would fail anyway.
 		 */
 		pg_log_error("no publisher connection string specified");
-		pg_log_error_hint("Try \"%s --help\" for more information.", progname);
+		pg_log_error_hint("Try \"%s --help\" for more information.", prog_name);
 		exit(1);
 	}
 	pg_log_info("validating publisher connection string");
@@ -2113,7 +2113,7 @@ main(int argc, char **argv)
 		{
 			pg_log_error("no database name specified");
 			pg_log_error_hint("Try \"%s --help\" for more information.",
-							  progname);
+							  prog_name);
 			exit(1);
 		}
 	}
@@ -2153,7 +2153,7 @@ main(int argc, char **argv)
 	 * called before atexit() because its return is used in the
 	 * cleanup_objects_atexit().
 	 */
-	dbinfo = store_pub_sub_info(&opt, pub_base_conninfo, sub_base_conninfo);
+	db_info = store_pub_sub_info(&opt, pub_base_conninfo, sub_base_conninfo);
 
 	/* Register a function to clean up objects in case of failure */
 	atexit(cleanup_objects_atexit);
@@ -2162,7 +2162,7 @@ main(int argc, char **argv)
 	 * Check if the subscriber data directory has the same system identifier
 	 * than the publisher data directory.
 	 */
-	pub_sysid = get_primary_sysid(dbinfo[0].pubconninfo);
+	pub_sysid = get_primary_sysid(db_info[0].pubconninfo);
 	sub_sysid = get_standby_sysid(subscriber_dir);
 	if (pub_sysid != sub_sysid)
 		pg_fatal("subscriber data directory is not a copy of the source database cluster");
@@ -2192,10 +2192,10 @@ main(int argc, char **argv)
 	start_standby_server(&opt, true, false);
 
 	/* Check if the standby server is ready for logical replication */
-	check_subscriber(dbinfo);
+	check_subscriber(db_info);
 
 	/* Check if the primary server is ready for logical replication */
-	check_publisher(dbinfo);
+	check_publisher(db_info);
 
 	/*
 	 * Stop the target server. The recovery process requires that the server
@@ -2208,10 +2208,10 @@ main(int argc, char **argv)
 	stop_standby_server(subscriber_dir);
 
 	/* Create the required objects for each database on publisher */
-	consistent_lsn = setup_publisher(dbinfo);
+	consistent_lsn = setup_publisher(db_info);
 
 	/* Write the required recovery parameters */
-	setup_recovery(dbinfo, subscriber_dir, consistent_lsn);
+	setup_recovery(db_info, subscriber_dir, consistent_lsn);
 
 	/*
 	 * Start subscriber so the recovery parameters will take effect. Wait
@@ -2222,7 +2222,7 @@ main(int argc, char **argv)
 	start_standby_server(&opt, true, true);
 
 	/* Waiting the subscriber to be promoted */
-	wait_for_end_recovery(dbinfo[0].subconninfo, &opt);
+	wait_for_end_recovery(db_info[0].subconninfo, &opt);
 
 	/*
 	 * Create the subscription for each database on subscriber. It does not
@@ -2230,13 +2230,13 @@ main(int argc, char **argv)
 	 * point to the LSN reported by setup_publisher().  It also cleans up
 	 * publications created by this tool and replication to the standby.
 	 */
-	setup_subscriber(dbinfo, consistent_lsn);
+	setup_subscriber(db_info, consistent_lsn);
 
 	/* Remove primary_slot_name if it exists on primary */
-	drop_primary_replication_slot(dbinfo, primary_slot_name);
+	drop_primary_replication_slot(db_info, primary_slot_name);
 
 	/* Remove failover replication slots if they exist on subscriber */
-	drop_failover_replication_slots(dbinfo);
+	drop_failover_replication_slots(db_info);
 
 	/* Stop the subscriber */
 	pg_log_info("stopping the subscriber");
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index ea36b18..a9631cd 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -254,7 +254,7 @@ do { \
 	completion_charp = query; \
 	completion_charpp = list; \
 	completion_verbatim = false; \
-	matches = rl_completion_matches(text, complete_from_query); \
+	matches = rl_completion_matches(txt, complete_from_query); \
 } while (0)
 
 #define COMPLETE_WITH_QUERY_PLUS(query, ...) \
@@ -271,7 +271,7 @@ do { \
 	completion_charp = query; \
 	completion_charpp = list; \
 	completion_verbatim = true; \
-	matches = rl_completion_matches(text, complete_from_query); \
+	matches = rl_completion_matches(txt, complete_from_query); \
 } while (0)
 
 #define COMPLETE_WITH_QUERY_VERBATIM_PLUS(query, ...) \
@@ -288,7 +288,7 @@ do { \
 	completion_vquery = query; \
 	completion_charpp = list; \
 	completion_verbatim = false; \
-	matches = rl_completion_matches(text, complete_from_versioned_query); \
+	matches = rl_completion_matches(txt, complete_from_versioned_query); \
 } while (0)
 
 #define COMPLETE_WITH_VERSIONED_QUERY_PLUS(query, ...) \
@@ -305,7 +305,7 @@ do { \
 	completion_squery = &(query); \
 	completion_charpp = list; \
 	completion_verbatim = false; \
-	matches = rl_completion_matches(text, complete_from_schema_query); \
+	matches = rl_completion_matches(txt, complete_from_schema_query); \
 } while (0)
 
 #define COMPLETE_WITH_SCHEMA_QUERY_PLUS(query, ...) \
@@ -319,7 +319,7 @@ do { \
 	completion_squery = &(query); \
 	completion_charpp = NULL; \
 	completion_verbatim = true; \
-	matches = rl_completion_matches(text, complete_from_schema_query); \
+	matches = rl_completion_matches(txt, complete_from_schema_query); \
 } while (0)
 
 #define COMPLETE_WITH_VERSIONED_SCHEMA_QUERY(query) \
@@ -330,7 +330,7 @@ do { \
 	completion_squery = query; \
 	completion_charpp = list; \
 	completion_verbatim = false; \
-	matches = rl_completion_matches(text, complete_from_versioned_schema_query); \
+	matches = rl_completion_matches(txt, complete_from_versioned_schema_query); \
 } while (0)
 
 #define COMPLETE_WITH_VERSIONED_SCHEMA_QUERY_PLUS(query, ...) \
@@ -347,14 +347,14 @@ do { \
 do { \
 	completion_case_sensitive = (cs); \
 	completion_charp = (con); \
-	matches = rl_completion_matches(text, complete_from_const); \
+	matches = rl_completion_matches(txt, complete_from_const); \
 } while (0)
 
 #define COMPLETE_WITH_LIST_INT(cs, list) \
 do { \
 	completion_case_sensitive = (cs); \
 	completion_charpp = (list); \
-	matches = rl_completion_matches(text, complete_from_list); \
+	matches = rl_completion_matches(txt, complete_from_list); \
 } while (0)
 
 #define COMPLETE_WITH_LIST(list) COMPLETE_WITH_LIST_INT(false, list)
@@ -381,7 +381,7 @@ do { \
 	completion_squery = &(Query_for_list_of_attributes); \
 	completion_charpp = list; \
 	completion_verbatim = false; \
-	matches = rl_completion_matches(text, complete_from_schema_query); \
+	matches = rl_completion_matches(txt, complete_from_schema_query); \
 } while (0)
 
 #define COMPLETE_WITH_ATTR_PLUS(relation, ...) \
@@ -392,21 +392,21 @@ do { \
 
 /*
  * libedit will typically include the literal's leading single quote in
- * "text", while readline will not.  Adapt our offered strings to fit.
- * But include a quote if there's not one just before "text", to get the
+ * "txt", while readline will not.  Adapt our offered strings to fit.
+ * But include a quote if there's not one just before "txt", to get the
  * user off to the right start.
  */
 #define COMPLETE_WITH_ENUM_VALUE(type) \
 do { \
 	set_completion_reference(type); \
-	if (text[0] == '\'' || \
+	if (txt[0] == '\'' || \
 		start == 0 || rl_line_buffer[start - 1] != '\'') \
 		completion_squery = &(Query_for_list_of_enum_values_quoted); \
 	else \
 		completion_squery = &(Query_for_list_of_enum_values_unquoted); \
 	completion_charpp = NULL; \
 	completion_verbatim = true; \
-	matches = rl_completion_matches(text, complete_from_schema_query); \
+	matches = rl_completion_matches(txt, complete_from_schema_query); \
 } while (0)
 
 /*
@@ -416,7 +416,7 @@ do { \
 #define COMPLETE_WITH_TIMEZONE_NAME() \
 do { \
 	static const char *const list[] = { "DEFAULT", NULL }; \
-	if (text[0] == '\'') \
+	if (txt[0] == '\'') \
 		completion_charp = Query_for_list_of_timezone_names_quoted_in; \
 	else if (start == 0 || rl_line_buffer[start - 1] != '\'') \
 		completion_charp = Query_for_list_of_timezone_names_quoted_out; \
@@ -424,7 +424,7 @@ do { \
 		completion_charp = Query_for_list_of_timezone_names_unquoted; \
 	completion_charpp = list;							  \
 	completion_verbatim = true; \
-	matches = rl_completion_matches(text, complete_from_query); \
+	matches = rl_completion_matches(txt, complete_from_query); \
 } while (0)
 
 #define COMPLETE_WITH_FUNCTION_ARG(function) \
@@ -433,7 +433,7 @@ do { \
 	completion_squery = &(Query_for_list_of_arguments); \
 	completion_charpp = NULL; \
 	completion_verbatim = true; \
-	matches = rl_completion_matches(text, complete_from_schema_query); \
+	matches = rl_completion_matches(txt, complete_from_schema_query); \
 } while (0)
 
 /*
@@ -1339,32 +1339,32 @@ static const char *const view_optional_parameters[] = {
 };
 
 /* Forward declaration of functions */
-static char **psql_completion(const char *text, int start, int end);
-static char *create_command_generator(const char *text, int state);
-static char *drop_command_generator(const char *text, int state);
-static char *alter_command_generator(const char *text, int state);
-static char *complete_from_query(const char *text, int state);
-static char *complete_from_versioned_query(const char *text, int state);
-static char *complete_from_schema_query(const char *text, int state);
-static char *complete_from_versioned_schema_query(const char *text, int state);
+static char **psql_completion(const char *txt, int start, int end);
+static char *create_command_generator(const char *txt, int state);
+static char *drop_command_generator(const char *txt, int state);
+static char *alter_command_generator(const char *txt, int state);
+static char *complete_from_query(const char *txt, int state);
+static char *complete_from_versioned_query(const char *txt, int state);
+static char *complete_from_schema_query(const char *txt, int state);
+static char *complete_from_versioned_schema_query(const char *txt, int state);
 static char *_complete_from_query(const char *simple_query,
 								  const SchemaQuery *schema_query,
 								  const char *const *keywords,
 								  bool verbatim,
-								  const char *text, int state);
+								  const char *txt, int state);
 static void set_completion_reference(const char *word);
 static void set_completion_reference_verbatim(const char *word);
-static char *complete_from_list(const char *text, int state);
-static char *complete_from_const(const char *text, int state);
+static char *complete_from_list(const char *txt, int state);
+static char *complete_from_const(const char *txt, int state);
 static void append_variable_names(char ***varnames, int *nvars,
 								  int *maxvars, const char *varname,
 								  const char *prefix, const char *suffix);
-static char **complete_from_variables(const char *text,
+static char **complete_from_variables(const char *txt,
 									  const char *prefix, const char *suffix, bool need_value);
-static char *complete_from_files(const char *text, int state);
+static char *complete_from_files(const char *txt, int state);
 
 static char *pg_strdup_keyword_case(const char *s, const char *ref);
-static char *escape_string(const char *text);
+static char *escape_string(const char *txt);
 static char *make_like_pattern(const char *word);
 static void parse_identifier(const char *ident,
 							 char **schemaname, char **objectname,
@@ -1635,7 +1635,7 @@ ends_with(const char *s, char c)
  * rl_completion_matches() function, so we don't have to worry about it.
  */
 static char **
-psql_completion(const char *text, int start, int end)
+psql_completion(const char *txt, int start, int end)
 {
 	/* This is the variable we'll return. */
 	char	  **matches = NULL;
@@ -1746,14 +1746,14 @@ psql_completion(const char *text, int start, int end)
 
 	/*
 	 * Temporary workaround for a bug in recent (2019) libedit: it incorrectly
-	 * de-escapes the input "text", causing us to fail to recognize backslash
+	 * de-escapes the input "txt", causing us to fail to recognize backslash
 	 * commands.  So get the string to look at from rl_line_buffer instead.
 	 */
-	char	   *text_copy = pnstrdup(rl_line_buffer + start, end - start);
-	text = text_copy;
+	char	   *txt_copy = pnstrdup(rl_line_buffer + start, end - start);
+	txt = txt_copy;
 
 	/* Remember last char of the given input word. */
-	completion_last_char = (end > start) ? text[end - start - 1] : '\0';
+	completion_last_char = (end > start) ? txt[end - start - 1] : '\0';
 
 	/* We usually want the append character to be a space. */
 	rl_completion_append_character = ' ';
@@ -1776,20 +1776,20 @@ psql_completion(const char *text, int start, int end)
 										&previous_words_count);
 
 	/* If current word is a backslash command, offer completions for that */
-	if (text[0] == '\\')
+	if (txt[0] == '\\')
 		COMPLETE_WITH_LIST_CS(backslash_commands);
 
 	/* If current word is a variable interpolation, handle that case */
-	else if (text[0] == ':' && text[1] != ':')
+	else if (txt[0] == ':' && txt[1] != ':')
 	{
-		if (text[1] == '\'')
-			matches = complete_from_variables(text, ":'", "'", true);
-		else if (text[1] == '"')
-			matches = complete_from_variables(text, ":\"", "\"", true);
-		else if (text[1] == '{' && text[2] == '?')
-			matches = complete_from_variables(text, ":{?", "}", true);
+		if (txt[1] == '\'')
+			matches = complete_from_variables(txt, ":'", "'", true);
+		else if (txt[1] == '"')
+			matches = complete_from_variables(txt, ":\"", "\"", true);
+		else if (txt[1] == '{' && txt[2] == '?')
+			matches = complete_from_variables(txt, ":{?", "}", true);
 		else
-			matches = complete_from_variables(text, ":", "", true);
+			matches = complete_from_variables(txt, ":", "", true);
 	}
 
 	/* If no previous word, suggest one of the basic sql commands */
@@ -1806,7 +1806,7 @@ psql_completion(const char *text, int start, int end)
 			/* for INDEX and TABLE/SEQUENCE, respectively */
 						  "UNIQUE", "UNLOGGED");
 		else
-			matches = rl_completion_matches(text, create_command_generator);
+			matches = rl_completion_matches(txt, create_command_generator);
 	}
 	/* complete with something you can create or replace */
 	else if (TailMatches("CREATE", "OR", "REPLACE"))
@@ -1816,7 +1816,7 @@ psql_completion(const char *text, int start, int end)
 /* DROP, but not DROP embedded in other commands */
 	/* complete with something you can drop */
 	else if (Matches("DROP"))
-		matches = rl_completion_matches(text, drop_command_generator);
+		matches = rl_completion_matches(txt, drop_command_generator);
 
 /* ALTER */
 
@@ -1827,7 +1827,7 @@ psql_completion(const char *text, int start, int end)
 
 	/* ALTER something */
 	else if (Matches("ALTER"))
-		matches = rl_completion_matches(text, alter_command_generator);
+		matches = rl_completion_matches(txt, alter_command_generator);
 	/* ALTER TABLE,INDEX,MATERIALIZED VIEW ALL IN TABLESPACE xxx */
 	else if (TailMatches("ALL", "IN", "TABLESPACE", MatchAny))
 		COMPLETE_WITH("SET TABLESPACE", "OWNED BY");
@@ -2882,13 +2882,13 @@ psql_completion(const char *text, int start, int end)
 	{
 		completion_charp = "";
 		completion_force_quote = true;	/* COPY requires quoted filename */
-		matches = rl_completion_matches(text, complete_from_files);
+		matches = rl_completion_matches(txt, complete_from_files);
 	}
 	else if (Matches("\\copy", MatchAny, "FROM|TO"))
 	{
 		completion_charp = "";
 		completion_force_quote = false;
-		matches = rl_completion_matches(text, complete_from_files);
+		matches = rl_completion_matches(txt, complete_from_files);
 	}
 
 	/* Complete COPY <sth> TO <sth> */
@@ -4791,7 +4791,7 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_CS("commands", "options", "variables");
 	else if (TailMatchesCS("\\connect|\\c"))
 	{
-		if (!recognized_connection_string(text))
+		if (!recognized_connection_string(txt))
 			COMPLETE_WITH_QUERY(Query_for_list_of_databases);
 	}
 	else if (TailMatchesCS("\\connect|\\c", MatchAny))
@@ -4896,9 +4896,9 @@ psql_completion(const char *text, int start, int end)
 	else if (TailMatchesCS("\\h|\\help", MatchAny))
 	{
 		if (TailMatches("DROP"))
-			matches = rl_completion_matches(text, drop_command_generator);
+			matches = rl_completion_matches(txt, drop_command_generator);
 		else if (TailMatches("ALTER"))
-			matches = rl_completion_matches(text, alter_command_generator);
+			matches = rl_completion_matches(txt, alter_command_generator);
 
 		/*
 		 * CREATE is recognized by tail match elsewhere, so doesn't need to be
@@ -4966,9 +4966,9 @@ psql_completion(const char *text, int start, int end)
 			COMPLETE_WITH_CS("single", "double");
 	}
 	else if (TailMatchesCS("\\unset"))
-		matches = complete_from_variables(text, "", "", true);
+		matches = complete_from_variables(txt, "", "", true);
 	else if (TailMatchesCS("\\set"))
-		matches = complete_from_variables(text, "", "", false);
+		matches = complete_from_variables(txt, "", "", false);
 	else if (TailMatchesCS("\\set", MatchAny))
 	{
 		if (TailMatchesCS("AUTOCOMMIT|ON_ERROR_STOP|QUIET|SHOW_ALL_RESULTS|"
@@ -5001,7 +5001,7 @@ psql_completion(const char *text, int start, int end)
 	{
 		completion_charp = "\\";
 		completion_force_quote = false;
-		matches = rl_completion_matches(text, complete_from_files);
+		matches = rl_completion_matches(txt, complete_from_files);
 	}
 
 	/*
@@ -5049,7 +5049,7 @@ psql_completion(const char *text, int start, int end)
 	/* free storage */
 	free(previous_words);
 	free(words_buffer);
-	free(text_copy);
+	free(txt_copy);
 	free(completion_ref_object);
 	completion_ref_object = NULL;
 	free(completion_ref_schema);
@@ -5079,7 +5079,7 @@ psql_completion(const char *text, int start, int end)
  * Entries that have 'excluded' flags are not returned.
  */
 static char *
-create_or_drop_command_generator(const char *text, int state, bits32 excluded)
+create_or_drop_command_generator(const char *txt, int state, bits32 excluded)
 {
 	static int	list_index,
 				string_length;
@@ -5089,15 +5089,15 @@ create_or_drop_command_generator(const char *text, int state, bits32 excluded)
 	if (state == 0)
 	{
 		list_index = 0;
-		string_length = strlen(text);
+		string_length = strlen(txt);
 	}
 
 	/* find something that matches */
 	while ((name = words_after_create[list_index++].name))
 	{
-		if ((pg_strncasecmp(name, text, string_length) == 0) &&
+		if ((pg_strncasecmp(name, txt, string_length) == 0) &&
 			!(words_after_create[list_index - 1].flags & excluded))
-			return pg_strdup_keyword_case(name, text);
+			return pg_strdup_keyword_case(name, txt);
 	}
 	/* if nothing matches, return NULL */
 	return NULL;
@@ -5108,27 +5108,27 @@ create_or_drop_command_generator(const char *text, int state, bits32 excluded)
  * as defined above.
  */
 static char *
-create_command_generator(const char *text, int state)
+create_command_generator(const char *txt, int state)
 {
-	return create_or_drop_command_generator(text, state, THING_NO_CREATE);
+	return create_or_drop_command_generator(txt, state, THING_NO_CREATE);
 }
 
 /*
  * This function gives you a list of things you can put after a DROP command.
  */
 static char *
-drop_command_generator(const char *text, int state)
+drop_command_generator(const char *txt, int state)
 {
-	return create_or_drop_command_generator(text, state, THING_NO_DROP);
+	return create_or_drop_command_generator(txt, state, THING_NO_DROP);
 }
 
 /*
  * This function gives you a list of things you can put after an ALTER command.
  */
 static char *
-alter_command_generator(const char *text, int state)
+alter_command_generator(const char *txt, int state)
 {
-	return create_or_drop_command_generator(text, state, THING_NO_ALTER);
+	return create_or_drop_command_generator(txt, state, THING_NO_ALTER);
 }
 
 /*
@@ -5137,15 +5137,15 @@ alter_command_generator(const char *text, int state)
  */
 
 static char *
-complete_from_query(const char *text, int state)
+complete_from_query(const char *txt, int state)
 {
 	/* query is assumed to work for any server version */
 	return _complete_from_query(completion_charp, NULL, completion_charpp,
-								completion_verbatim, text, state);
+								completion_verbatim, txt, state);
 }
 
 static char *
-complete_from_versioned_query(const char *text, int state)
+complete_from_versioned_query(const char *txt, int state)
 {
 	const VersionedQuery *vquery = completion_vquery;
 
@@ -5157,19 +5157,19 @@ complete_from_versioned_query(const char *text, int state)
 		return NULL;
 
 	return _complete_from_query(vquery->query, NULL, completion_charpp,
-								completion_verbatim, text, state);
+								completion_verbatim, txt, state);
 }
 
 static char *
-complete_from_schema_query(const char *text, int state)
+complete_from_schema_query(const char *txt, int state)
 {
 	/* query is assumed to work for any server version */
 	return _complete_from_query(NULL, completion_squery, completion_charpp,
-								completion_verbatim, text, state);
+								completion_verbatim, txt, state);
 }
 
 static char *
-complete_from_versioned_schema_query(const char *text, int state)
+complete_from_versioned_schema_query(const char *txt, int state)
 {
 	const SchemaQuery *squery = completion_squery;
 
@@ -5181,7 +5181,7 @@ complete_from_versioned_schema_query(const char *text, int state)
 		return NULL;
 
 	return _complete_from_query(NULL, squery, completion_charpp,
-								completion_verbatim, text, state);
+								completion_verbatim, txt, state);
 }
 
 
@@ -5219,7 +5219,7 @@ complete_from_versioned_schema_query(const char *text, int state)
  * query results; otherwise we parse it as a possibly-qualified identifier,
  * and reconstruct suitable quoting afterward.
  *
- * "text" and "state" are supplied by Readline.  "text" is the word we are
+ * "txt" and "state" are supplied by Readline.  "txt" is the word we are
  * trying to complete.  "state" is zero on first call, nonzero later.
  *
  * readline will call this repeatedly with the same text and varying
@@ -5231,7 +5231,7 @@ _complete_from_query(const char *simple_query,
 					 const SchemaQuery *schema_query,
 					 const char *const *keywords,
 					 bool verbatim,
-					 const char *text, int state)
+					 const char *txt, int state)
 {
 	static int	list_index,
 				num_schema_only,
@@ -5267,12 +5267,12 @@ _complete_from_query(const char *simple_query,
 		/* Parse text, splitting into schema and object name if needed */
 		if (verbatim)
 		{
-			objectname = pg_strdup(text);
+			objectname = pg_strdup(txt);
 			schemaname = NULL;
 		}
 		else
 		{
-			parse_identifier(text,
+			parse_identifier(txt,
 							 &schemaname, &objectname,
 							 &schemaquoted, &objectquoted);
 		}
@@ -5526,10 +5526,10 @@ _complete_from_query(const char *simple_query,
 				if (nskip-- > 0)
 					continue;
 				list_index++;
-				if (pg_strncasecmp(text, item, strlen(text)) == 0)
+				if (pg_strncasecmp(txt, item, strlen(txt)) == 0)
 				{
 					num_keywords++;
-					return pg_strdup_keyword_case(item, text);
+					return pg_strdup_keyword_case(item, txt);
 				}
 			}
 		}
@@ -5544,10 +5544,10 @@ _complete_from_query(const char *simple_query,
 				if (nskip-- > 0)
 					continue;
 				list_index++;
-				if (pg_strncasecmp(text, item, strlen(text)) == 0)
+				if (pg_strncasecmp(txt, item, strlen(txt)) == 0)
 				{
 					num_keywords++;
-					return pg_strdup_keyword_case(item, text);
+					return pg_strdup_keyword_case(item, txt);
 				}
 			}
 		}
@@ -5602,7 +5602,7 @@ set_completion_reference_verbatim(const char *word)
  * SQL words that can appear at certain spot.
  */
 static char *
-complete_from_list(const char *text, int state)
+complete_from_list(const char *txt, int state)
 {
 	static int	string_length,
 				list_index,
@@ -5617,7 +5617,7 @@ complete_from_list(const char *text, int state)
 	if (state == 0)
 	{
 		list_index = 0;
-		string_length = strlen(text);
+		string_length = strlen(txt);
 		casesensitive = completion_case_sensitive;
 		matches = 0;
 	}
@@ -5625,14 +5625,14 @@ complete_from_list(const char *text, int state)
 	while ((item = completion_charpp[list_index++]))
 	{
 		/* First pass is case sensitive */
-		if (casesensitive && strncmp(text, item, string_length) == 0)
+		if (casesensitive && strncmp(txt, item, string_length) == 0)
 		{
 			matches++;
 			return pg_strdup(item);
 		}
 
 		/* Second pass is case insensitive, don't bother counting matches */
-		if (!casesensitive && pg_strncasecmp(text, item, string_length) == 0)
+		if (!casesensitive && pg_strncasecmp(txt, item, string_length) == 0)
 		{
 			if (completion_case_sensitive)
 				return pg_strdup(item);
@@ -5642,7 +5642,7 @@ complete_from_list(const char *text, int state)
 				 * If case insensitive matching was requested initially,
 				 * adjust the case according to setting.
 				 */
-				return pg_strdup_keyword_case(item, text);
+				return pg_strdup_keyword_case(item, txt);
 		}
 	}
 
@@ -5655,7 +5655,7 @@ complete_from_list(const char *text, int state)
 		casesensitive = false;
 		list_index = 0;
 		state++;
-		return complete_from_list(text, state);
+		return complete_from_list(txt, state);
 	}
 
 	/* If no more matches, return null. */
@@ -5682,7 +5682,7 @@ complete_from_list(const char *text, int state)
  * that won't try to auto-correct "misspellings".
  */
 static char *
-complete_from_const(const char *text, int state)
+complete_from_const(const char *txt, int state)
 {
 	Assert(completion_charp != NULL);
 	if (state == 0)
@@ -5695,7 +5695,7 @@ complete_from_const(const char *text, int state)
 			 * If case insensitive matching was requested initially, adjust
 			 * the case according to setting.
 			 */
-			return pg_strdup_keyword_case(completion_charp, text);
+			return pg_strdup_keyword_case(completion_charp, txt);
 	}
 	else
 		return NULL;
@@ -5730,7 +5730,7 @@ append_variable_names(char ***varnames, int *nvars,
  * (those that have hooks) are included even if currently unset.
  */
 static char **
-complete_from_variables(const char *text, const char *prefix, const char *suffix,
+complete_from_variables(const char *txt, const char *prefix, const char *suffix,
 						bool need_value)
 {
 	char	  **matches;
@@ -5775,7 +5775,7 @@ complete_from_variables(const char *text, const char *prefix, const char *suffix
  * quotes around the result.  (The SQL COPY command requires that.)
  */
 static char *
-complete_from_files(const char *text, int state)
+complete_from_files(const char *txt, int state)
 {
 #ifdef USE_FILENAME_QUOTING_FUNCTIONS
 
@@ -5799,37 +5799,37 @@ complete_from_files(const char *text, int state)
 #endif
 
 	/* If user typed a quote, force quoting (never remove user's quote) */
-	if (*text == '\'')
+	if (*txt == '\'')
 		completion_force_quote = true;
 
-	return rl_filename_completion_function(text, state);
+	return rl_filename_completion_function(txt, state);
 #else
 
 	/*
 	 * Otherwise, we have to do the best we can.
 	 */
-	static const char *unquoted_text;
+	static const char *unquoted_txt;
 	char	   *unquoted_match;
 	char	   *ret = NULL;
 
 	/* If user typed a quote, force quoting (never remove user's quote) */
-	if (*text == '\'')
+	if (*txt == '\'')
 		completion_force_quote = true;
 
 	if (state == 0)
 	{
 		/* Initialization: stash the unquoted input. */
-		unquoted_text = strtokx(text, "", NULL, "'", *completion_charp,
+		unquoted_txt = strtokx(txt, "", NULL, "'", *completion_charp,
 								false, true, pset.encoding);
 		/* expect a NULL return for the empty string only */
-		if (!unquoted_text)
+		if (!unquoted_txt)
 		{
-			Assert(*text == '\0');
-			unquoted_text = text;
+			Assert(*txt == '\0');
+			unquoted_txt = txt;
 		}
 	}
 
-	unquoted_match = rl_filename_completion_function(unquoted_text, state);
+	unquoted_match = rl_filename_completion_function(unquoted_txt, state);
 	if (unquoted_match)
 	{
 		struct stat statbuf;
@@ -5907,15 +5907,15 @@ pg_strdup_keyword_case(const char *s, const char *ref)
  * The returned value has to be freed.
  */
 static char *
-escape_string(const char *text)
+escape_string(const char *txt)
 {
-	size_t		text_length;
+	size_t		txt_length;
 	char	   *result;
 
-	text_length = strlen(text);
+	txt_length = strlen(txt);
 
-	result = pg_malloc(text_length * 2 + 1);
-	PQescapeStringConn(pset.db, result, text, text_length, NULL);
+	result = pg_malloc(txt_length * 2 + 1);
+	PQescapeStringConn(pset.db, result, txt, txt_length, NULL);
 
 	return result;
 }
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index c578c21..61a25ce 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -108,32 +108,32 @@ free_statement(struct statement *stmt)
 }
 
 static int
-next_insert(char *text, int pos, bool questionmarks, bool std_strings)
+next_insert(char *txt, int pos, bool questionmarks, bool std_strings)
 {
 	bool		string = false;
 	int			p = pos;
 
-	for (; text[p] != '\0'; p++)
+	for (; txt[p] != '\0'; p++)
 	{
-		if (string && !std_strings && text[p] == '\\')	/* escape character */
+		if (string && !std_strings && txt[p] == '\\')	/* escape character */
 			p++;
-		else if (text[p] == '\'')
+		else if (txt[p] == '\'')
 			string = string ? false : true;
 		else if (!string)
 		{
-			if (text[p] == '$' && isdigit((unsigned char) text[p + 1]))
+			if (txt[p] == '$' && isdigit((unsigned char) txt[p + 1]))
 			{
 				/* this can be either a dollar quote or a variable */
 				int			i;
 
-				for (i = p + 1; isdigit((unsigned char) text[i]); i++)
+				for (i = p + 1; isdigit((unsigned char) txt[i]); i++)
 					 /* empty loop body */ ;
-				if (!isalpha((unsigned char) text[i]) &&
-					isascii((unsigned char) text[i]) && text[i] != '_')
+				if (!isalpha((unsigned char) txt[i]) &&
+					isascii((unsigned char) txt[i]) && txt[i] != '_')
 					/* not dollar delimited quote */
 					return p;
 			}
-			else if (questionmarks && text[p] == '?')
+			else if (questionmarks && txt[p] == '?')
 			{
 				/* also allow old style placeholders */
 				return p;
diff --git a/src/interfaces/ecpg/ecpglib/prepare.c b/src/interfaces/ecpg/ecpglib/prepare.c
index ea1146f..ff46561 100644
--- a/src/interfaces/ecpg/ecpglib/prepare.c
+++ b/src/interfaces/ecpg/ecpglib/prepare.c
@@ -101,21 +101,21 @@ ecpg_register_prepared_stmt(struct statement *stmt)
 }
 
 static bool
-replace_variables(char **text, int lineno)
+replace_variables(char **txt, int lineno)
 {
 	bool		string = false;
 	int			counter = 1,
 				ptr = 0;
 
-	for (; (*text)[ptr] != '\0'; ptr++)
+	for (; (*txt)[ptr] != '\0'; ptr++)
 	{
-		if ((*text)[ptr] == '\'')
+		if ((*txt)[ptr] == '\'')
 			string = string ? false : true;
 
-		if (string || (((*text)[ptr] != ':') && ((*text)[ptr] != '?')))
+		if (string || (((*txt)[ptr] != ':') && ((*txt)[ptr] != '?')))
 			continue;
 
-		if (((*text)[ptr] == ':') && ((*text)[ptr + 1] == ':'))
+		if (((*txt)[ptr] == ':') && ((*txt)[ptr + 1] == ':'))
 			ptr += 2;			/* skip  '::' */
 		else
 		{
@@ -130,25 +130,25 @@ replace_variables(char **text, int lineno)
 
 			snprintf(buffer, buffersize, "$%d", counter++);
 
-			for (len = 1; (*text)[ptr + len] && isvarchar((*text)[ptr + len]); len++)
+			for (len = 1; (*txt)[ptr + len] && isvarchar((*txt)[ptr + len]); len++)
 				 /* skip */ ;
-			if (!(newcopy = (char *) ecpg_alloc(strlen(*text) - len + strlen(buffer) + 1, lineno)))
+			if (!(newcopy = (char *) ecpg_alloc(strlen(*txt) - len + strlen(buffer) + 1, lineno)))
 			{
 				ecpg_free(buffer);
 				return false;
 			}
 
-			memcpy(newcopy, *text, ptr);
+			memcpy(newcopy, *txt, ptr);
 			strcpy(newcopy + ptr, buffer);
-			strcat(newcopy, (*text) +ptr + len);
+			strcat(newcopy, (*txt) +ptr + len);
 
-			ecpg_free(*text);
+			ecpg_free(*txt);
 			ecpg_free(buffer);
 
-			*text = newcopy;
+			*txt = newcopy;
 
-			if ((*text)[ptr] == '\0')	/* we reached the end */
-				ptr--;			/* since we will (*text)[ptr]++ in the top
+			if ((*txt)[ptr] == '\0')	/* we reached the end */
+				ptr--;			/* since we will (*txt)[ptr]++ in the top
 								 * level for loop */
 		}
 	}
@@ -267,16 +267,16 @@ deallocate_one(int lineno, enum COMPAT_MODE c, struct connection *con,
 	/* first deallocate the statement in the backend */
 	if (this->prepared)
 	{
-		char	   *text;
+		char	   *txt;
 		PGresult   *query;
 
-		text = (char *) ecpg_alloc(strlen("deallocate \"\" ") + strlen(this->name), this->stmt->lineno);
+		txt = (char *) ecpg_alloc(strlen("deallocate \"\" ") + strlen(this->name), this->stmt->lineno);
 
-		if (text)
+		if (txt)
 		{
-			sprintf(text, "deallocate \"%s\"", this->name);
-			query = PQexec(this->stmt->connection->connection, text);
-			ecpg_free(text);
+			sprintf(txt, "deallocate \"%s\"", this->name);
+			query = PQexec(this->stmt->connection->connection, txt);
+			ecpg_free(txt);
 			if (ecpg_check_PQresult(query, lineno,
 									this->stmt->connection->connection,
 									this->stmt->compat))
diff --git a/src/interfaces/ecpg/preproc/c_keywords.c b/src/interfaces/ecpg/preproc/c_keywords.c
index 14f20e2..17a117d 100644
--- a/src/interfaces/ecpg/preproc/c_keywords.c
+++ b/src/interfaces/ecpg/preproc/c_keywords.c
@@ -33,7 +33,7 @@ static const uint16 ScanCKeywordTokens[] = {
  * ScanKeywordLookup(), except we want case-sensitive matching.
  */
 int
-ScanCKeywordLookup(const char *text)
+ScanCKeywordLookup(const char *txt)
 {
 	size_t		len;
 	int			h;
@@ -43,7 +43,7 @@ ScanCKeywordLookup(const char *text)
 	 * Reject immediately if too long to be any keyword.  This saves useless
 	 * hashing work on long strings.
 	 */
-	len = strlen(text);
+	len = strlen(txt);
 	if (len > ScanCKeywords.max_kw_len)
 		return -1;
 
@@ -51,7 +51,7 @@ ScanCKeywordLookup(const char *text)
 	 * Compute the hash function.  Since it's a perfect hash, we need only
 	 * match to the specific keyword it identifies.
 	 */
-	h = ScanCKeywords_hash_func(text, len);
+	h = ScanCKeywords_hash_func(txt, len);
 
 	/* An out-of-range result implies no match */
 	if (h < 0 || h >= ScanCKeywords.num_keywords)
@@ -59,7 +59,7 @@ ScanCKeywordLookup(const char *text)
 
 	kw = GetScanKeyword(h, &ScanCKeywords);
 
-	if (strcmp(kw, text) == 0)
+	if (strcmp(kw, txt) == 0)
 		return ScanCKeywordTokens[h];
 
 	return -1;
-- 
1.8.3.1

