David Steele
790f7c7312
Enforce full branch coverage in C code.
2018-05-05 11:50:11 -04:00
David Steele
0a860e0b60
Full branch coverage for command/help/help, common/error, common/ini, and common/log modules.
2018-05-05 09:38:09 -04:00
David Steele
90aadc6534
Full branch coverage for config module.
2018-05-04 12:49:25 -04:00
David Steele
6c3b40152f
Improve module branch coverage.
...
Add full branch coverage for cipher/block, command/command, common/wait, and postgres/pageChecksum modules.
2018-05-04 09:21:32 -04:00
David Steele
c3a8fbe706
Add _FMT variants for all THROW macros so format types are checked by the compiler.
2018-05-03 11:24:29 -04:00
Yogesh Sharma
6a40c916d4
Add repo-s3-token option to allow temporary credentials tokens to be configured.
...
pgBackRest currently has no way to request new credentials so the entire command (e.g. backup, restore) must complete before the credentials expire.
Contributed by Yogesh Sharma.
2018-05-02 14:06:40 -04:00
David Steele
fd1984239e
Fix rendering of key/value and list options in help.
...
Reported by Clinton Adams.
2018-05-01 14:07:08 -04:00
David Steele
1a1ed8d6b9
Update help test to use restore command to provide better coverage.
2018-05-01 13:20:48 -04:00
David Steele
54dd6f3ed4
Add asynchronous, parallel archive-get.
...
This feature maintains a queue of WAL segments to help reduce latency when PostgreSQL requests a WAL segment with restore_command.
2018-04-30 17:27:39 -04:00
David Steele
321a28f6b0
Add walSegmentNext() and walSegmentRange().
2018-04-29 11:47:50 -04:00
David Steele
be02c67503
Add pgControlInfo() to read pg_control and determine the PostgreSQL version.
2018-04-29 11:20:51 -04:00
David Steele
8c6e2bdbc7
Add storageInfo() and track size in read objects.
2018-04-29 11:02:21 -04:00
David Steele
d74c167420
Add bufNewC() and only reallocate buffer when the size has changed.
2018-04-29 10:41:05 -04:00
David Steele
d44848baa0
Add strLstExists(), strLstExistsZ(), strSub(), and strSubN() to String and StringList objects.
2018-04-29 10:32:46 -04:00
David Steele
89d3476e32
Refactor archive common functions in preparation for parallel async archive-get.
2018-04-29 10:16:59 -04:00
Cynthia Shang
721432f6ae
Update the archive-push-queue-max, manifest-save-threshold, and buffer-size options to accept values in KB, MB, GB, TB, or PB where the multiplier is a power of 1024.
...
Contributed by Cynthia Shang.
2018-04-25 15:46:05 -04:00
Cynthia Shang
8eabc52f3b
Add strUpper, strLower, strChr, and strTrunc to String object.
...
Contributed by Cynthia Shang.
2018-04-25 15:16:42 -04:00
David Steele
bb8c315cad
Storage object improvements.
...
* Add storageCopy(), storageMove(), and storagePathSync().
* Separate StorageFile object into separate read and write objects.
* Abstract out Posix file read/write objects.
2018-04-23 17:26:27 -04:00
David Steele
18882cb882
Add bufEq and bufCat to Buffer object.
2018-04-23 10:19:45 -04:00
David Steele
f146502eae
Add TEST_ERROR_FMT macro to simplify testing of formatted error messages.
2018-04-23 10:10:55 -04:00
Cynthia Shang
27aa5f756e
Add support for additional pgBackRest configuration files.
...
Configuration files are loaded from the directory specified by the --config-include-path option.
Add --config-path option for overriding the default base path of the --config and --config-include-path option.
Contributed by Cynthia Shang.
2018-04-19 11:09:39 -04:00
David Steele
79b7552940
Rename archive-queue-max option to archive-push-queue-max.
...
This avoids confusion with the archive-get-queue-max option. The old option name will continue to be accepted.
2018-04-18 19:37:35 -04:00
David Steele
0381945caa
Show command parameters as well as command options in initial info message.
2018-04-17 18:47:14 -04:00
David Steele
e9790fd3b1
Update out-of-date description for the spool-path option.
2018-04-17 17:38:25 -04:00
David Steele
2a4ff2f904
Split cfgLoad() into multiple functions to make testing easier.
...
Mainly this helps with unit tests that need to do log expect testing. Add harnessCfgLoad() test function, which allows a new config to be loaded for unit testing without resetting log functions, opening a log file, or taking locks.
2018-04-13 16:05:52 -04:00
David Steele
f0250dab4b
Move async forking and more error handling to C.
...
The Perl process was exiting directly when called but that interfered with proper locking for the forked async process. Now Perl returns results to the C process which handles all errors, including signals.
2018-04-12 20:42:26 -04:00
David Steele
6fd0c3dcaa
Improved lock implementation written in C.
...
Now only two types of locks can be taken: archive and backup. Most commands use one or the other but the stanza-* commands acquire both locks. This provides better protection than the old command-based locking scheme.
2018-04-11 09:36:12 -04:00
David Steele
4744eb9387
Add storagePathRemove() and use it in the Perl Posix driver.
...
This implementation should be faster because it does not stat each file. It simply assumes that most directory entries are files so attempts an unlink() first. If the entry is reported by error codes to be a directory then it attempts an rmdir().
2018-04-11 08:21:09 -04:00
David Steele
b77b425096
Allow -DDEBUG_UNIT to be suppressed to test how debug macros behave.
2018-04-07 19:44:00 -04:00
David Steele
82751b3b51
Split debug and assert code into separate headers.
...
Assert can be used earlier because it only depends on the error-handler and not logging.
2018-04-07 13:12:35 -04:00
David Steele
f3b56cf8f3
Allow MemContext objects to be copied to a new parent.
...
This makes it easier to create objects and then copy them to another context when they are complete without having to worry about freeing them on error. Update List, StringList, and Buffer to allow moves. Update Ini and Storage to take advantage of moves.
2018-04-06 17:04:52 -04:00
David Steele
b9f636cab4
Cleanup C types.
...
* Remove pgBackRest defined types included with the C types.
* Remove redefinition of standard C types.
2018-04-05 22:38:11 -04:00
David Steele
bd25248df0
Abstract Posix storage driver code into a separate module.
2018-04-05 14:48:16 -04:00
David Steele
93fdb98d15
Storage object improvements.
...
* Convert all functions to variadic functions.
* Enforce read-only storage.
* Add storageLocalWrite() helper function. Add storageExists(), storagePathCreate(), storageRemove(), and storageStat().
* Add StorageFile object and storageOpenRead()/storageOpenWrite().
2018-04-03 12:25:21 -04:00
David Steele
635caff573
Add ASSERT() that is preserved in production builds.
2018-03-30 19:10:34 -04:00
David Steele
5518a2ac51
Full branch coverage for storage/storage module.
2018-03-27 20:40:33 -04:00
David Steele
c1ab7b3c98
Start work on C handle io object and use it to output help.
2018-03-25 11:39:24 -04:00
David Steele
9001b9b957
Replace THROW_ON_SYS_ERROR() with THROW_SYS_ERROR().
...
The former macro was hiding missing branch coverage for critical error handling.
2018-03-24 14:11:29 -04:00
David Steele
c6457b070f
Full branch coverage for config/parse module.
2018-03-21 13:46:08 -04:00
David Steele
b234f43c9d
Refactor usec to msec in common/time.c.
...
The implementation provides usec resolution but this is not needed in practice and it makes the interface more complicated due to the extra zeros.
2018-03-21 09:18:48 -04:00
David Steele
31830bdc55
Full branch coverage for all common/type modules.
2018-03-20 16:08:52 -04:00
David Steele
f4ed36d128
Add switch() to lcov branch exclusions.
...
lcov requires default to show complete coverage but --Wswitch-enum enforces all enum values be present so no default is needed.
Add documentation for each branch exclusion.
2018-03-20 10:17:53 -04:00
David Steele
d34142dee8
Update lcov settings.
...
Mark any coverage less that 100% as yellow, less that 90% as red.
Add comments to config file and make genhtml use it as well as lcov.
2018-03-20 09:47:51 -04:00
David Steele
07f38f584a
Use lcov for C unit test coverage reporting.
...
Switch from Devel::Cover because it would not report on branch coverage for reports converted from gcov.
Branch coverage is not complete, so for the time being errors will only be generated when statement coverage is not complete. Coverage of unit tests is not displayed in the report unless they are incomplete for either statement or branch coverage.
2018-03-19 23:33:28 -04:00
David Steele
45c6a0e864
Remove hard-coded release version from loadTest.c.
2018-03-19 21:03:42 -04:00
David Steele
2c1687721e
Fix issue where specifying log-level-stderr > warn would cause a local/remote process to error on exit due to output found on stderr when none was expected.
...
The max value for a local/remote process is now error since there's no reason for these processes to emit warnings.
Reported by Clinton Adams.
2018-03-19 13:08:42 -04:00
David Steele
f0451c1494
Enable -Wformat=2 and -Wformat-nonliteral and silence new warnings.
2018-03-15 13:53:03 -04:00
David Steele
8a1ce42c30
Immediately error when a secure option (e.g. repo1-s3-key) is passed on the command line.
...
Since pgBackRest would not pass secure options on to sub-processes an obscure error was thrown. The new error is much clearer and provides hints about how to fix the problem.
Update command documentation to omit secure options that cannot be specified on the command-line.
Reported by Brad Nicholson.
2018-03-15 12:02:09 -04:00
David Steele
dd3ce70810
Config test code writes secure options to a file instead of passing on the command-line.
2018-03-15 11:09:46 -04:00
David Steele
cced6ec03a
Add ASSERT_DEBUG() macro for debugging.
...
Replace all current assert() calls except in tests that can't use the debug code.
2018-03-12 14:31:22 -04:00
Cynthia Shang
dd31ae832d
Port most of Config::Config::configLoad() from Perl to C.
...
Contributed by Cynthia Shang.
2018-03-12 11:25:20 -04:00
David Steele
03f1082e86
Improve logging.
...
Move command begin to C except when it must be called after another command in Perl (e.g. expire after backup). Command begin logs correctly for complex data types like hash and list. Specify which commands will log to file immediately and set the default log level for log messages that are common to all commands. File logging is initiated from C.
2018-03-12 11:03:38 -04:00
David Steele
fbe4c40386
Move logic for setting Perl configuration defaults to C.
2018-03-09 09:30:50 -05:00
David Steele
919635b6f4
Set config before Main::main() call to avoid secrets being exposed in a stack trace.
2018-03-08 16:24:16 -05:00
Cynthia Shang
34898ce471
Error when multiple arguments are set in the config file for an option that does not accept multiple arguments.
...
Contributed by Cynthia Shang.
2018-03-08 14:15:05 -05:00
David Steele
62a9bdbd4c
Fix issue passing --no-config to embedded Perl.
...
Reported by Ibrahim Edib Kokdemir.
2018-03-08 10:43:09 -05:00
Cynthia Shang
45ffe37e4f
Add cfgOptionTest().
...
Update cfgOption() calls that are better implemented as cfgOptionTest().
Contributed by Cynthia Shang.
2018-03-05 18:51:48 -05:00
David Steele
c07aa2ae19
Improve code documentation in config module.
2018-03-02 22:42:02 -05:00
David Steele
406acf9cba
Enable -Wconversion and silence new warnings.
2018-03-02 12:07:12 -05:00
David Steele
72cbb9a9d4
Call Perl with built-in interpreter instead of execvp().
...
Exec'ing Perl worked fine but generated a very large command line in the process list and potentially exposed secrets.
2018-02-14 17:19:54 -05:00
David Steele
fda62dfc48
Move Perl option JSON generation to a new module.
...
Linking exec.c into LibC will not be an option once the perl exec loads the Perl interpreter.
2018-02-14 09:49:01 -05:00
David Steele
5242e8eec5
Generate suppressions when running Valgrind.
...
This makes it easier to suppress errors that are only occurring on Travis.
2018-02-14 09:18:27 -05:00
Cynthia Shang
00e9aca872
Fixed issue where --reset-* was not passing the default value to Perl.
...
Contributed by Cynthia Shang.
2018-02-13 15:58:14 -05:00
David Steele
7c58fe7451
Use 64-bit integers for config options.
...
In particular, archive-queue-max requires a greater range than is provided by a 32-bit integer.
2018-02-09 13:54:33 -05:00
David Steele
305a3e1761
Add int64 variant type.
2018-02-09 13:52:02 -05:00
David Steele
1659598cfe
Create a master list of errors in build/error.yaml.
...
The C and Perl errors lists are created automatically by Build.pm so they stay up to date.
2018-02-08 16:11:47 -05:00
David Steele
7d13087c4b
Rename -no to -reset for non-boolean options.
2018-02-06 11:26:06 -05:00
David Steele
808b6000eb
Fix some bugs in C config code:
...
1) Error when the same option is defined multiple times in a section using alternate names.
2) Fix logging of invalid command error.
3) Warn when a stanza-only option is in a global section.
Also, make a note to add validation of section names to the check command.
Per review by Cynthia Shang.
2018-02-05 15:48:26 -05:00
David Steele
d35757c05f
Fix missing log-level-stderr option for stanza-* commands.
2018-02-05 15:19:28 -05:00
David Steele
c3f47bf240
Move config parsing out of Perl tests.
...
cfgParseTest() is provided in the C library for parsing configs in unit tests.
2018-02-05 12:32:30 -05:00
David Steele
db21b7a360
Cleanup usage of internal options.
...
Apply internal to options that need to be read to determine locality but should not appear in the help.
2018-02-05 11:50:09 -05:00
David Steele
be90028100
Rename db-* options to pg-* and backup-* options to repo-* to improve consistency.
...
* repo-* options are now indexed although only one is allowed.
* List deprecated option names in documentation and command-line help.
2018-02-03 18:27:38 -05:00
David Steele
298b33988c
Fix non-compliant formatting for function declarations.
...
Per review by Cynthia Shang.
2018-01-31 18:22:25 -05:00
David Steele
a91a648019
Config parsing no longer implemented in Perl.
...
Options are passed to Perl as JSON from the C process.
2018-01-28 21:37:09 -05:00
David Steele
f0ef1dee05
Improve speed of C unit tests.
...
Preserve object files between tests and use a Makefile to avoid rebuilding object files.
2018-01-26 16:41:17 -05:00
David Steele
b58a45e067
Implement help command in C.
2018-01-23 13:34:24 -05:00
David Steele
3dd882a79e
Add internal flag to config definition.
2018-01-23 12:49:04 -05:00
David Steele
41bd5e8148
Improve KeyValue object.
...
Add kvGetList() to get a value as a list (of 1) even if it is a scalar.
2018-01-23 12:40:02 -05:00
David Steele
2afb73da1c
Improve String, StringList, and List objects.
...
* Add strCmp*() and strFirst*() to String.
* Add strLstSort() and strLstNewSplitSize() to StringList.
* Add strLstNewSplitZ() to StringList a update calls to strLstNewSplit() as needed.
* Add lstSort to List.
2018-01-23 12:17:30 -05:00
David Steele
2cc9b2287b
The archive-push command is now partially coded in C.
...
This allows the PostgreSQL archive_command to run significantly faster when processing status messages from the asynchronous archive process.
2018-01-17 15:52:00 -05:00
David Steele
7c73f4f6c9
Add command and exit modules.
2018-01-17 09:15:51 -05:00
David Steele
39cb971afb
Add log module.
2018-01-16 13:52:20 -05:00
David Steele
eb452c8add
Improvements to Storage object.
...
* storagePath() and storageList() commands
* Helper functions for local and spool storag
2018-01-16 13:38:37 -05:00
David Steele
8f81620b9f
Improve error module.
...
Add functions to convert error codes to C errors and handle system errors.
2018-01-16 13:29:27 -05:00
David Steele
bffc6c49b3
Add perl-bin option to specify the Perl binary location when /usr/bin/env perl won't work.
2018-01-16 13:23:08 -05:00
David Steele
d633417e5d
Add Wait object and time module.
2018-01-16 13:05:00 -05:00
David Steele
721d1127a0
Add RegExp object.
2018-01-16 12:57:23 -05:00
David Steele
05c731692b
Add varStrForce() to Variant object.
2018-01-16 12:54:06 -05:00
David Steele
83ddd75d82
Improvements to String object.
...
* Add strBeginsWith(), strEndsWith(), strEq(), and strBase().
* Enable compiler type checking for strNewFmt() and strCatFmt().
* Rename strNewSzN() to strNewN().
2018-01-16 12:47:08 -05:00
David Steele
526acca5bd
Config parsing implemented in C.
2017-12-22 23:27:49 -05:00
David Steele
d8c575801d
Add Ini object.
2017-12-22 22:55:17 -05:00
David Steele
69488ca8ff
Add Storage object.
2017-12-22 22:36:01 -05:00
David Steele
b2a64b1f43
Add KeyValue object.
2017-12-22 22:05:37 -05:00
David Steele
2add6cef95
Add Variant and VariantList objects.
2017-12-22 21:50:27 -05:00
David Steele
c4b30af645
Add Buffer object.
2017-12-22 19:56:01 -05:00
David Steele
f89b027dec
Improve String and StringList modules.
2017-12-22 19:30:15 -05:00
David Steele
5ea1263d8e
Run valgrind on all C unit tests.
...
Also refactor code to make valgrind happy.
2017-12-22 18:36:36 -05:00
David Steele
8d4674031e
More config parsing in C in preparation for all config parsing in C.
2017-12-05 10:09:07 -05:00
David Steele
4f1725dc36
Replace cfgCommandTotal()/cfgOptionTotal() functions with constants.
...
The constants are applicable in more cases and allow the compiler to optimize certain loops more efficiently.
2017-12-05 09:45:51 -05:00
David Steele
915ae5662a
Implement version command in C.
2017-11-28 21:44:05 -05:00
David Steele
74d6398ad2
The pgbackrest executable is now a C binary instead of Perl.
...
This allows certain time-critical commands (like async archive-push) to run more quickly.
2017-11-26 18:43:51 -05:00
David Steele
4d8ad4ac18
Add List and StringList objects to simplify list handling.
2017-11-26 18:23:11 -05:00
David Steele
1b3e8e0a5b
Add String object to simplify string handling.
2017-11-26 17:49:10 -05:00
David Steele
c164fc5fb9
Add memGrowRaw() to memory context module.
2017-11-26 12:22:50 -05:00
David Steele
deae0b8cd7
Refactor C page checksum unit test to compile with -Wstrict-aliasing.
2017-11-20 08:58:47 -05:00
David Steele
5d741ea9a9
Refactor C unit test macros so they compile with -Wstrict-aliasing.
2017-11-19 16:46:31 -05:00
David Steele
3b43047e0d
Disable -Wclobber compiler warning.
...
...because it is mostly useless but keep the rest of of -Wextra.
2017-11-19 16:44:33 -05:00
David Steele
dc1a5c18ac
Wrap try in a do...while loop to make sure that no random else is attached to the main if block.
2017-11-19 16:30:23 -05:00
David Steele
9395ad7043
Improve base64 implementation.
...
Different encoded strings could be generated based on compiler optimizations. Even though decoding was still successful the encoded strings did not match the standard.
2017-11-18 22:49:43 -05:00
David Steele
cf7da546a3
Simplify try..catch..finally names.
2017-11-13 21:22:13 -05:00
David Steele
bcdfc7d0b5
Enable additional warnings for C builds.
2017-11-06 22:55:34 -05:00
David Steele
8d6a08a32b
Library code for repository encryption support.
2017-11-03 13:57:58 -04:00
David Steele
ac542788da
Convert configuration definitions from auto-generated functions to auto-generated data structures.
2017-11-02 08:14:13 -04:00
David Steele
55f68ef013
Remove configurable option hints.
...
db-path was the only option with a hint so the feature seemed wasteful. All missing stanza options now output the same hint without needing configuration.
2017-10-30 10:58:04 -04:00
David Steele
1ef27ec8c2
Add list type for options.
...
The hash type was being used for lists with an additional flag (`value-hash`) to indicate that it was not really a hash.
2017-10-30 10:50:35 -04:00
David Steele
f4524aeaa9
Add base64 encode/decode.
2017-10-18 11:14:26 -04:00
David Steele
583a76f605
Add C memory contexts.
2017-10-16 11:25:49 -04:00
David Steele
6f5186f9e6
Convert config tests into C unit tests.
2017-10-16 11:13:51 -04:00
David Steele
9d78948a14
Improvements to page checksum module and tests:
...
* Page checksum module uses new C error handler.
* Convert page checksum tests into C unit tests.
2017-10-16 11:03:06 -04:00
David Steele
80758f0023
Add test macros for C results and errors.
2017-10-16 10:54:35 -04:00
David Steele
f1e739b4aa
Add C error handler.
...
Basic try ... catch ... finally pattern to simplify error handling in C.
2017-10-16 10:09:56 -04:00
David Steele
10dfbd90b5
Add C unit test infrastructure.
2017-10-12 12:55:48 -04:00