Commit Graph

93 Commits

Author SHA1 Message Date
Bruce Momjian daa076c4fd > Please find attached a submission to add a "exit on error" option to
> pg_restore, as it seems that some people have scripts that rely on the
> previous "abort on error" default behavior when restoring data with a
> direct connection.
>
> Fabien Coelho
2004-08-20 04:20:23 +00:00
Tom Lane 2193121fa9 Fix breakage with PUBLIC schema. Try to untwist the remarkably contorted
logic a little bit.
2004-08-13 21:37:28 +00:00
Tom Lane 576856b698 Dump comments on columns of composite types.
Instead of putting all the OWNER TO commands at the end, it dumps then
after each object.  This is WAY more readable and nice.  ACLs are still
at the end.

Christopher Kings-Lynne
2004-08-04 17:13:03 +00:00
Bruce Momjian 45995219a0 Here is another patch that fixes a stack of pg_dump bugs:
* Fix help text ordering

* Add back --set-session-authorization to pg_dumpall.  Updated the docs
for that.  Updated help for that.

* Dump ALTER USER commands for the cluster owner ("pgsql").  These are
dumped AFTER the create user and create database commands in case the
permissions to do these have been revoked.

* Dump ALTER OWNER for public schema (because it's possible to change
it).  This was done by adding TOC entries for the public schema, and
filtering them out at archiver time.  I also save the owner in the TOC
entry just for the public schema.

* Suppress dumping single quotes around schema_path and DateStyle
options when they are set using ALTER USER or ALTER DATABASE.  Added a
comment to the steps in guc.c to remind people to update that list.

* Fix dumping in --clean mode against a pre-7.3 server.  It just sets
all drop statements to assume the public schema, allowing it to restore
without error.

* Cleaned up text output.  eg. Don't output -- Tablespaces comment if
there are none.  Same for groups and users.

* Make the commands to DELETE FROM pg_shadow and DELETE FROM pg_group
only be output when -c mode is enabled.  I'm not sure why that hasn't
been done before?!?!

This should be good for application asap, after which I will start on
regression dumping 7.0-7.4 databases.

Christopher Kings-Lynne
2004-07-19 21:39:48 +00:00
Tom Lane 465edca3ec Fix incorrect tracking of session authorization in the presence of ACLs
that contain rights granted by non-owners.  Per bug report from
Nishad Prakash.
2004-07-19 21:02:17 +00:00
Bruce Momjian dc0e76ca36 Change pg_dump to use ALTER OWNER commands instead of SET SESSION
AUTHORIZATION commands by default.  Move all GRANT and REVOKE commands
to the end of the dump to avoid restore failures in several situations.
Bring back --use-set-session-authorization option to get previous SET
behaviour

Christopher Kings-Lyne
2004-07-13 03:00:17 +00:00
Bruce Momjian bef228d1ee Add end-of-dump markers for pg_dump and pg_dumpall. 2004-05-19 21:21:26 +00:00
Bruce Momjian ec7c4c1b66 Please find attached a small patch so that "pg_restore" ignores some sql
errors. This is the second submission, which integrates Tom comments about
localisation and exit code. I also added some comments about one sql
command which is not ignored.

Fabien COELHO
2004-04-22 02:39:10 +00:00
Bruce Momjian f23cce73b3 Use the new GUC variable default_with_oids in pg_dump, rather than using
WITH/WITHOUT OIDS in dump files.  This makes dump files more portable.

I have updated the pg_dump version so old binary dumps will load fine.

Pre-7.5 dumps use WITHOUT OIDS in SQL were needed, so they should be
fine.
2004-03-24 03:06:08 +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
Tom Lane 92bec9a0bc Cause pg_dump to emit a 'SET client_encoding' command at the start of
any restore operation, thereby ensuring that dumped data is interpreted
the same way it was dumped even if the target database has a different
encoding.  Per suggestions from Pavel Stehule and others.  Also,
simplify scheme for handling check_function_bodies ... we may as well
just set that at the head of the script.
2004-02-24 03:35:19 +00:00
Tom Lane 9a4ef0c562 Fix ReadOffset() to work correctly when off_t is wider than int. 2004-01-04 04:02:15 +00:00
Tom Lane 005a1217fb Massive overhaul of pg_dump: make use of dependency information from
pg_depend to determine a safe dump order.  Defaults and check constraints
can be emitted either as part of a table or domain definition, or
separately if that's needed to break a dependency loop.  Lots of old
half-baked code for controlling dump order removed.
2003-12-06 03:00:16 +00:00
PostgreSQL Daemon 969685ad44 $Header: -> $PostgreSQL Changes ... 2003-11-29 19:52:15 +00:00
Tom Lane 3b64171edb Complain if pg_restore is given both -d and -f options; this suggests
the user is confused about whether -f is input or output file.
2003-10-20 21:05:12 +00:00
Tom Lane ef88199f61 Issue 'SET check_function_bodies = false' to suppress possible restore
failures in SQL functions, due to forward references or unqualified
references to objects in other schemas.  Per recent discussion.
2003-10-03 20:10:59 +00:00
Tom Lane a9e9abebd9 Issue CREATE SCHEMA as the originally connecting user, with an
AUTHORIZATION clause to specify the desired owner.  This allows a
superuser to restore schemas owned by users without CREATE-SCHEMA
permissions (ie, schemas originally created by a superuser using
AUTHORIZATION).  --no-owner can be specified to suppress the
AUTHORIZATION clause if need be.
2003-09-23 23:31:52 +00:00
Tom Lane 6767cebc6f pg_dump/pg_restore now always use SET SESSION AUTHORIZATION, not \connect,
to control object ownership.  The use-set-session-authorization and
no-reconnect switches are obsolete (still accepted on the command line,
but they don't do anything).  This is a precursor to fixing handling
of CREATE SCHEMA, which will be a separate commit.
2003-09-23 22:48:53 +00:00
Tom Lane 209a8d63df pg_dump and pg_restore -r had managed to diverge on the ordering of
different object types.  Fix, and centralize logic to try to prevent
the same mistake in future.
2003-08-28 20:21:34 +00:00
Bruce Momjian 089003fb46 pgindent run. 2003-08-04 00:43:34 +00:00
Peter Eisentraut c154fc3a20 Apply message style guide to frontend programs. 2003-07-23 08:47:41 +00:00
Tom Lane f85f43dfb5 Backend support for autocommit removed, per recent discussions. The
only remnant of this failed experiment is that the server will take
SET AUTOCOMMIT TO ON.  Still TODO: provide some client-side autocommit
logic in libpq.
2003-05-14 03:26:03 +00:00
Tom Lane 228697179a Fix erroneous space calculation leading to core dump in dumpProcLangs,
per report from Olivier Prenant.  Also fix off-by-one space calculation
in ReadToc; this woould not have hurt us until we had more than 100
dependencies for a single object, but wrong is wrong.
2003-05-03 22:18:59 +00:00
Tom Lane e4704001ea This patch fixes a bunch of spelling mistakes in comments throughout the
PostgreSQL source code.

Neil Conway
2003-03-10 22:28:22 +00:00
Tom Lane b9e8ffcd5d pg_restore failed to restore blobs if -X disable-triggers is specified. 2003-03-09 19:38:52 +00:00
Bruce Momjian 3f6333357f Make pg_dump/restore safer for autocommit=off in postgresql.conf. 2003-02-14 19:40:42 +00:00
Tom Lane e0a1ee2053 Cleaner solution to the problem of loading pre-7.3 dumps containing
columns of type lo (see contrib/lo).  Rather than hacking the function
definitions on-the-fly, just modify the queries issued by FixupBlobRefs
so that they work even if CREATE CAST hasn't been issued.
2003-02-01 22:06:59 +00:00
Tom Lane 4b833d080b Prevent core dump when die_horribly() is called with null AH pointer.
Problem reported and fixed by Oliver Elphick.
2003-01-27 00:23:38 +00:00
Hiroshi Inoue de432ce39e Change Adjust_lo_type() so that it doesn't cause an error
even when cast functions are allowed to be volatile.
2003-01-13 04:28:55 +00:00
Hiroshi Inoue 150ffb2d50 Adjust lo type in contrib during pg_restore so that pg_restore could
reload the type.
2003-01-03 18:05:02 +00:00
Bruce Momjian 1b7f3cc02d This patch implements FOR EACH STATEMENT triggers, per my email to
-hackers a couple days ago.

Notes/caveats:

        - added regression tests for the new functionality, all
          regression tests pass on my machine

        - added pg_dump support

        - updated PL/PgSQL to support per-statement triggers; didn't
          look at the other procedural languages.

        - there's (even) more code duplication in trigger.c than there
          was previously. Any suggestions on how to refactor the
          ExecXXXTriggers() functions to reuse more code would be
          welcome -- I took a brief look at it, but couldn't see an
          easy way to do it (there are several subtly-different
          versions of the code in question)

        - updated the documentation. I also took the liberty of
          removing a big chunk of duplicated syntax documentation in
          the Programmer's Guide on triggers, and moving that
          information to the CREATE TRIGGER reference page.

        - I also included some spelling fixes and similar small
          cleanups I noticed while making the changes. If you'd like
          me to split those into a separate patch, let me know.

Neil Conway
2002-11-23 03:59:09 +00:00
Tom Lane 7a0671a37c Suppress compile warnings on OS X. 2002-10-27 02:52:10 +00:00
Bruce Momjian 3fd6d3260f Change to fseeko(), per Philip. 2002-10-25 03:47:30 +00:00
Bruce Momjian fc5c577e34 Allow fseeko in pg_dump only if fseeko() will work for all supported file
sizes.
2002-10-25 01:33:17 +00:00
Bruce Momjian 2b287020f4 Allow 8-byte off_t to properly pg_dump, from Philip Warner with mods by Bruce. 2002-10-22 19:15:23 +00:00
Bruce Momjian cda776e613 Make pg_dump save for autocommit = off. 2002-10-16 05:46:54 +00:00
Bruce Momjian e50f52a074 pgindent run. 2002-09-04 20:31:48 +00:00
Peter Eisentraut 7af5ea736f Reimplement pg_dumpall in C. Currently no change in functionality,
except that it's more robust, reconnects less often, and is NLS'ed.
2002-08-27 18:57:26 +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
Peter Eisentraut c828ec8820 Make pg_dump output more portable and more pleasing to look at.
The -n and -N options were removed.  Quoting is now smart enough to
supply quotes if and only if necessary.

Numerical types are now printed without quotes, except in cases of
special values such as NaN.

Boolean values printed as true and false.

Most string literals now do not escape whitespace characters (newlines,
etc.) for portability.

SET SESSION AUTHORIZATION argument is a string literal, to follow SQL.

Made commands output by pg_dump use consistent spacing and indentation.
2002-08-18 09:36:26 +00:00
Peter Eisentraut 029aa97f2d Make sure all clients have the same understanding of default user name
and database.  In particular, make script wrappers understand the
PGDATABASE environment variable.
2002-08-10 16:57:32 +00:00
Bruce Momjian d59478c4f3 More clearly document in pg_dump when we are dealing with an object name
as it appears in the schema dump, and index tags.
2002-07-04 15:35:07 +00:00
Bruce Momjian 3722dee6d9 Document function args are required for pg_restore -P.
Fix pg_dump to not quote the function name in the storage tag.
Fix pg_dump so GRANT/REVOKE(ACL) tag entries are not quoted, for
	consistency.
Fix pg_restore to properly handle quotes and some spaces in -P.
2002-07-04 03:04:55 +00:00
Bruce Momjian f4590995c9 The attached patch fixes 2 memory leaks in pg_dump, as well as corrects
a spelling mistake and deletes an antiquated comment.

Neil Conway
2002-07-02 05:49:52 +00:00
Tom Lane 9ca89b4f8c Another place that needs schema qualification. 2002-05-29 01:49:57 +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 36a1e732a6 Rework pg_dump namespace search criteria so that dumping of user objects
having names conflicting with system objects will work --- the search
path is now user-schema, pg_catalog rather than implicitly the other way
around.  Note this requires being careful to explicitly qualify references
to system names whenever pg_catalog is not first in the search path.
Also, add support for dumping ACLs of schemas.
2002-05-28 22:26:57 +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
Tom Lane 340b66cc70 Cause fmtId to always use its internal buffer for the returned value,
in hopes of making erroneous usage more apparent.  Per discussion 15-Apr.
2002-05-06 17:34:45 +00:00
Bruce Momjian 8be68479dc Remove compile warnings for lo dump by casting to char *. 2002-04-24 14:03:22 +00:00