New version the global patch unshadow. * names more consistent and readable. * without big changes. * goal,, unshadow all global variables, only, even the simplest.
regards, Ranier Vilela
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6bc1a6b46d..a496727e34 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -892,8 +892,8 @@ static int emode_for_corrupt_record(int emode, XLogRecPtr RecPtr); static void XLogFileClose(void); static void PreallocXlogFiles(XLogRecPtr endptr); static void RemoveTempXlogFiles(void); -static void RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr RedoRecPtr, XLogRecPtr endptr); -static void RemoveXlogFile(const char *segname, XLogRecPtr RedoRecPtr, XLogRecPtr endptr); +static void RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr lastRedoRecPtr, XLogRecPtr endptr); +static void RemoveXlogFile(const char *segname, XLogRecPtr lastRedoRecPtr, XLogRecPtr endptr); static void UpdateLastRemovedPtr(char *filename); static void ValidateXLOGDirectoryStructure(void); static void CleanupBackupHistory(void); @@ -2299,7 +2299,7 @@ assign_checkpoint_completion_target(double newval, void *extra) * XLOG segments? Returns the highest segment that should be preallocated. */ static XLogSegNo -XLOGfileslop(XLogRecPtr RedoRecPtr) +XLOGfileslop(XLogRecPtr lastRedoRecPtr) { XLogSegNo minSegNo; XLogSegNo maxSegNo; @@ -2311,9 +2311,9 @@ XLOGfileslop(XLogRecPtr RedoRecPtr) * correspond to. Always recycle enough segments to meet the minimum, and * remove enough segments to stay below the maximum. */ - minSegNo = RedoRecPtr / wal_segment_size + + minSegNo = lastRedoRecPtr / wal_segment_size + ConvertToXSegs(min_wal_size_mb, wal_segment_size) - 1; - maxSegNo = RedoRecPtr / wal_segment_size + + maxSegNo = lastRedoRecPtr / wal_segment_size + ConvertToXSegs(max_wal_size_mb, wal_segment_size) - 1; /* @@ -2328,7 +2328,7 @@ XLOGfileslop(XLogRecPtr RedoRecPtr) /* add 10% for good measure. */ distance *= 1.10; - recycleSegNo = (XLogSegNo) ceil(((double) RedoRecPtr + distance) / + recycleSegNo = (XLogSegNo) ceil(((double) lastRedoRecPtr + distance) / wal_segment_size); if (recycleSegNo < minSegNo) @@ -3949,12 +3949,12 @@ RemoveTempXlogFiles(void) /* * Recycle or remove all log files older or equal to passed segno. * - * endptr is current (or recent) end of xlog, and RedoRecPtr is the + * endptr is current (or recent) end of xlog, and lastRedoRecPtr is the * redo pointer of the last checkpoint. These are used to determine * whether we want to recycle rather than delete no-longer-wanted log files. */ static void -RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr RedoRecPtr, XLogRecPtr endptr) +RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr lastRedoRecPtr, XLogRecPtr endptr) { DIR *xldir; struct dirent *xlde; @@ -3997,7 +3997,7 @@ RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr RedoRecPtr, XLogRecPtr endptr) /* Update the last removed location in shared memory first */ UpdateLastRemovedPtr(xlde->d_name); - RemoveXlogFile(xlde->d_name, RedoRecPtr, endptr); + RemoveXlogFile(xlde->d_name, lastRedoRecPtr, endptr); } } } @@ -4071,14 +4071,14 @@ RemoveNonParentXlogFiles(XLogRecPtr switchpoint, TimeLineID newTLI) /* * Recycle or remove a log file that's no longer needed. * - * endptr is current (or recent) end of xlog, and RedoRecPtr is the + * endptr is current (or recent) end of xlog, and lastRedoRecPtr is the * redo pointer of the last checkpoint. These are used to determine * whether we want to recycle rather than delete no-longer-wanted log files. - * If RedoRecPtr is not known, pass invalid, and the function will recycle, + * If lastRedoRecPtr is not known, pass invalid, and the function will recycle, * somewhat arbitrarily, 10 future segments. */ static void -RemoveXlogFile(const char *segname, XLogRecPtr RedoRecPtr, XLogRecPtr endptr) +RemoveXlogFile(const char *segname, XLogRecPtr lastRedoRecPtr, XLogRecPtr endptr) { char path[MAXPGPATH]; #ifdef WIN32 @@ -4094,10 +4094,10 @@ RemoveXlogFile(const char *segname, XLogRecPtr RedoRecPtr, XLogRecPtr endptr) * Initialize info about where to try to recycle to. */ XLByteToSeg(endptr, endlogSegNo, wal_segment_size); - if (RedoRecPtr == InvalidXLogRecPtr) + if (lastRedoRecPtr == InvalidXLogRecPtr) recycleSegNo = endlogSegNo + 10; else - recycleSegNo = XLOGfileslop(RedoRecPtr); + recycleSegNo = XLOGfileslop(lastRedoRecPtr); } else recycleSegNo = 0; /* keep compiler quiet */ @@ -7158,11 +7158,11 @@ StartupXLOG(void) if (info == XLOG_CHECKPOINT_SHUTDOWN) { - CheckPoint checkPoint; + CheckPoint chkptrec; - memcpy(&checkPoint, XLogRecGetData(xlogreader), sizeof(CheckPoint)); - newTLI = checkPoint.ThisTimeLineID; - prevTLI = checkPoint.PrevTimeLineID; + memcpy(&chkptrec, XLogRecGetData(xlogreader), sizeof(CheckPoint)); + newTLI = chkptrec.ThisTimeLineID; + prevTLI = chkptrec.PrevTimeLineID; } else if (info == XLOG_END_OF_RECOVERY) { diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 67418b05f1..4915577e10 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -70,7 +70,7 @@ report_invalid_record(XLogReaderState *state, const char *fmt,...) * Returns NULL if the xlogreader couldn't be allocated. */ XLogReaderState * -XLogReaderAllocate(int wal_segment_size, const char *waldir, +XLogReaderAllocate(int segment_size, const char *waldir, XLogPageReadCB pagereadfunc, void *private_data) { XLogReaderState *state; @@ -99,7 +99,7 @@ XLogReaderAllocate(int wal_segment_size, const char *waldir, } /* Initialize segment info. */ - WALOpenSegmentInit(&state->seg, &state->segcxt, wal_segment_size, + WALOpenSegmentInit(&state->seg, &state->segcxt, segment_size, waldir); state->read_page = pagereadfunc; diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index 5408edcfc2..9931016fd7 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -57,7 +57,7 @@ static void parse_subscription_options(List *options, bool *connect, bool *enabled_given, bool *enabled, bool *create_slot, bool *slot_name_given, char **slot_name, - bool *copy_data, char **synchronous_commit, + bool *copy_data, char **synchr_commit, bool *refresh) { ListCell *lc; @@ -85,8 +85,8 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given, } if (copy_data) *copy_data = true; - if (synchronous_commit) - *synchronous_commit = NULL; + if (synchr_commit) + *synchr_commit = NULL; if (refresh) *refresh = true; @@ -150,17 +150,17 @@ parse_subscription_options(List *options, bool *connect, bool *enabled_given, *copy_data = defGetBoolean(defel); } else if (strcmp(defel->defname, "synchronous_commit") == 0 && - synchronous_commit) + synchr_commit) { - if (*synchronous_commit) + if (*synchr_commit) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("conflicting or redundant options"))); - *synchronous_commit = defGetString(defel); + *synchr_commit = defGetString(defel); /* Test if the given value is valid for synchronous_commit GUC. */ - (void) set_config_option("synchronous_commit", *synchronous_commit, + (void) set_config_option("synchronous_commit", *synchr_commit, PGC_BACKEND, PGC_S_TEST, GUC_ACTION_SET, false, 0, false); } @@ -317,7 +317,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel) bool enabled_given; bool enabled; bool copy_data; - char *synchronous_commit; + char *synchr_commit; char *conninfo; char *slotname; bool slotname_given; @@ -332,7 +332,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel) */ parse_subscription_options(stmt->options, &connect, &enabled_given, &enabled, &create_slot, &slotname_given, - &slotname, ©_data, &synchronous_commit, + &slotname, ©_data, &synchr_commit, NULL); /* @@ -375,8 +375,8 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel) slotname = stmt->subname; /* The default for synchronous_commit of subscriptions is off. */ - if (synchronous_commit == NULL) - synchronous_commit = "off"; + if (synchr_commit == NULL) + synchr_commit = "off"; conninfo = stmt->conninfo; publications = stmt->publication; @@ -407,7 +407,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel) else nulls[Anum_pg_subscription_subslotname - 1] = true; values[Anum_pg_subscription_subsynccommit - 1] = - CStringGetTextDatum(synchronous_commit); + CStringGetTextDatum(synchr_commit); values[Anum_pg_subscription_subpublications - 1] = publicationListToArray(publications); @@ -453,7 +453,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel) * Get the table list from publisher and build local table status * info. */ - tables = fetch_table_list(wrconn, publications); + tables = fetch_table_list(WalReceiverConnection, publications); foreach(lc, tables) { RangeVar *rv = (RangeVar *) lfirst(lc); @@ -478,7 +478,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel) { Assert(slotname); - walrcv_create_slot(wrconn, slotname, false, + walrcv_create_slot(WalReceiverConnection, slotname, false, CRS_NOEXPORT_SNAPSHOT, &lsn); ereport(NOTICE, (errmsg("created replication slot \"%s\" on publisher", @@ -487,7 +487,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel) } PG_FINALLY(); { - walrcv_disconnect(wrconn); + walrcv_disconnect(WalReceiverConnection); } PG_END_TRY(); } @@ -524,16 +524,16 @@ AlterSubscription_refresh(Subscription *sub, bool copy_data) load_file("libpqwalreceiver", false); /* Try to connect to the publisher. */ - wrconn = walrcv_connect(sub->conninfo, true, sub->name, &err); - if (!wrconn) + WalReceiverConnection = walrcv_connect(sub->conninfo, true, sub->name, &err); + if (!WalReceiverConnection) ereport(ERROR, (errmsg("could not connect to the publisher: %s", err))); /* Get the table list from publisher. */ - pubrel_names = fetch_table_list(wrconn, sub->publications); + pubrel_names = fetch_table_list(WalReceiverConnection, sub->publications); /* We are done with the remote side, close connection. */ - walrcv_disconnect(wrconn); + walrcv_disconnect(WalReceiverConnection); /* Get local table list. */ subrel_states = GetSubscriptionRelations(sub->oid); @@ -668,11 +668,11 @@ AlterSubscription(AlterSubscriptionStmt *stmt) { char *slotname; bool slotname_given; - char *synchronous_commit; + char *synchr_commit; parse_subscription_options(stmt->options, NULL, NULL, NULL, NULL, &slotname_given, &slotname, - NULL, &synchronous_commit, NULL); + NULL, &synchr_commit, NULL); if (slotname_given) { @@ -690,10 +690,10 @@ AlterSubscription(AlterSubscriptionStmt *stmt) replaces[Anum_pg_subscription_subslotname - 1] = true; } - if (synchronous_commit) + if (synchr_commit) { values[Anum_pg_subscription_subsynccommit - 1] = - CStringGetTextDatum(synchronous_commit); + CStringGetTextDatum(synchr_commit); replaces[Anum_pg_subscription_subsynccommit - 1] = true; } diff --git a/src/backend/main/main.c b/src/backend/main/main.c index a9edbfd4a4..9885a519ba 100644 --- a/src/backend/main/main.c +++ b/src/backend/main/main.c @@ -47,10 +47,10 @@ const char *progname; -static void startup_hacks(const char *progname); +static void startup_hacks(const char *appname); static void init_locale(const char *categoryname, int category, const char *locale); -static void help(const char *progname); -static void check_root(const char *progname); +static void help(const char *appname); +static void check_root(const char *appname); /* @@ -225,7 +225,7 @@ main(int argc, char *argv[]) * without help. Avoid adding more here, if you can. */ static void -startup_hacks(const char *progname) +startup_hacks(const char *appname) { /* * Windows-specific execution environment hacking. @@ -305,10 +305,10 @@ init_locale(const char *categoryname, int category, const char *locale) * Messages emitted in write_console() do not exhibit this problem. */ static void -help(const char *progname) +help(const char *appname) { - printf(_("%s is the PostgreSQL server.\n\n"), progname); - printf(_("Usage:\n %s [OPTION]...\n\n"), progname); + printf(_("%s is the PostgreSQL server.\n\n"), appname); + printf(_("Usage:\n %s [OPTION]...\n\n"), appname); printf(_("Options:\n")); printf(_(" -B NBUFFERS number of shared buffers\n")); printf(_(" -c NAME=VALUE set run-time parameter\n")); @@ -365,7 +365,7 @@ help(const char *progname) static void -check_root(const char *progname) +check_root(const char *appname) { #ifndef WIN32 if (geteuid() == 0) @@ -388,7 +388,7 @@ check_root(const char *progname) if (getuid() != geteuid()) { write_stderr("%s: real and effective user IDs must match\n", - progname); + appname); exit(1); } #else /* WIN32 */ diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 9ff2832c00..29a3a7517d 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -2538,7 +2538,7 @@ ConnFree(Port *conn) * the global variable yet when this is called. */ void -ClosePostmasterPorts(bool am_syslogger) +ClosePostmasterPorts(bool syslogger) { int i; @@ -2567,7 +2567,7 @@ ClosePostmasterPorts(bool am_syslogger) } /* If using syslogger, close the read side of the pipe */ - if (!am_syslogger) + if (!syslogger) { #ifndef WIN32 if (syslogPipe[0] >= 0) diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c index 4643af95fe..7fb7b4ad73 100644 --- a/src/backend/replication/logical/launcher.c +++ b/src/backend/replication/logical/launcher.c @@ -706,8 +706,8 @@ static void logicalrep_worker_onexit(int code, Datum arg) { /* Disconnect gracefully from the remote side. */ - if (wrconn) - walrcv_disconnect(wrconn); + if (WalReceiverConnection) + walrcv_disconnect(WalReceiverConnection); logicalrep_worker_detach(); diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c index e01d18c3a1..28b89f9af4 100644 --- a/src/backend/replication/logical/tablesync.c +++ b/src/backend/replication/logical/tablesync.c @@ -288,7 +288,7 @@ process_syncing_tables_for_sync(XLogRecPtr current_lsn) MyLogicalRepWorker->relstate, MyLogicalRepWorker->relstate_lsn); - walrcv_endstreaming(wrconn, &tli); + walrcv_endstreaming(WalReceiverConnection, &tli); finish_sync_worker(); } else @@ -584,7 +584,7 @@ copy_read_data(void *outbuf, int minread, int maxread) for (;;) { /* Try read the data. */ - len = walrcv_receive(wrconn, &buf, &fd); + len = walrcv_receive(WalReceiverConnection, &buf, &fd); CHECK_FOR_INTERRUPTS(); @@ -658,7 +658,7 @@ fetch_remote_table_info(char *nspname, char *relname, " AND c.relkind = 'r'", quote_literal_cstr(nspname), quote_literal_cstr(relname)); - res = walrcv_exec(wrconn, cmd.data, 2, tableRow); + res = walrcv_exec(WalReceiverConnection, cmd.data, 2, tableRow); if (res->status != WALRCV_OK_TUPLES) ereport(ERROR, @@ -694,9 +694,9 @@ fetch_remote_table_info(char *nspname, char *relname, " AND a.attrelid = %u" " ORDER BY a.attnum", lrel->remoteid, - (walrcv_server_version(wrconn) >= 120000 ? "AND a.attgenerated = ''" : ""), + (walrcv_server_version(WalReceiverConnection) >= 120000 ? "AND a.attgenerated = ''" : ""), lrel->remoteid); - res = walrcv_exec(wrconn, cmd.data, 4, attrRow); + res = walrcv_exec(WalReceiverConnection, cmd.data, 4, attrRow); if (res->status != WALRCV_OK_TUPLES) ereport(ERROR, @@ -766,7 +766,7 @@ copy_table(Relation rel) initStringInfo(&cmd); appendStringInfo(&cmd, "COPY %s TO STDOUT", quote_qualified_identifier(lrel.nspname, lrel.relname)); - res = walrcv_exec(wrconn, cmd.data, 0, NULL); + res = walrcv_exec(WalReceiverConnection, cmd.data, 0, NULL); pfree(cmd.data); if (res->status != WALRCV_OK_COPY_OUT) ereport(ERROR, @@ -833,8 +833,8 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos) * application_name, so that it is different from the main apply worker, * so that synchronous replication can distinguish them. */ - wrconn = walrcv_connect(MySubscription->conninfo, true, slotname, &err); - if (wrconn == NULL) + WalReceiverConnection = walrcv_connect(MySubscription->conninfo, true, slotname, &err); + if (WalReceiverConnection == NULL) ereport(ERROR, (errmsg("could not connect to the publisher: %s", err))); @@ -879,7 +879,7 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos) * inside the transaction so that we can use the snapshot made * by the slot to get existing data. */ - res = walrcv_exec(wrconn, + res = walrcv_exec(WalReceiverConnection, "BEGIN READ ONLY ISOLATION LEVEL " "REPEATABLE READ", 0, NULL); if (res->status != WALRCV_OK_COMMAND) @@ -896,14 +896,14 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos) * that is consistent with the lsn used by the slot to start * decoding. */ - walrcv_create_slot(wrconn, slotname, true, + walrcv_create_slot(WalReceiverConnection, slotname, true, CRS_USE_SNAPSHOT, origin_startpos); PushActiveSnapshot(GetTransactionSnapshot()); copy_table(rel); PopActiveSnapshot(); - res = walrcv_exec(wrconn, "COMMIT", 0, NULL); + res = walrcv_exec(WalReceiverConnection, "COMMIT", 0, NULL); if (res->status != WALRCV_OK_COMMAND) ereport(ERROR, (errmsg("table copy could not finish transaction on publisher"), diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index ced0d191c2..4f5400c369 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -97,7 +97,7 @@ typedef struct SlotErrCallbackArg static MemoryContext ApplyMessageContext = NULL; MemoryContext ApplyContext = NULL; -WalReceiverConn *wrconn = NULL; +WalReceiverConn *WalReceiverConnection = NULL; Subscription *MySubscription = NULL; bool MySubscriptionValid = false; @@ -1132,7 +1132,7 @@ LogicalRepApplyLoop(XLogRecPtr last_received) MemoryContextSwitchTo(ApplyMessageContext); - len = walrcv_receive(wrconn, &buf, &fd); + len = walrcv_receive(WalReceiverConnection, &buf, &fd); if (len != 0) { @@ -1212,7 +1212,7 @@ LogicalRepApplyLoop(XLogRecPtr last_received) MemoryContextReset(ApplyMessageContext); } - len = walrcv_receive(wrconn, &buf, &fd); + len = walrcv_receive(WalReceiverConnection, &buf, &fd); } } @@ -1242,7 +1242,7 @@ LogicalRepApplyLoop(XLogRecPtr last_received) { TimeLineID tli; - walrcv_endstreaming(wrconn, &tli); + walrcv_endstreaming(WalReceiverConnection, &tli); break; } @@ -1408,7 +1408,7 @@ send_feedback(XLogRecPtr recvpos, bool force, bool requestReply) (uint32) (flushpos >> 32), (uint32) flushpos ); - walrcv_send(wrconn, reply_message->data, reply_message->len); + walrcv_send(WalReceiverConnection, reply_message->data, reply_message->len); if (recvpos > last_recvpos) last_recvpos = recvpos; @@ -1714,9 +1714,9 @@ ApplyWorkerMain(Datum main_arg) origin_startpos = replorigin_session_get_progress(false); CommitTransactionCommand(); - wrconn = walrcv_connect(MySubscription->conninfo, true, MySubscription->name, + WalReceiverConnection = walrcv_connect(MySubscription->conninfo, true, MySubscription->name, &err); - if (wrconn == NULL) + if (WalReceiverConnection == NULL) ereport(ERROR, (errmsg("could not connect to the publisher: %s", err))); @@ -1724,7 +1724,7 @@ ApplyWorkerMain(Datum main_arg) * We don't really use the output identify_system for anything but it * does some initializations on the upstream so let's still call it. */ - (void) walrcv_identify_system(wrconn, &startpointTLI); + (void) walrcv_identify_system(WalReceiverConnection, &startpointTLI); } @@ -1744,7 +1744,7 @@ ApplyWorkerMain(Datum main_arg) options.proto.logical.publication_names = MySubscription->publications; /* Start normal logical streaming replication. */ - walrcv_startstreaming(wrconn, &options); + walrcv_startstreaming(WalReceiverConnection, &options); /* Run the main loop. */ LogicalRepApplyLoop(origin_startpos); diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c index c1e439adb4..f9d3a9feb9 100644 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -78,7 +78,7 @@ int wal_receiver_timeout; bool hot_standby_feedback; /* libpqwalreceiver connection */ -static WalReceiverConn *wrconn = NULL; +static WalReceiverConn *WalReceiverConnection = NULL; WalReceiverFunctionsType *WalReceiverFunctions = NULL; #define NAPTIME_PER_CYCLE 100 /* max sleep time between cycles (100ms) */ @@ -270,8 +270,8 @@ WalReceiverMain(void) PG_SETMASK(&UnBlockSig); /* Establish the connection to the primary for XLOG streaming */ - wrconn = walrcv_connect(conninfo, false, cluster_name[0] ? cluster_name : "walreceiver", &err); - if (!wrconn) + WalReceiverConnection = walrcv_connect(conninfo, false, cluster_name[0] ? cluster_name : "walreceiver", &err); + if (!WalReceiverConnection) ereport(ERROR, (errmsg("could not connect to the primary server: %s", err))); @@ -280,8 +280,8 @@ WalReceiverMain(void) * conninfo, for security. Also save host and port of the sender server * this walreceiver is connected to. */ - tmp_conninfo = walrcv_get_conninfo(wrconn); - walrcv_get_senderinfo(wrconn, &sender_host, &sender_port); + tmp_conninfo = walrcv_get_conninfo(WalReceiverConnection); + walrcv_get_senderinfo(WalReceiverConnection, &sender_host, &sender_port); SpinLockAcquire(&walrcv->mutex); memset(walrcv->conninfo, 0, MAXCONNINFO); if (tmp_conninfo) @@ -312,7 +312,7 @@ WalReceiverMain(void) * Check that we're connected to a valid server using the * IDENTIFY_SYSTEM replication command. */ - primary_sysid = walrcv_identify_system(wrconn, &primaryTLI); + primary_sysid = walrcv_identify_system(WalReceiverConnection, &primaryTLI); snprintf(standby_sysid, sizeof(standby_sysid), UINT64_FORMAT, GetSystemIdentifier()); @@ -362,7 +362,7 @@ WalReceiverMain(void) options.slotname = slotname[0] != '\0' ? slotname : NULL; options.proto.physical.startpointTLI = startpointTLI; ThisTimeLineID = startpointTLI; - if (walrcv_startstreaming(wrconn, &options)) + if (walrcv_startstreaming(WalReceiverConnection, &options)) { if (first_stream) ereport(LOG, @@ -413,7 +413,7 @@ WalReceiverMain(void) } /* See if we can read data immediately */ - len = walrcv_receive(wrconn, &buf, &wait_fd); + len = walrcv_receive(WalReceiverConnection, &buf, &wait_fd); if (len != 0) { /* @@ -444,7 +444,7 @@ WalReceiverMain(void) endofwal = true; break; } - len = walrcv_receive(wrconn, &buf, &wait_fd); + len = walrcv_receive(WalReceiverConnection, &buf, &wait_fd); } /* Let the master know that we received some data. */ @@ -553,7 +553,7 @@ WalReceiverMain(void) * The backend finished streaming. Exit streaming COPY-mode from * our side, too. */ - walrcv_endstreaming(wrconn, &primaryTLI); + walrcv_endstreaming(WalReceiverConnection, &primaryTLI); /* * If the server had switched to a new timeline that we didn't @@ -700,7 +700,7 @@ WalRcvFetchTimeLineHistoryFiles(TimeLineID first, TimeLineID last) (errmsg("fetching timeline history file for timeline %u from primary server", tli))); - walrcv_readtimelinehistoryfile(wrconn, tli, &fname, &content, &len); + walrcv_readtimelinehistoryfile(WalReceiverConnection, tli, &fname, &content, &len); /* * Check that the filename on the master matches what we @@ -751,8 +751,8 @@ WalRcvDie(int code, Datum arg) SpinLockRelease(&walrcv->mutex); /* Terminate the connection gracefully. */ - if (wrconn != NULL) - walrcv_disconnect(wrconn); + if (WalReceiverConnection != NULL) + walrcv_disconnect(WalReceiverConnection); /* Wake up the startup process to notice promptly that we're gone */ WakeupRecovery(); @@ -1114,7 +1114,7 @@ XLogWalRcvSendReply(bool force, bool requestReply) (uint32) (applyPtr >> 32), (uint32) applyPtr, requestReply ? " (reply requested)" : ""); - walrcv_send(wrconn, reply_message.data, reply_message.len); + walrcv_send(WalReceiverConnection, reply_message.data, reply_message.len); } /* @@ -1230,7 +1230,7 @@ XLogWalRcvSendHSFeedback(bool immed) pq_sendint32(&reply_message, xmin_epoch); pq_sendint32(&reply_message, catalog_xmin); pq_sendint32(&reply_message, catalog_xmin_epoch); - walrcv_send(wrconn, reply_message.data, reply_message.len); + walrcv_send(WalReceiverConnection, reply_message.data, reply_message.len); if (TransactionIdIsValid(xmin) || TransactionIdIsValid(catalog_xmin)) master_has_standby_xmin = true; else diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 8b2a2be1c0..e06e9a3015 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -146,7 +146,7 @@ static XLogRecPtr sendTimeLineValidUpto = InvalidXLogRecPtr; * How far have we sent WAL already? This is also advertised in * MyWalSnd->sentPtr. (Actually, this is the next WAL location to send.) */ -static XLogRecPtr sentPtr = 0; +static XLogRecPtr WalSentPtr = 0; /* Buffers for constructing outgoing messages and processing reply messages. */ static StringInfoData output_message; @@ -683,11 +683,11 @@ StartReplication(StartReplicationCmd *cmd) } /* Start streaming from the requested point */ - sentPtr = cmd->startpoint; + WalSentPtr = cmd->startpoint; /* Initialize shared memory status, too */ SpinLockAcquire(&MyWalSnd->mutex); - MyWalSnd->sentPtr = sentPtr; + MyWalSnd->sentPtr = WalSentPtr; SpinLockRelease(&MyWalSnd->mutex); SyncRepInitConfig(); @@ -1135,9 +1135,9 @@ StartLogicalReplication(StartReplicationCmd *cmd) /* * Report the location after which we'll send out further commits as the - * current sentPtr. + * current WalSentPtr. */ - sentPtr = MyReplicationSlot->data.confirmed_flush; + WalSentPtr = MyReplicationSlot->data.confirmed_flush; /* Also update the sent position status in shared memory */ SpinLockAcquire(&MyWalSnd->mutex); @@ -1390,8 +1390,8 @@ WalSndWaitForWal(XLogRecPtr loc) * possibly are waiting for a later location. So we send pings * containing the flush location every now and then. */ - if (MyWalSnd->flush < sentPtr && - MyWalSnd->write < sentPtr && + if (MyWalSnd->flush < WalSentPtr && + MyWalSnd->write < WalSentPtr && !waiting_for_ping_response) { WalSndKeepalive(false); @@ -1848,7 +1848,7 @@ ProcessStandbyReplyMessage(void) * until more WAL traffic arrives. */ clearLagTimes = false; - if (applyPtr == sentPtr) + if (applyPtr == WalSentPtr) { if (fullyAppliedLastTime) clearLagTimes = true; @@ -2607,11 +2607,11 @@ XLogSendPhysical(void) * terminated at a WAL page boundary, the valid portion of the timeline * might end in the middle of a WAL record. We might've already sent the * first half of that partial WAL record to the cascading standby, so that - * sentPtr > sendTimeLineValidUpto. That's OK; the cascading standby can't + * WalSentPtr > sendTimeLineValidUpto. That's OK; the cascading standby can't * replay the partial WAL record either, so it can still follow our * timeline switch. */ - if (sendTimeLineIsHistoric && sendTimeLineValidUpto <= sentPtr) + if (sendTimeLineIsHistoric && sendTimeLineValidUpto <= WalSentPtr) { /* close the current file. */ if (sendSeg->ws_file >= 0) @@ -2626,13 +2626,13 @@ XLogSendPhysical(void) elog(DEBUG1, "walsender reached end of timeline at %X/%X (sent up to %X/%X)", (uint32) (sendTimeLineValidUpto >> 32), (uint32) sendTimeLineValidUpto, - (uint32) (sentPtr >> 32), (uint32) sentPtr); + (uint32) (WalSentPtr >> 32), (uint32) WalSentPtr); return; } /* Do we have any work to do? */ - Assert(sentPtr <= SendRqstPtr); - if (SendRqstPtr <= sentPtr) + Assert(WalSentPtr <= SendRqstPtr); + if (SendRqstPtr <= WalSentPtr) { WalSndCaughtUp = true; return; @@ -2649,7 +2649,7 @@ XLogSendPhysical(void) * page boundary is always a safe cut-off point. We also assume that * SendRqstPtr never points to the middle of a WAL record. */ - startptr = sentPtr; + startptr = WalSentPtr; endptr = startptr; endptr += MAX_SEND_SIZE; @@ -2743,14 +2743,14 @@ retry: pq_putmessage_noblock('d', output_message.data, output_message.len); - sentPtr = endptr; + WalSentPtr = endptr; /* Update shared memory status */ { WalSnd *walsnd = MyWalSnd; SpinLockAcquire(&walsnd->mutex); - walsnd->sentPtr = sentPtr; + walsnd->sentPtr = WalSentPtr; SpinLockRelease(&walsnd->mutex); } @@ -2760,7 +2760,7 @@ retry: char activitymsg[50]; snprintf(activitymsg, sizeof(activitymsg), "streaming %X/%X", - (uint32) (sentPtr >> 32), (uint32) sentPtr); + (uint32) (WalSentPtr >> 32), (uint32) WalSentPtr); set_ps_display(activitymsg, false); } } @@ -2804,7 +2804,7 @@ XLogSendLogical(void) */ LogicalDecodingProcessRecord(logical_decoding_ctx, logical_decoding_ctx->reader); - sentPtr = logical_decoding_ctx->reader->EndRecPtr; + WalSentPtr = logical_decoding_ctx->reader->EndRecPtr; } /* Set flag if we're caught up. */ @@ -2824,7 +2824,7 @@ XLogSendLogical(void) WalSnd *walsnd = MyWalSnd; SpinLockAcquire(&walsnd->mutex); - walsnd->sentPtr = sentPtr; + walsnd->sentPtr = WalSentPtr; SpinLockRelease(&walsnd->mutex); } } @@ -2854,7 +2854,7 @@ WalSndDone(WalSndSendDataCallback send_data) replicatedPtr = XLogRecPtrIsInvalid(MyWalSnd->flush) ? MyWalSnd->write : MyWalSnd->flush; - if (WalSndCaughtUp && sentPtr == replicatedPtr && + if (WalSndCaughtUp && WalSentPtr == replicatedPtr && !pq_is_send_pending()) { /* Inform the standby that XLOG streaming is done */ @@ -3370,7 +3370,7 @@ WalSndKeepalive(bool requestReply) /* construct the message... */ resetStringInfo(&output_message); pq_sendbyte(&output_message, 'k'); - pq_sendint64(&output_message, sentPtr); + pq_sendint64(&output_message, WalSentPtr); pq_sendint64(&output_message, GetCurrentTimestamp()); pq_sendbyte(&output_message, requestReply ? 1 : 0); diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index 709bbaaf5a..63097739c4 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -508,16 +508,16 @@ Datum date_pli(PG_FUNCTION_ARGS) { DateADT dateVal = PG_GETARG_DATEADT(0); - int32 days = PG_GETARG_INT32(1); + int32 ndays = PG_GETARG_INT32(1); DateADT result; if (DATE_NOT_FINITE(dateVal)) PG_RETURN_DATEADT(dateVal); /* can't change infinity */ - result = dateVal + days; + result = dateVal + ndays; /* Check for integer overflow and out-of-allowed-range */ - if ((days >= 0 ? (result < dateVal) : (result > dateVal)) || + if ((ndays >= 0 ? (result < dateVal) : (result > dateVal)) || !IS_VALID_DATE(result)) ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), @@ -532,16 +532,16 @@ Datum date_mii(PG_FUNCTION_ARGS) { DateADT dateVal = PG_GETARG_DATEADT(0); - int32 days = PG_GETARG_INT32(1); + int32 ndays = PG_GETARG_INT32(1); DateADT result; if (DATE_NOT_FINITE(dateVal)) PG_RETURN_DATEADT(dateVal); /* can't change infinity */ - result = dateVal - days; + result = dateVal - ndays; /* Check for integer overflow and out-of-allowed-range */ - if ((days >= 0 ? (result > dateVal) : (result < dateVal)) || + if ((ndays >= 0 ? (result > dateVal) : (result < dateVal)) || !IS_VALID_DATE(result)) ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), @@ -1810,18 +1810,18 @@ interval_time(PG_FUNCTION_ARGS) { Interval *span = PG_GETARG_INTERVAL_P(0); TimeADT result; - int64 days; + int64 ndays; result = span->time; if (result >= USECS_PER_DAY) { - days = result / USECS_PER_DAY; - result -= days * USECS_PER_DAY; + ndays = result / USECS_PER_DAY; + result -= ndays * USECS_PER_DAY; } else if (result < 0) { - days = (-result + USECS_PER_DAY - 1) / USECS_PER_DAY; - result += days * USECS_PER_DAY; + ndays = (-result + USECS_PER_DAY - 1) / USECS_PER_DAY; + result += ndays * USECS_PER_DAY; } PG_RETURN_TIMEADT(result); diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 31bdb37c55..2f721ee67e 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -1500,9 +1500,9 @@ Datum make_interval(PG_FUNCTION_ARGS) { int32 years = PG_GETARG_INT32(0); - int32 months = PG_GETARG_INT32(1); + int32 nmonths = PG_GETARG_INT32(1); int32 weeks = PG_GETARG_INT32(2); - int32 days = PG_GETARG_INT32(3); + int32 ndays = PG_GETARG_INT32(3); int32 hours = PG_GETARG_INT32(4); int32 mins = PG_GETARG_INT32(5); double secs = PG_GETARG_FLOAT8(6); @@ -1518,8 +1518,8 @@ make_interval(PG_FUNCTION_ARGS) errmsg("interval out of range"))); result = (Interval *) palloc(sizeof(Interval)); - result->month = years * MONTHS_PER_YEAR + months; - result->day = weeks * 7 + days; + result->month = years * MONTHS_PER_YEAR + nmonths; + result->day = weeks * 7 + ndays; secs = rint(secs * USECS_PER_SEC); result->time = hours * ((int64) SECS_PER_HOUR * USECS_PER_SEC) + @@ -2343,22 +2343,22 @@ interval_cmp_value(const Interval *interval) { INT128 span; int64 dayfraction; - int64 days; + int64 ndays; /* * Separate time field into days and dayfraction, then add the month and * day fields to the days part. We cannot overflow int64 days here. */ dayfraction = interval->time % USECS_PER_DAY; - days = interval->time / USECS_PER_DAY; - days += interval->month * INT64CONST(30); - days += interval->day; + ndays = interval->time / USECS_PER_DAY; + ndays += interval->month * INT64CONST(30); + ndays += interval->day; /* Widen dayfraction to 128 bits */ span = int64_to_int128(dayfraction); /* Scale up days to microseconds, forming a 128-bit product */ - int128_add_int64_mul_int64(&span, days, USECS_PER_DAY); + int128_add_int64_mul_int64(&span, ndays, USECS_PER_DAY); return span; } diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index ba74bf9f7d..6da19113cd 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -5383,13 +5383,13 @@ InitializeOneGUCOption(struct config_generic *gconf) * * This is called after processing command-line switches. * userDoption is the -D switch value if any (NULL if unspecified). - * progname is just for use in error messages. + * appname is just for use in error messages. * * Returns true on success; on failure, prints a suitable error message * to stderr and returns false. */ bool -SelectConfigFiles(const char *userDoption, const char *progname) +SelectConfigFiles(const char *userDoption, const char *appname) { char *configdir; char *fname; @@ -5404,7 +5404,7 @@ SelectConfigFiles(const char *userDoption, const char *progname) if (configdir && stat(configdir, &stat_buf) != 0) { write_stderr("%s: could not access directory \"%s\": %s\n", - progname, + appname, configdir, strerror(errno)); if (errno == ENOENT) @@ -5431,7 +5431,7 @@ SelectConfigFiles(const char *userDoption, const char *progname) write_stderr("%s does not know where to find the server configuration file.\n" "You must specify the --config-file or -D invocation " "option or set the PGDATA environment variable.\n", - progname); + appname); return false; } @@ -5448,7 +5448,7 @@ SelectConfigFiles(const char *userDoption, const char *progname) if (stat(ConfigFileName, &stat_buf) != 0) { write_stderr("%s: could not access the server configuration file \"%s\": %s\n", - progname, ConfigFileName, strerror(errno)); + appname, ConfigFileName, strerror(errno)); free(configdir); return false; } @@ -5477,7 +5477,7 @@ SelectConfigFiles(const char *userDoption, const char *progname) "This can be specified as \"data_directory\" in \"%s\", " "or by the -D invocation option, or by the " "PGDATA environment variable.\n", - progname, ConfigFileName); + appname, ConfigFileName); return false; } @@ -5525,7 +5525,7 @@ SelectConfigFiles(const char *userDoption, const char *progname) "This can be specified as \"hba_file\" in \"%s\", " "or by the -D invocation option, or by the " "PGDATA environment variable.\n", - progname, ConfigFileName); + appname, ConfigFileName); return false; } SetConfigOption("hba_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE); @@ -5548,7 +5548,7 @@ SelectConfigFiles(const char *userDoption, const char *progname) "This can be specified as \"ident_file\" in \"%s\", " "or by the -D invocation option, or by the " "PGDATA environment variable.\n", - progname, ConfigFileName); + appname, ConfigFileName); return false; } SetConfigOption("ident_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE); diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 1f6d8939be..3dc3a3fc6c 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -266,12 +266,12 @@ static void trapsig(int signum); static void check_ok(void); static char *escape_quotes(const char *src); static char *escape_quotes_bki(const char *src); -static int locale_date_order(const char *locale); -static void check_locale_name(int category, const char *locale, +static int locale_date_order(const char *locale_name); +static void check_locale_name(int category, const char *locale_name, char **canonname); -static bool check_locale_encoding(const char *locale, int encoding); +static bool check_locale_encoding(const char *locale_name, int encoding); static void setlocales(void); -static void usage(const char *progname); +static void usage(const char *appname); void setup_pgdata(void); void setup_bin_paths(const char *argv0); void setup_data_file_paths(void); @@ -631,7 +631,7 @@ cleanup_directories_atexit(void) static char * get_id(void) { - const char *username; + const char *user_name; #ifndef WIN32 if (geteuid() == 0) /* 0 is root's uid */ @@ -644,9 +644,9 @@ get_id(void) } #endif - username = get_user_name_or_exit(progname); + user_name = get_user_name_or_exit(progname); - return pg_strdup(username); + return pg_strdup(user_name); } static char * @@ -864,17 +864,17 @@ write_version_file(const char *extrapath) static void set_null_conf(void) { - FILE *conf_file; + FILE *file; char *path; path = psprintf("%s/postgresql.conf", pg_data); - conf_file = fopen(path, PG_BINARY_W); - if (conf_file == NULL) + file = fopen(path, PG_BINARY_W); + if (file == NULL) { pg_log_error("could not open file \"%s\" for writing: %m", path); exit(1); } - if (fclose(conf_file)) + if (fclose(file)) { pg_log_error("could not write file \"%s\": %m", path); exit(1); @@ -2107,7 +2107,7 @@ my_strftime(char *s, size_t max, const char *fmt, const struct tm *tm) * Determine likely date order from locale */ static int -locale_date_order(const char *locale) +locale_date_order(const char *locale_name) { struct tm testtime; char buf[128]; @@ -2125,7 +2125,7 @@ locale_date_order(const char *locale) return result; save = pg_strdup(save); - setlocale(LC_TIME, locale); + setlocale(LC_TIME, locale_name); memset(&testtime, 0, sizeof(testtime)); testtime.tm_mday = 22; @@ -2170,7 +2170,7 @@ locale_date_order(const char *locale) * this should match the backend's check_locale() function */ static void -check_locale_name(int category, const char *locale, char **canonname) +check_locale_name(int category, const char *locale_name, char **canonname) { char *save; char *res; @@ -2193,7 +2193,7 @@ check_locale_name(int category, const char *locale, char **canonname) locale = ""; /* set the locale with setlocale, to see if it accepts it. */ - res = setlocale(category, locale); + res = setlocale(category, locale_name); /* save canonical name if requested. */ if (res && canonname) @@ -2210,8 +2210,8 @@ check_locale_name(int category, const char *locale, char **canonname) /* complain if locale wasn't valid */ if (res == NULL) { - if (*locale) - pg_log_error("invalid locale name \"%s\"", locale); + if (*locale_name) + pg_log_error("invalid locale name \"%s\"", locale_name); else { /* @@ -2234,11 +2234,11 @@ check_locale_name(int category, const char *locale, char **canonname) * this should match the similar check in the backend createdb() function */ static bool -check_locale_encoding(const char *locale, int user_enc) +check_locale_encoding(const char *locale_name, int user_enc) { int locale_enc; - locale_enc = pg_get_encoding_from_locale(locale, true); + locale_enc = pg_get_encoding_from_locale(locale_name, true); /* See notes in createdb() to understand these tests */ if (!(locale_enc == user_enc || @@ -2321,11 +2321,11 @@ setlocales(void) * print help text */ static void -usage(const char *progname) +usage(const char *appname) { - printf(_("%s initializes a PostgreSQL database cluster.\n\n"), progname); + printf(_("%s initializes a PostgreSQL database cluster.\n\n"), appname); printf(_("Usage:\n")); - printf(_(" %s [OPTION]... [DATADIR]\n"), progname); + printf(_(" %s [OPTION]... [DATADIR]\n"), appname); printf(_("\nOptions:\n")); printf(_(" -A, --auth=METHOD default authentication method for local connections\n")); printf(_(" --auth-host=METHOD default authentication method for local TCP/IP connections\n")); @@ -2393,22 +2393,22 @@ check_authmethod_valid(const char *authmethod, const char *const *valid_methods, } static void -check_need_password(const char *authmethodlocal, const char *authmethodhost) +check_need_password(const char *authmethod, const char *host) { - if ((strcmp(authmethodlocal, "md5") == 0 || - strcmp(authmethodlocal, "password") == 0 || - strcmp(authmethodlocal, "scram-sha-256") == 0) && - (strcmp(authmethodhost, "md5") == 0 || - strcmp(authmethodhost, "password") == 0 || - strcmp(authmethodhost, "scram-sha-256") == 0) && + if ((strcmp(authmethod, "md5") == 0 || + strcmp(authmethod, "password") == 0 || + strcmp(authmethod, "scram-sha-256") == 0) && + (strcmp(authmethod, "md5") == 0 || + strcmp(authmethod, "password") == 0 || + strcmp(authmethod, "scram-sha-256") == 0) && !(pwprompt || pwfilename)) { pg_log_error("must specify a password for the superuser to enable %s authentication", - (strcmp(authmethodlocal, "md5") == 0 || - strcmp(authmethodlocal, "password") == 0 || - strcmp(authmethodlocal, "scram-sha-256") == 0) - ? authmethodlocal - : authmethodhost); + (strcmp(authmethod, "md5") == 0 || + strcmp(authmethod, "password") == 0 || + strcmp(authmethod, "scram-sha-256") == 0) + ? authmethod + : host); exit(1); } } diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c index 19e21ab491..3eb335fb0b 100644 --- a/src/bin/pg_controldata/pg_controldata.c +++ b/src/bin/pg_controldata/pg_controldata.c @@ -30,11 +30,11 @@ #include "pg_getopt.h" static void -usage(const char *progname) +usage(const char *appname) { - printf(_("%s displays control information of a PostgreSQL database cluster.\n\n"), progname); + printf(_("%s displays control information of a PostgreSQL database cluster.\n\n"), appname); printf(_("Usage:\n")); - printf(_(" %s [OPTION] [DATADIR]\n"), progname); + printf(_(" %s [OPTION] [DATADIR]\n"), appname); printf(_("\nOptions:\n")); printf(_(" [-D, --pgdata=]DATADIR data directory\n")); printf(_(" -V, --version output version information, then exit\n")); @@ -69,9 +69,9 @@ dbState(DBState state) } static const char * -wal_level_str(WalLevel wal_level) +wal_level_str(WalLevel level) { - switch (wal_level) + switch (level) { case WAL_LEVEL_MINIMAL: return "minimal"; diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 65f9fb4c0a..80715bae01 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -742,7 +742,7 @@ read_post_opts(void) * waiting for the server to start up, the server launch is aborted. */ static void -trap_sigint_during_startup(int sig) +trap_sigint_during_startup(int signal) { if (postmasterPID != -1) { @@ -760,18 +760,18 @@ trap_sigint_during_startup(int sig) } static char * -find_other_exec_or_die(const char *argv0, const char *target, const char *versionstr) +find_other_exec_or_die(const char *argv_0, const char *target, const char *versionstr) { int ret; char *found_path; found_path = pg_malloc(MAXPGPATH); - if ((ret = find_other_exec(argv0, target, versionstr, found_path)) < 0) + if ((ret = find_other_exec(argv_0, target, versionstr, found_path)) < 0) { char full_path[MAXPGPATH]; - if (find_my_exec(argv0, full_path) < 0) + if (find_my_exec(argv_0, full_path) < 0) strlcpy(full_path, progname, sizeof(full_path)); if (ret == -1) diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 37432a6f4b..ef5cd5c60c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -64,10 +64,10 @@ static int numExtensions; static ExtensionMemberId *extmembers; static int numextmembers; -static void flagInhTables(Archive *fout, TableInfo *tbinfo, int numTables, +static void flagInhTables(Archive *fout, TableInfo *tbinfo, int nTables, InhInfo *inhinfo, int numInherits); -static void flagInhIndexes(Archive *fout, TableInfo *tblinfo, int numTables); -static void flagInhAttrs(DumpOptions *dopt, TableInfo *tblinfo, int numTables); +static void flagInhIndexes(Archive *fout, TableInfo *tblinfo, int nTables); +static void flagInhAttrs(DumpOptions *dopt, TableInfo *tblinfo, int nTables); static DumpableObject **buildIndexArray(void *objArray, int numObjs, Size objSize); static int DOCatalogIdCompare(const void *p1, const void *p2); @@ -270,14 +270,14 @@ getSchemaData(Archive *fout, int *numTablesPtr) * modifies tblinfo */ static void -flagInhTables(Archive *fout, TableInfo *tblinfo, int numTables, +flagInhTables(Archive *fout, TableInfo *tblinfo, int nTables, InhInfo *inhinfo, int numInherits) { DumpOptions *dopt = fout->dopt; int i, j; - for (i = 0; i < numTables; i++) + for (i = 0; i < nTables; i++) { bool find_parents = true; bool mark_parents = true; @@ -329,7 +329,7 @@ flagInhTables(Archive *fout, TableInfo *tblinfo, int numTables, * appropriate dependency links. */ static void -flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) +flagInhIndexes(Archive *fout, TableInfo tblinfo[], int nTables) { int i, j, @@ -339,7 +339,7 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) parentIndexArray = (DumpableObject ***) pg_malloc0(getMaxDumpId() * sizeof(DumpableObject **)); - for (i = 0; i < numTables; i++) + for (i = 0; i < nTables; i++) { TableInfo *parenttbl; IndexAttachInfo *attachinfo; @@ -436,13 +436,13 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) * modifies tblinfo */ static void -flagInhAttrs(DumpOptions *dopt, TableInfo *tblinfo, int numTables) +flagInhAttrs(DumpOptions *dopt, TableInfo *tblinfo, int nTables) { int i, j, k; - for (i = 0; i < numTables; i++) + for (i = 0; i < nTables; i++) { TableInfo *tbinfo = &(tblinfo[i]); int numParents; diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 08658c8e86..d5498272b8 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -147,7 +147,7 @@ static int extra_float_digits; fmtQualifiedId((obj)->dobj.namespace->dobj.name, \ (obj)->dobj.name) -static void help(const char *progname); +static void help(const char *appname); static void setup_connection(Archive *AH, const char *dumpencoding, const char *dumpsnapshot, char *use_role); @@ -155,11 +155,11 @@ static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode); static void expand_schema_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids, - bool strict_names); + bool is_strict_names); static void expand_table_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids, - bool strict_names); + bool is_strict_names); static NamespaceInfo *findNamespace(Archive *fout, Oid nsoid); static void dumpTableData(Archive *fout, TableDataInfo *tdinfo); static void refreshMatViewData(Archive *fout, TableDataInfo *tdinfo); @@ -972,11 +972,11 @@ main(int argc, char **argv) static void -help(const char *progname) +help(const char *appname) { - printf(_("%s dumps a database as a text file or to other formats.\n\n"), progname); + printf(_("%s dumps a database as a text file or to other formats.\n\n"), appname); printf(_("Usage:\n")); - printf(_(" %s [OPTION]... [DBNAME]\n"), progname); + printf(_(" %s [OPTION]... [DBNAME]\n"), appname); printf(_("\nGeneral options:\n")); printf(_(" -f, --file=FILENAME output file or directory name\n")); @@ -1293,7 +1293,7 @@ static void expand_schema_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids, - bool strict_names) + bool is_strict_names) { PQExpBuffer query; PGresult *res; @@ -1318,7 +1318,7 @@ expand_schema_name_patterns(Archive *fout, false, NULL, "n.nspname", NULL, NULL); res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); - if (strict_names && PQntuples(res) == 0) + if (is_strict_names && PQntuples(res) == 0) fatal("no matching schemas were found for pattern \"%s\"", cell->val); for (i = 0; i < PQntuples(res); i++) @@ -1341,7 +1341,7 @@ expand_schema_name_patterns(Archive *fout, static void expand_table_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids, - bool strict_names) + bool is_strict_names) { PQExpBuffer query; PGresult *res; @@ -1383,7 +1383,7 @@ expand_table_name_patterns(Archive *fout, res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); PQclear(ExecuteSqlQueryForSingleRow(fout, ALWAYS_SECURE_SEARCH_PATH_SQL)); - if (strict_names && PQntuples(res) == 0) + if (is_strict_names && PQntuples(res) == 0) fatal("no matching tables were found for pattern \"%s\"", cell->val); for (i = 0; i < PQntuples(res); i++) diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c index d1a36b1495..716368e24c 100644 --- a/src/bin/pg_dump/pg_restore.c +++ b/src/bin/pg_dump/pg_restore.c @@ -50,7 +50,7 @@ #include "parallel.h" #include "pg_backup_utils.h" -static void usage(const char *progname); +static void usage(const char *appname); int main(int argc, char **argv) @@ -456,11 +456,11 @@ main(int argc, char **argv) } static void -usage(const char *progname) +usage(const char *appname) { - printf(_("%s restores a PostgreSQL database from an archive created by pg_dump.\n\n"), progname); + printf(_("%s restores a PostgreSQL database from an archive created by pg_dump.\n\n"), appname); printf(_("Usage:\n")); - printf(_(" %s [OPTION]... [FILE]\n"), progname); + printf(_(" %s [OPTION]... [FILE]\n"), appname); printf(_("\nGeneral options:\n")); printf(_(" -d, --dbname=NAME connect to database name\n")); diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c index 2e286f6339..7fb590ffb8 100644 --- a/src/bin/pg_resetwal/pg_resetwal.c +++ b/src/bin/pg_resetwal/pg_resetwal.c @@ -738,9 +738,9 @@ GuessControlValues(void) * reset by RewriteControlFile(). */ static void -PrintControlValues(bool guessed) +PrintControlValues(bool guessed_control) { - if (guessed) + if (guessed_control) printf(_("Guessed pg_control values:\n\n")); else printf(_("Current pg_control values:\n\n")); diff --git a/src/bin/pg_test_fsync/pg_test_fsync.c b/src/bin/pg_test_fsync/pg_test_fsync.c index 2ca1608bd2..9ef52bff32 100644 --- a/src/bin/pg_test_fsync/pg_test_fsync.c +++ b/src/bin/pg_test_fsync/pg_test_fsync.c @@ -91,7 +91,7 @@ static void signal_cleanup(int sig); #ifdef HAVE_FSYNC_WRITETHROUGH static int pg_fsync_writethrough(int fd); #endif -static void print_elapse(struct timeval start_t, struct timeval stop_t, int ops); +static void print_elapse(struct timeval start, struct timeval stop, int ops); #define die(msg) do { pg_log_error("%s: %m", _(msg)); exit(1); } while(0) @@ -576,10 +576,10 @@ pg_fsync_writethrough(int fd) * print out the writes per second for tests */ static void -print_elapse(struct timeval start_t, struct timeval stop_t, int ops) +print_elapse(struct timeval start, struct timeval stop, int ops) { - double total_time = (stop_t.tv_sec - start_t.tv_sec) + - (stop_t.tv_usec - start_t.tv_usec) * 0.000001; + double total_time = (stop.tv_sec - start.tv_sec) + + (stop.tv_usec - start.tv_usec) * 0.000001; double per_second = ops / total_time; double avg_op_time_us = (total_time / ops) * USECS_SEC; diff --git a/src/include/access/xlogreader.h b/src/include/access/xlogreader.h index 0193611b7f..f4f5117b8b 100644 --- a/src/include/access/xlogreader.h +++ b/src/include/access/xlogreader.h @@ -209,7 +209,7 @@ struct XLogReaderState }; /* Get a new XLogReader */ -extern XLogReaderState *XLogReaderAllocate(int wal_segment_size, +extern XLogReaderState *XLogReaderAllocate(int segment_size, const char *waldir, XLogPageReadCB pagereadfunc, void *private_data); diff --git a/src/include/replication/worker_internal.h b/src/include/replication/worker_internal.h index 05f4936419..132b4199e8 100644 --- a/src/include/replication/worker_internal.h +++ b/src/include/replication/worker_internal.h @@ -60,7 +60,7 @@ typedef struct LogicalRepWorker extern MemoryContext ApplyContext; /* libpqreceiver connection */ -extern struct WalReceiverConn *wrconn; +extern struct WalReceiverConn *WalReceiverConnection; /* Worker and subscription objects. */ extern Subscription *MySubscription; diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index 50098e63fe..5ab7ed1a80 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -354,7 +354,7 @@ extern const char *GetConfigOptionResetString(const char *name); extern int GetConfigOptionFlags(const char *name, bool missing_ok); extern void ProcessConfigFile(GucContext context); extern void InitializeGUCOptions(void); -extern bool SelectConfigFiles(const char *userDoption, const char *progname); +extern bool SelectConfigFiles(const char *userDoption, const char *appname); extern void ResetAllOptions(void); extern void AtStart_GUC(void); extern int NewGUCNestLevel(void); diff --git a/src/interfaces/ecpg/preproc/descriptor.c b/src/interfaces/ecpg/preproc/descriptor.c index a29f530327..7568d1c1a9 100644 --- a/src/interfaces/ecpg/preproc/descriptor.c +++ b/src/interfaces/ecpg/preproc/descriptor.c @@ -73,7 +73,7 @@ ECPGnumeric_lvalue(char *name) static struct descriptor *descriptors; void -add_descriptor(char *name, char *connection) +add_descriptor(char *name, char *conn_str) { struct descriptor *new; @@ -87,16 +87,16 @@ add_descriptor(char *name, char *connection) strcpy(new->name, name); if (connection) { - new->connection = mm_alloc(strlen(connection) + 1); - strcpy(new->connection, connection); + new->connection = mm_alloc(strlen(conn_str) + 1); + strcpy(new->connection, conn_str); } else - new->connection = connection; + new->connection = conn_str; descriptors = new; } void -drop_descriptor(char *name, char *connection) +drop_descriptor(char *name, char *conn_str) { struct descriptor *i; struct descriptor **lastptr = &descriptors; @@ -108,9 +108,9 @@ drop_descriptor(char *name, char *connection) { if (strcmp(name, i->name) == 0) { - if ((!connection && !i->connection) - || (connection && i->connection - && strcmp(connection, i->connection) == 0)) + if ((!conn_str && !i->connection) + || (conn_str && i->connection + && strcmp(conn_str, i->connection) == 0)) { *lastptr = i->next; if (i->connection) @@ -126,7 +126,7 @@ drop_descriptor(char *name, char *connection) struct descriptor * -lookup_descriptor(char *name, char *connection) +lookup_descriptor(char *name, char *conn_str) { struct descriptor *i; @@ -137,9 +137,9 @@ lookup_descriptor(char *name, char *connection) { if (strcmp(name, i->name) == 0) { - if ((!connection && !i->connection) - || (connection && i->connection - && strcmp(connection, i->connection) == 0)) + if ((!conn_str && !i->connection) + || (conn_str && i->connection + && strcmp(conn_str, i->connection) == 0)) return i; } }