Commit Graph

22 Commits

Author SHA1 Message Date
Tom Lane d3adaabaf7 Revert "pg_dump: Lock all relations, not just plain tables".
Revert 403a3d91c, as well as the followup fix 7f4235032, in all
branches.  We need to think a bit harder about what the behavior
of LOCK TABLE on views should be, and there's no time for that
before next week's releases.  We'll take another crack at this
later.

Discussion: https://postgr.es/m/16703-e348f58aab3cf6cc@postgresql.org
2020-11-06 15:48:04 -05:00
Alvaro Herrera 403a3d91c8
pg_dump: Lock all relations, not just plain tables
Now that LOCK TABLE can take any relation type, acquire lock on all
relations that are to be dumped.  This prevents schema changes or
deadlock errors that could cause a dump to fail after expending much
effort.  The server is tested to have the capability and the feature
disabled if it doesn't, so that a patched pg_dump doesn't fail when
connecting to an unpatched server.

Backpatch to 9.5.

Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reported-by: Wells Oliver <wells.oliver@gmail.com>
Discussion: https://postgr.es/m/20201021200659.GA32358@alvherre.pgsql
2020-10-27 14:31:37 -03:00
Tom Lane 8255c7a5ee Phase 2 pgindent run for v12.
Switch to 2.1 version of pg_bsd_indent.  This formats
multiline function declarations "correctly", that is with
additional lines of parameter declarations indented to match
where the first line's left parenthesis is.

Discussion: https://postgr.es/m/CAEepm=0P3FeTXRcU5B2W3jv3PgRVZ-kGUXLGfd42FFhUROO3ug@mail.gmail.com
2019-05-22 13:04:48 -04:00
Peter Eisentraut 0e1539ba0d Add some const decorations to prototypes
Reviewed-by: Fabien COELHO <coelho@cri.ensmp.fr>
2017-11-10 13:38:57 -05:00
Magnus Hagander d74048defc Make pg_dump error cleanly with -j against hot standby
Getting a synchronized snapshot is not supported on a hot standby node,
and is by default taken when using -j with multiple sessions. Trying to
do so still failed, but with a server error that would also go in the
log. Instead, proprely detect this case and give a better error message.
2016-05-26 22:14:23 +02:00
Alvaro Herrera 0eea8047bf pg_dump: Reduce use of global variables
Most pg_dump.c global variables, which were passed down individually to
dumping routines, are now grouped as members of the new DumpOptions
struct, which is used as a local variable and passed down into routines
that need it.  This helps future development efforts; in particular it
is said to enable a mode in which a parallel pg_dump run can output
multiple streams, and have them restored in parallel.

Also take the opportunity to clean up the pg_dump header files somewhat,
to avoid circularity.

Author: Joachim Wieland, revised by Álvaro Herrera
Reviewed by Peter Eisentraut
2014-10-14 15:00:55 -03:00
Robert Haas 1631598ea2 pg_dump: Further reduce reliance on global variables.
This is another round of refactoring to make things simpler for parallel
pg_dump.  pg_dump.c now issues SQL queries through the relevant Archive
object, rather than relying on the global variable g_conn.  This commit
isn't quite enough to get rid of g_conn entirely, but it makes a big
dent in its utilization and, along the way, manages to be slightly less
code than before.
2012-02-07 10:07:02 -05:00
Tom Lane 6545a901aa Fix pg_restore's direct-to-database mode for standard_conforming_strings.
pg_backup_db.c contained a mini SQL lexer with which it tried to identify
boundaries between SQL commands, but that code was not designed to cope
with standard_conforming_strings, and would get the wrong answer if a
backslash immediately precedes a closing single quote in such a string,
as per report from Julian Mehnle.  The bug only affects direct-to-database
restores from archive files made with standard_conforming_strings = on.

Rather than complicating the code some more to try to fix that, let's just
rip it all out.  The only reason it was needed was to cope with COPY data
embedded into ordinary archive entries, which was a layout that was used
only for about the first three weeks of the archive format's existence,
and never in any production release of pg_dump.  Instead, just rely on the
archive file layout to tell us whether we're printing COPY data or not.

This bug represents a data corruption hazard in all releases in which
standard_conforming_strings can be turned on, ie 8.2 and later, so
back-patch to all supported branches.
2011-07-28 14:06:57 -04:00
Magnus Hagander 9f2e211386 Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
Bruce Momjian fcd1b0d891 Mark a few functions as static or NOT_USED. 2006-07-18 17:42:01 +00:00
Bruce Momjian b85a965f5f Allow each C include file to compile on its own by including any needed
header files.
2006-07-11 13:54:25 +00:00
Tom Lane 7a28de2052 pg_dump can now dump large objects even in plain-text output mode, by
using the recently added lo_create() function.  The restore logic in
pg_restore is greatly simplified as well, since there's no need anymore
to try to adjust database references to match a new set of blob OIDs.
2005-06-21 20:45:44 +00:00
Tom Lane 9e733eab69 Modify pg_dump so that the preferred dump order is by name within
object types, rather than by OID.  This should help ensure consistent
dump output from databases that are logically the same but have different
histories, per recent discussion about 'diffing' databases.  The patch
is bulky because of renaming of fields, but not very complicated.
Also, do some tweaking to cause BLOB restoration to be done in a better
order, and clean up pg_restore's textual output to exactly match pg_dump.
2004-03-03 21:28:55 +00:00
PostgreSQL Daemon 969685ad44 $Header: -> $PostgreSQL Changes ... 2003-11-29 19:52:15 +00:00
Peter Eisentraut 6faf8024fa Enable large file support.
Use off_t and size_t in pg_dump to handle file offset arithmetic correctly.
2002-08-20 17:54:45 +00:00
Tom Lane 49bf04ba8c Fix some more not-schema-aware queries in pg_dump. Also fix some places
that would do the wrong thing with BLOB OIDs exceeding 2G.
2002-05-29 01:38:56 +00:00
Tom Lane 9f0ae0c820 First pass at schema-fying pg_dump/pg_restore. Much to do still,
but the basic capability seems to work.
2002-05-10 22:36:27 +00:00
Peter Eisentraut b559382134 National language support for pg_dump and pg_restore. Combined with big
message clean up.
2001-06-27 21:21:37 +00:00
Bruce Momjian 9e1552607a pgindent run. Make it all clean. 2001-03-22 04:01:46 +00:00
Philip Warner cfeccdf80a - Added CVS headers to files
- Avoid forcing table name to lower case in FixupBlobXrefs
 - Removed fmtId calls for all ArchiveEntry name fields. This fixes
   quoting problems in trigger enable/disable code for mixed case
   table names, and avoids commands like 'pg_restore -t '"TblA"'
2001-03-19 02:35:29 +00:00
Philip Warner 44954fae08 Added long-standing transaction when restoring BLOBS (uses commit every BLOB_BATCH_SIZE)
Prevent dumping of languages from template1.
2000-10-31 14:20:30 +00:00
Philip Warner c3e18804ff - Support for TAR output
- Support for BLOB output from pg_dump and input via pg_restore
- Support for direct DB connection in pg_restore
- Fixes in support for --insert flag
- pg_dump now outputs in modified OID order
2000-07-21 11:43:26 +00:00