Commit Graph

269 Commits

Author SHA1 Message Date
Bruce Momjian 12ee6ec71f In pg_upgrade, dump each database separately and use
--single-transaction to restore each database schema.  This yields
performance improvements for databases with many tables.  Also, remove
split_old_dump() as it is no longer needed.
2012-11-30 16:30:13 -05:00
Bruce Momjian bd9c8e741b Move long_options structures to the top of main() functions, for
consistency.

Per suggestion from Tom.
2012-11-30 14:49:55 -05:00
Bruce Momjian 49ec613201 In our source code, make a copy of getopt's 'optarg' string arguments,
rather than just storing a pointer.
2012-10-12 13:35:43 -04:00
Peter Eisentraut bb7520cc26 Make documentation of --help and --version options more consistent
Before, some places didn't document the short options (-? and -V),
some documented both, some documented nothing, and they were listed in
various orders.  Now this is hopefully more consistent and complete.
2012-06-18 02:46:59 +03:00
Bruce Momjian 927d61eeff Run pgindent on 9.2 source tree in preparation for first 9.3
commit-fest.
2012-06-10 15:20:04 -04:00
Peter Eisentraut 2273a50364 Realign some --help output to have better spacing between columns 2012-05-18 20:34:14 +03:00
Peter Eisentraut acfaa596cc pg_dump: Fix some minor memory leaks
Although we often don't care about freeing all memory in pg_dump,
these functions already freed the same memory in other code paths, so
we might as well do it consistently.

found by Coverity
2012-03-13 21:36:43 +02:00
Robert Haas e9a22259c4 Invent on_exit_nicely for pg_dump.
Per recent discussions on pgsql-hackers regarding parallel pg_dump.
2012-02-16 11:49:20 -05:00
Bruce Momjian e126958c2e Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
Magnus Hagander 16d8e594ac Remove spclocation field from pg_tablespace
Instead, add a function pg_tablespace_location(oid) used to return
the same information, and do this by reading the symbolic link.

Doing it this way makes it possible to relocate a tablespace when the
database is down by simply changing the symbolic link.
2011-12-07 10:37:33 +01:00
Tom Lane be2f909200 Remove duplicate definition of 'progname'.
Per buildfarm.
2011-11-29 23:19:46 -05:00
Tom Lane 0195e5c4ab Clean up after recent pg_dump patches.
Fix entirely broken handling of va_list printing routines, update some
out-of-date comments, fix some bogus inclusion orders, fix NLS declarations,
fix missed realloc calls.
2011-11-29 20:41:54 -05:00
Bruce Momjian 8b08deb0d1 Simplify the pg_dump/pg_restore error reporting macros, and allow
pg_dumpall to use the same memory allocation functions as the others.
2011-11-29 16:34:45 -05:00
Bruce Momjian 3c0afde11a Modify pg_dump to use error-free memory allocation macros. This avoids
ignoring errors and call-site error checking.
2011-11-25 15:40:51 -05:00
Robert Haas deb1580324 Remove hard-coded "\connect postgres" from pg_dumpall.
This doesn't appear to accompish anything useful, and does make the
restore fail if the postgres database happens to have been dropped.
2011-10-28 15:50:42 -04:00
Robert Haas dea95c7a7b Dump all roles first, then all config settings on roles.
This way, if a role's config setting uses the name of another role,
the validity of the dump isn't dependent on the order in which those
two roles are dumped.

Code by Phil Sorber, comment by me.
2011-10-14 14:16:02 -04:00
Robert Haas 463f2625a5 Support SECURITY LABEL on databases, tablespaces, and roles.
This requires a new shared catalog, pg_shseclabel.

Along the way, fix the security_label regression tests so that they
don't monkey with the labels of any pre-existing objects.  This is
unlikely to matter in practice, since only the label for the "dummy"
provider was being manipulated.  But this way still seems cleaner.

KaiGai Kohei, with fairly extensive hacking by me.
2011-07-20 13:18:24 -04:00
Peter Eisentraut 3439e40f9a Put options in some sensible order
For the --help output and reference pages of pg_dump, pg_dumpall,
pg_restore, put the options in some consistent, mostly alphabetical,
and consistent order, rather than newest option last or something like
that.
2011-05-25 21:53:26 +03:00
Peter Eisentraut c58b945e23 Message style improvements 2011-05-23 21:21:45 +03:00
Peter Eisentraut c8e0c32119 Rename pg_dump --no-security-label to --no-security-labels
Other similar options also use the plural form.
2011-05-19 23:20:11 +03:00
Peter Eisentraut ce2fc20071 Fix alignment of --help output
Tabs replaced by spaces.
2011-05-04 20:29:40 +03:00
Peter Eisentraut 5caa3479c2 Clean up most -Wunused-but-set-variable warnings from gcc 4.6
This warning is new in gcc 4.6 and part of -Wall.  This patch cleans
up most of the noise, but there are some still warnings that are
trickier to remove.
2011-04-11 22:28:45 +03:00
Bruce Momjian bf50caf105 pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
Robert Haas f78ba0a73a Woops. Previous patch to remove -X options missed getopt_long calls().
Noted by Tom Lane.
2011-03-18 21:23:28 -04:00
Robert Haas c5eb835bbf Remove ancient -X options to pg_dump, pg_dumpall, pg_restore.
The last version in which these options were documented is now EOL, so
it's time to get rid of them for real.  We now use GNU-style long
options instead.
2011-03-18 09:44:44 -04:00
Bruce Momjian d8d3d2a4f3 Fix pg_upgrade of large object permissions by preserving pg_auth.oid,
which is stored in pg_largeobject_metadata.

No backpatch to 9.0 because you can't migrate from 9.0 to 9.0 with the
same catversion (because of tablespace conflict), and a pre-9.0
migration to 9.0 has not large object permissions to migrate.
2011-01-07 21:59:29 -05:00
Bruce Momjian 5d950e3b0c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
Robert Haas 53dbc27c62 Support unlogged tables.
The contents of an unlogged table are WAL-logged; thus, they are not
available on standby servers and are truncated whenever the database
system enters recovery.  Indexes on unlogged tables are also unlogged.
Unlogged GiST indexes are not currently supported.
2010-12-29 06:48:53 -05:00
Magnus Hagander 9b8aff8c19 Add REPLICATION privilege for ROLEs
This privilege is required to do Streaming Replication, instead of
superuser, making it possible to set up a SR slave that doesn't
have write permissions on the master.

Superuser privileges do NOT override this check, so in order to
use the default superuser account for replication it must be
explicitly granted the REPLICATION permissions. This is backwards
incompatible change, in the interest of higher default security.
2010-12-29 11:05:03 +01:00
Robert Haas 4d355a8336 Add a SECURITY LABEL command.
This is intended as infrastructure to support integration with label-based
mandatory access control systems such as SE-Linux. Further changes (mostly
hooks) will be needed, but this is a big chunk of it.

KaiGai Kohei and Robert Haas
2010-09-27 20:55:27 -04:00
Magnus Hagander 9f2e211386 Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
Tom Lane e4155c8483 Fix pg_restore to complain if any arguments remain after parsing the switches
and input file name, per bug #5617 from Leo Shklovskii.  Rearrange the
corresponding code in pg_dump and pg_dumpall so that all three programs
handle this in a consistent, straightforward fashion.

Back-patch to 9.0, but no further.  Although this is certainly a bug, it's
possible that people have scripts that will be broken by the added error
check, so it seems better not to change the behavior in stable branches.
2010-08-13 14:38:04 +00:00
Tom Lane 3491520986 Code review for --quote-all-identifiers patch: add missing --help documentation
for new pg_dump/pg_dumpall parameters, make a couple of trivial stylistic
adjustments to make the code follow usual project style.
2010-08-03 19:24:05 +00:00
Robert Haas 4da29da181 Fix bogus server version in pg_dumpall --quote-all-identifiers. 2010-07-22 01:25:01 +00:00
Robert Haas ce68df468a Add options to force quoting of all identifiers.
I've added a quote_all_identifiers GUC which affects the behavior
of the backend, and a --quote-all-identifiers argument to pg_dump
and pg_dumpall which sets the GUC and also affects the quoting done
internally by those applications.

Design by Tom Lane; review by Alex Hunsaker; in response to bug #5488
filed by Hartmut Goebel.
2010-07-22 01:22:35 +00:00
Bruce Momjian 65e806cba1 pgindent run for 9.0 2010-02-26 02:01:40 +00:00
Tom Lane 50a90fac40 Stamp HEAD as 9.0devel, and update various places that were referring to 8.5
(hope I got 'em all).  Per discussion, this release will be 9.0 not 8.5.
2010-02-17 04:19:41 +00:00
Joe Conway f419a82c70 Modify recently added PQconnectdbParams() with new argument, expand_dbname.
If expand_dbname is non-zero and dbname contains an = sign, it is taken as
a conninfo string in exactly the same way as if it had been passed to
PQconnectdb. This is equivalent to the way PQsetdbLogin() works, allowing
PQconnectdbParams() to be a complete alternative.

Also improve the way the new function is called from psql and replace a
previously missed call to PQsetdbLogin() in psql. Additionally use
PQconnectdbParams() for pg_dump and friends, and the bin/scripts
command line utilities such as vacuumdb, createdb, etc.

Finally, update the documentation for the new parameter, as well as the
nuances of precedence in cases where key words are repeated or duplicated
in the conninfo string.
2010-02-05 03:09:05 +00:00
Bruce Momjian 6f8d2008fc Remove erroneous comma added to pg_dumpall tablespace query when running
with PG version 8.2-8.4.
2010-01-06 03:34:41 +00:00
Robert Haas d86d51a958 Support ALTER TABLESPACE name SET/RESET ( tablespace_options ).
This patch only supports seq_page_cost and random_page_cost as parameters,
but it provides the infrastructure to scalably support many more.
In particular, we may want to add support for effective_io_concurrency,
but I'm leaving that as future work for now.

Thanks to Tom Lane for design help and Alvaro Herrera for the review.
2010-01-05 21:54:00 +00:00
Bruce Momjian 0239800893 Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
Alvaro Herrera 2eda8dfb52 Make it possibly to specify GUC params per user and per database.
Create a new catalog pg_db_role_setting where they are now stored, and better
encapsulate the code that deals with settings into its realm.  The old
datconfig and rolconfig columns are removed.

psql has gained a \drds command to display the settings.

Backwards compatibility warning: while the backwards-compatible system views
still have the config columns, they no longer completely represent the
configuration for a user or database.

Catalog version bumped.
2009-10-07 22:14:26 +00:00
Tom Lane 249724cb01 Create an ALTER DEFAULT PRIVILEGES command, which allows users to adjust
the privileges that will be applied to subsequently-created objects.

Such adjustments are always per owning role, and can be restricted to objects
created in particular schemas too.  A notable benefit is that users can
override the traditional default privilege settings, eg, the PUBLIC EXECUTE
privilege traditionally granted by default for functions.

Petr Jelinek
2009-10-05 19:24:49 +00:00
Bruce Momjian d747140279 8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef list
provided by Andrew.
2009-06-11 14:49:15 +00:00
Tom Lane 4db44b433b Adjust pg_dumpall so that it emits ENCODING, LC_COLLATE, and LC_CTYPE options
in its CREATE DATABASE commands only for databases that have settings
different from the installation defaults.  This is a low-tech method of
avoiding unnecessary platform dependencies in dump files.  Eventually we ought
to have a platform-independent way of specifying LC_COLLATE and LC_CTYPE, but
that's not going to happen for 8.4, and this patch at least avoids the issue
for people who aren't setting up per-database locales.  ENCODING doesn't have
the platform dependency problem, but it seems consistent to make it act the
same as the locale settings.
2009-05-10 02:51:44 +00:00
Tom Lane e1e17e2a0a Fix pg_dumpall so that when --clean is specified, it drops roles and
tablespaces in an order that has some chance of working.
Per a complaint from Kevin Bailey.

This is a pre-existing bug, but given the lack of prior complaints I'm
not sure it's worth back-patching.  In most cases failure of the DROP
commands wouldn't be that important anyway.

In passing, fix syntax errors in dumpCreateDB()'s queries for old servers;
these were apparently introduced in recent binary_upgrade patch.
2009-04-11 20:23:05 +00:00
Heikki Linnakangas 84bb600be1 Quote string literals correctly in the new CREATE SERVER statements
and binary upgrade UPDATE statements.
2009-04-08 19:02:37 +00:00
Heikki Linnakangas 1eef90d0a2 Rename the new CREATE DATABASE options to set collation and ctype into
LC_COLLATE and LC_CTYPE, per discussion on pgsql-hackers.
2009-04-06 08:42:53 +00:00
Tom Lane 27fbfd396c Remove a boatload of useless definitions of 'int optreset'. If we
are using our own ports of getopt or getopt_long, those will define
the variable for themselves; and if not, we don't need these, because
we never touch the variable anyway.
2009-04-05 04:19:59 +00:00
Tom Lane 5698f6b925 Remove the -d and -D options of pg_dump and pg_dumpall. The functionality
is still available, but you must now write the long equivalent --inserts
or --column-inserts.  This change is made to eliminate confusion with the
use of -d to specify a database name in most other Postgres client programs.
Original patch by Greg Mullane, modified per subsequent discussion.
2009-03-22 16:44:26 +00:00
Peter Eisentraut b966b519f5 Provide some proper minimal documentation for the pg_dump(all) --binary-upgrade
option.  We don't want to commit to what it does, but hiding it will only
cause confusion.
2009-03-04 11:57:00 +00:00
Peter Eisentraut 9de59fd191 Add a -w/--no-password option that prevents all password prompts to all
programs that have a -W/--password option.

In passing, remove the ancient PSQL_ALWAYS_GET_PASSWORDS compile option.
2009-02-26 16:02:39 +00:00
Peter Eisentraut a3c502c89f Remove feof(stdin) calls related to when to prompt for a password,
leftovers from when the password was read from stdin.
2009-02-25 13:24:40 +00:00
Peter Eisentraut cd3b750929 Sort the output of --help mostly alphabetical, make it align better, make
help of pg_dump and pg_dumpall more similar.
2009-02-25 13:03:07 +00:00
Bruce Momjian 1d88d4e2c0 Have pg_dump/pg_dumpall --binary-upgrade restore frozenids for relations
and databases.
2009-02-18 12:07:08 +00:00
Bruce Momjian 6883c54a62 Add pg_dump --binary-upgrade flag to be used by binary upgrade
utilities.

The new code allows transfer of dropped column information to the
upgraded server.
2009-02-17 15:41:50 +00:00
Tom Lane 3cb5d6580a Support column-level privileges, as required by SQL standard.
Stephen Frost, with help from KaiGai Kohei and others
2009-01-22 20:16:10 +00:00
Bruce Momjian 32695413f3 Make pg_dump and pg_dumpall --clean options match the SGML docs, for consistency. 2009-01-06 18:01:57 +00:00
Tom Lane b0a6ad70a1 Add a --role option to pg_dump, pg_dumpall, and pg_restore. This allows
performing dumps and restores in accordance with a security policy that
forbids logging in directly as superuser, but instead specifies that you
should log into an admin account and then SET ROLE to the superuser.

In passing, clean up some ugly and mostly-broken code for quoting shell
arguments in pg_dumpall.

Benedek László, with some help from Tom Lane
2009-01-05 16:54:37 +00:00
Bruce Momjian 511db38ace Update copyright for 2009. 2009-01-01 17:24:05 +00:00
Peter Eisentraut 218b4e8dd8 Append major version number and for libraries soname major version number
to the gettext domain name, to simplify parallel installations.

Also, rename set_text_domain() to pg_bindtextdomain(), because that is what
it does.
2008-12-11 07:34:09 +00:00
Magnus Hagander 822f26069e Fix a few more format argument warnings. 2008-11-21 20:14:27 +00:00
Heikki Linnakangas 61d9674988 Make LC_COLLATE and LC_CTYPE database-level settings. Collation and
ctype are now more like encoding, stored in new datcollate and datctype
columns in pg_database.

This is a stripped-down version of Radek Strnad's patch, with further
changes by me.
2008-09-23 09:20:39 +00:00
Alvaro Herrera 7ad60b49dc Fixup pg_dumpall adding --lock-wait-timeout, to match pg_dump.
David Gould
2008-08-29 17:28:43 +00:00
Bruce Momjian a1183238be Use SYSTEMQUOTE as concatentation to strings, rather than %s printf
patterns, for clarity.
2008-06-26 01:35:45 +00:00
Tom Lane c22ed3d523 Turn the -i/--ignore-version options of pg_dump and pg_dumpall into no-ops:
the server version check is now always enforced.  Relax the version check to
allow a server that is of pg_dump's own major version but a later minor
version; this is the only case that -i was at all safe to use in.

pg_restore already enforced only a very weak version check, so this is
really just a documentation change for it.

Per discussion.
2008-04-13 03:49:22 +00:00
Bruce Momjian c22de3989b Strengthen warnings about using pg_dump's -i option. 2008-03-26 14:32:22 +00:00
Tom Lane 27dfc11d67 Dept of second thoughts: --no-tablespaces had better also prevent
pg_dumpall from attaching TABLESPACE options to CREATE DATABASE commands.
2008-03-20 17:42:51 +00:00
Tom Lane 68528d37bb Support a --no-tablespaces option in pg_dump/pg_dumpall/pg_restore, so that
dumps can be loaded into databases without the same tablespaces that the
source had.  The option acts by suppressing all "SET default_tablespace"
commands, and also CREATE TABLESPACE commands in pg_dumpall's case.

Gavin Roy, with documentation and minor fixes by me.
2008-03-20 17:36:58 +00:00
Bruce Momjian 9098ab9e32 Update copyrights in source tree to 2008. 2008-01-01 19:46:01 +00:00
Tom Lane 4f9bf7fc5a Fix up the PQconnectionUsedPassword mess: create a separate
PQconnectionNeedsPassword function that tells the right thing for whether to
prompt for a password, and improve PQconnectionUsedPassword so that it checks
whether the password used by the connection was actually supplied as a
connection argument, instead of coming from environment or a password file.
Per bug report from Mark Cave-Ayland and subsequent discussion.
2007-12-09 19:01:40 +00:00
Bruce Momjian fdf5a5efb7 pgindent run for 8.3. 2007-11-15 21:14:46 +00:00
Peter Eisentraut e4c26b03bf Make help synopsis consistent 2007-11-15 19:35:26 +00:00
Peter Eisentraut 27d18ffcc0 Error message cleanup 2007-11-07 13:11:05 +00:00
Peter Eisentraut 5f9869d0ee Use "alternative" instead of "alternate" where it is clearer. 2007-11-07 12:24:24 +00:00
Tom Lane 27c033ed98 Make pg_dump and friends consistently report both the filename and the
errno string when complaining of fopen failures.  Per gripe from Bob
Pawley, it's not always instantly obvious to the user which name we
tried to open.
2007-10-28 21:55:52 +00:00
Tom Lane 8468146b03 Fix the inadvertent libpq ABI breakage discovered by Martin Pitt: the
renumbering of encoding IDs done between 8.2 and 8.3 turns out to break 8.2
initdb and psql if they are run with an 8.3beta1 libpq.so.  For the moment
we can rearrange the order of enum pg_enc to keep the same number for
everything except PG_JOHAB, which isn't a problem since there are no direct
references to it in the 8.2 programs anyway.  (This does force initdb
unfortunately.)

Going forward, we want to fix things so that encoding IDs can be changed
without an ABI break, and this commit includes the changes needed to allow
libpq's encoding IDs to be treated as fully independent of the backend's.
The main issue is that libpq clients should not include pg_wchar.h or
otherwise assume they know the specific values of libpq's encoding IDs,
since they might encounter version skew between pg_wchar.h and the libpq.so
they are using.  To fix, have libpq officially export functions needed for
encoding name<=>ID conversion and validity checking; it was doing this
anyway unofficially.

It's still the case that we can't renumber backend encoding IDs until the
next bump in libpq's major version number, since doing so will break the
8.2-era client programs.  However the code is now prepared to avoid this
type of problem in future.

Note that initdb is no longer a libpq client: we just pull in the two
source files we need directly.  The patch also fixes a few places that
were being sloppy about checking for an unrecognized encoding name.
2007-10-13 20:18:42 +00:00
Tom Lane 8331c11f3f Get rid of client-code dependencies on the exact text of the no-password
error message, by using PQconnectionUsedPassword() instead.  Someday
we might be able to localize that error message, but not until this
coding technique has disappeared everywhere.
2007-07-08 19:07:38 +00:00
Alvaro Herrera d365ce1f5c Avoid emitting empty role names in the GRANTED BY clause of GRANT ROLE
when the grantor has been dropped.  This is a workaround for the fact
that we don't track the grantor as a shared dependency.
2007-05-15 20:20:21 +00:00
Peter Eisentraut 4ab8fcba8a StrNCpy -> strlcpy (not complete) 2007-02-10 14:58:55 +00:00
Bruce Momjian 6441288ec9 Add 'output file' option for pg_dumpall, especially useful for Win32,
where output redirection of child processes (pg_dump) doesn't work.

Dave Page
2007-01-25 03:30:43 +00:00
Bruce Momjian d37881fd90 Allow pg_dumpall to specify a database name rather than the default
'template1'.

Dave Page
2007-01-25 02:46:33 +00:00
Bruce Momjian 5ce94b28cc Add --tablespaces-only and --roles-only options to pg_dumpall.
Dave Page
2007-01-25 02:30:32 +00:00
Bruce Momjian 29dccf5fe0 Update CVS HEAD for 2007 copyright. Back branches are typically not
back-stamped for this.
2007-01-05 22:20:05 +00:00
Tom Lane 5fc2d7e451 Suppress timezone (%Z) part of timestamp display when running on Windows,
because on that platform strftime produces localized zone names in varying
encodings.  Even though it's only in a comment, this can cause encoding
errors when reloading the dump script.  Per suggestion from Andreas
Seltenreich.  Also, suppress %Z on Windows in the %s escape of
log_line_prefix ... not sure why this one is different from the other two,
but it shouldn't be.
2006-11-21 22:19:46 +00:00
Peter Eisentraut 2b25e1169f The -X option in pg_dump was supposed to be a workaround for the lack of
portable long options.  But we have had portable long options for a long
time now, so this is obsolete.  Now people have added options which *only*
work with -X but not as regular long option, so I'm putting a stop to this:
-X is deprecated; it still works, but it has been removed from the
documentation, and please don't add more of them.
2006-10-07 20:59:05 +00:00
Bruce Momjian f99a569a2e pgindent run for 8.2. 2006-10-04 00:30:14 +00:00
Tom Lane 9ba4065312 Remove separate strdup.h header file; it's redundant with port.h. 2006-09-27 15:41:24 +00:00
Bruce Momjian e0522505bd Remove 576 references of include files that were not needed. 2006-07-14 14:52:27 +00:00
Bruce Momjian 4fff9d7290 Document issues with non-default tablespaces and pg_dumpall restores.
Backpatch documentation addition to 8.1.X.
2006-06-16 22:01:17 +00:00
Bruce Momjian 399a36a75d Prepare code to be built by MSVC:
o  remove many WIN32_CLIENT_ONLY defines
	o  add WIN32_ONLY_COMPILER define
	o  add 3rd argument to open() for portability
	o  add include/port/win32_msvc directory for
	   system includes

Magnus Hagander
2006-06-07 22:24:46 +00:00
Bruce Momjian eaca1175e9 Escape processing patch:
o  turns off escape_string_warning in pg_dumpall.c
        o  optionally use E'' for \password (undocumented option?)
        o  honor standard_conforming-strings for \copy (but not
           support literal E'' strings)
        o  optionally use E'' for \d commands
        o  turn off escape_string_warning for createdb, createuser,
           droplang
2006-05-31 11:02:42 +00:00
Tom Lane 134b463f02 Fix up pg_dump to do string escaping fully correctly for client encoding
and standard_conforming_strings; likewise for the other client programs
that need it.  As per previous discussion, a pg_dump dump now conforms
to the standard_conforming_strings setting of the source database.
We don't use E'' syntax in the dump, thereby improving portability of
the SQL.  I added a SET escape_strings_warning = off command to keep
the dumps from getting a lot of back-chatter from that.
2006-05-28 21:13:54 +00:00
Bruce Momjian 7a846ecc00 Use E'' strings internally only when standard_conforming_strings =
'off'. This allows pg_dump output with standard_conforming_strings =
'on' to generate proper strings that can be loaded into other databases
without the backslash doubling we typically do.  I have added the
dumping of the standard_conforming_strings value to pg_dump.

I also added standard backslash handling for plpgsql.
2006-05-26 23:48:54 +00:00
Peter Eisentraut 79e371037b Add strerror to pg_dump error messages where missing. 2006-05-22 11:21:54 +00:00
Tom Lane 74bdf965a6 Fix pg_dumpall to do something sane when a pre-8.1 installation has
identically named user and group: we merge these into a single entity
with LOGIN permission.  Also, add ORDER BY commands to ensure consistent
dump ordering, for ease of comparing outputs from different installations.
2006-04-07 21:26:29 +00:00
Andrew Dunstan bee34e9930 Fix bad SQL, per Stefan Kaltenbrunner. 2006-03-30 01:08:15 +00:00
Bruce Momjian f2f5b05655 Update copyright for 2006. Update scripts. 2006-03-05 15:59:11 +00:00
Bruce Momjian 58634caa0f Add MSVC support for utility commands and pg_dump.
Hiroshi Saito
2006-02-12 06:11:51 +00:00
Bruce Momjian f9a726aa88 I've created a new shared catalog table pg_shdescription to store
comments on cluster global objects like databases, tablespaces, and
roles.

It touches a lot of places, but not much in the way of big changes.  The
only design decision I made was to duplicate the query and manipulation
functions rather than to try and have them handle both shared and local
comments.  I believe this is simpler for the code and not an issue for
callers because they know what type of object they are dealing with.
This has resulted in a shobj_description function analagous to
obj_description and backend functions [Create/Delete]SharedComments
mirroring the existing [Create/Delete]Comments functions.

pg_shdescription.h goes into src/include/catalog/

Kris Jurka
2006-02-12 03:22:21 +00:00
Bruce Momjian 1dc3498251 Standard pgindent run for 8.1. 2005-10-15 02:49:52 +00:00
Tom Lane c6b9924bec Remove the DELETEs from pg_shadow and pg_group that pg_dumpall used to
emit when given the --clean option, in favor of individual DROP ROLE
commands.  The old technique could not possibly work in 8.1, and was
never a very good idea anyway IMHO.  The DROP ROLE approach has the
defect that the DROPs will fail for roles that own objects or have
privileges, but perhaps we can improve that later.
2005-10-10 22:29:48 +00:00
Tom Lane 0845538f3a dumpUserConfig failed (in a pretty harmless way, but failed nonetheless)
to cope with a group name when dumping from a pre-8.1 installation.
Per report from Stefan Kaltenbrunner.
2005-08-28 16:31:37 +00:00
Tom Lane d42cf5a42a Add per-user and per-database connection limit options.
This patch also includes preliminary update of pg_dumpall for roles.
Petr Jelinek, with review by Bruce Momjian and Tom Lane.
2005-07-31 17:19:22 +00:00
Tom Lane 4a2972d691 Awhile back we replaced all uses of strcasecmp and strncasecmp with
pg_strcasecmp and pg_strncasecmp ... but I see some of the former have
crept back in.
Eternal vigilance is the price of locale independence, apparently.
2005-07-25 04:52:32 +00:00
Tom Lane affcb4371c Avoid use of E'', and thereby creating an unnecessary version-dependency,
by using LIKE...ESCAPE instead.  Per suggestion by andrew@supernews.
2005-07-18 19:12:09 +00:00
Tom Lane 0ed5f90d73 Try connecting to both postgres and template1 databases to do the initial
inspection of shared catalogs.  This allows pg_dumpall to continue to
work with pre-8.1 servers that likely won't have a database named postgres.
Also, suppress output of SYSID options for users and groups, since server
no longer does anything with these except emit a rude message.
There is much more to be done to update pg_dumpall for the roles feature,
but this at least makes it usable again.  Per gripe from Chris K-L.
2005-07-08 16:51:30 +00:00
Bruce Momjian bb3cce4ec9 Add E'' syntax so eventually normal strings can treat backslashes
literally.

Add GUC variables:

        "escape_string_warning" - warn about backslashes in non-E strings
        "escape_string_syntax" - supports E'' syntax?
        "standard_compliant_strings" - treats backslashes literally in ''

Update code to use E'' when escapes are used.
2005-06-26 03:04:37 +00:00
Tom Lane b49d871f6a Fix pg_dumpall to do the right thing with "postgres" database, per
Dave Page.  Also, cause it to emit rather than ignore any ACL and
datconfig options that may be set for these two databases.
2005-06-21 15:22:18 +00:00
Tom Lane 6f7fc0bade Cause initdb to create a third standard database "postgres", which
unlike template0 and template1 does not have any special status in
terms of backend functionality.  However, all external utilities such
as createuser and createdb now connect to "postgres" instead of
template1, and the documentation is changed to encourage people to use
"postgres" instead of template1 as a play area.  This should fix some
longstanding gotchas involving unexpected propagation of database
objects by createdb (when you used template1 without understanding
the implications), as well as ameliorating the problem that CREATE
DATABASE is unhappy if anyone else is connected to template1.
Patch by Dave Page, minor editing by Tom Lane.  All per recent
pghackers discussions.
2005-06-21 04:02:34 +00:00
Tom Lane c822fe05ae pg_dumpall should enforce the server version check for itself, rather
than simply passing it down to pg_dump.  Else, version-related failures
in pg_dumpall itself generate unhelpful error messages.
2005-04-18 23:47:52 +00:00
Bruce Momjian 0542b1e2fe Use _() macro consistently rather than gettext(). Add translation
macros around strings that were missing them.
2005-02-22 04:43:23 +00:00
PostgreSQL Daemon 2ff501590b Tag appropriate files for rc3
Also performed an initial run through of upgrading our Copyright date to
extend to 2005 ... first run here was very simple ... change everything
where: grep 1996-2004 && the word 'Copyright' ... scanned through the
generated list with 'less' first, and after, to make sure that I only
picked up the right entries ...
2004-12-31 22:04:05 +00:00
Tom Lane 2ee3a720a4 Adjust help message for --no-owner, per Alvaro Herrera. 2004-12-03 18:48:19 +00:00
Tom Lane 90c3ebe4d7 Fix HAVE_OPTRESET to be HAVE_INT_OPTRESET. Typos spotted by Lorne Sunley. 2004-11-27 18:51:08 +00:00
Bruce Momjian 88fd162ef6 Allow pg_ctl to determine the server is up when getting a request for a
password.

Make password error message a #define and use it consistently.

Sean Chittenden
2004-10-16 03:10:17 +00:00
Bruce Momjian a49f6ad014 Add full path in error report for version mismatch of binaries. 2004-10-15 04:32:28 +00:00
Bruce Momjian dedb53f29c Fix pg_dumpall to use double-quote for Win32 arguments.
Luiz K. Matsumura
2004-10-06 17:02:02 +00:00
Bruce Momjian b6b71b85bc Pgindent run for 8.0. 2004-08-29 05:07:03 +00:00
Bruce Momjian da9a8649d8 Update copyright to 2004. 2004-08-29 04:13:13 +00:00
Bruce Momjian 640d0dc0f0 Fix compiler warning in the proper way. 2004-08-08 07:00:22 +00:00
Bruce Momjian 6ec4520a5b Supress warning about zero-length format string. 2004-08-08 06:58:00 +00:00
Bruce Momjian 7ee3c35152 Allow libpgport to call memory allocation routines even though
CurrentMemoryContext is DLLIMPORT on Win32.  Work around that by
creating stubs in the backend for palloc/pstrdup.

Also fix pg_dumpall to do proper quoting on Win32.
2004-08-08 06:44:36 +00:00
Tom Lane fcbc438727 Label CVS tip as 8.0devel instead of 7.5devel. Adjust various comments
and documentation to reference 8.0 instead of 7.5.
2004-08-04 21:34:35 +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
Bruce Momjian a0db74a35c This patch adds the following options to pg_dumpall, to be passed to
pg_dump:

-S, --superuser=NAME

-O, --no-owner

-X disable-dollar-quoting, --disable-dollar-quoting

-X disable-triggers, --disable-triggers

Christopher Kings-Lynne
2004-07-12 14:35:45 +00:00
Tom Lane ba6b87f330 Fix pg_dump and pg_dumpall for new names of built-in tablespaces,
per Chris K-L.
2004-06-21 13:36:42 +00:00
Tom Lane 2467394ee1 Tablespaces. Alternate database locations are dead, long live tablespaces.
There are various things left to do: contrib dbsize and oid2name modules
need work, and so does the documentation.  Also someone should think about
COMMENT ON TABLESPACE and maybe RENAME TABLESPACE.  Also initlocation is
dead, it just doesn't know it yet.

Gavin Sherry and Tom Lane.
2004-06-18 06:14:31 +00:00
Bruce Momjian 10a3d19ad4 Handle multiple double-quoted strings using Win32's system() call.
Document limitations.
2004-06-10 16:35:18 +00:00
Bruce Momjian 3a0df651da Use single quotes around pg_dump call from pg_dumpall. 2004-06-09 17:37:28 +00:00
Bruce Momjian 7ac67fd189 Add time.h to pg_dumpall. 2004-06-09 17:05:14 +00:00
Bruce Momjian 9136613803 Add start/stop times for pg_dump/pg_dumpall when verbose output is used. 2004-06-07 20:35:57 +00:00
Bruce Momjian 641c5b565b Slight code cleanup for printf's. 2004-06-05 04:27:48 +00:00
Bruce Momjian 6870843339 Add PGETC (for pg_service.conf) and PGLOCALE (for locale dir)
environment variable processing to libpq.

The patch also adds code to our client apps so we set the environment
variable directly based on our binary location, unless it is already
set. This will allow our applications to emit proper locale messages
that are generated in libpq.
2004-06-03 00:07:38 +00:00
Bruce Momjian 228897774c Make the locale location relocatable.
Adjust get_*_path functions to be limited to MAXPGPATH.
2004-05-25 01:00:30 +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 9f944f0443 Adjust find_my_exec/find_other_exec() so that the return parameter is
last, not first.  This fits our style better.
2004-05-14 17:04:48 +00:00
Bruce Momjian b1ffacddfc Rename find_my_binary/find_other_binary to
find_my_exec/find_other_exec().  Remove passing of progname to these
functions as they can find that out from argv[0], which they already
have.

Make get_progname return const char *, and update all progname variables
to be const char *.
2004-05-12 13:38:49 +00:00
Bruce Momjian fda15b351a As part of the work for making relocatable installs, I have re-factored
all the code that looks for other binaries.  I move FindExec into
port/exec.c (and renamed it to find_my_binary()).  I also added
find_other_binary that looks for another binary in the same directory as
the calling program, and checks the version string.

The only behavior change was that initdb and pg_dump would look in the
hard-coded bindir directory if it can't find the requested binary in the
same directory as the caller.  The new code throws an error.  The old
behavior seemed too error prone for version mismatches.
2004-05-11 21:57:15 +00:00
Tom Lane 5ad7d65da4 Fix incorrect dumping of database LOCATION from 7.0.* servers.
Per report from Mattias Kregert.
2004-01-22 19:09:32 +00:00
PostgreSQL Daemon 969685ad44 $Header: -> $PostgreSQL Changes ... 2003-11-29 19:52:15 +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 33ab177a56 Don't assume that struct option is available just because we can find a
getopt_long().  This is more or less the same problem as we saw earlier
with getaddrinfo() and struct addrinfo, and for the same reason: random
user-added libraries might contain the subroutine, but there's no
guarantee we will find the matching header files.
2003-08-07 21:11:58 +00:00
Bruce Momjian f3c3deb7d0 Update copyrights to 2003. 2003-08-04 02:40:20 +00:00
Bruce Momjian 089003fb46 pgindent run. 2003-08-04 00:43:34 +00:00
Tom Lane f353f8e83b There is no reason to cast valuntil to timestamp, and a very good
reason not to: it fails for an 'invalid' abstime.  Per bug report
of today's date.
2003-07-29 14:17:37 +00:00
Peter Eisentraut c154fc3a20 Apply message style guide to frontend programs. 2003-07-23 08:47:41 +00:00
Tom Lane dd81eee222 Use libpq's new logic to get the server version, instead of doing it ourselves. 2003-06-22 00:56:58 +00:00
Bruce Momjian 8de72414ea Document the -h client flag can use a socket directory as well as a host
name.
2003-06-11 05:13:12 +00:00
Tom Lane 9e1e72b698 Cause pg_dumpall to support the -a, -s, -x options of pg_dump. 2003-05-30 23:55:10 +00:00