Commit Graph

3301 Commits

Author SHA1 Message Date
Peter Eisentraut 11745364d0 Add collation support on Windows (MSVC build)
There is not yet support in initdb to populate the pg_collation
catalog, but if that is done manually, the rest should work.
2011-04-10 00:15:41 +03:00
Tom Lane 7c76906b7e Don't show unusable collations in psql's \dO command.
"Unusable" collations are those not matching the current database's
encoding.  The former behavior inconsistently showed such collations
some of the time, depending on the details of the pattern argument.
2011-04-09 14:08:41 -04:00
Robert Haas cba9cd4192 Make psql use pg_table_size instead of pg_relation_size on 9.0+ servers.
Per discussion, pg_table_size() is a more helpful number than
pg_relation_size().

Bernd Helmle, reviewed by Susanne Ebrecht and me.
2011-04-08 15:52:49 -04:00
Tom Lane d4c810d570 Modify initdb to complain only when no usable system locales are found.
Per discussion, the original behavior seems too noisy.  But if things
are so broken that none of the locales reported by "locale -a" are usable,
that's probably worth warning about.
2011-04-08 15:39:25 -04:00
Bruce Momjian 9c38bce29c Have pg_upgrade properly preserve relfrozenxid in toast tables.
This fixes a pg_upgrade bug that could lead to query errors when clog
files are improperly removed.
2011-04-08 11:46:34 -04:00
Tom Lane 1471a147f0 Fix SortTocFromFile() to cope with lines that are too long for its buffer.
The original coding supposed that a dump TOC file could never contain lines
longer than 1K.  The folly of that was exposed by a recent report from
Per-Olov Esgard.  We only really need to see the first dozen or two bytes
of each line, since we're just trying to read off the numeric ID at the
start of the line; so there's no need for a particularly huge buffer.
What there is a need for is logic to not process continuation bufferloads.

Back-patch to all supported branches, since it's always been like this.
2011-04-07 11:40:23 -04:00
Bruce Momjian 82a4f37073 Preserve pg_largeobject_metadata.relfrozenxid in pg_upgrade.
This is needed only in 9.1 because only 9.0 had this and no one is
upgrading from a 9.0 beta to 9.0 anymore.  We basically don't backpatch
9.0 beta fixes at this point.
2011-04-07 09:57:09 -04:00
Robert Haas e49ad77ff9 Tab completion for COMMENT ON FOREIGN DATA WRAPPER / SERVER. 2011-04-01 13:15:49 -04:00
Robert Haas dd095b623e pg_dump support for comments on FOREIGN DATA WRAPPER and SERVER objects.
Shigeru Hanada, with some corrections.
2011-04-01 11:41:07 -04:00
Greg Stark 7b66e2c086 fix up a couple non-prototypes of the form foo() to be foo(void) -- found using -Wstrict-prototypes 2011-03-27 21:31:41 +01:00
Tom Lane 5d1d679dbf Make initdb ignore locales for client-only encodings.
While putting such entries into pg_collation is harmless (since backends
will ignore entries that don't match the database encoding), it's also
useless.
2011-03-22 17:20:50 -04:00
Tom Lane 176d5bae1d Fix up handling of C/POSIX collations.
Install just one instance of the "C" and "POSIX" collations into
pg_collation, rather than one per encoding.  Make these instances exist
and do something useful even in machines without locale_t support: to wit,
it's now possible to force comparisons and case-folding functions to use C
locale in an otherwise non-C database, whether or not the platform has
support for using any additional collations.

Fix up severely broken upper/lower/initcap functions, too: the C/POSIX
fastpath now does what it is supposed to, and non-default collations are
handled correctly in single-byte database encodings.

Merge the two separate collation hashtables that were being maintained in
pg_locale.c, and be more wary of the possibility that we fail partway
through filling a cache entry.
2011-03-20 12:44:13 -04:00
Magnus Hagander 6f9192df61 Rename ident authentication over local connections to peer
This removes an overloading of two authentication options where
one is very secure (peer) and one is often insecure (ident). Peer
is also the name used in libpq from 9.1 to specify the same type
of authentication.

Also make initdb select peer for local connections when ident is
chosen, and ident for TCP connections when peer is chosen.

ident keyword in pg_hba.conf is still accepted and maps to peer
authentication.
2011-03-19 18:44:35 +01:00
Magnus Hagander 4a0014806d Properly clear the verbose output of pg_basebackup
Don't leave partial filename information on the last status or
dangling characters if the previous filename was longer than
the current one.
2011-03-19 16:38:50 +01: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
Robert Haas ad3aff45f0 Tab completion for \pset format and \pset linestyle.
Pavel Stehule
2011-03-16 17:46:15 -04:00
Bruce Momjian ddd6ff289f Add database comments to template0 and postgres databases, and improve
the comments on the template1 database.  No catalog version bump because
they are just comments.
2011-03-15 11:26:57 -04:00
Magnus Hagander 01c1a12a5b Remove special case allowing parameters to ident auth for initdb
This was required in pre-8.4 versions to allow the specification of
"ident sameuser", but sameuser is no longer required. It could be extended
to allow all parameters in the future, but should then apply to all
methods and not just ident.
2011-03-14 19:51:09 +01:00
Tom Lane e3c732a85c Create an explicit concept of collations that work for any encoding.
Use collencoding = -1 to represent such a collation in pg_collation.
We need this to make the "default" entry work sanely, and a later
patch will fix the C/POSIX entries to be represented this way instead
of duplicating them across all encodings.  All lookup operations now
search first for an entry that's database-encoding-specific, and then
for the same name with collencoding = -1.

Also some incidental code cleanup in collationcmds.c and pg_collation.c.
2011-03-11 13:20:11 -05:00
Bruce Momjian f887294ccf Change "TIP" to "HINT" to match backend message style, in pg_ctl -m fast
suggestion.
2011-03-11 05:02:57 -05:00
Bruce Momjian 72bd19dbdd Remove pg_dump -X options that are only in 9.1 and not needed for
backward compatibility.
2011-03-10 22:58:18 -05:00
Bruce Momjian c3462e413e Add C comment that new new pg_dump -X options are to be created. 2011-03-10 22:36:14 -05:00
Bruce Momjian 3f9cf6b336 When a smart pg_ctl shutdown fails, mention -m fast as a tip. 2011-03-10 22:04:00 -05:00
Tom Lane 7564654adf Revert addition of third argument to format_type().
Including collation in the behavior of that function promotes a world view
we do not want.  Moreover, it was producing the wrong behavior for pg_dump
anyway: what we want is to dump a COLLATE clause on attributes whose
attcollation is different from the underlying type, and likewise for
domains, and the function cannot do that for us.  Doing it the hard way
in pg_dump is a bit more tedious but produces more correct output.

In passing, fix initdb so that the initial entry in pg_collation is
properly pinned.  It was droppable before :-(
2011-03-10 17:30:46 -05:00
Itagaki Takahiro 2d8de0a50b Cleanup copyright years and file names in the header comments of some files. 2011-03-10 15:05:33 +09:00
Tom Lane f24fa9c1a5 Fix pg_dump's dump order for collations versus extensions.
Mixing them together alphabetically won't be nice.  Per my gripe of
2011-02-12.
2011-03-06 18:26:53 -05:00
Tom Lane ba0c93a0f4 Convert createlang/droplang to use CREATE/DROP EXTENSION.
In createlang this is a one-line change.  In droplang there's a whole
lot of cruft that can be discarded since the extension mechanism now
manages removal of the language's support functions.

Also, add deprecation notices to these two programs' reference pages,
since per discussion we may toss them overboard altogether in a release
or two.
2011-03-05 14:03:06 -05:00
Tom Lane 63b656b7bf Create extension infrastructure for the core procedural languages.
This mostly just involves creating control, install, and
update-from-unpackaged scripts for them.  However, I had to adjust plperl
and plpython to not share the same support functions between variants,
because we can't put the same function into multiple extensions.

catversion bump forced due to new contents of pg_pltemplate, and because
initdb now installs plpgsql as an extension not a bare language.

Add support for regression testing these as extensions not bare
languages.

Fix a couple of other issues that popped up while testing this: my initial
hack at pg_dump binary-upgrade support didn't work right, and we don't want
an extra schema permissions test after all.

Documentation changes still to come, but I'm committing now to see
whether the MSVC build scripts need work (likely they do).
2011-03-04 21:51:14 -05:00
Tom Lane 8d3b421f5f Allow non-superusers to create (some) extensions.
Remove the unconditional superuser permissions check in CREATE EXTENSION,
and instead define a "superuser" extension property, which when false
(not the default) skips the superuser permissions check.  In this case
the calling user only needs enough permissions to execute the commands
in the extension's installation script.  The superuser property is also
enforced in the same way for ALTER EXTENSION UPDATE cases.

In other ALTER EXTENSION cases and DROP EXTENSION, test ownership of
the extension rather than superuserness.  ALTER EXTENSION ADD/DROP needs
to insist on ownership of the target object as well; to do that without
duplicating code, refactor comment.c's big switch for permissions checks
into a separate function in objectaddress.c.

I also removed the superuserness checks in pg_available_extensions and
related functions; there's no strong reason why everybody shouldn't
be able to see that info.

Also invent an IF NOT EXISTS variant of CREATE EXTENSION, and use that
in pg_dump, so that dumps won't fail for installed-by-default extensions.
We don't have any of those yet, but we will soon.

This is all per discussion of wrapping the standard procedural languages
into extensions.  I'll make those changes in a separate commit; this is
just putting the core infrastructure in place.
2011-03-04 16:08:53 -05:00
Tom Lane 908ab80286 Further refine patch for commenting operator implementation functions.
Instead of manually maintaining the "implementation of XXX operator"
comments in pg_proc.h, delete all those entries and let initdb create
them via a join.  To let initdb figure out which name to use when there
is a conflict, change the comments for deprecated operators to say they
are deprecated --- which seems like a good thing to do anyway.
2011-03-03 15:55:47 -05:00
Heikki Linnakangas 8e2d8b1497 Add tab-completion for table name after JOIN.
Andrey Popp
2011-03-03 09:42:49 +02:00
Tom Lane 94133a9354 Mark operator implementation functions as such in their comments.
Historically, we've not had separate comments for built-in pg_operator
entries, but relied on the comments for the underlying functions.  The
trouble with this approach is that there isn't much of anything to suggest
to users that they'd be better off using the operators instead.  So, move
all the relevant comments into pg_operator, and give each underlying
function a comment that just says "implementation of XXX operator".
There are only about half a dozen cases where it seems reasonable to use
the underlying function interchangeably with the operator; in these cases
I left the same comment in place on the function as on the operator.

While at it, establish a policy that every built-in function and operator
entry should have a comment: there are now queries in the opr_sanity
regression test that will complain if one doesn't.  This only required
adding a dozen or two more entries than would have been there anyway.

I also spent some time trying to eliminate gratuitous inconsistencies in
the style of the comments, though it's hopeless to suppose that more won't
creep in soon enough.

Per my proposal of 2010-10-15.
2011-03-03 01:34:17 -05:00
Peter Eisentraut 16143d6451 Dump the COLLATABLE attribute in CREATE TYPE
This was previously omitted by accident.
2011-03-01 18:45:34 +02:00
Magnus Hagander b04137a294 Fix verbose display of REPLICATION role attribute
Josh Kupershmidt
2011-02-27 12:35:31 +01:00
Itagaki Takahiro 6079375431 More psql tab-completion for new commands.
- ALTER FOREIGN DATA WRAPPER with HANDLER
- ALTER TABLE VALIDATE CONSTRAINT
- ALTER TYPE ADD VALUE
- COPY with ENCODING and FORCE NOT NULL
- CREATE FOREIGN DATA WRAPPER with HANDLER
- CREATE TRIGGER ... INSTEAD OF
2011-02-24 21:05:40 +09:00
Itagaki Takahiro 4191e16cbe Add tab-completion for CREATE UNLOGGED TABLE in psql,
and fix unexpected completion for DROP TEMP and UNIQUE.
2011-02-24 10:13:27 +09:00
Itagaki Takahiro 5a922f13ef Make the second words lowercase in psql's \d titles for unlogged tables. 2011-02-23 09:58:00 +09:00
Peter Eisentraut 02e14562a8 Set psql client encoding from locale by default
Add a new libpq connection option client_encoding (which includes the
existing PGCLIENTENCODING environment variable), which besides an
encoding name accepts a special value "auto" that tries to determine
the encoding from the locale in the client's environment, using the
mechanisms that have been in use in initdb.

psql sets this new connection option to "auto" when running from a
terminal and not overridden by setting PGCLIENTENCODING.

original code by Heikki Linnakangas, with subsequent contributions by
Jaime Casanova, Peter Eisentraut, Stephen Frost, Ibrar Ahmed
2011-02-19 08:54:58 +02:00
Tom Lane 327e025071 Create the catalog infrastructure for foreign-data-wrapper handlers.
Add a fdwhandler column to pg_foreign_data_wrapper, plus HANDLER options
in the CREATE FOREIGN DATA WRAPPER and ALTER FOREIGN DATA WRAPPER commands,
plus pg_dump support for same.  Also invent a new pseudotype fdw_handler
with properties similar to language_handler.

This is split out of the "FDW API" patch for ease of review; it's all stuff
we will certainly need, regardless of any other details of the FDW API.
FDW handler functions will not actually get called yet.

In passing, fix some omissions and infelicities in foreigncmds.c.

Shigeru Hanada, Jan Urbanski, Heikki Linnakangas
2011-02-19 00:07:15 -05:00
Tom Lane 4cff100d73 Fix parallel pg_restore to handle comments on POST_DATA items correctly.
The previous coding would try to process all SECTION_NONE items in the
initial sequential-restore pass, which failed if they were dependencies of
not-yet-restored items.  Fix by postponing such items into the parallel
processing pass once we have skipped any non-PRE_DATA item.

Back-patch into 9.0; the original parallel-restore coding in 8.4 did not
have this bug, so no need to change it.

Report and diagnosis by Arnd Hannemann.
2011-02-18 13:11:45 -05:00
Peter Eisentraut b15fabf997 Also process psqlrc when running psql -l
This was previously not very useful, but with many people customizing
the linestyle, it is nice for a consistent appearance.
2011-02-16 23:15:54 +02:00
Robert Haas 4695da5ae9 pg_ctl promote
Fujii Masao, reviewed by Robert Haas, Stephen Frost, and Magnus Hagander.
2011-02-15 21:30:23 -05:00
Tom Lane 89c29c0331 Fix corner case for binary upgrade: extension functions in pg_catalog.
Normally, pg_dump summarily excludes functions in pg_catalog from
consideration.  However, some extensions may create functions in pg_catalog
(adminpack already does that, and extensions for procedural languages will
likely do it too).  In binary-upgrade mode, we have to dump such functions,
or the extension will be incomplete after upgrading.  Per experimentation
with adminpack.
2011-02-15 18:10:22 -05:00
Tom Lane 555353c0c5 Rearrange extension-related views as per recent discussion.
The original design of pg_available_extensions did not consider the
possibility of version-specific control files.  Split it into two views:
pg_available_extensions shows information that is generic about an
extension, while pg_available_extension_versions shows all available
versions together with information that could be version-dependent.
Also, add an SRF pg_extension_update_paths() to assist in checking that
a collection of update scripts provide sane update path sequences.
2011-02-14 19:22:36 -05:00
Simon Riggs f0b8a79c4b Add version-sensitive SQL for psql when constraints NOT VALID
Bug report and fix by Andres Freund
2011-02-15 00:08:15 +00:00
Peter Eisentraut b313bca0af DDL support for collations
- collowner field
- CREATE COLLATION
- ALTER COLLATION
- DROP COLLATION
- COMMENT ON COLLATION
- integration with extensions
- pg_dump support for the above
- dependency management
- psql tab completion
- psql \dO command
2011-02-12 15:55:18 +02:00
Tom Lane 1214749901 Add support for multiple versions of an extension and ALTER EXTENSION UPDATE.
This follows recent discussions, so it's quite a bit different from
Dimitri's original.  There will probably be more changes once we get a bit
of experience with it, but let's get it in and start playing with it.

This is still just core code.  I'll start converting contrib modules
shortly.

Dimitri Fontaine and Tom Lane
2011-02-11 21:25:57 -05:00
Robert Haas 5917574539 Allow tab-completion of :variable even as first word on a line.
Christoph Berg
2011-02-11 16:57:58 -05:00
Tom Lane 01467d3e4f Extend "ALTER EXTENSION ADD object" to permit "DROP object" as well.
Per discussion, this is something we should have sooner rather than later,
and it doesn't take much additional code to support it.
2011-02-10 17:37:22 -05:00