Convert some extern variables to static

These probably should have been static all along, it was only
forgotten out of sloppiness.

Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/flat/e0a62134-83da-4ba4-8cdb-ceb0111c95ce@eisentraut.org
This commit is contained in:
Peter Eisentraut 2024-07-02 06:53:19 +02:00
parent a4c87df43a
commit 720b0eaae9
29 changed files with 99 additions and 96 deletions

View File

@ -11,7 +11,7 @@
*/
/* where the digit set begins, and how many of them are in the table */
const unsigned EAN13_index[10][2] = {
static const unsigned EAN13_index[10][2] = {
{0, 6},
{6, 1},
{7, 1},
@ -23,7 +23,7 @@ const unsigned EAN13_index[10][2] = {
{90, 17},
{107, 12},
};
const char *EAN13_range[][2] = {
static const char *EAN13_range[][2] = {
{"000", "019"}, /* GS1 US */
{"020", "029"}, /* Restricted distribution (MO defined) */
{"030", "039"}, /* GS1 US */

View File

@ -34,7 +34,7 @@
*/
/* where the digit set begins, and how many of them are in the table */
const unsigned ISBN_index[10][2] = {
static const unsigned ISBN_index[10][2] = {
{0, 6},
{6, 6},
{12, 8},
@ -47,7 +47,7 @@ const unsigned ISBN_index[10][2] = {
{192, 718},
};
const char *ISBN_range[][2] = {
static const char *ISBN_range[][2] = {
{"0-00", "0-19"},
{"0-200", "0-699"},
{"0-7000", "0-8499"},
@ -967,7 +967,7 @@ const char *ISBN_range[][2] = {
*/
/* where the digit set begins, and how many of them are in the table */
const unsigned ISBN_index_new[10][2] = {
static const unsigned ISBN_index_new[10][2] = {
{0, 0},
{0, 5},
{5, 0},
@ -980,7 +980,7 @@ const unsigned ISBN_index_new[10][2] = {
{5, 0},
};
const char *ISBN_range_new[][2] = {
static const char *ISBN_range_new[][2] = {
{"10-00", "10-19"},
{"10-200", "10-699"},
{"10-7000", "10-8999"},

View File

@ -30,7 +30,7 @@
*/
/* where the digit set begins, and how many of them are in the table */
const unsigned ISMN_index[10][2] = {
static const unsigned ISMN_index[10][2] = {
{0, 5},
{5, 0},
{5, 0},
@ -42,7 +42,7 @@ const unsigned ISMN_index[10][2] = {
{5, 0},
{5, 0},
};
const char *ISMN_range[][2] = {
static const char *ISMN_range[][2] = {
{"0-000", "0-099"},
{"0-1000", "0-3999"},
{"0-40000", "0-69999"},

View File

@ -31,7 +31,7 @@
*/
/* where the digit set begins, and how many of them are in the table */
const unsigned ISSN_index[10][2] = {
static const unsigned ISSN_index[10][2] = {
{0, 1},
{0, 1},
{0, 1},
@ -43,7 +43,7 @@ const unsigned ISSN_index[10][2] = {
{0, 1},
{0, 1},
};
const char *ISSN_range[][2] = {
static const char *ISSN_range[][2] = {
{"0000-000", "9999-999"},
{NULL, NULL}
};

View File

@ -11,7 +11,7 @@
*/
/* where the digit set begins, and how many of them are in the table */
const unsigned UPC_index[10][2] = {
static const unsigned UPC_index[10][2] = {
{0, 0},
{0, 0},
{0, 0},
@ -23,6 +23,6 @@ const unsigned UPC_index[10][2] = {
{0, 0},
{0, 0},
};
const char *UPC_range[][2] = {
static const char *UPC_range[][2] = {
{NULL, NULL}
};

View File

@ -84,8 +84,8 @@ typedef struct
/* GUC parameters */
int Password_encryption = PASSWORD_TYPE_SCRAM_SHA_256;
char *createrole_self_grant = "";
bool createrole_self_grant_enabled = false;
GrantRoleOptions createrole_self_grant_options;
static bool createrole_self_grant_enabled = false;
static GrantRoleOptions createrole_self_grant_options;
/* Hook to check passwords in CreateRole() and AlterRole() */
check_password_hook_type check_password_hook = NULL;

View File

@ -176,7 +176,7 @@ typedef struct
bool shmem_attach;
} child_process_kind;
child_process_kind child_process_kinds[] = {
static child_process_kind child_process_kinds[] = {
[B_INVALID] = {"invalid", NULL, false},
[B_BACKEND] = {"backend", BackendMain, true},

View File

@ -103,7 +103,7 @@ typedef struct SlotSyncCtxStruct
slock_t mutex;
} SlotSyncCtxStruct;
SlotSyncCtxStruct *SlotSyncCtx = NULL;
static SlotSyncCtxStruct *SlotSyncCtx = NULL;
/* GUC variable */
bool sync_replication_slots = false;

View File

@ -275,7 +275,7 @@ typedef enum
} TransApplyAction;
/* errcontext tracker */
ApplyErrorCallbackArg apply_error_callback_arg =
static ApplyErrorCallbackArg apply_error_callback_arg =
{
.command = 0,
.rel = NULL,

View File

@ -517,7 +517,8 @@ bool check_function_bodies = true;
* This GUC exists solely for backward compatibility, check its definition for
* details.
*/
bool default_with_oids = false;
static bool default_with_oids = false;
bool current_role_is_superuser;
int log_min_error_statement = ERROR;
@ -555,7 +556,7 @@ int tcp_user_timeout;
* This avoids breaking compatibility with clients that have never supported
* renegotiation and therefore always try to zero it.
*/
int ssl_renegotiation_limit;
static int ssl_renegotiation_limit;
/*
* This really belongs in pg_shmem.c, but is defined here so that it doesn't
@ -563,7 +564,7 @@ int ssl_renegotiation_limit;
*/
int huge_pages = HUGE_PAGES_TRY;
int huge_page_size;
int huge_pages_status = HUGE_PAGES_UNKNOWN;
static int huge_pages_status = HUGE_PAGES_UNKNOWN;
/*
* These variables are all dummies that don't do anything, except in some

View File

@ -19,17 +19,18 @@
#include "common/logging.h"
#include "getopt_long.h"
const char *progname;
static const char *progname;
/* Options and defaults */
bool dryrun = false; /* are we performing a dry-run operation? */
bool cleanBackupHistory = false; /* remove files including backup
static bool dryrun = false; /* are we performing a dry-run operation? */
static bool cleanBackupHistory = false; /* remove files including backup
* history files */
char *additional_ext = NULL; /* Extension to remove from filenames */
static char *additional_ext = NULL; /* Extension to remove from filenames */
char *archiveLocation; /* where to find the archive? */
char *restartWALFileName; /* the file from which we can restart restore */
char exclusiveCleanupFileName[MAXFNAMELEN]; /* the oldest file we want
static char *archiveLocation; /* where to find the archive? */
static char *restartWALFileName; /* the file from which we can restart
* restore */
static char exclusiveCleanupFileName[MAXFNAMELEN]; /* the oldest file we want
* to remain in archive */

View File

@ -43,7 +43,7 @@ static void bbstreamer_plain_writer_content(bbstreamer *streamer,
static void bbstreamer_plain_writer_finalize(bbstreamer *streamer);
static void bbstreamer_plain_writer_free(bbstreamer *streamer);
const bbstreamer_ops bbstreamer_plain_writer_ops = {
static const bbstreamer_ops bbstreamer_plain_writer_ops = {
.content = bbstreamer_plain_writer_content,
.finalize = bbstreamer_plain_writer_finalize,
.free = bbstreamer_plain_writer_free
@ -59,7 +59,7 @@ static void extract_directory(const char *filename, mode_t mode);
static void extract_link(const char *filename, const char *linktarget);
static FILE *create_file_for_extract(const char *filename, mode_t mode);
const bbstreamer_ops bbstreamer_extractor_ops = {
static const bbstreamer_ops bbstreamer_extractor_ops = {
.content = bbstreamer_extractor_content,
.finalize = bbstreamer_extractor_finalize,
.free = bbstreamer_extractor_free

View File

@ -45,7 +45,7 @@ static void bbstreamer_gzip_writer_finalize(bbstreamer *streamer);
static void bbstreamer_gzip_writer_free(bbstreamer *streamer);
static const char *get_gz_error(gzFile gzf);
const bbstreamer_ops bbstreamer_gzip_writer_ops = {
static const bbstreamer_ops bbstreamer_gzip_writer_ops = {
.content = bbstreamer_gzip_writer_content,
.finalize = bbstreamer_gzip_writer_finalize,
.free = bbstreamer_gzip_writer_free
@ -60,7 +60,7 @@ static void bbstreamer_gzip_decompressor_free(bbstreamer *streamer);
static void *gzip_palloc(void *opaque, unsigned items, unsigned size);
static void gzip_pfree(void *opaque, void *address);
const bbstreamer_ops bbstreamer_gzip_decompressor_ops = {
static const bbstreamer_ops bbstreamer_gzip_decompressor_ops = {
.content = bbstreamer_gzip_decompressor_content,
.finalize = bbstreamer_gzip_decompressor_finalize,
.free = bbstreamer_gzip_decompressor_free

View File

@ -33,7 +33,7 @@ static void bbstreamer_recovery_injector_content(bbstreamer *streamer,
static void bbstreamer_recovery_injector_finalize(bbstreamer *streamer);
static void bbstreamer_recovery_injector_free(bbstreamer *streamer);
const bbstreamer_ops bbstreamer_recovery_injector_ops = {
static const bbstreamer_ops bbstreamer_recovery_injector_ops = {
.content = bbstreamer_recovery_injector_content,
.finalize = bbstreamer_recovery_injector_finalize,
.free = bbstreamer_recovery_injector_free

View File

@ -42,7 +42,7 @@ static void bbstreamer_lz4_compressor_content(bbstreamer *streamer,
static void bbstreamer_lz4_compressor_finalize(bbstreamer *streamer);
static void bbstreamer_lz4_compressor_free(bbstreamer *streamer);
const bbstreamer_ops bbstreamer_lz4_compressor_ops = {
static const bbstreamer_ops bbstreamer_lz4_compressor_ops = {
.content = bbstreamer_lz4_compressor_content,
.finalize = bbstreamer_lz4_compressor_finalize,
.free = bbstreamer_lz4_compressor_free
@ -55,7 +55,7 @@ static void bbstreamer_lz4_decompressor_content(bbstreamer *streamer,
static void bbstreamer_lz4_decompressor_finalize(bbstreamer *streamer);
static void bbstreamer_lz4_decompressor_free(bbstreamer *streamer);
const bbstreamer_ops bbstreamer_lz4_decompressor_ops = {
static const bbstreamer_ops bbstreamer_lz4_decompressor_ops = {
.content = bbstreamer_lz4_decompressor_content,
.finalize = bbstreamer_lz4_decompressor_finalize,
.free = bbstreamer_lz4_decompressor_free

View File

@ -50,7 +50,7 @@ static void bbstreamer_tar_parser_finalize(bbstreamer *streamer);
static void bbstreamer_tar_parser_free(bbstreamer *streamer);
static bool bbstreamer_tar_header(bbstreamer_tar_parser *mystreamer);
const bbstreamer_ops bbstreamer_tar_parser_ops = {
static const bbstreamer_ops bbstreamer_tar_parser_ops = {
.content = bbstreamer_tar_parser_content,
.finalize = bbstreamer_tar_parser_finalize,
.free = bbstreamer_tar_parser_free
@ -63,7 +63,7 @@ static void bbstreamer_tar_archiver_content(bbstreamer *streamer,
static void bbstreamer_tar_archiver_finalize(bbstreamer *streamer);
static void bbstreamer_tar_archiver_free(bbstreamer *streamer);
const bbstreamer_ops bbstreamer_tar_archiver_ops = {
static const bbstreamer_ops bbstreamer_tar_archiver_ops = {
.content = bbstreamer_tar_archiver_content,
.finalize = bbstreamer_tar_archiver_finalize,
.free = bbstreamer_tar_archiver_free
@ -76,7 +76,7 @@ static void bbstreamer_tar_terminator_content(bbstreamer *streamer,
static void bbstreamer_tar_terminator_finalize(bbstreamer *streamer);
static void bbstreamer_tar_terminator_free(bbstreamer *streamer);
const bbstreamer_ops bbstreamer_tar_terminator_ops = {
static const bbstreamer_ops bbstreamer_tar_terminator_ops = {
.content = bbstreamer_tar_terminator_content,
.finalize = bbstreamer_tar_terminator_finalize,
.free = bbstreamer_tar_terminator_free

View File

@ -38,7 +38,7 @@ static void bbstreamer_zstd_compressor_content(bbstreamer *streamer,
static void bbstreamer_zstd_compressor_finalize(bbstreamer *streamer);
static void bbstreamer_zstd_compressor_free(bbstreamer *streamer);
const bbstreamer_ops bbstreamer_zstd_compressor_ops = {
static const bbstreamer_ops bbstreamer_zstd_compressor_ops = {
.content = bbstreamer_zstd_compressor_content,
.finalize = bbstreamer_zstd_compressor_finalize,
.free = bbstreamer_zstd_compressor_free
@ -51,7 +51,7 @@ static void bbstreamer_zstd_decompressor_content(bbstreamer *streamer,
static void bbstreamer_zstd_decompressor_finalize(bbstreamer *streamer);
static void bbstreamer_zstd_decompressor_free(bbstreamer *streamer);
const bbstreamer_ops bbstreamer_zstd_decompressor_ops = {
static const bbstreamer_ops bbstreamer_zstd_decompressor_ops = {
.content = bbstreamer_zstd_decompressor_content,
.finalize = bbstreamer_zstd_decompressor_finalize,
.free = bbstreamer_zstd_decompressor_free

View File

@ -55,7 +55,7 @@ static int dir_sync(Walfile *f);
static bool dir_finish(WalWriteMethod *wwmethod);
static void dir_free(WalWriteMethod *wwmethod);
const WalWriteMethodOps WalDirectoryMethodOps = {
static const WalWriteMethodOps WalDirectoryMethodOps = {
.open_for_write = dir_open_for_write,
.close = dir_close,
.existsfile = dir_existsfile,
@ -676,7 +676,7 @@ static int tar_sync(Walfile *f);
static bool tar_finish(WalWriteMethod *wwmethod);
static void tar_free(WalWriteMethod *wwmethod);
const WalWriteMethodOps WalTarMethodOps = {
static const WalWriteMethodOps WalTarMethodOps = {
.open_for_write = tar_open_for_write,
.close = tar_close,
.existsfile = tar_existsfile,

View File

@ -60,8 +60,8 @@ static const char *progname;
/*
* Progress status information.
*/
int64 total_size = 0;
int64 current_size = 0;
static int64 total_size = 0;
static int64 current_size = 0;
static pg_time_t last_progress_report = 0;
static void

View File

@ -97,7 +97,7 @@ typedef struct cb_tablespace
} cb_tablespace;
/* Directories to be removed if we exit uncleanly. */
cb_cleanup_dir *cleanup_dir_list = NULL;
static cb_cleanup_dir *cleanup_dir_list = NULL;
static void add_tablespace_mapping(cb_options *opt, char *arg);
static StringInfo check_backup_label_files(int n_backups, char **backup_dirs);

View File

@ -60,21 +60,21 @@ static ControlFileData ControlFile_target;
static ControlFileData ControlFile_source;
static ControlFileData ControlFile_source_after;
const char *progname;
static const char *progname;
int WalSegSz;
/* Configuration options */
char *datadir_target = NULL;
char *datadir_source = NULL;
char *connstr_source = NULL;
char *restore_command = NULL;
char *config_file = NULL;
static char *datadir_source = NULL;
static char *connstr_source = NULL;
static char *restore_command = NULL;
static char *config_file = NULL;
static bool debug = false;
bool showprogress = false;
bool dry_run = false;
bool do_sync = true;
bool restore_wal = false;
static bool restore_wal = false;
DataDirSyncMethod sync_method = DATA_DIR_SYNC_METHOD_FSYNC;
/* Target history */

View File

@ -20,7 +20,7 @@ static uint64 test_timing(unsigned int duration);
static void output(uint64 loop_count);
/* record duration in powers of 2 microseconds */
long long int histogram[32];
static long long int histogram[32];
int
main(int argc, char *argv[])

View File

@ -170,37 +170,37 @@ typedef struct socket_set
#define MIN_ZIPFIAN_PARAM 1.001 /* minimum parameter for zipfian */
#define MAX_ZIPFIAN_PARAM 1000.0 /* maximum parameter for zipfian */
int nxacts = 0; /* number of transactions per client */
int duration = 0; /* duration in seconds */
int64 end_time = 0; /* when to stop in micro seconds, under -T */
static int nxacts = 0; /* number of transactions per client */
static int duration = 0; /* duration in seconds */
static int64 end_time = 0; /* when to stop in micro seconds, under -T */
/*
* scaling factor. for example, scale = 10 will make 1000000 tuples in
* pgbench_accounts table.
*/
int scale = 1;
static int scale = 1;
/*
* fillfactor. for example, fillfactor = 90 will use only 90 percent
* space during inserts and leave 10 percent free.
*/
int fillfactor = 100;
static int fillfactor = 100;
/*
* use unlogged tables?
*/
bool unlogged_tables = false;
static bool unlogged_tables = false;
/*
* log sampling rate (1.0 = log everything, 0.0 = option not given)
*/
double sample_rate = 0.0;
static double sample_rate = 0.0;
/*
* When threads are throttled to a given rate limit, this is the target delay
* to reach that rate in usec. 0 is the default and means no throttling.
*/
double throttle_delay = 0;
static double throttle_delay = 0;
/*
* Transactions which take longer than this limit (in usec) are counted as
@ -208,13 +208,13 @@ double throttle_delay = 0;
* throttling is enabled, execution time slots that are more than this late
* are skipped altogether, and counted separately.
*/
int64 latency_limit = 0;
static int64 latency_limit = 0;
/*
* tablespace selection
*/
char *tablespace = NULL;
char *index_tablespace = NULL;
static char *tablespace = NULL;
static char *index_tablespace = NULL;
/*
* Number of "pgbench_accounts" partitions. 0 is the default and means no
@ -234,7 +234,7 @@ static partition_method_t partition_method = PART_NONE;
static const char *const PARTITION_METHOD[] = {"none", "range", "hash"};
/* random seed used to initialize base_random_sequence */
int64 random_seed = -1;
static int64 random_seed = -1;
/*
* end of configurable parameters
@ -254,20 +254,20 @@ int64 random_seed = -1;
*/
#define SCALE_32BIT_THRESHOLD 20000
bool use_log; /* log transaction latencies to a file */
bool use_quiet; /* quiet logging onto stderr */
int agg_interval; /* log aggregates instead of individual
static bool use_log; /* log transaction latencies to a file */
static bool use_quiet; /* quiet logging onto stderr */
static int agg_interval; /* log aggregates instead of individual
* transactions */
bool per_script_stats = false; /* whether to collect stats per script */
int progress = 0; /* thread progress report every this seconds */
bool progress_timestamp = false; /* progress report with Unix time */
int nclients = 1; /* number of clients */
int nthreads = 1; /* number of threads */
bool is_connect; /* establish connection for each transaction */
bool report_per_command = false; /* report per-command latencies,
static bool per_script_stats = false; /* whether to collect stats per script */
static int progress = 0; /* thread progress report every this seconds */
static bool progress_timestamp = false; /* progress report with Unix time */
static int nclients = 1; /* number of clients */
static int nthreads = 1; /* number of threads */
static bool is_connect; /* establish connection for each transaction */
static bool report_per_command = false; /* report per-command latencies,
* retries after errors and failures
* (errors without retrying) */
int main_pid; /* main process id used in log filename */
static int main_pid; /* main process id used in log filename */
/*
* There are different types of restrictions for deciding that the current
@ -287,21 +287,22 @@ int main_pid; /* main process id used in log filename */
* We cannot retry a transaction after the serialization/deadlock error if its
* number of tries reaches this maximum; if its value is zero, it is not used.
*/
uint32 max_tries = 1;
static uint32 max_tries = 1;
bool failures_detailed = false; /* whether to group failures in
static bool failures_detailed = false; /* whether to group failures in
* reports or logs by basic types */
const char *pghost = NULL;
const char *pgport = NULL;
const char *username = NULL;
const char *dbName = NULL;
char *logfile_prefix = NULL;
const char *progname;
static const char *pghost = NULL;
static const char *pgport = NULL;
static const char *username = NULL;
static const char *dbName = NULL;
static char *logfile_prefix = NULL;
static const char *progname;
#define WSEP '@' /* weight separator */
volatile sig_atomic_t timer_exceeded = false; /* flag from signal handler */
volatile static sig_atomic_t timer_exceeded = false; /* flag from signal
* handler */
/*
* We don't want to allocate variables one by one; for efficiency, add a
@ -446,7 +447,7 @@ typedef struct StatsData
* For displaying Unix epoch timestamps, as some time functions may have
* another reference.
*/
pg_time_usec_t epoch_shift;
static pg_time_usec_t epoch_shift;
/*
* Error status for errors during script execution.

View File

@ -60,7 +60,7 @@ typedef enum
OBJFILTER_SCHEMA_EXCLUDE = (1 << 4), /* -N | --exclude-schema */
} VacObjFilter;
VacObjFilter objfilter = OBJFILTER_NONE;
static VacObjFilter objfilter = OBJFILTER_NONE;
static void vacuum_one_database(ConnParams *cparams,
vacuumingOptions *vacopts,

View File

@ -47,8 +47,8 @@ bool plpgsql_print_strict_params = false;
bool plpgsql_check_asserts = true;
char *plpgsql_extra_warnings_string = NULL;
char *plpgsql_extra_errors_string = NULL;
static char *plpgsql_extra_warnings_string = NULL;
static char *plpgsql_extra_errors_string = NULL;
int plpgsql_extra_warnings;
int plpgsql_extra_errors;

View File

@ -15,9 +15,9 @@
#include "lib/stringinfo.h"
#include "pg_regress.h"
char saved_argv0[MAXPGPATH];
char isolation_exec[MAXPGPATH];
bool looked_up_isolation_exec = false;
static char saved_argv0[MAXPGPATH];
static char isolation_exec[MAXPGPATH];
static bool looked_up_isolation_exec = false;
#define PG_ISOLATION_VERSIONSTR "isolationtester (PostgreSQL) " PG_VERSION "\n"

View File

@ -24,10 +24,10 @@
PG_MODULE_MAGIC;
/* parse table for fillRelOptions */
relopt_parse_elt di_relopt_tab[6];
static relopt_parse_elt di_relopt_tab[6];
/* Kind of relation options for dummy index */
relopt_kind di_relopt_kind;
static relopt_kind di_relopt_kind;
typedef enum DummyAmEnum
{
@ -47,7 +47,7 @@ typedef struct DummyIndexOptions
int option_string_null_offset;
} DummyIndexOptions;
relopt_enum_elt_def dummyAmEnumValues[] =
static relopt_enum_elt_def dummyAmEnumValues[] =
{
{"one", DUMMY_AM_ENUM_ONE},
{"two", DUMMY_AM_ENUM_TWO},

View File

@ -31,10 +31,10 @@ static void pg_attribute_noreturn() pg_fatal_impl(int line, const char *fmt,...)
static bool process_result(PGconn *conn, PGresult *res, int results,
int numsent);
const char *const progname = "libpq_pipeline";
static const char *const progname = "libpq_pipeline";
/* Options and defaults */
char *tracefile = NULL; /* path to PQtrace() file */
static char *tracefile = NULL; /* path to PQtrace() file */
#ifdef DEBUG_OUTPUT

View File

@ -60,7 +60,7 @@ static JsonParseErrorType do_array_element_start(void *state, bool isnull);
static JsonParseErrorType do_array_element_end(void *state, bool isnull);
static JsonParseErrorType do_scalar(void *state, char *token, JsonTokenType tokentype);
JsonSemAction sem = {
static JsonSemAction sem = {
.object_start = do_object_start,
.object_end = do_object_end,
.object_field_start = do_object_field_start,