Commit Graph

3459 Commits

Author SHA1 Message Date
Peter Eisentraut a671d9409b pg_dump: Dump user mappings ordered by user name
This is to get a deterministic dump order independent of the order in
which the user mappings were created.
2011-12-29 21:16:15 +02:00
Peter Eisentraut 66843265ee Indicate default format in --help output of pg_dump and pg_basebackup 2011-12-28 21:06:12 +02:00
Peter Eisentraut 037a82704c Standardize treatment of strcmp() return value
Always compare the return value to 0, don't use cute tricks like
if (!strcmp(...)).
2011-12-27 21:19:09 +02:00
Peter Eisentraut d383c23f6f Remove support for on_exit()
All supported platforms support the C89 standard function atexit()
(SunOS 4 probably being the last one not to), and supporting both
makes the code clumsy.
2011-12-27 20:57:59 +02:00
Robert Haas 0e4611c023 Add a security_barrier option for views.
When a view is marked as a security barrier, it will not be pulled up
into the containing query, and no quals will be pushed down into it,
so that no function or operator chosen by the user can be applied to
rows not exposed by the view.  Views not configured with this
option cannot provide robust row-level security, but will perform far
better.

Patch by KaiGai Kohei; original problem report by Heikki Linnakangas
(in October 2009!).  Review (in earlier versions) by Noah Misch and
others.  Design advice by Tom Lane and myself.  Further review and
cleanup by me.
2011-12-22 16:16:31 -05:00
Peter Eisentraut 729205571e Add support for privileges on types
This adds support for the more or less SQL-conforming USAGE privilege
on types and domains.  The intent is to be able restrict which users
can create dependencies on types, which restricts the way in which
owners can alter types.

reviewed by Yeb Havinga
2011-12-20 00:05:19 +02:00
Alvaro Herrera 61d81bd28d Allow CHECK constraints to be declared ONLY
This makes them enforceable only on the parent table, not on children
tables.  This is useful in various situations, per discussion involving
people bitten by the restrictive behavior introduced in 8.4.

Message-Id:
8762mp93iw.fsf@comcast.net
CAFaPBrSMMpubkGf4zcRL_YL-AERUbYF_-ZNNYfb3CVwwEqc9TQ@mail.gmail.com

Authors: Nikhil Sontakke, Alex Hunsaker
Reviewed by Robert Haas and myself
2011-12-19 17:30:23 -03:00
Tom Lane fb4bbc8113 Add missing 'static' qualifier. 2011-12-16 23:19:06 -05:00
Andrew Dunstan a4cd6abcc9 Add --section option to pg_dump and pg_restore.
Valid values are --pre-data, data and post-data. The option can be
given more than once. --schema-only is equivalent to
--section=pre-data --section=post-data. --data-only is equivalent
to --section=data.

Andrew Dunstan, reviewed by Joachim Wieland and Josh Berkus.
2011-12-16 19:09:38 -05:00
Andrew Dunstan 7b070e896c Add --exclude-table-data option to pg_dump.
Andrew Dunstan, reviewed by Josh Berkus, Robert Haas and Peter Geoghegan.

This allows dumping of a table definition but not its data, on a per table basis.
Table name patterns are supported just as for --exclude-table.
2011-12-14 09:23:17 -05:00
Andrew Dunstan 0f44335122 Miscellaneous cleanup to silence compiler warnings seen on Mingw.
Remove some dead code, conditionally declare some items or call
some code, and fix one or two declarations.
2011-12-10 18:15:15 -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 c6e3ac11b6 Create a "sort support" interface API for faster sorting.
This patch creates an API whereby a btree index opclass can optionally
provide non-SQL-callable support functions for sorting.  In the initial
patch, we only use this to provide a directly-callable comparator function,
which can be invoked with a bit less overhead than the traditional
SQL-callable comparator.  While that should be of value in itself, the real
reason for doing this is to provide a datatype-extensible framework for
more aggressive optimizations, as in Peter Geoghegan's recent work.

Robert Haas and Tom Lane
2011-12-07 00:19:39 -05:00
Robert Haas 68281e0054 Make command-line tools smarter about finding a DB to connect to.
If unable to connect to "postgres", try "template1".  This allows things to
work more smoothly in the case where the postgres database has been
dropped.  And just in case that's not good enough, also allow the user to
specify a maintenance database to be used for the initial connection, to
cover the case where neither postgres nor template1 is suitable.
2011-12-06 08:48:15 -05:00
Andrew Dunstan e6d9e2106f Add a \setenv command to psql.
This can be used to set (or unset) environment variables that will
affect programs called by psql (such as the PAGER), probably most
usefully in a .psqlrc file.

Andrew Dunstan, reviewed by Josh Kupershmidt.
2011-12-04 11:43:38 -05:00
Peter Eisentraut b6f9834a9e psql: Make temporary editor files have .sql extension
This gives editors a better chance to treat these files as the SQL
files that they are.
2011-12-02 23:38:33 +02: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
Peter Eisentraut 9922fc5f9f pg_dump: Add gettext plural support to error message 2011-11-29 19:49:02 +02:00
Peter Eisentraut cc534f8b3c pg_dump: Fix clean rule after file renaming shuffle 2011-11-29 06:30:45 +02:00
Tom Lane 9761ad672f Fix some bogosities in pg_dump's foreign-table support.
The server name for a foreign table was not quoted at need, as per report
from Ronan Dunklau.  Also, queries related to FDW options were inadequately
schema-qualified in places where the search path isn't just pg_catalog, and
were inconsistently formatted everywhere, and we didn't always check that
we got the expected number of rows from them.
2011-11-28 12:51:41 -05:00
Bruce Momjian 9a7d49d1fb Move pg_dump memory routines into pg_dumpmem.c/h and restore common.c
with its original functions.  The previous function migration would
cause too many difficulties in back-patching.
2011-11-26 22:34:36 -05:00
Alvaro Herrera f717f4bca2 Fix unvalidated check constraints on domains, too
Same bug as reported by Thom Brown for check constraints on tables: the
constraint must be dumped separately from the domain, otherwise it is
restored before the data and thus prevents potentially-violating data
from being loaded in the first place.

Per Dean Rasheed
2011-11-25 18:19:18 -03: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
Bruce Momjian 35e27226b6 Allow pg_upgrade to upgrade clusters that use exclusion contraints by
fixing pg_dump to properly preserve such indexes.

Backpatch to 9.1 and 9.0 (where the bug was introduced).
2011-11-25 14:40:27 -05:00
Alvaro Herrera e90710f34a Dump an unvalidated constraint separately from its table
This allows possibly violating data to be imported before the constraint
is installed.

Bug reported by Thom Brown
2011-11-24 18:40:38 -03:00
Tom Lane 74c1723fc8 Remove user-selectable ANALYZE option for range types.
It's not clear that a per-datatype typanalyze function would be any more
useful than a generic typanalyze for ranges.  What *is* clear is that
letting unprivileged users select typanalyze functions is a crash risk or
worse.  So remove the option from CREATE TYPE AS RANGE, and instead put in
a generic typanalyze function for ranges.  The generic function does
nothing as yet, but hopefully we'll improve that before 9.2 release.
2011-11-23 00:03:22 -05:00
Tom Lane b985d48779 Further code review for range types patch.
Fix some bugs in coercion logic and pg_dump; more comment cleanup;
minor cosmetic improvements.
2011-11-20 23:50:27 -05:00
Tom Lane a1a233af66 Further review of range-types patch.
Lots of documentation cleanup today, and still more type_sanity tests.
2011-11-18 18:24:32 -05:00
Robert Haas ff4fd4bf53 Don't elide blank lines when accumulating psql command history.
This can change the meaning of queries, if the blank line happens to
occur in the middle of a quoted literal, as per complaint from Tomas Vondra.

Back-patch to all supported branches.
2011-11-15 20:34:47 -05:00
Peter Eisentraut 95d2af1646 Add psql expanded auto mode
This adds the "auto" option to the \x command, which switches to the
expanded mode when the normal output would be wider than the screen.

reviewed by Noah Misch
2011-11-12 17:03:10 +02:00
Robert Haas a6ce8ba2f3 Fix psql's \dd version check for operator families.
Report and patch by Josh Kupershmidt; comment revisions by me.
2011-11-11 23:33:44 -05:00
Tom Lane 6f3dc00e24 Throw nice error if server is too old to support psql's \ef or \sf command.
Previously, you'd get "function pg_catalog.pg_get_functiondef(integer) does
not exist", which is at best rather unprofessional-looking.  Back-patch
to 8.4 where \ef was introduced.

Josh Kupershmidt
2011-11-10 18:36:49 -05:00
Tom Lane cf22e851b6 Avoid platform-dependent infinite loop in pg_dump.
If malloc(0) returns NULL, the binary search in findSecLabels() will
probably go into an infinite loop when there are no security labels,
because NULL-1 is greater than NULL after wraparound.

(We've seen this pathology before ... I wonder whether there's a way to
detect the class of bugs automatically?)

Diagnosis and patch by Steve Singer, cosmetic adjustments by me
2011-11-10 16:09:01 -05:00
Magnus Hagander ebcadba29f Show statistics target for columns in \d+ on a table 2011-11-05 13:02:48 +01:00
Magnus Hagander 6f81a1f668 Make psql \d on a sequence show the table/column owning it 2011-11-05 12:54:58 +01:00
Magnus Hagander 6187df1532 Add missing space in comment 2011-11-04 15:57:43 +01:00
Magnus Hagander 3b06105c7d Properly close replication connection in pg_receivexlog 2011-11-03 15:44:02 +01:00
Magnus Hagander e7cc8437bb Pre-pad WAL files when streaming transaction log
Instead of filling files as they appear, pre-pad the
WAL files received when streaming xlog the same way
that the server does. Data is streamed into a .partial
file which is then renamed()d into palce when it's complete,
but it will always be 16MB.

This also means that the starting position for pg_receivexlog
is now simply right after the last complete segment, and we
never need to deal with partial segments there.

Patch by me, review by Fujii Masao
2011-11-03 15:37:08 +01:00
Heikki Linnakangas 4429f6a9e3 Support range data types.
Selectivity estimation functions are missing for some range type operators,
which is a TODO.

Jeff Davis
2011-11-03 13:42:15 +02: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
Bruce Momjian 360429e1d1 Fix pg_bsd_indent bug where newlines were not being trimmed from typedef
lines.  Update pg_bsd_indent required version to 1.1 (and update ftp
site).

Problem reported by Magnus.
2011-10-26 17:24:19 -04:00
Magnus Hagander d9bae53173 Implement streaming xlog for backup tools
Add option for parallel streaming of the transaction log while a
base backup is running, to get the logfiles before the server has
removed them.

Also add a tool called pg_receivexlog, which streams the transaction
log into files, creating a log archive without having to wait for
segments to complete, thus decreasing the window of data loss without
having to waste space using archive_timeout. This works best in
combination with archive_command - suggested usage docs etc coming later.
2011-10-26 20:13:33 +02:00
Magnus Hagander 2b64f3f17a MingW doesn't support wcstombs_s()... 2011-10-26 19:26:13 +02:00
Magnus Hagander 9c4c8c8468 Remove argument decoration that appears unsupported on mingw 2011-10-25 21:30:53 +02:00
Magnus Hagander d8ea33f2c0 Support configurable eventlog application names on Windows
This allows different instances to use the eventlog with different
identifiers, by setting the event_source GUC, similar to how
syslog_ident works.

Original patch by MauMau, heavily modified by Magnus Hagander
2011-10-25 20:02:55 +02:00
Magnus Hagander a74a5f5913 Make TABLE tab complation in psql include all relations
Not just tables, since views also work fine with the
TABLE command.
2011-10-24 13:22:59 +02:00
Tom Lane 8140c1bcf3 Make psql support tab completion of EXECUTE <prepared-statement-name>.
Andreas Karlsson, reviewed by Josh Kupershmidt
2011-10-23 19:25:34 -04:00
Tom Lane bb446b689b Support synchronization of snapshots through an export/import procedure.
A transaction can export a snapshot with pg_export_snapshot(), and then
others can import it with SET TRANSACTION SNAPSHOT.  The data does not
leave the server so there are not security issues.  A snapshot can only
be imported while the exporting transaction is still running, and there
are some other restrictions.

I'm not totally convinced that we've covered all the bases for SSI (true
serializable) mode, but it works fine for lesser isolation modes.

Joachim Wieland, reviewed by Marko Tiikkaja, and rather heavily modified
by Tom Lane
2011-10-22 18:23:30 -04:00