Re: Non-text mode for pg_dumpall
Srinath Reddy Sadipiralla <srinath2133@gmail.com>
From: Srinath Reddy <srinath2133@gmail.com>
To: Mahendra Singh Thalor <mahi6run@gmail.com>, jian.universality@gmail.com
Cc: pgsql-hackers@lists.postgresql.org
Date: 2025-02-03T08:53:38Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Add non-text output formats to pg_dumpall
- 763aaa06f034 19 (unreleased) landed
-
Improve pg_dump/pg_dumpall help synopses and terminology
- dec6643487bb 18.0 cited
-
Non text modes for pg_dumpall, correspondingly change pg_restore
- 1495eff7bdb0 18.0 landed
-
Doc: manually break lines in wide UUID examples.
- a6524105d20b 18.0 cited
Hi,
I found a bug ,while using "./pg_restore pdd -f -" actually it has to copy
everything(global sql commands + remaining dump ) into stdout as per the
"-f, --file=FILENAME output file name (- for stdout)" but it is
copying global sql commands to a file literally naming it as "-" and
remaining dump is written to stdout without those global sql commands."-"
is not a output file it signifies stdout in terminal cmds.so we have to
handle this case.
because of above reason "./pg_restore pdd -g -f -" also does the same
creates a file "-" and writes globals to that file instead of stdout.
This is the delta patch to handle this case.please have a look and give
some feedback.
@@ -84,7 +84,7 @@ static int restoreAllDatabases(PGconn *conn, const char
*dumpdirpath,
SimpleStringList
db_exclude_patterns, RestoreOptions *opts, int numWorkers);
static void execute_global_sql_commands(PGconn *conn, const char
*dumpdirpath,
const char *outfile);
-static void copy_global_file_to_out_file(const char *outfile, FILE *pfile);
+static void copy_global_file(const char *outfile, FILE *pfile);
static int filter_dbnames_for_restore(PGconn *conn,
SimpleDatabaseOidList *dbname_oid_list,
- ofile = fopen(out_file_path, PG_BINARY_W);
+ if (strcmp(outfile, "-") == 0){
+ int fn = fileno(stdout);
+ ofile = fdopen(dup(fn), PG_BINARY_W);
+ }
+ else{
+ snprintf(out_file_path, MAXPGPATH, "%s", outfile);
+ ofile = fopen(out_file_path, PG_BINARY_W);
+ }
+
if (ofile == NULL)
{
Regards,
Srinath Reddy Sadipiralla,
EDB: https://www.enterprisedb.com <http://www.enterprisedb.com/>
>