aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2000-03-26 18:32:30 +0000
committerPeter Eisentraut <peter_e@gmx.net>2000-03-26 18:32:30 +0000
commit4579e68db24e56141e0ed179f23a6021c6d304d3 (patch)
treed91011e7c8727f0f061d0d69a0e5dc8214c77e41 /src
parent3871b69ba1d5d795bbd0d479e982546c1e4c375f (diff)
downloadpostgresql-4579e68db24e56141e0ed179f23a6021c6d304d3.tar.gz
postgresql-4579e68db24e56141e0ed179f23a6021c6d304d3.zip
Updated user's guide to match new psql's output format
Fixed bug in createdb/alternative location
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/dbcommands.c27
-rw-r--r--src/bin/initlocation/initlocation.sh6
2 files changed, 18 insertions, 15 deletions
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 5cda0f07913..d4e88ec2dde 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.51 2000/03/15 06:50:51 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.52 2000/03/26 18:32:28 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -61,6 +61,7 @@ createdb(const char *dbname, const char *dbpath, int encoding)
{
char buf[2 * MAXPGPATH + 100];
char *loc;
+ char locbuf[512];
int4 user_id;
bool use_super, use_createdb;
Relation pg_database_rel;
@@ -70,23 +71,25 @@ createdb(const char *dbname, const char *dbpath, int encoding)
char new_record_nulls[Natts_pg_database] = { ' ', ' ', ' ', ' ' };
if (!get_user_info(GetPgUserName(), &user_id, &use_super, &use_createdb))
- elog(ERROR, "Current user name is invalid");
+ elog(ERROR, "current user name is invalid");
if (!use_createdb && !use_super)
- elog(ERROR, "CREATE DATABASE: Permission denied");
+ elog(ERROR, "CREATE DATABASE: permission denied");
if (get_db_info(dbname, NULL, NULL, NULL))
- elog(ERROR, "CREATE DATABASE: Database \"%s\" already exists", dbname);
+ elog(ERROR, "CREATE DATABASE: database \"%s\" already exists", dbname);
/* don't call this in a transaction block */
if (IsTransactionBlock())
- elog(ERROR, "CREATE DATABASE: May not be called in a transaction block");
+ elog(ERROR, "CREATE DATABASE: may not be called in a transaction block");
/* Generate directory name for the new database */
- if (dbpath == NULL)
- dbpath = dbname;
+ if (dbpath == NULL || strcmp(dbpath, dbname)==0)
+ strcpy(locbuf, dbname);
+ else
+ snprintf(locbuf, sizeof(locbuf), "%s/%s", dbpath, dbname);
- loc = ExpandDatabasePath(dbpath);
+ loc = ExpandDatabasePath(locbuf);
if (loc == NULL)
elog(ERROR,
@@ -105,10 +108,10 @@ createdb(const char *dbname, const char *dbpath, int encoding)
pg_database_dsc = RelationGetDescr(pg_database_rel);
/* Form tuple */
- new_record[Anum_pg_database_datname-1] = NameGetDatum(dbname);
+ new_record[Anum_pg_database_datname-1] = NameGetDatum(namein(dbname));
new_record[Anum_pg_database_datdba-1] = Int32GetDatum(user_id);
new_record[Anum_pg_database_encoding-1] = Int32GetDatum(encoding);
- new_record[Anum_pg_database_datpath-1] = PointerGetDatum(textin((char *)dbpath));
+ new_record[Anum_pg_database_datpath-1] = PointerGetDatum(textin(locbuf));
tuple = heap_formtuple(pg_database_dsc, new_record, new_record_nulls);
@@ -137,7 +140,7 @@ createdb(const char *dbname, const char *dbpath, int encoding)
/* Copy the template database to the new location */
if (mkdir(loc, S_IRWXU) != 0) {
- elog(ERROR, "CREATE DATABASE: Unable to create database directory '%s': %s", loc, strerror(errno));
+ elog(ERROR, "CREATE DATABASE: unable to create database directory '%s': %s", loc, strerror(errno));
}
snprintf(buf, sizeof(buf), "cp %s%cbase%ctemplate1%c* '%s'",
@@ -147,7 +150,7 @@ createdb(const char *dbname, const char *dbpath, int encoding)
snprintf(buf, sizeof(buf), "rm -rf '%s'", loc);
ret = system(buf);
if (ret == 0)
- elog(ERROR, "CREATE DATABASE: Could not initialize database directory");
+ elog(ERROR, "CREATE DATABASE: could not initialize database directory");
else
elog(ERROR, "CREATE DATABASE: Could not initialize database directory. Delete failed as well");
}
diff --git a/src/bin/initlocation/initlocation.sh b/src/bin/initlocation/initlocation.sh
index e9ccf43fa98..d2f77783479 100644
--- a/src/bin/initlocation/initlocation.sh
+++ b/src/bin/initlocation/initlocation.sh
@@ -8,7 +8,7 @@
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation.sh,v 1.6 2000/03/25 19:01:48 tgl Exp $
+# $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation.sh,v 1.7 2000/03/26 18:32:30 petere Exp $
#
#-------------------------------------------------------------------------
@@ -156,9 +156,9 @@ echo "$CMDNAME is complete."
# path, which the backend won't allow by default.
if [ "$haveenv" = "t" ]; then
echo "You can now create a database using"
- echo " CREATE DATABASE <name> WITH LOCATION = '$Location/<name>'"
+ echo " CREATE DATABASE <name> WITH LOCATION = '$Location'"
echo "in SQL, or"
- echo " createdb <name> -D '$Location/<name>'"
+ echo " createdb <name> -D '$Location'"
echo "from the shell."
fi
echo