diff options
Diffstat (limited to 'src/bin')
28 files changed, 346 insertions, 298 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index a66dd078a79..67021a6dc13 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -1460,7 +1460,7 @@ setup_auth(FILE *cmdfd) if (superuser_password) PG_CMD_PRINTF("ALTER USER \"%s\" WITH PASSWORD E'%s';\n\n", - username, escape_quotes(superuser_password)); + username, escape_quotes(superuser_password)); } /* @@ -1674,8 +1674,8 @@ setup_collation(FILE *cmdfd) * that it wins if libc defines a locale named ucs_basic. */ PG_CMD_PRINTF("INSERT INTO pg_collation (oid, collname, collnamespace, collowner, collprovider, collisdeterministic, collencoding, collcollate, collctype)" - "VALUES (pg_nextoid('pg_catalog.pg_collation', 'oid', 'pg_catalog.pg_collation_oid_index'), 'ucs_basic', 'pg_catalog'::regnamespace, %u, '%c', true, %d, 'C', 'C');\n\n", - BOOTSTRAP_SUPERUSERID, COLLPROVIDER_LIBC, PG_UTF8); + "VALUES (pg_nextoid('pg_catalog.pg_collation', 'oid', 'pg_catalog.pg_collation_oid_index'), 'ucs_basic', 'pg_catalog'::regnamespace, %u, '%c', true, %d, 'C', 'C');\n\n", + BOOTSTRAP_SUPERUSERID, COLLPROVIDER_LIBC, PG_UTF8); /* Now import all collations we can find in the operating system */ PG_CMD_PUTS("SELECT pg_import_system_collations('pg_catalog');\n\n"); @@ -1918,15 +1918,15 @@ setup_schema(FILE *cmdfd) free(lines); PG_CMD_PRINTF("UPDATE information_schema.sql_implementation_info " - " SET character_value = '%s' " - " WHERE implementation_info_name = 'DBMS VERSION';\n\n", - infoversion); + " SET character_value = '%s' " + " WHERE implementation_info_name = 'DBMS VERSION';\n\n", + infoversion); PG_CMD_PRINTF("COPY information_schema.sql_features " - " (feature_id, feature_name, sub_feature_id, " - " sub_feature_name, is_supported, comments) " - " FROM E'%s';\n\n", - escape_quotes(features_file)); + " (feature_id, feature_name, sub_feature_id, " + " sub_feature_name, is_supported, comments) " + " FROM E'%s';\n\n", + escape_quotes(features_file)); } /* diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index 2e9035d6137..b9ec640d2fc 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -1050,7 +1050,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum) #ifdef HAVE_LIBZ if (compresslevel != 0) { - int fd = dup(fileno(stdout)); + int fd = dup(fileno(stdout)); + if (fd < 0) { pg_log_error("could not duplicate stdout: %m"); @@ -1224,7 +1225,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum) if (strcmp(basedir, "-") == 0 && manifest) { char header[512]; - PQExpBufferData buf; + PQExpBufferData buf; initPQExpBuffer(&buf); ReceiveBackupManifestInMemory(conn, &buf); diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl index 63381764e97..208df557b85 100644 --- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl +++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl @@ -103,7 +103,7 @@ foreach my $filename (@tempRelationFiles) # Run base backup. $node->command_ok([ 'pg_basebackup', '-D', "$tempdir/backup", '-X', 'none' ], 'pg_basebackup runs'); -ok(-f "$tempdir/backup/PG_VERSION", 'backup was created'); +ok(-f "$tempdir/backup/PG_VERSION", 'backup was created'); ok(-f "$tempdir/backup/backup_manifest", 'backup manifest included'); # Permissions on backup should be default @@ -161,13 +161,14 @@ rmtree("$tempdir/backup"); $node->command_ok( [ - 'pg_basebackup', '-D', "$tempdir/backup2", '--no-manifest', - '--waldir', "$tempdir/xlog2" + 'pg_basebackup', '-D', + "$tempdir/backup2", '--no-manifest', + '--waldir', "$tempdir/xlog2" ], 'separate xlog directory'); -ok(-f "$tempdir/backup2/PG_VERSION", 'backup was created'); -ok(! -f "$tempdir/backup2/backup_manifest", 'manifest was suppressed'); -ok(-d "$tempdir/xlog2/", 'xlog directory was created'); +ok(-f "$tempdir/backup2/PG_VERSION", 'backup was created'); +ok(!-f "$tempdir/backup2/backup_manifest", 'manifest was suppressed'); +ok(-d "$tempdir/xlog2/", 'xlog directory was created'); rmtree("$tempdir/backup2"); rmtree("$tempdir/xlog2"); diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c index 9aa9f756f66..1daa5aed0e0 100644 --- a/src/bin/pg_checksums/pg_checksums.c +++ b/src/bin/pg_checksums/pg_checksums.c @@ -244,7 +244,7 @@ scan_file(const char *fn, BlockNumber segmentno) } else if (mode == PG_MODE_ENABLE) { - int w; + int w; /* Set checksum in page header */ header->pd_checksum = csum; diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index fa1d569f0f8..f33c2463a72 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -2412,8 +2412,8 @@ makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo) /* Skip FOREIGN TABLEs (no data to dump) unless requested explicitly */ if (tbinfo->relkind == RELKIND_FOREIGN_TABLE && (foreign_servers_include_oids.head == NULL || - !simple_oid_list_member(&foreign_servers_include_oids, - tbinfo->foreign_server))) + !simple_oid_list_member(&foreign_servers_include_oids, + tbinfo->foreign_server))) return; /* Skip partitioned tables (data in partitions) */ if (tbinfo->relkind == RELKIND_PARTITIONED_TABLE) @@ -4074,8 +4074,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables) TableInfo *tbinfo = &tblinfo[i]; /* - * Only regular and partitioned tables can be added to - * publications. + * Only regular and partitioned tables can be added to publications. */ if (tbinfo->relkind != RELKIND_RELATION && tbinfo->relkind != RELKIND_PARTITIONED_TABLE) @@ -4397,12 +4396,12 @@ append_depends_on_extension(Archive *fout, { if (dobj->depends_on_ext) { - char *nm; + char *nm; PGresult *res; - PQExpBuffer query; - int ntups; - int i_extname; - int i; + PQExpBuffer query; + int ntups; + int i_extname; + int i; /* dodge fmtId() non-reentrancy */ nm = pg_strdup(objname); @@ -7294,7 +7293,10 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables) indxinfo[j].indisclustered = (PQgetvalue(res, j, i_indisclustered)[0] == 't'); indxinfo[j].indisreplident = (PQgetvalue(res, j, i_indisreplident)[0] == 't'); indxinfo[j].parentidx = atooid(PQgetvalue(res, j, i_parentidx)); - indxinfo[j].partattaches = (SimplePtrList) { NULL, NULL }; + indxinfo[j].partattaches = (SimplePtrList) + { + NULL, NULL + }; contype = *(PQgetvalue(res, j, i_contype)); if (contype == 'p' || contype == 'u' || contype == 'x') @@ -7492,7 +7494,7 @@ getConstraints(Archive *fout, TableInfo tblinfo[], int numTables) for (j = 0; j < ntups; j++) { - TableInfo *reftable; + TableInfo *reftable; constrinfo[j].dobj.objType = DO_FK_CONSTRAINT; constrinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_contableoid)); @@ -16802,7 +16804,7 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) delq = createPQExpBuffer(); foreign = tbinfo && - tbinfo->relkind == RELKIND_FOREIGN_TABLE ? "FOREIGN " : ""; + tbinfo->relkind == RELKIND_FOREIGN_TABLE ? "FOREIGN " : ""; if (coninfo->contype == 'p' || coninfo->contype == 'u' || diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index 61c909e06d8..5f70400b257 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -132,7 +132,7 @@ typedef struct _dumpableObject DumpComponents dump; /* bitmask of components to dump */ DumpComponents dump_contains; /* as above, but for contained objects */ bool ext_member; /* true if object is member of extension */ - bool depends_on_ext; /* true if object depends on an extension */ + bool depends_on_ext; /* true if object depends on an extension */ DumpId *dependencies; /* dumpIds of objects this one depends on */ int nDeps; /* number of valid dependencies */ int allocDeps; /* allocated size of dependencies[] */ @@ -369,7 +369,7 @@ typedef struct _indxInfo bool indisclustered; bool indisreplident; Oid parentidx; /* if partitioned, parent index OID */ - SimplePtrList partattaches; /* if partitioned, partition attach objects */ + SimplePtrList partattaches; /* if partitioned, partition attach objects */ /* if there is an associated constraint object, its dumpId: */ DumpId indexconstraint; diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index 1b90cbd9b58..e116235769b 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -1378,7 +1378,7 @@ my %tests = ( 'CREATE COLLATION test0 FROM "C"' => { create_order => 76, create_sql => 'CREATE COLLATION test0 FROM "C";', - regexp => + regexp => qr/CREATE COLLATION public.test0 \(provider = libc, locale = 'C'(, version = '[^']*')?\);/m, collation => 1, like => { %full_runs, section_pre_data => 1, }, @@ -1411,8 +1411,9 @@ my %tests = ( "CREATE DATABASE dump_test2 LOCALE = 'C'" => { create_order => 47, - create_sql => "CREATE DATABASE dump_test2 LOCALE = 'C' TEMPLATE = template0;", - regexp => qr/^ + create_sql => + "CREATE DATABASE dump_test2 LOCALE = 'C' TEMPLATE = template0;", + regexp => qr/^ \QCREATE DATABASE dump_test2 \E.*\QLOCALE = 'C';\E /xm, like => { pg_dumpall_dbprivs => 1, }, @@ -1575,7 +1576,7 @@ my %tests = ( unlike => { exclude_dump_test_schema => 1, }, }, - # verify that a custom operator/opclass/range type is dumped in right order + # verify that a custom operator/opclass/range type is dumped in right order 'CREATE OPERATOR CLASS dump_test.op_class_custom' => { create_order => 74, create_sql => 'CREATE OPERATOR dump_test.~~ ( @@ -2574,7 +2575,8 @@ my %tests = ( 'ALTER STATISTICS extended_stats_options' => { create_order => 98, - create_sql => 'ALTER STATISTICS dump_test.test_ext_stats_opts SET STATISTICS 1000', + create_sql => + 'ALTER STATISTICS dump_test.test_ext_stats_opts SET STATISTICS 1000', regexp => qr/^ \QALTER STATISTICS dump_test.test_ext_stats_opts SET STATISTICS 1000;\E /xms, diff --git a/src/bin/pg_dump/t/003_pg_dump_with_server.pl b/src/bin/pg_dump/t/003_pg_dump_with_server.pl index 8c8063908b9..dd9a60a2c9f 100644 --- a/src/bin/pg_dump/t/003_pg_dump_with_server.pl +++ b/src/bin/pg_dump/t/003_pg_dump_with_server.pl @@ -18,19 +18,19 @@ $node->start; # Verify that dumping foreign data includes only foreign tables of # matching servers -$node->safe_psql( 'postgres', "CREATE FOREIGN DATA WRAPPER dummy"); -$node->safe_psql( 'postgres', "CREATE SERVER s0 FOREIGN DATA WRAPPER dummy"); -$node->safe_psql( 'postgres', "CREATE SERVER s1 FOREIGN DATA WRAPPER dummy"); -$node->safe_psql( 'postgres', "CREATE SERVER s2 FOREIGN DATA WRAPPER dummy"); -$node->safe_psql( 'postgres', "CREATE FOREIGN TABLE t0 (a int) SERVER s0"); -$node->safe_psql( 'postgres', "CREATE FOREIGN TABLE t1 (a int) SERVER s1"); +$node->safe_psql('postgres', "CREATE FOREIGN DATA WRAPPER dummy"); +$node->safe_psql('postgres', "CREATE SERVER s0 FOREIGN DATA WRAPPER dummy"); +$node->safe_psql('postgres', "CREATE SERVER s1 FOREIGN DATA WRAPPER dummy"); +$node->safe_psql('postgres', "CREATE SERVER s2 FOREIGN DATA WRAPPER dummy"); +$node->safe_psql('postgres', "CREATE FOREIGN TABLE t0 (a int) SERVER s0"); +$node->safe_psql('postgres', "CREATE FOREIGN TABLE t1 (a int) SERVER s1"); my ($cmd, $stdout, $stderr, $result); command_fails_like( - [ "pg_dump", '-p', $port, '--include-foreign-data=s0', 'postgres' ], + [ "pg_dump", '-p', $port, '--include-foreign-data=s0', 'postgres' ], qr/foreign-data wrapper \"dummy\" has no handler\r?\npg_dump: error: query was:.*t0/, "correctly fails to dump a foreign table from a dummy FDW"); command_ok( - [ "pg_dump", '-p', $port, '-a', '--include-foreign-data=s2', 'postgres' ] , + [ "pg_dump", '-p', $port, '-a', '--include-foreign-data=s2', 'postgres' ], "dump foreign server with no tables"); diff --git a/src/bin/pg_rewind/libpq_fetch.c b/src/bin/pg_rewind/libpq_fetch.c index a17799a5d71..1dbbceab0bd 100644 --- a/src/bin/pg_rewind/libpq_fetch.c +++ b/src/bin/pg_rewind/libpq_fetch.c @@ -23,7 +23,7 @@ #include "pg_rewind.h" #include "port/pg_bswap.h" -PGconn *conn = NULL; +PGconn *conn = NULL; /* * Files are fetched max CHUNKSIZE bytes at a time. diff --git a/src/bin/pg_verifybackup/parse_manifest.h b/src/bin/pg_verifybackup/parse_manifest.h index 7d38194907e..cbb7ca1397e 100644 --- a/src/bin/pg_verifybackup/parse_manifest.h +++ b/src/bin/pg_verifybackup/parse_manifest.h @@ -21,16 +21,16 @@ struct JsonManifestParseContext; typedef struct JsonManifestParseContext JsonManifestParseContext; -typedef void (*json_manifest_perfile_callback)(JsonManifestParseContext *, - char *pathname, - size_t size, pg_checksum_type checksum_type, - int checksum_length, uint8 *checksum_payload); -typedef void (*json_manifest_perwalrange_callback)(JsonManifestParseContext *, - TimeLineID tli, - XLogRecPtr start_lsn, XLogRecPtr end_lsn); -typedef void (*json_manifest_error_callback)(JsonManifestParseContext *, - const char *fmt, ...) pg_attribute_printf(2, 3) - pg_attribute_noreturn(); +typedef void (*json_manifest_perfile_callback) (JsonManifestParseContext *, + char *pathname, + size_t size, pg_checksum_type checksum_type, + int checksum_length, uint8 *checksum_payload); +typedef void (*json_manifest_perwalrange_callback) (JsonManifestParseContext *, + TimeLineID tli, + XLogRecPtr start_lsn, XLogRecPtr end_lsn); +typedef void (*json_manifest_error_callback) (JsonManifestParseContext *, + const char *fmt,...) pg_attribute_printf(2, 3) + pg_attribute_noreturn(); struct JsonManifestParseContext { diff --git a/src/bin/pg_verifybackup/pg_verifybackup.c b/src/bin/pg_verifybackup/pg_verifybackup.c index 2fa2aa6ae04..70b6ffdec00 100644 --- a/src/bin/pg_verifybackup/pg_verifybackup.c +++ b/src/bin/pg_verifybackup/pg_verifybackup.c @@ -644,11 +644,10 @@ verify_backup_file(verifier_context *context, char *relpath, char *fullpath) } /* - * We don't verify checksums at this stage. We first finish verifying - * that we have the expected set of files with the expected sizes, and - * only afterwards verify the checksums. That's because computing - * checksums may take a while, and we'd like to report more obvious - * problems quickly. + * We don't verify checksums at this stage. We first finish verifying that + * we have the expected set of files with the expected sizes, and only + * afterwards verify the checksums. That's because computing checksums may + * take a while, and we'd like to report more obvious problems quickly. */ } @@ -707,7 +706,7 @@ verify_backup_checksums(verifier_context *context) */ static void verify_file_checksum(verifier_context *context, manifest_file *m, - char *fullpath) + char *fullpath) { pg_checksum_context checksum_ctx; char *relpath = m->pathname; diff --git a/src/bin/pg_verifybackup/t/001_basic.pl b/src/bin/pg_verifybackup/t/001_basic.pl index 0d4d71aaa10..0c35062dc0a 100644 --- a/src/bin/pg_verifybackup/t/001_basic.pl +++ b/src/bin/pg_verifybackup/t/001_basic.pl @@ -9,22 +9,25 @@ program_help_ok('pg_verifybackup'); program_version_ok('pg_verifybackup'); program_options_handling_ok('pg_verifybackup'); -command_fails_like(['pg_verifybackup'], - qr/no backup directory specified/, - 'target directory must be specified'); -command_fails_like(['pg_verifybackup', $tempdir], - qr/could not open file.*\/backup_manifest\"/, - 'pg_verifybackup requires a manifest'); -command_fails_like(['pg_verifybackup', $tempdir, $tempdir], - qr/too many command-line arguments/, - 'multiple target directories not allowed'); +command_fails_like( + ['pg_verifybackup'], + qr/no backup directory specified/, + 'target directory must be specified'); +command_fails_like( + [ 'pg_verifybackup', $tempdir ], + qr/could not open file.*\/backup_manifest\"/, + 'pg_verifybackup requires a manifest'); +command_fails_like( + [ 'pg_verifybackup', $tempdir, $tempdir ], + qr/too many command-line arguments/, + 'multiple target directories not allowed'); # create fake manifest file open(my $fh, '>', "$tempdir/backup_manifest") || die "open: $!"; close($fh); # but then try to use an alternate, nonexisting manifest -command_fails_like(['pg_verifybackup', '-m', "$tempdir/not_the_manifest", - $tempdir], - qr/could not open file.*\/not_the_manifest\"/, - 'pg_verifybackup respects -m flag'); +command_fails_like( + [ 'pg_verifybackup', '-m', "$tempdir/not_the_manifest", $tempdir ], + qr/could not open file.*\/not_the_manifest\"/, + 'pg_verifybackup respects -m flag'); diff --git a/src/bin/pg_verifybackup/t/002_algorithm.pl b/src/bin/pg_verifybackup/t/002_algorithm.pl index ee82dcee376..d0c97ae3cc3 100644 --- a/src/bin/pg_verifybackup/t/002_algorithm.pl +++ b/src/bin/pg_verifybackup/t/002_algorithm.pl @@ -16,16 +16,16 @@ $master->start; for my $algorithm (qw(bogus none crc32c sha224 sha256 sha384 sha512)) { my $backup_path = $master->backup_dir . '/' . $algorithm; - my @backup = ('pg_basebackup', '-D', $backup_path, - '--manifest-checksums', $algorithm, - '--no-sync'); + my @backup = ( + 'pg_basebackup', '-D', $backup_path, + '--manifest-checksums', $algorithm, '--no-sync'); my @verify = ('pg_verifybackup', '-e', $backup_path); # A backup with a bogus algorithm should fail. if ($algorithm eq 'bogus') { $master->command_fails(\@backup, - "backup fails with algorithm \"$algorithm\""); + "backup fails with algorithm \"$algorithm\""); next; } @@ -44,14 +44,14 @@ for my $algorithm (qw(bogus none crc32c sha224 sha256 sha384 sha512)) { my $manifest = slurp_file("$backup_path/backup_manifest"); my $count_of_algorithm_in_manifest = - (() = $manifest =~ /$algorithm/mig); - cmp_ok($count_of_algorithm_in_manifest, '>', 100, - "$algorithm is mentioned many times in the manifest"); + (() = $manifest =~ /$algorithm/mig); + cmp_ok($count_of_algorithm_in_manifest, + '>', 100, "$algorithm is mentioned many times in the manifest"); } # Make sure that it verifies OK. $master->command_ok(\@verify, - "verify backup with algorithm \"$algorithm\""); + "verify backup with algorithm \"$algorithm\""); # Remove backup immediately to save disk space. rmtree($backup_path); diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl index 113959420ee..c2e04d0be20 100644 --- a/src/bin/pg_verifybackup/t/003_corruption.pl +++ b/src/bin/pg_verifybackup/t/003_corruption.pl @@ -15,7 +15,7 @@ $master->start; # Include a user-defined tablespace in the hopes of detecting problems in that # area. -my $source_ts_path = TestLib::perl2host(TestLib::tempdir_short()); +my $source_ts_path = TestLib::perl2host(TestLib::tempdir_short()); my $source_ts_prefix = $source_ts_path; $source_ts_prefix =~ s!(^[A-Z]:/[^/]*)/.*!$1!; @@ -29,106 +29,107 @@ EOM my @scenario = ( { - 'name' => 'extra_file', + 'name' => 'extra_file', 'mutilate' => \&mutilate_extra_file, 'fails_like' => - qr/extra_file.*present on disk but not in the manifest/ + qr/extra_file.*present on disk but not in the manifest/ }, { - 'name' => 'extra_tablespace_file', + 'name' => 'extra_tablespace_file', 'mutilate' => \&mutilate_extra_tablespace_file, 'fails_like' => - qr/extra_ts_file.*present on disk but not in the manifest/ + qr/extra_ts_file.*present on disk but not in the manifest/ }, { - 'name' => 'missing_file', + 'name' => 'missing_file', 'mutilate' => \&mutilate_missing_file, 'fails_like' => - qr/pg_xact\/0000.*present in the manifest but not on disk/ + qr/pg_xact\/0000.*present in the manifest but not on disk/ }, { - 'name' => 'missing_tablespace', + 'name' => 'missing_tablespace', 'mutilate' => \&mutilate_missing_tablespace, 'fails_like' => - qr/pg_tblspc.*present in the manifest but not on disk/ + qr/pg_tblspc.*present in the manifest but not on disk/ }, { - 'name' => 'append_to_file', - 'mutilate' => \&mutilate_append_to_file, - 'fails_like' => - qr/has size \d+ on disk but size \d+ in the manifest/ + 'name' => 'append_to_file', + 'mutilate' => \&mutilate_append_to_file, + 'fails_like' => qr/has size \d+ on disk but size \d+ in the manifest/ }, { - 'name' => 'truncate_file', - 'mutilate' => \&mutilate_truncate_file, - 'fails_like' => - qr/has size 0 on disk but size \d+ in the manifest/ + 'name' => 'truncate_file', + 'mutilate' => \&mutilate_truncate_file, + 'fails_like' => qr/has size 0 on disk but size \d+ in the manifest/ }, { - 'name' => 'replace_file', - 'mutilate' => \&mutilate_replace_file, + 'name' => 'replace_file', + 'mutilate' => \&mutilate_replace_file, 'fails_like' => qr/checksum mismatch for file/ }, { - 'name' => 'bad_manifest', - 'mutilate' => \&mutilate_bad_manifest, + 'name' => 'bad_manifest', + 'mutilate' => \&mutilate_bad_manifest, 'fails_like' => qr/manifest checksum mismatch/ }, { - 'name' => 'open_file_fails', - 'mutilate' => \&mutilate_open_file_fails, - 'fails_like' => qr/could not open file/, + 'name' => 'open_file_fails', + 'mutilate' => \&mutilate_open_file_fails, + 'fails_like' => qr/could not open file/, 'skip_on_windows' => 1 }, { - 'name' => 'open_directory_fails', - 'mutilate' => \&mutilate_open_directory_fails, - 'cleanup' => \&cleanup_open_directory_fails, - 'fails_like' => qr/could not open directory/, + 'name' => 'open_directory_fails', + 'mutilate' => \&mutilate_open_directory_fails, + 'cleanup' => \&cleanup_open_directory_fails, + 'fails_like' => qr/could not open directory/, 'skip_on_windows' => 1 }, { - 'name' => 'search_directory_fails', - 'mutilate' => \&mutilate_search_directory_fails, - 'cleanup' => \&cleanup_search_directory_fails, - 'fails_like' => qr/could not stat file or directory/, + 'name' => 'search_directory_fails', + 'mutilate' => \&mutilate_search_directory_fails, + 'cleanup' => \&cleanup_search_directory_fails, + 'fails_like' => qr/could not stat file or directory/, 'skip_on_windows' => 1 - } -); + }); for my $scenario (@scenario) { my $name = $scenario->{'name'}; - SKIP: + SKIP: { skip "unix-style permissions not supported on Windows", 4 - if $scenario->{'skip_on_windows'} && $windows_os; + if $scenario->{'skip_on_windows'} && $windows_os; # Take a backup and check that it verifies OK. - my $backup_path = $master->backup_dir . '/' . $name; + my $backup_path = $master->backup_dir . '/' . $name; my $backup_ts_path = TestLib::perl2host(TestLib::tempdir_short()); # The tablespace map parameter confuses Msys2, which tries to mangle # it. Tell it not to. # See https://www.msys2.org/wiki/Porting/#filesystem-namespaces local $ENV{MSYS2_ARG_CONV_EXCL} = $source_ts_prefix; - $master->command_ok(['pg_basebackup', '-D', $backup_path, '--no-sync', - '-T', "${source_ts_path}=${backup_ts_path}"], - "base backup ok"); - command_ok(['pg_verifybackup', $backup_path ], - "intact backup verified"); + $master->command_ok( + [ + 'pg_basebackup', '-D', $backup_path, '--no-sync', + '-T', "${source_ts_path}=${backup_ts_path}" + ], + "base backup ok"); + command_ok([ 'pg_verifybackup', $backup_path ], + "intact backup verified"); # Mutilate the backup in some way. $scenario->{'mutilate'}->($backup_path); # Now check that the backup no longer verifies. - command_fails_like(['pg_verifybackup', $backup_path ], - $scenario->{'fails_like'}, - "corrupt backup fails verification: $name"); + command_fails_like( + [ 'pg_verifybackup', $backup_path ], + $scenario->{'fails_like'}, + "corrupt backup fails verification: $name"); # Run cleanup hook, if provided. $scenario->{'cleanup'}->($backup_path) - if exists $scenario->{'cleanup'}; + if exists $scenario->{'cleanup'}; # Finally, use rmtree to reclaim space. rmtree($backup_path); @@ -157,14 +158,14 @@ sub mutilate_extra_file sub mutilate_extra_tablespace_file { my ($backup_path) = @_; - my ($tsoid) = grep { $_ ne '.' && $_ ne '..' } - slurp_dir("$backup_path/pg_tblspc"); + my ($tsoid) = + grep { $_ ne '.' && $_ ne '..' } slurp_dir("$backup_path/pg_tblspc"); my ($catvdir) = grep { $_ ne '.' && $_ ne '..' } - slurp_dir("$backup_path/pg_tblspc/$tsoid"); + slurp_dir("$backup_path/pg_tblspc/$tsoid"); my ($tsdboid) = grep { $_ ne '.' && $_ ne '..' } - slurp_dir("$backup_path/pg_tblspc/$tsoid/$catvdir"); + slurp_dir("$backup_path/pg_tblspc/$tsoid/$catvdir"); create_extra_file($backup_path, - "pg_tblspc/$tsoid/$catvdir/$tsdboid/extra_ts_file"); + "pg_tblspc/$tsoid/$catvdir/$tsdboid/extra_ts_file"); return; } @@ -181,8 +182,8 @@ sub mutilate_missing_file sub mutilate_missing_tablespace { my ($backup_path) = @_; - my ($tsoid) = grep { $_ ne '.' && $_ ne '..' } - slurp_dir("$backup_path/pg_tblspc"); + my ($tsoid) = + grep { $_ ne '.' && $_ ne '..' } slurp_dir("$backup_path/pg_tblspc"); my $pathname = "$backup_path/pg_tblspc/$tsoid"; if ($windows_os) { @@ -226,8 +227,8 @@ sub mutilate_truncate_file sub mutilate_replace_file { my ($backup_path) = @_; - my $pathname = "$backup_path/PG_VERSION"; - my $contents = slurp_file($pathname); + my $pathname = "$backup_path/PG_VERSION"; + my $contents = slurp_file($pathname); open(my $fh, '>', $pathname) || die "open $pathname: $!"; print $fh 'q' x length($contents); close($fh); @@ -279,7 +280,7 @@ sub mutilate_search_directory_fails } # rmtree can't cope with a mode 400 directory, so change back to 700. -sub cleanup_search_directory_fails +sub cleanup_search_directory_fails { my ($backup_path) = @_; my $pathname = "$backup_path/base"; diff --git a/src/bin/pg_verifybackup/t/004_options.pl b/src/bin/pg_verifybackup/t/004_options.pl index 9bae8eb565b..271b7ee5043 100644 --- a/src/bin/pg_verifybackup/t/004_options.pl +++ b/src/bin/pg_verifybackup/t/004_options.pl @@ -14,14 +14,14 @@ my $master = get_new_node('master'); $master->init(allows_streaming => 1); $master->start; my $backup_path = $master->backup_dir . '/test_options'; -$master->command_ok(['pg_basebackup', '-D', $backup_path, '--no-sync' ], - "base backup ok"); +$master->command_ok([ 'pg_basebackup', '-D', $backup_path, '--no-sync' ], + "base backup ok"); # Verify that pg_verifybackup -q succeeds and produces no output. my $stdout; my $stderr; -my $result = IPC::Run::run ['pg_verifybackup', '-q', $backup_path ], - '>', \$stdout, '2>', \$stderr; +my $result = IPC::Run::run [ 'pg_verifybackup', '-q', $backup_path ], + '>', \$stdout, '2>', \$stderr; ok($result, "-q succeeds: exit code 0"); is($stdout, '', "-q succeeds: no stdout"); is($stderr, '', "-q succeeds: no stderr"); @@ -34,56 +34,71 @@ print $fh 'q' x length($version_contents); close($fh); # Verify that pg_verifybackup -q now fails. -command_fails_like(['pg_verifybackup', '-q', $backup_path ], - qr/checksum mismatch for file \"PG_VERSION\"/, - '-q checksum mismatch'); +command_fails_like( + [ 'pg_verifybackup', '-q', $backup_path ], + qr/checksum mismatch for file \"PG_VERSION\"/, + '-q checksum mismatch'); # Since we didn't change the length of the file, verification should succeed # if we ignore checksums. Check that we get the right message, too. -command_like(['pg_verifybackup', '-s', $backup_path ], - qr/backup successfully verified/, - '-s skips checksumming'); +command_like( + [ 'pg_verifybackup', '-s', $backup_path ], + qr/backup successfully verified/, + '-s skips checksumming'); # Validation should succeed if we ignore the problem file. -command_like(['pg_verifybackup', '-i', 'PG_VERSION', $backup_path ], - qr/backup successfully verified/, - '-i ignores problem file'); +command_like( + [ 'pg_verifybackup', '-i', 'PG_VERSION', $backup_path ], + qr/backup successfully verified/, + '-i ignores problem file'); # PG_VERSION is already corrupt; let's try also removing all of pg_xact. rmtree($backup_path . "/pg_xact"); # We're ignoring the problem with PG_VERSION, but not the problem with # pg_xact, so verification should fail here. -command_fails_like(['pg_verifybackup', '-i', 'PG_VERSION', $backup_path ], - qr/pg_xact.*is present in the manifest but not on disk/, - '-i does not ignore all problems'); +command_fails_like( + [ 'pg_verifybackup', '-i', 'PG_VERSION', $backup_path ], + qr/pg_xact.*is present in the manifest but not on disk/, + '-i does not ignore all problems'); # If we use -i twice, we should be able to ignore all of the problems. -command_like(['pg_verifybackup', '-i', 'PG_VERSION', '-i', 'pg_xact', - $backup_path ], - qr/backup successfully verified/, - 'multiple -i options work'); +command_like( + [ 'pg_verifybackup', '-i', 'PG_VERSION', '-i', 'pg_xact', $backup_path ], + qr/backup successfully verified/, + 'multiple -i options work'); # Verify that when -i is not used, both problems are reported. -$result = IPC::Run::run ['pg_verifybackup', $backup_path ], - '>', \$stdout, '2>', \$stderr; +$result = IPC::Run::run [ 'pg_verifybackup', $backup_path ], + '>', \$stdout, '2>', \$stderr; ok(!$result, "multiple problems: fails"); -like($stderr, qr/pg_xact.*is present in the manifest but not on disk/, - "multiple problems: missing files reported"); -like($stderr, qr/checksum mismatch for file \"PG_VERSION\"/, - "multiple problems: checksum mismatch reported"); +like( + $stderr, + qr/pg_xact.*is present in the manifest but not on disk/, + "multiple problems: missing files reported"); +like( + $stderr, + qr/checksum mismatch for file \"PG_VERSION\"/, + "multiple problems: checksum mismatch reported"); # Verify that when -e is used, only the problem detected first is reported. -$result = IPC::Run::run ['pg_verifybackup', '-e', $backup_path ], - '>', \$stdout, '2>', \$stderr; +$result = IPC::Run::run [ 'pg_verifybackup', '-e', $backup_path ], + '>', \$stdout, '2>', \$stderr; ok(!$result, "-e reports 1 error: fails"); -like($stderr, qr/pg_xact.*is present in the manifest but not on disk/, - "-e reports 1 error: missing files reported"); -unlike($stderr, qr/checksum mismatch for file \"PG_VERSION\"/, - "-e reports 1 error: checksum mismatch not reported"); +like( + $stderr, + qr/pg_xact.*is present in the manifest but not on disk/, + "-e reports 1 error: missing files reported"); +unlike( + $stderr, + qr/checksum mismatch for file \"PG_VERSION\"/, + "-e reports 1 error: checksum mismatch not reported"); # Test valid manifest with nonexistent backup directory. -command_fails_like(['pg_verifybackup', '-m', "$backup_path/backup_manifest", - "$backup_path/fake" ], - qr/could not open directory/, - 'nonexistent backup directory'); +command_fails_like( + [ + 'pg_verifybackup', '-m', + "$backup_path/backup_manifest", "$backup_path/fake" + ], + qr/could not open directory/, + 'nonexistent backup directory'); diff --git a/src/bin/pg_verifybackup/t/005_bad_manifest.pl b/src/bin/pg_verifybackup/t/005_bad_manifest.pl index 3dd2b5a20df..afd64d1a96b 100644 --- a/src/bin/pg_verifybackup/t/005_bad_manifest.pl +++ b/src/bin/pg_verifybackup/t/005_bad_manifest.pl @@ -11,9 +11,10 @@ use Test::More tests => 58; my $tempdir = TestLib::tempdir; -test_bad_manifest('input string ended unexpectedly', - qr/could not parse backup manifest: The input string ended unexpectedly/, - <<EOM); +test_bad_manifest( + 'input string ended unexpectedly', + qr/could not parse backup manifest: The input string ended unexpectedly/, + <<EOM); { EOM @@ -163,7 +164,7 @@ my $manifest_without_newline = <<EOM; EOM chomp($manifest_without_newline); test_parse_error('last line not newline-terminated', - $manifest_without_newline); + $manifest_without_newline); test_fatal_error('invalid manifest checksum', <<EOM); {"PostgreSQL-Backup-Manifest-Version": 1, "Files": [], @@ -175,8 +176,8 @@ sub test_parse_error my ($test_name, $manifest_contents) = @_; test_bad_manifest($test_name, - qr/could not parse backup manifest: $test_name/, - $manifest_contents); + qr/could not parse backup manifest: $test_name/, + $manifest_contents); return; } @@ -184,9 +185,7 @@ sub test_fatal_error { my ($test_name, $manifest_contents) = @_; - test_bad_manifest($test_name, - qr/fatal: $test_name/, - $manifest_contents); + test_bad_manifest($test_name, qr/fatal: $test_name/, $manifest_contents); return; } @@ -198,7 +197,6 @@ sub test_bad_manifest print $fh $manifest_contents; close($fh); - command_fails_like(['pg_verifybackup', $tempdir], $regexp, - $test_name); + command_fails_like([ 'pg_verifybackup', $tempdir ], $regexp, $test_name); return; } diff --git a/src/bin/pg_verifybackup/t/006_encoding.pl b/src/bin/pg_verifybackup/t/006_encoding.pl index 3c6b57adcd4..5ab9649ab6f 100644 --- a/src/bin/pg_verifybackup/t/006_encoding.pl +++ b/src/bin/pg_verifybackup/t/006_encoding.pl @@ -12,16 +12,20 @@ my $master = get_new_node('master'); $master->init(allows_streaming => 1); $master->start; my $backup_path = $master->backup_dir . '/test_encoding'; -$master->command_ok(['pg_basebackup', '-D', $backup_path, '--no-sync', - '--manifest-force-encode' ], - "backup ok with forced hex encoding"); +$master->command_ok( + [ + 'pg_basebackup', '-D', + $backup_path, '--no-sync', + '--manifest-force-encode' + ], + "backup ok with forced hex encoding"); my $manifest = slurp_file("$backup_path/backup_manifest"); -my $count_of_encoded_path_in_manifest = - (() = $manifest =~ /Encoded-Path/mig); -cmp_ok($count_of_encoded_path_in_manifest, '>', 100, - "many paths are encoded in the manifest"); +my $count_of_encoded_path_in_manifest = (() = $manifest =~ /Encoded-Path/mig); +cmp_ok($count_of_encoded_path_in_manifest, + '>', 100, "many paths are encoded in the manifest"); -command_like(['pg_verifybackup', '-s', $backup_path ], - qr/backup successfully verified/, - 'backup with forced encoding verified'); +command_like( + [ 'pg_verifybackup', '-s', $backup_path ], + qr/backup successfully verified/, + 'backup with forced encoding verified'); diff --git a/src/bin/pg_verifybackup/t/007_wal.pl b/src/bin/pg_verifybackup/t/007_wal.pl index 5e891d1b6f4..56d536675c9 100644 --- a/src/bin/pg_verifybackup/t/007_wal.pl +++ b/src/bin/pg_verifybackup/t/007_wal.pl @@ -14,26 +14,28 @@ my $master = get_new_node('master'); $master->init(allows_streaming => 1); $master->start; my $backup_path = $master->backup_dir . '/test_wal'; -$master->command_ok(['pg_basebackup', '-D', $backup_path, '--no-sync' ], - "base backup ok"); +$master->command_ok([ 'pg_basebackup', '-D', $backup_path, '--no-sync' ], + "base backup ok"); # Rename pg_wal. -my $original_pg_wal = $backup_path . '/pg_wal'; +my $original_pg_wal = $backup_path . '/pg_wal'; my $relocated_pg_wal = $master->backup_dir . '/relocated_pg_wal'; rename($original_pg_wal, $relocated_pg_wal) || die "rename pg_wal: $!"; # WAL verification should fail. -command_fails_like(['pg_verifybackup', $backup_path ], - qr/WAL parsing failed for timeline 1/, - 'missing pg_wal causes failure'); +command_fails_like( + [ 'pg_verifybackup', $backup_path ], + qr/WAL parsing failed for timeline 1/, + 'missing pg_wal causes failure'); # Should work if we skip WAL verification. -command_ok(['pg_verifybackup', '-n', $backup_path ], - 'missing pg_wal OK if not verifying WAL'); +command_ok( + [ 'pg_verifybackup', '-n', $backup_path ], + 'missing pg_wal OK if not verifying WAL'); # Should also work if we specify the correct WAL location. -command_ok(['pg_verifybackup', '-w', $relocated_pg_wal, $backup_path ], - '-w can be used to specify WAL directory'); +command_ok([ 'pg_verifybackup', '-w', $relocated_pg_wal, $backup_path ], + '-w can be used to specify WAL directory'); # Move directory back to original location. rename($relocated_pg_wal, $original_pg_wal) || die "rename pg_wal back: $!"; @@ -43,13 +45,14 @@ my @walfiles = grep { /^[0-9A-F]{24}$/ } slurp_dir($original_pg_wal); # Replace the contents of one of the files with garbage of equal length. my $wal_corruption_target = $original_pg_wal . '/' . $walfiles[0]; -my $wal_size = -s $wal_corruption_target; +my $wal_size = -s $wal_corruption_target; open(my $fh, '>', $wal_corruption_target) - || die "open $wal_corruption_target: $!"; + || die "open $wal_corruption_target: $!"; print $fh 'w' x $wal_size; close($fh); # WAL verification should fail. -command_fails_like(['pg_verifybackup', $backup_path ], - qr/WAL parsing failed for timeline 1/, - 'corrupt WAL file causes failure'); +command_fails_like( + [ 'pg_verifybackup', $backup_path ], + qr/WAL parsing failed for timeline 1/, + 'corrupt WAL file causes failure'); diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index ef8ef447f66..08a5947a9e6 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -200,7 +200,7 @@ typedef enum PART_NONE, /* no partitioning */ PART_RANGE, /* range partitioning */ PART_HASH /* hash partitioning */ -} partition_method_t; +} partition_method_t; static partition_method_t partition_method = PART_NONE; static const char *PARTITION_METHOD[] = {"none", "range", "hash"}; @@ -3321,7 +3321,7 @@ executeMetaCommand(CState *st, instr_time *now) if (unlikely(__pg_log_level <= PG_LOG_DEBUG)) { - PQExpBufferData buf; + PQExpBufferData buf; initPQExpBuffer(&buf); @@ -3992,7 +3992,7 @@ initGenerateDataServerSide(PGconn *con) snprintf(sql, sizeof(sql), "insert into pgbench_accounts(aid,bid,abalance,filler) " "select aid, (aid - 1) / %d + 1, 0, '' " - "from generate_series(1, "INT64_FORMAT") as aid", + "from generate_series(1, " INT64_FORMAT ") as aid", naccounts, (int64) naccounts * scale); executeStatement(con, sql); @@ -4390,7 +4390,7 @@ syntax_error(const char *source, int lineno, { fprintf(stderr, "%s\n", line); if (column >= 0) - fprintf(stderr, "%*c error found here\n", column+1, '^'); + fprintf(stderr, "%*c error found here\n", column + 1, '^'); } exit(1); diff --git a/src/bin/pgbench/t/001_pgbench_with_server.pl b/src/bin/pgbench/t/001_pgbench_with_server.pl index e85728c3790..52009c35242 100644 --- a/src/bin/pgbench/t/001_pgbench_with_server.pl +++ b/src/bin/pgbench/t/001_pgbench_with_server.pl @@ -68,8 +68,7 @@ my $ets = TestLib::perl2host($ts); # the next commands will issue a syntax error if the path contains a "'" $node->safe_psql('postgres', - "CREATE TABLESPACE regress_pgbench_tap_1_ts LOCATION '$ets';" -); + "CREATE TABLESPACE regress_pgbench_tap_1_ts LOCATION '$ets';"); # Test concurrent OID generation via pg_enum_oid_index. This indirectly # exercises LWLock and spinlock concurrency. @@ -106,8 +105,10 @@ pgbench( '-i', 0, [qr{^$}], [ - qr{creating tables}, qr{vacuuming}, - qr{creating primary keys}, qr{done in \d+\.\d\d s } + qr{creating tables}, + qr{vacuuming}, + qr{creating primary keys}, + qr{done in \d+\.\d\d s } ], 'pgbench scale 1 initialization',); @@ -123,7 +124,7 @@ pgbench( qr{vacuuming}, qr{creating primary keys}, qr{creating foreign keys}, - qr{(?!vacuuming)}, # no vacuum + qr{(?!vacuuming)}, # no vacuum qr{done in \d+\.\d\d s } ], 'pgbench scale 1 initialization'); @@ -140,7 +141,7 @@ pgbench( qr{creating primary keys}, qr{generating data \(server-side\)}, qr{creating foreign keys}, - qr{(?!vacuuming)}, # no vacuum + qr{(?!vacuuming)}, # no vacuum qr{done in \d+\.\d\d s } ], 'pgbench --init-steps'); @@ -276,85 +277,90 @@ COMMIT; # 1. Logging neither with errors nor with statements $node->append_conf('postgresql.conf', - "log_min_duration_statement = 0\n" . - "log_parameter_max_length = 0\n" . - "log_parameter_max_length_on_error = 0"); + "log_min_duration_statement = 0\n" + . "log_parameter_max_length = 0\n" + . "log_parameter_max_length_on_error = 0"); $node->reload; pgbench( - '-n -t1 -c1 -M prepared', - 2, - [], - [ + '-n -t1 -c1 -M prepared', + 2, + [], + [ qr{ERROR: invalid input syntax for type json}, qr{(?!extended query with parameters)} - ], - 'server parameter logging', - { - '001_param_1' => q[select '{ invalid ' as value \gset + ], + 'server parameter logging', + { + '001_param_1' => q[select '{ invalid ' as value \gset select $$'Valame Dios!' dijo Sancho; 'no le dije yo a vuestra merced que mirase bien lo que hacia?'$$ as long \gset select column1::jsonb from (values (:value), (:long)) as q; ] }); my $log = TestLib::slurp_file($node->logfile); -unlike($log, qr[DETAIL: parameters: \$1 = '\{ invalid ',], "no parameters logged"); +unlike( + $log, + qr[DETAIL: parameters: \$1 = '\{ invalid ',], + "no parameters logged"); $log = undef; # 2. Logging truncated parameters on error, full with statements $node->append_conf('postgresql.conf', - "log_parameter_max_length = -1\n" . - "log_parameter_max_length_on_error = 64"); + "log_parameter_max_length = -1\n" + . "log_parameter_max_length_on_error = 64"); $node->reload; pgbench( - '-n -t1 -c1 -M prepared', - 2, - [], - [ + '-n -t1 -c1 -M prepared', + 2, + [], + [ qr{ERROR: division by zero}, qr{CONTEXT: extended query with parameters: \$1 = '1', \$2 = NULL} - ], - 'server parameter logging', - { - '001_param_2' => q{select '1' as one \gset + ], + 'server parameter logging', + { + '001_param_2' => q{select '1' as one \gset SELECT 1 / (random() / 2)::int, :one::int, :two::int; } }); pgbench( - '-n -t1 -c1 -M prepared', - 2, - [], - [ + '-n -t1 -c1 -M prepared', + 2, + [], + [ qr{ERROR: invalid input syntax for type json}, qr[CONTEXT: JSON data, line 1: \{ invalid\.\.\.[\r\n]+extended query with parameters: \$1 = '\{ invalid ', \$2 = '''Valame Dios!'' dijo Sancho; ''no le dije yo a vuestra merced que \.\.\.']m - ], - 'server parameter logging', - { - '001_param_3' => q[select '{ invalid ' as value \gset + ], + 'server parameter logging', + { + '001_param_3' => q[select '{ invalid ' as value \gset select $$'Valame Dios!' dijo Sancho; 'no le dije yo a vuestra merced que mirase bien lo que hacia?'$$ as long \gset select column1::jsonb from (values (:value), (:long)) as q; ] }); $log = TestLib::slurp_file($node->logfile); -like($log, qr[DETAIL: parameters: \$1 = '\{ invalid ', \$2 = '''Valame Dios!'' dijo Sancho; ''no le dije yo a vuestra merced que mirase bien lo que hacia\?'''], - "parameter report does not truncate"); +like( + $log, + qr[DETAIL: parameters: \$1 = '\{ invalid ', \$2 = '''Valame Dios!'' dijo Sancho; ''no le dije yo a vuestra merced que mirase bien lo que hacia\?'''], + "parameter report does not truncate"); $log = undef; # 3. Logging full parameters on error, truncated with statements $node->append_conf('postgresql.conf', - "log_min_duration_statement = -1\n" . - "log_parameter_max_length = 7\n" . - "log_parameter_max_length_on_error = -1"); + "log_min_duration_statement = -1\n" + . "log_parameter_max_length = 7\n" + . "log_parameter_max_length_on_error = -1"); $node->reload; pgbench( - '-n -t1 -c1 -M prepared', - 2, - [], - [ + '-n -t1 -c1 -M prepared', + 2, + [], + [ qr{ERROR: division by zero}, qr{CONTEXT: extended query with parameters: \$1 = '1', \$2 = NULL} - ], - 'server parameter logging', - { - '001_param_4' => q{select '1' as one \gset + ], + 'server parameter logging', + { + '001_param_4' => q{select '1' as one \gset SELECT 1 / (random() / 2)::int, :one::int, :two::int; } }); @@ -362,30 +368,32 @@ SELECT 1 / (random() / 2)::int, :one::int, :two::int; $node->append_conf('postgresql.conf', "log_min_duration_statement = 0"); $node->reload; pgbench( - '-n -t1 -c1 -M prepared', - 2, - [], - [ + '-n -t1 -c1 -M prepared', + 2, + [], + [ qr{ERROR: invalid input syntax for type json}, qr[CONTEXT: JSON data, line 1: \{ invalid\.\.\.[\r\n]+extended query with parameters: \$1 = '\{ invalid ', \$2 = '''Valame Dios!'' dijo Sancho; ''no le dije yo a vuestra merced que mirase bien lo que hacia\?']m - ], - 'server parameter logging', - { - '001_param_5' => q[select '{ invalid ' as value \gset + ], + 'server parameter logging', + { + '001_param_5' => q[select '{ invalid ' as value \gset select $$'Valame Dios!' dijo Sancho; 'no le dije yo a vuestra merced que mirase bien lo que hacia?'$$ as long \gset select column1::jsonb from (values (:value), (:long)) as q; ] }); $log = TestLib::slurp_file($node->logfile); -like($log, qr[DETAIL: parameters: \$1 = '\{ inval\.\.\.', \$2 = '''Valame\.\.\.'], - "parameter report truncates"); +like( + $log, + qr[DETAIL: parameters: \$1 = '\{ inval\.\.\.', \$2 = '''Valame\.\.\.'], + "parameter report truncates"); $log = undef; # Restore default logging config $node->append_conf('postgresql.conf', - "log_min_duration_statement = -1\n" . - "log_parameter_max_length_on_error = 0\n" . - "log_parameter_max_length = -1"); + "log_min_duration_statement = -1\n" + . "log_parameter_max_length_on_error = 0\n" + . "log_parameter_max_length = -1"); $node->reload; # test expressions diff --git a/src/bin/pgbench/t/002_pgbench_no_server.pl b/src/bin/pgbench/t/002_pgbench_no_server.pl index 66b1bd6ff6e..e38c7d77d1c 100644 --- a/src/bin/pgbench/t/002_pgbench_no_server.pl +++ b/src/bin/pgbench/t/002_pgbench_no_server.pl @@ -147,7 +147,10 @@ my @options = ( [ 'invalid init step', '-i -I dta', - [ qr{unrecognized initialization step}, qr{Allowed step characters are} ] + [ + qr{unrecognized initialization step}, + qr{Allowed step characters are} + ] ], [ 'bad random seed', @@ -158,12 +161,20 @@ my @options = ( qr{error while setting random seed from --random-seed option} ] ], - [ 'bad partition method', '-i --partition-method=BAD', [qr{"range"}, qr{"hash"}, qr{"BAD"}] ], - [ 'bad partition number', '-i --partitions -1', [ qr{invalid number of partitions: "-1"} ] ], + [ + 'bad partition method', + '-i --partition-method=BAD', + [ qr{"range"}, qr{"hash"}, qr{"BAD"} ] + ], + [ + 'bad partition number', + '-i --partitions -1', + [qr{invalid number of partitions: "-1"}] + ], [ 'partition method without partitioning', '-i --partition-method=hash', - [ qr{partition-method requires greater than zero --partitions} ] + [qr{partition-method requires greater than zero --partitions}] ], # logging sub-options @@ -231,8 +242,10 @@ pgbench( '--show-script se', 0, [qr{^$}], - [ qr{select-only: }, qr{SELECT abalance FROM pgbench_accounts WHERE}, - qr{(?!UPDATE)}, qr{(?!INSERT)} ], + [ + qr{select-only: }, qr{SELECT abalance FROM pgbench_accounts WHERE}, + qr{(?!UPDATE)}, qr{(?!INSERT)} + ], 'pgbench builtin listing'); my @script_tests = ( diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index 621a33f7e83..06f801764b6 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -707,7 +707,7 @@ PrintNotifications(void) static bool PrintQueryTuples(const PGresult *results) { - bool result = true; + bool result = true; /* write output to \g argument, if any */ if (pset.gfname) diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 8dca6d8bb43..9b526e40cdd 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3074,7 +3074,7 @@ describeOneTableDetails(const char *schemaname, /* Visually distinguish inherited triggers */ if (!PQgetisnull(result, i, 4)) appendPQExpBuffer(&buf, ", ON TABLE %s", - PQgetvalue(result, i, 4)); + PQgetvalue(result, i, 4)); printTableAddFooter(&cont, buf.data); } diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c index bdf803a0535..7abe016e403 100644 --- a/src/bin/psql/mainloop.c +++ b/src/bin/psql/mainloop.c @@ -238,11 +238,10 @@ MainLoop(FILE *source) bool found_q = false; /* - * The assistance words, help/exit/quit, must have no - * whitespace before them, and only whitespace after, with an - * optional semicolon. This prevents indented use of these - * words, perhaps as identifiers, from invoking the assistance - * behavior. + * The assistance words, help/exit/quit, must have no whitespace + * before them, and only whitespace after, with an optional + * semicolon. This prevents indented use of these words, perhaps + * as identifiers, from invoking the assistance behavior. */ if (pg_strncasecmp(first_word, "help", 4) == 0) { diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index f6fd623c98b..1e931a56cb6 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -1743,14 +1743,14 @@ psql_completion(const char *text, int start, int end) /* ALTER INDEX <foo> SET|RESET ( */ else if (Matches("ALTER", "INDEX", MatchAny, "RESET", "(")) COMPLETE_WITH("fillfactor", - "vacuum_cleanup_index_scale_factor", "deduplicate_items", /* BTREE */ + "vacuum_cleanup_index_scale_factor", "deduplicate_items", /* BTREE */ "fastupdate", "gin_pending_list_limit", /* GIN */ "buffering", /* GiST */ "pages_per_range", "autosummarize" /* BRIN */ ); else if (Matches("ALTER", "INDEX", MatchAny, "SET", "(")) COMPLETE_WITH("fillfactor =", - "vacuum_cleanup_index_scale_factor =", "deduplicate_items =", /* BTREE */ + "vacuum_cleanup_index_scale_factor =", "deduplicate_items =", /* BTREE */ "fastupdate =", "gin_pending_list_limit =", /* GIN */ "buffering =", /* GiST */ "pages_per_range =", "autosummarize =" /* BRIN */ diff --git a/src/bin/scripts/createuser.c b/src/bin/scripts/createuser.c index ebdb72a45cc..9ced079ac75 100644 --- a/src/bin/scripts/createuser.c +++ b/src/bin/scripts/createuser.c @@ -88,7 +88,7 @@ main(int argc, char *argv[]) while ((c = getopt_long(argc, argv, "h:p:U:g:wWedDsSrRiIlLc:PE", long_options, &optindex)) != -1) { - char *endptr; + char *endptr; switch (c) { @@ -145,7 +145,7 @@ main(int argc, char *argv[]) break; case 'c': conn_limit = strtol(optarg, &endptr, 10); - if (*endptr != '\0' || conn_limit < -1) /* minimum valid value */ + if (*endptr != '\0' || conn_limit < -1) /* minimum valid value */ { pg_log_error("invalid value for --connection-limit: %s", optarg); diff --git a/src/bin/scripts/t/090_reindexdb.pl b/src/bin/scripts/t/090_reindexdb.pl index c20ffbd505c..87417c86ff4 100644 --- a/src/bin/scripts/t/090_reindexdb.pl +++ b/src/bin/scripts/t/090_reindexdb.pl @@ -109,7 +109,7 @@ $node->issues_sql_like( qr/statement:\ REINDEX TABLE s1.t1;/, 'parallel reindexdb for schemas does a per-table REINDEX'); $node->command_ok( - ['reindexdb', '-j', '2', '-S', 's3'], + [ 'reindexdb', '-j', '2', '-S', 's3' ], 'parallel reindexdb with empty schema'); $node->command_checks_all( [ 'reindexdb', '-j', '2', '--concurrently', '-d', 'postgres' ], diff --git a/src/bin/scripts/t/100_vacuumdb.pl b/src/bin/scripts/t/100_vacuumdb.pl index c2284c8195f..b136bd44570 100644 --- a/src/bin/scripts/t/100_vacuumdb.pl +++ b/src/bin/scripts/t/100_vacuumdb.pl @@ -89,8 +89,7 @@ $node->command_fails( $node->command_fails( [ 'vacuumdb', '--analyze', '--table', 'vactable(c)', 'postgres' ], 'incorrect column name with ANALYZE'); -$node->command_fails( - [ 'vacuumdb', '-P', -1, 'postgres' ], +$node->command_fails([ 'vacuumdb', '-P', -1, 'postgres' ], 'negative parallel degree'); $node->issues_sql_like( [ 'vacuumdb', '--analyze', '--table', 'vactable(a, b)', 'postgres' ], |
