Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tesLd-00G9IG-8U for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Feb 2025 09:02:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tesLc-00BfMl-C2 for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Feb 2025 09:02:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tesLb-00BfMd-UR for pgsql-hackers@lists.postgresql.org; Mon, 03 Feb 2025 09:02:28 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tesLZ-002vAa-2Q for pgsql-hackers@lists.postgresql.org; Mon, 03 Feb 2025 09:02:27 +0000 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-ab2c9b8aecaso696970266b.0 for ; Mon, 03 Feb 2025 01:02:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738573345; x=1739178145; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=SJcbMK1DBCujjwk4HZ3z4wasiRR5BLAJ7WzoGzpJ5Jc=; b=l2XkSwQ/z2DMpKvWkIIfeh5rQ19oCJSruH6S7b188hfH21NEfP9cx8aCnTt1gw/Y3Y ETTs1orkFqvcXlbXludv6GHw4Uk3rJjzIXQweFuNdyx26t4Yb3gL0UBt6Vc/i6nzoPET WLAAIidWzmDYGatRe4Ohlg9f6VagXvxCcrHHJmTZXVqpPlUf+PjjncbNlnwSR9TT2LeC 5lyCipXTp5DOZBsPA4dw/dq27DZDGri9zy6tt3lO4QhReeh/1f3nIA2/o9r70bzZcPiy 1gB/DS+l5KyO81Rfel0gCnYYynfZ6QGXU4ZBO7GI3IEW+XInS6gFMLFU2fja98gLtbwM 1fSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738573345; x=1739178145; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SJcbMK1DBCujjwk4HZ3z4wasiRR5BLAJ7WzoGzpJ5Jc=; b=iERDZi155f/dXO95nJfSeh+X4qJFMe1hxqcGqJadGLp21I7aMJJ3xi902MXZky6LFD kBmMfJH/aCRZcN9cJEfqsfMZ+jPzCGPCNNHbuafrTGe/pTtFFxIMNg+bU8wBtHFXqGVv Aj/rgoF3JhZuBGhwZEsGeJB3Esj66DbUlra4krFRmdJMKrl9lSsokI+M1ZP9pD5Y4AJt o3bX4cDlbU6/okmnJszrwR/FxCKzp57kwmiY30bHrCxsrJwAy1C01cA26VXGtKWH3uD1 96Yau6EKAv2oPjIjeL94HNBP2U1r035scWYO98nga5SjFiy4gBAIu0SPgv1gnNuD/4Fw Qivw== X-Gm-Message-State: AOJu0Yxq/QjFO4TJZ3Z55RaRLHVK0KiPqfm6YdgK5xyD6MSy712rXLYi Ya5D4oAP5TuLEvXxSQt3R3KjEyeyCG3DSMkT/rz5inaP/a1I3XQjNYYvg7SbYVgrNhpNc92x6jW iupmpJqW0l85aa8da91FpJFtYoJs= X-Gm-Gg: ASbGncsWWMGxig4kQsu7NsHDPptguwsjiF9nQcb6/ImD6pPog2ZnMacLmhqEkArggFZ d18GPeJijZb2c2TQupua36FLh0shdd0b0I5Xhdvn3Iw0EPoFrD1hbyJlRrfnMW6P3QDUWvAPvHg == X-Google-Smtp-Source: AGHT+IF2fi3BORkEI/xrzmLm4UcfqY22A5Mx7kRi+vsWbDkuWwN7ChFscKqB9OZYJ6AxYSknX0D5bgTFC3HDAFddNRc= X-Received: by 2002:a17:907:7244:b0:aab:da48:493e with SMTP id a640c23a62f3a-ab6cfceb50bmr1817695566b.21.1738573344105; Mon, 03 Feb 2025 01:02:24 -0800 (PST) MIME-Version: 1.0 References: <202501110844.5ztsym4vbflm@alvherre.pgsql> In-Reply-To: From: Srinath Reddy Date: Mon, 3 Feb 2025 14:32:11 +0530 X-Gm-Features: AWEUYZnrE_02YVpBlqu3FVZMKzEmAU0dhNQC1cy2QNHdM4qCtOrZ6UVKz1_9MqI Message-ID: Subject: Re: Non-text mode for pg_dumpall To: Mahendra Singh Thalor , jian.universality@gmail.com Cc: pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000097701f062d3926f6" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000097701f062d3926f6 Content-Type: text/plain; charset="UTF-8" here's the whole version of delta patch diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c index 42c4fe3ce2..90e6b71a50 100644 --- a/src/bin/pg_dump/pg_restore.c +++ b/src/bin/pg_dump/pg_restore.c @@ -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, SimpleStringList db_exclude_patterns); @@ -1178,7 +1178,7 @@ execute_global_sql_commands(PGconn *conn, const char *dumpdirpath, const char *o */ if (outfile) { - copy_global_file_to_out_file(outfile, pfile); + copy_global_file(outfile, pfile); return; } @@ -1207,24 +1207,35 @@ execute_global_sql_commands(PGconn *conn, const char *dumpdirpath, const char *o } /* - * copy_global_file_to_out_file + * copy_global_file * - * This will copy global.dat file into out file. + * This will copy global.dat file into out file, if file is given + * else copies to stdout. + * */ static void -copy_global_file_to_out_file(const char *outfile, FILE *pfile) +copy_global_file(const char *outfile, FILE *pfile) { char out_file_path[MAXPGPATH]; FILE *ofile; int c; - snprintf(out_file_path, MAXPGPATH, "%s", outfile); - 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) { fclose(pfile); - pg_fatal("could not open file: \"%s\"", out_file_path); + pg_fatal("could not open file: \"%s\"", outfile); } /* Now append global.dat into out file. */ > Regards, > Srinath Reddy Sadipiralla, > EDB: https://www.enterprisedb.com > >> --00000000000097701f062d3926f6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
here's the whole version of delta pat= ch

diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_re= store.c
index 42c4fe3ce2..90e6b71a50 100644
--- a/src/bin/pg_dump/pg_= restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -84,7 +84,7 @@ static= int restoreAllDatabases(PGconn *conn, const char *dumpdirpath,
=C2=A0 = =C2=A0 SimpleStringList db_exclude_patterns, RestoreOptions *opts, in= t numWorkers);
=C2=A0static void execute_global_sql_commands(PGconn *con= n, const char *dumpdirpath,
=C2=A0 const char *outfile);
-st= atic void copy_global_file_to_out_file(const char *outfile, FILE *pfile);+static void copy_global_file(const char *outfile, FILE *pfile);
=C2= =A0static int filter_dbnames_for_restore(PGconn *conn,
=C2=A0 = =C2=A0SimpleDatabaseOidList *dbname_oid_list,
=C2=A0 =C2=A0Simp= leStringList db_exclude_patterns);
@@ -1178,7 +1178,7 @@ execute_global_= sql_commands(PGconn *conn, const char *dumpdirpath, const char *o
=C2=A0= */
=C2=A0 if (outfile)
=C2=A0 {
- copy_global_file_to_out_file(= outfile, pfile);
+ copy_global_file(outfile, pfile);
=C2=A0 return;=
=C2=A0 }
=C2=A0
@@ -1207,24 +1207,35 @@ execute_global_sql_comman= ds(PGconn *conn, const char *dumpdirpath, const char *o
=C2=A0}
=C2= =A0
=C2=A0/*
- * copy_global_file_to_out_file
+ * copy_global_file=
=C2=A0 *
- * This will copy global.dat file into out file.
+ * Th= is will copy global.dat file into out file, if file is given
+ * else co= pies to stdout.
+ *
=C2=A0 */
=C2=A0static void
-copy_global_f= ile_to_out_file(const char *outfile, FILE *pfile)
+copy_global_file(cons= t char *outfile, FILE *pfile)
=C2=A0{
=C2=A0 char out_file_path[MAXPG= PATH];
=C2=A0 FILE *ofile;
=C2=A0 int c;
=C2=A0
- snprintf(out= _file_path, MAXPGPATH, "%s", outfile);
- ofile =3D fopen(out_f= ile_path, PG_BINARY_W);
+ if (strcmp(outfile, "-") =3D=3D 0)+ {
+ int fn =3D fileno(stdout);
+ ofile =3D fdopen(dup(fn), PG_B= INARY_W);
+ }
+ else
+ {
+ snprintf(out_file_path, MAXPGPATH, = "%s", outfile);
+ ofile =3D fopen(out_file_path, PG_BINARY_W)= ;
+ }
+
=C2=A0
=C2=A0 if (ofile =3D=3D NULL)
=C2=A0 {
=C2= =A0 fclose(pfile);
- pg_fatal("could not open file: \"%s\&qu= ot;", out_file_path);
+ pg_fatal("could not open file: \"= ;%s\"", outfile);
=C2=A0 }
=C2=A0
=C2=A0 /* Now append g= lobal.dat into out file. */
=C2=A0
<= div dir=3D"ltr">
Regards,
Srinath Reddy Sadipiralla,
EDB:=C2=A0https://www.enterprisedb.com
--00000000000097701f062d3926f6--