|
17 | 17 | #include <ctype.h>
|
18 | 18 |
|
19 | 19 | #include "dumputils.h"
|
20 |
| -#include "pg_backup.h" |
21 | 20 |
|
22 | 21 | #include "parser/keywords.h"
|
23 | 22 |
|
@@ -1230,6 +1229,37 @@ emitShSecLabels(PGconn *conn, PGresult *res, PQExpBuffer buffer,
|
1230 | 1229 | }
|
1231 | 1230 |
|
1232 | 1231 |
|
| 1232 | +/* |
| 1233 | + * Parse a --section=foo command line argument. |
| 1234 | + * |
| 1235 | + * Set or update the bitmask in *dumpSections according to arg. |
| 1236 | + * dumpSections is initialised as DUMP_UNSECTIONED by pg_dump and |
| 1237 | + * pg_restore so they can know if this has even been called. |
| 1238 | + */ |
| 1239 | +void |
| 1240 | +set_dump_section(const char *arg, int *dumpSections) |
| 1241 | +{ |
| 1242 | + /* if this is the first call, clear all the bits */ |
| 1243 | + if (*dumpSections == DUMP_UNSECTIONED) |
| 1244 | + *dumpSections = 0; |
| 1245 | + |
| 1246 | + if (strcmp(arg,"pre-data") == 0) |
| 1247 | + *dumpSections |= DUMP_PRE_DATA; |
| 1248 | + else if (strcmp(arg,"data") == 0) |
| 1249 | + *dumpSections |= DUMP_DATA; |
| 1250 | + else if (strcmp(arg,"post-data") == 0) |
| 1251 | + *dumpSections |= DUMP_POST_DATA; |
| 1252 | + else |
| 1253 | + { |
| 1254 | + fprintf(stderr, _("%s: unknown section name \"%s\")\n"), |
| 1255 | + progname, arg); |
| 1256 | + fprintf(stderr, _("Try \"%s --help\" for more information.\n"), |
| 1257 | + progname); |
| 1258 | + exit_nicely(1); |
| 1259 | + } |
| 1260 | +} |
| 1261 | + |
| 1262 | + |
1233 | 1263 | /*
|
1234 | 1264 | * Write a printf-style message to stderr.
|
1235 | 1265 | *
|
@@ -1279,35 +1309,6 @@ exit_horribly(const char *modulename, const char *fmt,...)
|
1279 | 1309 | exit_nicely(1);
|
1280 | 1310 | }
|
1281 | 1311 |
|
1282 |
| -/* |
1283 |
| - * Set the bitmask in dumpSections according to the first argument. |
1284 |
| - * dumpSections is initialised as DUMP_UNSECTIONED by pg_dump and |
1285 |
| - * pg_restore so they can know if this has even been called. |
1286 |
| - */ |
1287 |
| - |
1288 |
| -void |
1289 |
| -set_section (const char *arg, int *dumpSections) |
1290 |
| -{ |
1291 |
| - /* if this is the first, clear all the bits */ |
1292 |
| - if (*dumpSections == DUMP_UNSECTIONED) |
1293 |
| - *dumpSections = 0; |
1294 |
| - |
1295 |
| - if (strcmp(arg,"pre-data") == 0) |
1296 |
| - *dumpSections |= DUMP_PRE_DATA; |
1297 |
| - else if (strcmp(arg,"data") == 0) |
1298 |
| - *dumpSections |= DUMP_DATA; |
1299 |
| - else if (strcmp(arg,"post-data") == 0) |
1300 |
| - *dumpSections |= DUMP_POST_DATA; |
1301 |
| - else |
1302 |
| - { |
1303 |
| - fprintf(stderr, _("%s: unknown section name \"%s\")\n"), |
1304 |
| - progname, arg); |
1305 |
| - fprintf(stderr, _("Try \"%s --help\" for more information.\n"), |
1306 |
| - progname); |
1307 |
| - exit_nicely(1); |
1308 |
| - } |
1309 |
| -} |
1310 |
| - |
1311 | 1312 | /* Register a callback to be run when exit_nicely is invoked. */
|
1312 | 1313 | void
|
1313 | 1314 | on_exit_nicely(on_exit_nicely_callback function, void *arg)
|
|
0 commit comments