pg_dump reporing version of server & pg_dump as comments in the output - Mailing list pgsql-hackers

From Wang, Jing
Subject pg_dump reporing version of server & pg_dump as comments in the output
Date
Msg-id F40B0968DB0A904DA78A924E633BE7863C25F6@SYDEXCHTMP2.au.fjanz.com
Whole thread Raw
Responses Re: pg_dump reporing version of server & pg_dump as comments in the output
List pgsql-hackers
<div class="WordSection1"><p class="MsoNormal">Enclosed is the patch to implement the requirement that pg_dump should
reportversion of server & pg_dump as comments in the output. <p class="MsoNormal"> <p class="MsoNormal">[Benefit]<p
class="MsoNormal">Byrunning "head" on pg_dump output, you can readily discover what version of PostgreSQL was used to
generatethat dump. Very useful especially for "mouldy old database dumps."<p class="MsoNormal">The benefit of this
requirementis to let user clearly understand from which version the dump output file will be insert into which version
databaseserver and easy handle the problems of Incompatibility versions.<p class="MsoNormal"> <p
class="MsoNormal">[Analysis]<pclass="MsoNormal">Using pg_dump can dump the data into the file with format set to be
'c','t'or plain text. In the existing version the version of server & pg_dump is already there when the format of
fileis 'c' or 't'. And even for the plain text format file the version of server & pg_dump is already there if
using'--verbose' in pg_dump. Using '--verbose' leads to some many other prints which are not required always. <p
class="MsoNormal"> <pclass="MsoNormal">So the requirement is dump the version of server & pg_dump as comment into
theplain text format output file even without using '--verbose' option.<p class="MsoNormal"> <p
class="MsoNormal">[Solutiondetails]<p class="MsoNormal">The main change is in the pg_backup_archiver.c file, in the
function'RestoreArchive' the version of server & pg_dump is only print when finding the '--verbose' option to be
usedin current version.  Now we just let the printing works even without finding the '--verbose' option.<p
class="MsoNormal"> <pclass="MsoNormal">[what is changed when applying the patch]<p class="MsoNormal">1. The output file
whichis created by pg_dump with format set to be 'plain text' and without using ‘--verbose’ option will include the
versionof server & pg_dump. One example is  as following:<p class="MsoNormal">--<p class="MsoNormal">-- PostgreSQL
databasedump<p class="MsoNormal">--<p class="MsoNormal"> <p class="MsoNormal">-- Dumped from database version 9.2.4<p
class="MsoNormal">--Dumped by pg_dump version 9.4devel<p class="MsoNormal"> <p class="MsoNormal">SET statement_timeout
=0;<p class="MsoNormal">SET lock_timeout = 0;<p class="MsoNormal">SET client_encoding = 'UTF8';<p
class="MsoNormal">...<pclass="MsoNormal"> <p class="MsoNormal">2. The output file which is created by pg_dumpall with
formatset to be 'plain text' and without using ‘--verbose’ option will include the version of server & pg_dump. The
exampleis as following:<p class="MsoNormal"> <p class="MsoNormal">--<p class="MsoNormal">-- PostgreSQL database cluster
dump<pclass="MsoNormal">--<p class="MsoNormal"> <p class="MsoNormal">SET default_transaction_read_only = off;<p
class="MsoNormal"> <pclass="MsoNormal">...<p class="MsoNormal"> <p class="MsoNormal">\connect connectdb<p
class="MsoNormal"> <pclass="MsoNormal">SET default_transaction_read_only = off;<p class="MsoNormal"> <p
class="MsoNormal">--<pclass="MsoNormal">-- PostgreSQL database dump<p class="MsoNormal">--<p class="MsoNormal"> <p
class="MsoNormal">--Dumped from database version 9.2.4<p class="MsoNormal">-- Dumped by pg_dump version 9.4devel<p
class="MsoNormal"> <pclass="MsoNormal">SET statement_timeout = 0;<p class="MsoNormal">SET lock_timeout = 0;<p
class="MsoNormal">SETclient_encoding = 'UTF8';<p class="MsoNormal">SET standard_conforming_strings = on;<p
class="MsoNormal"> <pclass="MsoNormal">...<p class="MsoNormal"> <p class="MsoNormal">\connect postgres<p
class="MsoNormal"> <pclass="MsoNormal">SET default_transaction_read_only = off;<p class="MsoNormal"> <p
class="MsoNormal">--<pclass="MsoNormal">-- PostgreSQL database dump<p class="MsoNormal">--<p class="MsoNormal"> <p
class="MsoNormal">--Dumped from database version 9.2.4<p class="MsoNormal">-- Dumped by pg_dump version 9.4devel<p
class="MsoNormal"> <pclass="MsoNormal">SET statement_timeout = 0;<p class="MsoNormal">SET lock_timeout = 0;<p
class="MsoNormal">SETclient_encoding = 'UTF8';<p class="MsoNormal">SET standard_conforming_strings = on;<p
class="MsoNormal">SETcheck_function_bodies = false;<p class="MsoNormal"> <p class="MsoNormal"> <p class="MsoNormal">3.
Theversion of server and pg_dump will be dumped into the output file. The output file is created by the following
command:<pclass="MsoNormal">pg_restore inputFile -f output.sql <p class="MsoNormal"> <p class="MsoNormal">One example
isas following:<p class="MsoNormal">--<p class="MsoNormal">-- PostgreSQL database dump<p class="MsoNormal">--<p
class="MsoNormal"> <pclass="MsoNormal">-- Dumped from database version 9.2.4<p class="MsoNormal">-- Dumped by pg_dump
version9.4devel<p class="MsoNormal"> <p class="MsoNormal">SET statement_timeout = 0;<p class="MsoNormal">SET
lock_timeout= 0;<p class="MsoNormal">SET client_encoding = 'UTF8';<p class="MsoNormal">SET standard_conforming_strings
=on;<p class="MsoNormal">…<p class="MsoNormal"> <p class="MsoNormal"> <p class="MsoNormal">Kind regards<p
class="MsoNormal">Jing</div>

pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: Another possible corruption bug in 9.3.2 or possibly a known MultiXact problem?
Next
From: Tom Lane
Date:
Subject: Windows exit code 128 ... it's baaack