postgresql/src/bin/pg_dump/t/001_basic.pl

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

230 lines
8.5 KiB
Perl
Raw Normal View History

# Copyright (c) 2021-2023, PostgreSQL Global Development Group
use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More;
my $tempdir = PostgreSQL::Test::Utils::tempdir;
#########################################
# Basic checks
program_help_ok('pg_dump');
program_version_ok('pg_dump');
program_options_handling_ok('pg_dump');
program_help_ok('pg_restore');
program_version_ok('pg_restore');
program_options_handling_ok('pg_restore');
program_help_ok('pg_dumpall');
program_version_ok('pg_dumpall');
program_options_handling_ok('pg_dumpall');
#########################################
# Test various invalid options and disallowed combinations
# Doesn't require a PG instance to be set up, so do this first.
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
[ 'pg_dump', 'qqq', 'abc' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_dump: error: too many command-line arguments (first is "abc")\E/,
'pg_dump: too many command-line arguments');
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
[ 'pg_restore', 'qqq', 'abc' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_restore: error: too many command-line arguments (first is "abc")\E/,
'pg_restore: too many command-line arguments');
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
[ 'pg_dumpall', 'qqq', 'abc' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_dumpall: error: too many command-line arguments (first is "qqq")\E/,
'pg_dumpall: too many command-line arguments');
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
[ 'pg_dump', '-s', '-a' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_dump: error: options -s\/--schema-only and -a\/--data-only cannot be used together\E/,
'pg_dump: options -s/--schema-only and -a/--data-only cannot be used together'
);
command_fails_like(
[ 'pg_dump', '-s', '--include-foreign-data=xxx' ],
qr/\Qpg_dump: error: options -s\/--schema-only and --include-foreign-data cannot be used together\E/,
'pg_dump: options -s/--schema-only and --include-foreign-data cannot be used together'
);
command_fails_like(
[ 'pg_dump', '-j2', '--include-foreign-data=xxx' ],
qr/\Qpg_dump: error: option --include-foreign-data is not supported with parallel backup\E/,
'pg_dump: option --include-foreign-data is not supported with parallel backup'
);
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
['pg_restore'],
qr{\Qpg_restore: error: one of -d/--dbname and -f/--file must be specified\E},
'pg_restore: error: one of -d/--dbname and -f/--file must be specified');
command_fails_like(
[ 'pg_restore', '-s', '-a', '-f -' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_restore: error: options -s\/--schema-only and -a\/--data-only cannot be used together\E/,
'pg_restore: options -s/--schema-only and -a/--data-only cannot be used together'
);
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
[ 'pg_restore', '-d', 'xxx', '-f', 'xxx' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_restore: error: options -d\/--dbname and -f\/--file cannot be used together\E/,
'pg_restore: options -d/--dbname and -f/--file cannot be used together');
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
[ 'pg_dump', '-c', '-a' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_dump: error: options -c\/--clean and -a\/--data-only cannot be used together\E/,
'pg_dump: options -c/--clean and -a/--data-only cannot be used together');
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
[ 'pg_restore', '-c', '-a', '-f -' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_restore: error: options -c\/--clean and -a\/--data-only cannot be used together\E/,
'pg_restore: options -c/--clean and -a/--data-only cannot be used together'
);
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
[ 'pg_dump', '--if-exists' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_dump: error: option --if-exists requires option -c\/--clean\E/,
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
'pg_dump: option --if-exists requires option -c/--clean');
command_fails_like(
[ 'pg_dump', '-j3' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_dump: error: parallel backup only supported by the directory format\E/,
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
'pg_dump: parallel backup only supported by the directory format');
# Note the trailing whitespace for the value of --jobs, that is valid.
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
[ 'pg_dump', '-j', '-1 ' ],
qr/\Qpg_dump: error: -j\/--jobs must be in range\E/,
'pg_dump: -j/--jobs must be in range');
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
[ 'pg_dump', '-F', 'garbage' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_dump: error: invalid output format\E/,
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
'pg_dump: invalid output format');
command_fails_like(
[ 'pg_restore', '-j', '-1', '-f -' ],
qr/\Qpg_restore: error: -j\/--jobs must be in range\E/,
'pg_restore: -j/--jobs must be in range');
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
[ 'pg_restore', '--single-transaction', '-j3', '-f -' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_restore: error: cannot specify both --single-transaction and multiple jobs\E/,
'pg_restore: cannot specify both --single-transaction and multiple jobs');
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
Switch pg_dump to use compression specifications Compression specifications are currently used by pg_basebackup and pg_receivewal, and are able to let the user control in an extended way the method and level of compression used. As an effect of this commit, pg_dump's -Z/--compress is now able to use more than just an integer, as of the grammar "method[:detail]". The method can be either "none" or "gzip", and can optionally take a detail string. If the detail string is only an integer, it defines the compression level. A comma-separated list of keywords can also be used method allows for more options, the only keyword supported now is "level". The change is backward-compatible, hence specifying only an integer leads to no compression for a level of 0 and gzip compression when the level is greater than 0. Most of the code changes are straight-forward, as pg_dump was relying on an integer tracking the compression level to check for gzip or no compression. These are changed to use a compression specification and the algorithm stored in it. As of this change, note that the dump format is not bumped because there is no need yet to track the compression algorithm in the TOC entries. Hence, we still rely on the compression level to make the difference when reading them. This will be mandatory once a new compression method is added, though. In order to keep the code simpler when parsing the compression specification, the code is changed so as pg_dump now fails hard when using gzip on -Z/--compress without its support compiled, rather than enforcing no compression without the user knowing about it except through a warning. Like before this commit, archive and custom formats are compressed by default when the code is compiled with gzip, and left uncompressed without gzip. Author: Georgios Kokolatos Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/O4mutIrCES8ZhlXJiMvzsivT7ztAMja2lkdL1LJx6O5f22I2W8PBIeLKz7mDLwxHoibcnRAYJXm1pH4tyUNC4a8eDzLn22a6Pb1S74Niexg=@pm.me
2022-12-02 02:45:02 +01:00
[ 'pg_dump', '--compress', 'garbage' ],
qr/\Qpg_dump: error: unrecognized compression algorithm/,
'pg_dump: invalid --compress');
command_fails_like(
[ 'pg_dump', '--compress', 'none:1' ],
qr/\Qpg_dump: error: invalid compression specification: compression algorithm "none" does not accept a compression level\E/,
'pg_dump: invalid compression specification: compression algorithm "none" does not accept a compression level'
);
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
if (check_pg_config("#define HAVE_LIBZ 1"))
{
Switch pg_dump to use compression specifications Compression specifications are currently used by pg_basebackup and pg_receivewal, and are able to let the user control in an extended way the method and level of compression used. As an effect of this commit, pg_dump's -Z/--compress is now able to use more than just an integer, as of the grammar "method[:detail]". The method can be either "none" or "gzip", and can optionally take a detail string. If the detail string is only an integer, it defines the compression level. A comma-separated list of keywords can also be used method allows for more options, the only keyword supported now is "level". The change is backward-compatible, hence specifying only an integer leads to no compression for a level of 0 and gzip compression when the level is greater than 0. Most of the code changes are straight-forward, as pg_dump was relying on an integer tracking the compression level to check for gzip or no compression. These are changed to use a compression specification and the algorithm stored in it. As of this change, note that the dump format is not bumped because there is no need yet to track the compression algorithm in the TOC entries. Hence, we still rely on the compression level to make the difference when reading them. This will be mandatory once a new compression method is added, though. In order to keep the code simpler when parsing the compression specification, the code is changed so as pg_dump now fails hard when using gzip on -Z/--compress without its support compiled, rather than enforcing no compression without the user knowing about it except through a warning. Like before this commit, archive and custom formats are compressed by default when the code is compiled with gzip, and left uncompressed without gzip. Author: Georgios Kokolatos Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/O4mutIrCES8ZhlXJiMvzsivT7ztAMja2lkdL1LJx6O5f22I2W8PBIeLKz7mDLwxHoibcnRAYJXm1pH4tyUNC4a8eDzLn22a6Pb1S74Niexg=@pm.me
2022-12-02 02:45:02 +01:00
command_fails_like(
[ 'pg_dump', '-Z', '15' ],
qr/\Qpg_dump: error: invalid compression specification: compression algorithm "gzip" expects a compression level between 1 and 9 (default at -1)\E/,
'pg_dump: invalid compression specification: must be in range');
command_fails_like(
[ 'pg_dump', '--compress', '1', '--format', 'tar' ],
qr/\Qpg_dump: error: compression is not supported by tar archive format\E/,
'pg_dump: compression is not supported by tar archive format');
Switch pg_dump to use compression specifications Compression specifications are currently used by pg_basebackup and pg_receivewal, and are able to let the user control in an extended way the method and level of compression used. As an effect of this commit, pg_dump's -Z/--compress is now able to use more than just an integer, as of the grammar "method[:detail]". The method can be either "none" or "gzip", and can optionally take a detail string. If the detail string is only an integer, it defines the compression level. A comma-separated list of keywords can also be used method allows for more options, the only keyword supported now is "level". The change is backward-compatible, hence specifying only an integer leads to no compression for a level of 0 and gzip compression when the level is greater than 0. Most of the code changes are straight-forward, as pg_dump was relying on an integer tracking the compression level to check for gzip or no compression. These are changed to use a compression specification and the algorithm stored in it. As of this change, note that the dump format is not bumped because there is no need yet to track the compression algorithm in the TOC entries. Hence, we still rely on the compression level to make the difference when reading them. This will be mandatory once a new compression method is added, though. In order to keep the code simpler when parsing the compression specification, the code is changed so as pg_dump now fails hard when using gzip on -Z/--compress without its support compiled, rather than enforcing no compression without the user knowing about it except through a warning. Like before this commit, archive and custom formats are compressed by default when the code is compiled with gzip, and left uncompressed without gzip. Author: Georgios Kokolatos Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/O4mutIrCES8ZhlXJiMvzsivT7ztAMja2lkdL1LJx6O5f22I2W8PBIeLKz7mDLwxHoibcnRAYJXm1pH4tyUNC4a8eDzLn22a6Pb1S74Niexg=@pm.me
2022-12-02 02:45:02 +01:00
command_fails_like(
[ 'pg_dump', '-Z', 'gzip:nonInt' ],
qr/\Qpg_dump: error: invalid compression specification: unrecognized compression option: "nonInt"\E/,
'pg_dump: invalid compression specification: must be an integer');
}
else
{
# --jobs > 1 forces an error with tar format.
command_fails_like(
Switch pg_dump to use compression specifications Compression specifications are currently used by pg_basebackup and pg_receivewal, and are able to let the user control in an extended way the method and level of compression used. As an effect of this commit, pg_dump's -Z/--compress is now able to use more than just an integer, as of the grammar "method[:detail]". The method can be either "none" or "gzip", and can optionally take a detail string. If the detail string is only an integer, it defines the compression level. A comma-separated list of keywords can also be used method allows for more options, the only keyword supported now is "level". The change is backward-compatible, hence specifying only an integer leads to no compression for a level of 0 and gzip compression when the level is greater than 0. Most of the code changes are straight-forward, as pg_dump was relying on an integer tracking the compression level to check for gzip or no compression. These are changed to use a compression specification and the algorithm stored in it. As of this change, note that the dump format is not bumped because there is no need yet to track the compression algorithm in the TOC entries. Hence, we still rely on the compression level to make the difference when reading them. This will be mandatory once a new compression method is added, though. In order to keep the code simpler when parsing the compression specification, the code is changed so as pg_dump now fails hard when using gzip on -Z/--compress without its support compiled, rather than enforcing no compression without the user knowing about it except through a warning. Like before this commit, archive and custom formats are compressed by default when the code is compiled with gzip, and left uncompressed without gzip. Author: Georgios Kokolatos Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/O4mutIrCES8ZhlXJiMvzsivT7ztAMja2lkdL1LJx6O5f22I2W8PBIeLKz7mDLwxHoibcnRAYJXm1pH4tyUNC4a8eDzLn22a6Pb1S74Niexg=@pm.me
2022-12-02 02:45:02 +01:00
[ 'pg_dump', '--format', 'tar', '-j3' ],
qr/\Qpg_dump: error: parallel backup only supported by the directory format\E/,
'pg_dump: warning: parallel backup not supported by tar format');
command_fails_like(
[ 'pg_dump', '-Z', 'gzip:nonInt', '--format', 'tar', '-j2' ],
qr/\Qpg_dump: error: invalid compression specification: unrecognized compression option\E/,
'pg_dump: invalid compression specification: must be an integer');
}
command_fails_like(
[ 'pg_dump', '--extra-float-digits', '-16' ],
qr/\Qpg_dump: error: --extra-float-digits must be in range\E/,
'pg_dump: --extra-float-digits must be in range');
command_fails_like(
[ 'pg_dump', '--rows-per-insert', '0' ],
qr/\Qpg_dump: error: --rows-per-insert must be in range\E/,
'pg_dump: --rows-per-insert must be in range');
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
[ 'pg_restore', '--if-exists', '-f -' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_restore: error: option --if-exists requires option -c\/--clean\E/,
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
'pg_restore: option --if-exists requires option -c/--clean');
command_fails_like(
[ 'pg_restore', '-f -', '-F', 'garbage' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_restore: error: unrecognized archive format "garbage";\E/,
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
'pg_dump: unrecognized archive format');
command_fails_like(
[ 'pg_dump', '--on-conflict-do-nothing' ],
2019-07-01 13:07:14 +02:00
qr/pg_dump: error: option --on-conflict-do-nothing requires option --inserts, --rows-per-insert, or --column-inserts/,
'pg_dump: --on-conflict-do-nothing requires --inserts, --rows-per-insert, --column-inserts'
);
# pg_dumpall command-line argument checks
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
[ 'pg_dumpall', '-g', '-r' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_dumpall: error: options -g\/--globals-only and -r\/--roles-only cannot be used together\E/,
'pg_dumpall: options -g/--globals-only and -r/--roles-only cannot be used together'
);
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
[ 'pg_dumpall', '-g', '-t' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_dumpall: error: options -g\/--globals-only and -t\/--tablespaces-only cannot be used together\E/,
'pg_dumpall: options -g/--globals-only and -t/--tablespaces-only cannot be used together'
);
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
[ 'pg_dumpall', '-r', '-t' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_dumpall: error: options -r\/--roles-only and -t\/--tablespaces-only cannot be used together\E/,
'pg_dumpall: options -r/--roles-only and -t/--tablespaces-only cannot be used together'
);
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
command_fails_like(
[ 'pg_dumpall', '--if-exists' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_dumpall: error: option --if-exists requires option -c\/--clean\E/,
Improve pg_dump regression tests and code coverage These improvements bring the lines-of-code coverage of pg_dump.c up to 87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearly every function is covered, three of the four which aren't are only called when talking to older PG instances. There is more which can, and should, be done here to improve the coverage but it's past time to see what the buildfarm thinks of this. What has been added: - Coverage for many more command-line options - Use command_fails_like instead of command_exit_is - Operator classes, operator families - Text search configuration, templates, parsers, dictionaries - FDWs, servers, foreign tables - Materialized views - Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl) - Unlogged tables - Partitioned tables - Additional ACL testing for various object types There is room for improvement, specifically: - Various type-based option (alignment, storage, etc) - Composite type collation - Extra Procedural language functions (inline, validator) - Different function options (SRF, Transform, config, security definer, cost, leakproof) - OpClass options (default, storage, order by, recheck) - OpFamily options (order by, recheck) - Aggregate functions (combinefunc, serialfunc, deserialfunc, etc) - Text Search parser 'headline' - Text Search template 'init' - FDW options (handler, validator, options) - Server options (type, version, options) - User mapping options - Default ACLs for sequences, types - Security labels - View circular dependencies (last function that needs coverage) - Toast table autovacuum options - Replica identity options - Independent indexes (plus marking them as clustered on) - Deferrable / initially deferred constraints - Independent domain constraints There's bits of extension pg_dump'ing also not covered, but those will need to go into test_pg_dump (such as having a filter for config tables). Last, but not least, this approximately halves the number of tests run with 'ok()' by removing the ok()-based checking of if all runs are covered by each test. Instead, 002_pg_dump.pl will just exit out in such a case (with a message in the log file). In general, when adding tests, cover all runs unless there is a very good reason not to (such as adding a 'catch-all' case). With these changes, the resulting output and number of "tests" run is actually reduced.
2017-03-18 18:18:24 +01:00
'pg_dumpall: option --if-exists requires option -c/--clean');
command_fails_like(
[ 'pg_restore', '-C', '-1', '-f -' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_restore: error: options -C\/--create and -1\/--single-transaction cannot be used together\E/,
'pg_restore: options -C\/--create and -1\/--single-transaction cannot be used together'
);
# also fails for -r and -t, but it seems pointless to add more tests for those.
command_fails_like(
[ 'pg_dumpall', '--exclude-database=foo', '--globals-only' ],
Unified logging system for command-line programs This unifies the various ad hoc logging (message printing, error printing) systems used throughout the command-line programs. Features: - Program name is automatically prefixed. - Message string does not end with newline. This removes a common source of inconsistencies and omissions. - Additionally, a final newline is automatically stripped, simplifying use of PQerrorMessage() etc., another common source of mistakes. - I converted error message strings to use %m where possible. - As a result of the above several points, more translatable message strings can be shared between different components and between frontends and backend, without gratuitous punctuation or whitespace differences. - There is support for setting a "log level". This is not meant to be user-facing, but can be used internally to implement debug or verbose modes. - Lazy argument evaluation, so no significant overhead if logging at some level is disabled. - Some color in the messages, similar to gcc and clang. Set PG_COLOR=auto to try it out. Some colors are predefined, but can be customized by setting PG_COLORS. - Common files (common/, fe_utils/, etc.) can handle logging much more simply by just using one API without worrying too much about the context of the calling program, requiring callbacks, or having to pass "progname" around everywhere. - Some programs called setvbuf() to make sure that stderr is unbuffered, even on Windows. But not all programs did that. This is now done centrally. Soft goals: - Reduces vertical space use and visual complexity of error reporting in the source code. - Encourages more deliberate classification of messages. For example, in some cases it wasn't clear without analyzing the surrounding code whether a message was meant as an error or just an info. - Concepts and terms are vaguely aligned with popular logging frameworks such as log4j and Python logging. This is all just about printing stuff out. Nothing affects program flow (e.g., fatal exits). The uses are just too varied to do that. Some existing code had wrappers that do some kind of print-and-exit, and I adapted those. I tried to keep the output mostly the same, but there is a lot of historical baggage to unwind and special cases to consider, and I might not always have succeeded. One significant change is that pg_rewind used to write all error messages to stdout. That is now changed to stderr. Reviewed-by: Donald Dong <xdong@csumb.edu> Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru> Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
qr/\Qpg_dumpall: error: option --exclude-database cannot be used together with -g\/--globals-only\E/,
'pg_dumpall: option --exclude-database cannot be used together with -g/--globals-only'
);
done_testing();