Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 23e7b38

Browse files
committed
Pre-beta mechanical code beautification.
Run pgindent, pgperltidy, and reformat-dat-files. I manually fixed a couple of comments that pgindent uglified.
1 parent 9390959 commit 23e7b38

File tree

287 files changed

+5195
-3551
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

287 files changed

+5195
-3551
lines changed

config/check_modules.pl

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
diag("Time::HiRes::VERSION: $Time::HiRes::VERSION");
2222

2323
# Check that if prove is using msys perl it is for an msys target
24-
ok(($ENV{__CONFIG_HOST_OS__} || "") eq 'msys',
25-
"Msys perl used for correct target")
26-
if $Config{osname} eq 'msys';
24+
ok( ($ENV{__CONFIG_HOST_OS__} || "") eq 'msys',
25+
"Msys perl used for correct target") if $Config{osname} eq 'msys';
2726
ok(1);
2827
done_testing();

contrib/amcheck/verify_heapam.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1402,17 +1402,17 @@ check_tuple_attribute(HeapCheckContext *ctx)
14021402
cmid = TOAST_COMPRESS_METHOD(&toast_pointer);
14031403
switch (cmid)
14041404
{
1405-
/* List of all valid compression method IDs */
1405+
/* List of all valid compression method IDs */
14061406
case TOAST_PGLZ_COMPRESSION_ID:
14071407
case TOAST_LZ4_COMPRESSION_ID:
14081408
valid = true;
14091409
break;
14101410

1411-
/* Recognized but invalid compression method ID */
1411+
/* Recognized but invalid compression method ID */
14121412
case TOAST_INVALID_COMPRESSION_ID:
14131413
break;
14141414

1415-
/* Intentionally no default here */
1415+
/* Intentionally no default here */
14161416
}
14171417
if (!valid)
14181418
report_corruption(ctx,

contrib/basebackup_to_shell/basebackup_to_shell.c

+13-14
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ typedef struct bbsink_shell
3737
FILE *pipe;
3838
} bbsink_shell;
3939

40-
void _PG_init(void);
40+
void _PG_init(void);
4141

4242
static void *shell_check_detail(char *target, char *target_detail);
4343
static bbsink *shell_get_sink(bbsink *next_sink, void *detail_arg);
4444

4545
static void bbsink_shell_begin_archive(bbsink *sink,
46-
const char *archive_name);
46+
const char *archive_name);
4747
static void bbsink_shell_archive_contents(bbsink *sink, size_t len);
4848
static void bbsink_shell_end_archive(bbsink *sink);
4949
static void bbsink_shell_begin_manifest(bbsink *sink);
@@ -101,7 +101,7 @@ shell_check_detail(char *target, char *target_detail)
101101
{
102102
if (shell_required_role[0] != '\0')
103103
{
104-
Oid roleid;
104+
Oid roleid;
105105

106106
StartTransactionCommand();
107107
roleid = get_role_oid(shell_required_role, true);
@@ -125,8 +125,8 @@ static bbsink *
125125
shell_get_sink(bbsink *next_sink, void *detail_arg)
126126
{
127127
bbsink_shell *sink;
128-
bool has_detail_escape = false;
129-
char *c;
128+
bool has_detail_escape = false;
129+
char *c;
130130

131131
/*
132132
* Set up the bbsink.
@@ -171,15 +171,15 @@ shell_get_sink(bbsink *next_sink, void *detail_arg)
171171
/*
172172
* Since we're passing the string provided by the user to popen(), it will
173173
* be interpreted by the shell, which is a potential security
174-
* vulnerability, since the user invoking this module is not necessarily
175-
* a superuser. To stay out of trouble, we must disallow any shell
174+
* vulnerability, since the user invoking this module is not necessarily a
175+
* superuser. To stay out of trouble, we must disallow any shell
176176
* metacharacters here; to be conservative and keep things simple, we
177177
* allow only alphanumerics.
178178
*/
179179
if (sink->target_detail != NULL)
180180
{
181-
char *d;
182-
bool scary = false;
181+
char *d;
182+
bool scary = false;
183183

184184
for (d = sink->target_detail; *d != '\0'; ++d)
185185
{
@@ -210,7 +210,7 @@ static char *
210210
shell_construct_command(char *base_command, const char *filename,
211211
char *target_detail)
212212
{
213-
StringInfoData buf;
213+
StringInfoData buf;
214214
char *c;
215215

216216
initStringInfo(&buf);
@@ -271,7 +271,7 @@ shell_construct_command(char *base_command, const char *filename,
271271
static void
272272
shell_finish_command(bbsink_shell *sink)
273273
{
274-
int pclose_rc;
274+
int pclose_rc;
275275

276276
/* There should be a command running. */
277277
Assert(sink->current_command != NULL);
@@ -335,9 +335,8 @@ shell_send_data(bbsink_shell *sink, size_t len)
335335
{
336336
/*
337337
* The error we're about to throw would shut down the command
338-
* anyway, but we may get a more meaningful error message by
339-
* doing this. If not, we'll fall through to the generic error
340-
* below.
338+
* anyway, but we may get a more meaningful error message by doing
339+
* this. If not, we'll fall through to the generic error below.
341340
*/
342341
shell_finish_command(sink);
343342
errno = EPIPE;

contrib/basebackup_to_shell/t/001_basic.pl

+38-33
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020

2121
# Make sure pg_hba.conf is set up to allow connections from backupuser.
2222
# This is only needed on Windows machines that don't use UNIX sockets.
23-
$node->init('allows_streaming' => 1,
24-
'auth_extra' => [ '--create-role', 'backupuser' ]);
23+
$node->init(
24+
'allows_streaming' => 1,
25+
'auth_extra' => [ '--create-role', 'backupuser' ]);
2526

2627
$node->append_conf('postgresql.conf',
27-
"shared_preload_libraries = 'basebackup_to_shell'");
28+
"shared_preload_libraries = 'basebackup_to_shell'");
2829
$node->start;
2930
$node->safe_psql('postgres', 'CREATE USER backupuser REPLICATION');
3031
$node->safe_psql('postgres', 'CREATE ROLE trustworthy');
@@ -41,61 +42,61 @@
4142

4243
# Can't use this module without setting basebackup_to_shell.command.
4344
$node->command_fails_like(
44-
[ @pg_basebackup_cmd, '--target', 'shell' ],
45+
[ @pg_basebackup_cmd, '--target', 'shell' ],
4546
qr/shell command for backup is not configured/,
4647
'fails if basebackup_to_shell.command is not set');
4748

4849
# Configure basebackup_to_shell.command and reload the configuation file.
49-
my $backup_path = PostgreSQL::Test::Utils::tempdir;
50+
my $backup_path = PostgreSQL::Test::Utils::tempdir;
5051
my $escaped_backup_path = $backup_path;
51-
$escaped_backup_path =~ s{\\}{\\\\}g if ($PostgreSQL::Test::Utils::windows_os);
52+
$escaped_backup_path =~ s{\\}{\\\\}g
53+
if ($PostgreSQL::Test::Utils::windows_os);
5254
my $shell_command =
53-
$PostgreSQL::Test::Utils::windows_os
54-
? qq{$gzip --fast > "$escaped_backup_path\\\\%f.gz"}
55-
: qq{$gzip --fast > "$escaped_backup_path/%f.gz"};
55+
$PostgreSQL::Test::Utils::windows_os
56+
? qq{$gzip --fast > "$escaped_backup_path\\\\%f.gz"}
57+
: qq{$gzip --fast > "$escaped_backup_path/%f.gz"};
5658
$node->append_conf('postgresql.conf',
57-
"basebackup_to_shell.command='$shell_command'");
59+
"basebackup_to_shell.command='$shell_command'");
5860
$node->reload();
5961

6062
# Should work now.
6163
$node->command_ok(
62-
[ @pg_basebackup_cmd, '--target', 'shell' ],
64+
[ @pg_basebackup_cmd, '--target', 'shell' ],
6365
'backup with no detail: pg_basebackup');
6466
verify_backup('', $backup_path, "backup with no detail");
6567

6668
# Should fail with a detail.
6769
$node->command_fails_like(
68-
[ @pg_basebackup_cmd, '--target', 'shell:foo' ],
70+
[ @pg_basebackup_cmd, '--target', 'shell:foo' ],
6971
qr/a target detail is not permitted because the configured command does not include %d/,
7072
'fails if detail provided without %d');
7173

7274
# Reconfigure to restrict access and require a detail.
7375
$shell_command =
74-
$PostgreSQL::Test::Utils::windows_os
75-
? qq{$gzip --fast > "$escaped_backup_path\\\\%d.%f.gz"}
76-
: qq{$gzip --fast > "$escaped_backup_path/%d.%f.gz"};
76+
$PostgreSQL::Test::Utils::windows_os
77+
? qq{$gzip --fast > "$escaped_backup_path\\\\%d.%f.gz"}
78+
: qq{$gzip --fast > "$escaped_backup_path/%d.%f.gz"};
7779
$node->append_conf('postgresql.conf',
78-
"basebackup_to_shell.command='$shell_command'");
80+
"basebackup_to_shell.command='$shell_command'");
7981
$node->append_conf('postgresql.conf',
80-
"basebackup_to_shell.required_role='trustworthy'");
82+
"basebackup_to_shell.required_role='trustworthy'");
8183
$node->reload();
8284

8385
# Should fail due to lack of permission.
8486
$node->command_fails_like(
85-
[ @pg_basebackup_cmd, '--target', 'shell' ],
87+
[ @pg_basebackup_cmd, '--target', 'shell' ],
8688
qr/permission denied to use basebackup_to_shell/,
8789
'fails if required_role not granted');
8890

8991
# Should fail due to lack of a detail.
9092
$node->safe_psql('postgres', 'GRANT trustworthy TO backupuser');
9193
$node->command_fails_like(
92-
[ @pg_basebackup_cmd, '--target', 'shell' ],
94+
[ @pg_basebackup_cmd, '--target', 'shell' ],
9395
qr/a target detail is required because the configured command includes %d/,
9496
'fails if %d is present and detail not given');
9597

9698
# Should work.
97-
$node->command_ok(
98-
[ @pg_basebackup_cmd, '--target', 'shell:bar' ],
99+
$node->command_ok([ @pg_basebackup_cmd, '--target', 'shell:bar' ],
99100
'backup with detail: pg_basebackup');
100101
verify_backup('bar.', $backup_path, "backup with detail");
101102

@@ -105,30 +106,34 @@ sub verify_backup
105106
{
106107
my ($prefix, $backup_dir, $test_name) = @_;
107108

108-
ok(-f "$backup_dir/${prefix}backup_manifest.gz",
109-
"$test_name: backup_manifest.gz was created");
110-
ok(-f "$backup_dir/${prefix}base.tar.gz",
111-
"$test_name: base.tar.gz was created");
109+
ok( -f "$backup_dir/${prefix}backup_manifest.gz",
110+
"$test_name: backup_manifest.gz was created");
111+
ok( -f "$backup_dir/${prefix}base.tar.gz",
112+
"$test_name: base.tar.gz was created");
112113

113-
SKIP: {
114+
SKIP:
115+
{
114116
my $tar = $ENV{TAR};
115117
skip "no tar program available", 1 if (!defined $tar || $tar eq '');
116118

117119
# Decompress.
118120
system_or_bail($gzip, '-d',
119-
$backup_dir . '/' . $prefix . 'backup_manifest.gz');
121+
$backup_dir . '/' . $prefix . 'backup_manifest.gz');
120122
system_or_bail($gzip, '-d',
121-
$backup_dir . '/' . $prefix . 'base.tar.gz');
123+
$backup_dir . '/' . $prefix . 'base.tar.gz');
122124

123125
# Untar.
124126
my $extract_path = PostgreSQL::Test::Utils::tempdir;
125127
system_or_bail($tar, 'xf', $backup_dir . '/' . $prefix . 'base.tar',
126-
'-C', $extract_path);
128+
'-C', $extract_path);
127129

128130
# Verify.
129-
$node->command_ok([ 'pg_verifybackup', '-n',
130-
'-m', "${backup_dir}/${prefix}backup_manifest",
131-
'-e', $extract_path ],
132-
"$test_name: backup verifies ok");
131+
$node->command_ok(
132+
[
133+
'pg_verifybackup', '-n',
134+
'-m', "${backup_dir}/${prefix}backup_manifest",
135+
'-e', $extract_path
136+
],
137+
"$test_name: backup verifies ok");
133138
}
134139
}

contrib/basic_archive/basic_archive.c

+26-25
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040

4141
PG_MODULE_MAGIC;
4242

43-
void _PG_init(void);
44-
void _PG_archive_module_init(ArchiveModuleCallbacks *cb);
43+
void _PG_init(void);
44+
void _PG_archive_module_init(ArchiveModuleCallbacks *cb);
4545

4646
static char *archive_directory = NULL;
4747
static MemoryContext basic_archive_context;
@@ -102,8 +102,8 @@ check_archive_directory(char **newval, void **extra, GucSource source)
102102

103103
/*
104104
* The default value is an empty string, so we have to accept that value.
105-
* Our check_configured callback also checks for this and prevents archiving
106-
* from proceeding if it is still empty.
105+
* Our check_configured callback also checks for this and prevents
106+
* archiving from proceeding if it is still empty.
107107
*/
108108
if (*newval == NULL || *newval[0] == '\0')
109109
return true;
@@ -119,7 +119,7 @@ check_archive_directory(char **newval, void **extra, GucSource source)
119119
}
120120

121121
/*
122-
* Do a basic sanity check that the specified archive directory exists. It
122+
* Do a basic sanity check that the specified archive directory exists. It
123123
* could be removed at some point in the future, so we still need to be
124124
* prepared for it not to exist in the actual archiving logic.
125125
*/
@@ -155,18 +155,19 @@ basic_archive_file(const char *file, const char *path)
155155
MemoryContext oldcontext;
156156

157157
/*
158-
* We run basic_archive_file_internal() in our own memory context so that we
159-
* can easily reset it during error recovery (thus avoiding memory leaks).
158+
* We run basic_archive_file_internal() in our own memory context so that
159+
* we can easily reset it during error recovery (thus avoiding memory
160+
* leaks).
160161
*/
161162
oldcontext = MemoryContextSwitchTo(basic_archive_context);
162163

163164
/*
164-
* Since the archiver operates at the bottom of the exception stack, ERRORs
165-
* turn into FATALs and cause the archiver process to restart. However,
166-
* using ereport(ERROR, ...) when there are problems is easy to code and
167-
* maintain. Therefore, we create our own exception handler to catch ERRORs
168-
* and return false instead of restarting the archiver whenever there is a
169-
* failure.
165+
* Since the archiver operates at the bottom of the exception stack,
166+
* ERRORs turn into FATALs and cause the archiver process to restart.
167+
* However, using ereport(ERROR, ...) when there are problems is easy to
168+
* code and maintain. Therefore, we create our own exception handler to
169+
* catch ERRORs and return false instead of restarting the archiver
170+
* whenever there is a failure.
170171
*/
171172
if (sigsetjmp(local_sigjmp_buf, 1) != 0)
172173
{
@@ -228,14 +229,14 @@ basic_archive_file_internal(const char *file, const char *path)
228229
snprintf(destination, MAXPGPATH, "%s/%s", archive_directory, file);
229230

230231
/*
231-
* First, check if the file has already been archived. If it already exists
232-
* and has the same contents as the file we're trying to archive, we can
233-
* return success (after ensuring the file is persisted to disk). This
234-
* scenario is possible if the server crashed after archiving the file but
235-
* before renaming its .ready file to .done.
232+
* First, check if the file has already been archived. If it already
233+
* exists and has the same contents as the file we're trying to archive,
234+
* we can return success (after ensuring the file is persisted to disk).
235+
* This scenario is possible if the server crashed after archiving the
236+
* file but before renaming its .ready file to .done.
236237
*
237-
* If the archive file already exists but has different contents, something
238-
* might be wrong, so we just fail.
238+
* If the archive file already exists but has different contents,
239+
* something might be wrong, so we just fail.
239240
*/
240241
if (stat(destination, &st) == 0)
241242
{
@@ -274,8 +275,8 @@ basic_archive_file_internal(const char *file, const char *path)
274275
archive_directory, "archtemp", file, MyProcPid, epoch);
275276

276277
/*
277-
* Copy the file to its temporary destination. Note that this will fail if
278-
* temp already exists.
278+
* Copy the file to its temporary destination. Note that this will fail
279+
* if temp already exists.
279280
*/
280281
copy_file(unconstify(char *, path), temp);
281282

@@ -318,9 +319,9 @@ compare_files(const char *file1, const char *file2)
318319

319320
for (;;)
320321
{
321-
int nbytes = 0;
322-
int buf1_len = 0;
323-
int buf2_len = 0;
322+
int nbytes = 0;
323+
int buf1_len = 0;
324+
int buf2_len = 0;
324325

325326
while (buf1_len < CMP_BUF_SIZE)
326327
{

contrib/btree_gist/btree_bool.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ gbt_boollt(const void *a, const void *b, FmgrInfo *flinfo)
5353
static int
5454
gbt_boolkey_cmp(const void *a, const void *b, FmgrInfo *flinfo)
5555
{
56-
boolKEY *ia = (boolKEY *) (((const Nsrt *) a)->t);
57-
boolKEY *ib = (boolKEY *) (((const Nsrt *) b)->t);
56+
boolKEY *ia = (boolKEY *) (((const Nsrt *) a)->t);
57+
boolKEY *ib = (boolKEY *) (((const Nsrt *) b)->t);
5858

5959
if (ia->lower == ib->lower)
6060
{

contrib/hstore_plpython/hstore_plpython.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ hstore_to_plpython(PG_FUNCTION_ARGS)
9999
PyObject *key;
100100

101101
key = PLyUnicode_FromStringAndSize(HSTORE_KEY(entries, base, i),
102-
HSTORE_KEYLEN(entries, i));
102+
HSTORE_KEYLEN(entries, i));
103103
if (HSTORE_VALISNULL(entries, i))
104104
PyDict_SetItem(dict, key, Py_None);
105105
else
106106
{
107107
PyObject *value;
108108

109109
value = PLyUnicode_FromStringAndSize(HSTORE_VAL(entries, base, i),
110-
HSTORE_VALLEN(entries, i));
110+
HSTORE_VALLEN(entries, i));
111111
PyDict_SetItem(dict, key, value);
112112
Py_XDECREF(value);
113113
}

0 commit comments

Comments
 (0)