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/>

>

Reply via email to