Skip to content
Snippets Groups Projects
Commit a6f39b26 authored by Martin Pitt's avatar Martin Pitt
Browse files

merge changes from laptop branch

parent acf7db28
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,4 @@ postgresql TODO ...@@ -3,6 +3,4 @@ postgresql TODO
- Provide do.maintenance which vacuums all running clusters. - Provide do.maintenance which vacuums all running clusters.
- Handle configuration files in pg_upgradecluster somehow. - Handle configuration files in pg_upgradecluster somehow.
- Check validity of locale before initdb and pg_ctl start.
- Handle stale pid files/sockets.
- add CAN numbers to per-version changelogs(?) - add CAN numbers to per-version changelogs(?)
PostgreSQL for Debian
=====================
PostgreSQL is the successor to Postgres95, which in turn succeeded POSTGRES.
PostgreSQL is a relational database with object-oriented extensions. It
implements the greater part of SQL-92 and is intended to implement it in full;
in addition it supports its own extended facilities.
Since the on-disk data format of all major PostgreSQL versions (like 7.2, 7.4,
8.0, etc.) is incompatible to each other, Debian's PostgreSQL packaging
architecture is designed to maintain clusters of different major versions in
parallel.
This postgresql-common package provides the common infrastructure and all
frontend programs that users and administrators use. The version specific
server and client programs are shipped in postgresql-*-<version> packages.
For a detailled description of the architecture, please see
/usr/share/doc/postgresql-common/architecture.html
First steps for the impatient
-----------------------------
Eventually you will not get around reading at least some parts of the manual,
but if you want to get straight into playing SQL, here are the steps to create
a database user and a database for the Unix user 'joe':
1. Install a database server with the major version of your choice, preferrably
the latest version. This will automatically create a default cluster 'main'
with the database superuser 'postgres'.
2. Get a shell for the database superuser 'postgres'. If your system has an
active root user, use su:
$ su -c "su postgres"
If your system uses sudo to get administrative rights, use sudo instead:
joe$ sudo -u postgres sh
3. In this postgres shell, create a database user with the same name as your
Unix login:
$ createuser -A -D joe
For details about the options, see createuser(1).
4. Create a database "joework" which is owned by "joe":
$ createdb -O joe joework
For details about the options, see createdb(1).
5. Exit the postgres shell.
6. As user joe, you should now be able to connect to your database with
$ psql joework
Cluster management
------------------
For managing clusters, the following commands are provided (each with its own
manual page):
pg_createcluster - Create a new cluster or integrate an existing one into
the postgresql-common architecture.
pg_dropcluster - Completely remove a cluster.
pg_ctlcluster - Control the server process of a cluster (start, stop,
restart).
pg_lsclusters - Show a list of all existing clusters and their status.
pg_upgradecluster - Migrate a cluster from one major version to another one.
Further documentation
---------------------
All commands shipped by postgresql-common have detailled manpages. See
postgresql-common(7) for the documentation of the database client program
wrapping, and user_clusters(5) and postgresqlrc(5) for the cluster
configuration.
The documentation of the database server and client functions, SQL commands,
modules, etc. documented is shipped in the per-version packages
postgresql-doc-<version>.
postgresql-common (9) experimental; urgency=low postgresql-common (9) experimental; urgency=low
* * Add README.Debian with some general introduction, "first steps for the
impatient", and pointers to further documentation.
* pg_ctlcluster: Check validity of postmaster locale before setting it.
* pg_createcluster: Check validity of locale before calling initdb under it.
* pg_wrapper: Support PGCLUSTER environment variable. Closes: #305912
-- Martin Pitt <mpitt@debian.org> Fri, 13 May 2005 00:51:18 +0200 -- Martin Pitt <mpitt@debian.org> Thu, 19 May 2005 22:21:13 +0200
postgresql-common (8) experimental; urgency=low postgresql-common (8) experimental; urgency=low
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
use lib '/usr/share/postgresql-common'; use lib '/usr/share/postgresql-common';
use PgCommon; use PgCommon;
use Getopt::Long; use Getopt::Long;
use POSIX qw/setlocale LC_ALL/;
# call initdb # call initdb
# Arguments: <version> <data directory> <owner uid> <owner gid> # Arguments: <version> <data directory> <owner uid> <owner gid>
...@@ -106,6 +107,11 @@ sub add_local_hba_entry { ...@@ -106,6 +107,11 @@ sub add_local_hba_entry {
exit 1 unless GetOptions ('u|user=s' => \$owneruid, 'g|group=s' => \$ownergid); exit 1 unless GetOptions ('u|user=s' => \$owneruid, 'g|group=s' => \$ownergid);
# check validity of locale
unless (setlocale (LC_ALL, "")) {
error ('The locale requested by the environment is invalid.')
}
if ($#ARGV < 1) { if ($#ARGV < 1) {
print "Usage: $0 [-u <uid>] [-g <gid>] <version> <cluster name> [<data directory>]\n"; print "Usage: $0 [-u <uid>] [-g <gid>] <version> <cluster name> [<data directory>]\n";
exit 1; exit 1;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
use lib '/usr/share/postgresql-common'; use lib '/usr/share/postgresql-common';
use Getopt::Long; use Getopt::Long;
use POSIX qw/setsid/; use POSIX qw/setsid setlocale LC_ALL/;
use PgCommon; use PgCommon;
# command line options # command line options
...@@ -89,7 +89,12 @@ sub start { ...@@ -89,7 +89,12 @@ sub start {
close CTRL; close CTRL;
$locale or error ('Could not parse locale out of pg_controldata output'); $locale or error ('Could not parse locale out of pg_controldata output');
# set locale used by initdb # check validity of locale
unless (setlocale (LC_ALL, $locale)) {
error ("The server must be started under the locale $locale which does not exist any more.")
}
# set locale for the postmaster
$ENV{'LC_ALL'} = $ENV{'LANG'} = $locale; $ENV{'LC_ALL'} = $ENV{'LANG'} = $locale;
@options = ($pg_ctl, 'start', '-D', $info{'pgdata'},'-l', $info{'logfile'}, '-s'); @options = ($pg_ctl, 'start', '-D', $info{'pgdata'},'-l', $info{'logfile'}, '-s');
......
...@@ -14,6 +14,14 @@ use PgCommon; ...@@ -14,6 +14,14 @@ use PgCommon;
$cmd = (split '/', $0)[-1]; $cmd = (split '/', $0)[-1];
grep { $cmd eq $_ } @commands or die "pg_wrapper: invalid command name $cmd"; grep { $cmd eq $_ } @commands or die "pg_wrapper: invalid command name $cmd";
# Check for PGCLUSTER in %ENV
if (defined $ENV{PGCLUSTER}) {
($version, $cluster) = split ('/', $ENV{PGCLUSTER}, 2);
error 'Invalid version specified with $PGCLUSTER' unless $version;
error 'Invalid cluster specified with $PGCLUSTER' unless $cluster;
error 'Cluster specified with $PGCLUSTER does not exist' unless cluster_exists $version, $cluster;
}
# Check for --cluster argument and filter it out # Check for --cluster argument and filter it out
for ($i = 0; $i <= $#ARGV; ++$i) { for ($i = 0; $i <= $#ARGV; ++$i) {
if ($ARGV[$i] eq '--cluster') { if ($ARGV[$i] eq '--cluster') {
...@@ -66,9 +74,22 @@ configured cluster and database for the user and calls the appropriate version ...@@ -66,9 +74,22 @@ configured cluster and database for the user and calls the appropriate version
of the desired program to connect to that cluster and database, supplying any of the desired program to connect to that cluster and database, supplying any
specifed options to that command. specifed options to that command.
By default, the cluster is determined from the configuration files By default, the cluster is determined from the configuration files
L<user_clusters(5)> and L<postgresqlrc(5)>. However, this can be overriden by L<user_clusters(5)> and L<postgresqlrc(5)>. However, this can be overriden by
specifying the B<--cluster> I<version>/I<cluster> option. specifying the B<$PGCLUSTER> environment variable or the B<--cluster>
I<version>/I<cluster> option.
=head1 ENVIRONMENT
=over
=item B<PGCLUSTER>
If B<$PGCLUSTER> is set, its value (of the form I<version>/I<cluster>)
specifies the desired cluster, similar to the B<--cluster> option. However, if
B<--cluster> is specified, it overrides the value of B<$PGCLUSTER>.
=back
=head1 FILES =head1 FILES
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment