1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-26 01:22:12 +03:00

In createlang, make dbname optional, not langname, or rather, make

existing code of dbname optional actually work.
This commit is contained in:
Bruce Momjian
2002-01-03 05:30:04 +00:00
parent b3d9768f3b
commit 04f3342e03
2 changed files with 23 additions and 26 deletions

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/createlang.sgml,v 1.21 2001/12/08 03:24:35 thomas Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/createlang.sgml,v 1.22 2002/01/03 05:30:03 momjian Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
@ -23,8 +23,8 @@ PostgreSQL documentation
<cmdsynopsis> <cmdsynopsis>
<command>createlang</command> <command>createlang</command>
<arg rep="repeat"><replaceable>connection-options</replaceable></arg> <arg rep="repeat"><replaceable>connection-options</replaceable></arg>
<arg><replaceable>langname</replaceable></arg> <arg choice="plain"><replaceable>langname</replaceable></arg>
<arg choice="plain"><replaceable>dbname</replaceable></arg> <arg><replaceable>dbname</replaceable></arg>
<sbr> <sbr>
<command>createlang</command> <command>createlang</command>
<arg rep="repeat"><replaceable>connection-options</replaceable></arg> <arg rep="repeat"><replaceable>connection-options</replaceable></arg>
@ -46,9 +46,6 @@ PostgreSQL documentation
<para> <para>
Specifies the name of the procedural programming language to be Specifies the name of the procedural programming language to be
defined. defined.
<application>createlang</application> will prompt for
<replaceable class="parameter">langname</replaceable>
if it is not specified on the command line.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -58,6 +55,8 @@ PostgreSQL documentation
<listitem> <listitem>
<para> <para>
Specifies to which database the language should be added. Specifies to which database the language should be added.
The default is to create a database with the same name as the
current system user.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@ -7,7 +7,7 @@
# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group # Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California # Portions Copyright (c) 1994, Regents of the University of California
# #
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.31 2001/09/30 22:17:51 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.32 2002/01/03 05:30:04 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -125,7 +125,7 @@ if [ -n "$usage" ]; then
echo "$CMDNAME installs a procedural language into a PostgreSQL database." echo "$CMDNAME installs a procedural language into a PostgreSQL database."
echo echo
echo "Usage:" echo "Usage:"
echo " $CMDNAME [options] [langname] dbname" echo " $CMDNAME [options] langname [dbname]"
echo echo
echo "Options:" echo "Options:"
echo " -h, --host=HOSTNAME Database server host" echo " -h, --host=HOSTNAME Database server host"
@ -136,26 +136,23 @@ if [ -n "$usage" ]; then
echo " -L, --pglib=DIRECTORY Find language interpreter file in DIRECTORY" echo " -L, --pglib=DIRECTORY Find language interpreter file in DIRECTORY"
echo " -l, --list Show a list of currently installed languages" echo " -l, --list Show a list of currently installed languages"
echo echo
echo "If 'langname' is not specified, you will be prompted interactively."
echo "A database name must be specified."
echo
echo "Report bugs to <pgsql-bugs@postgresql.org>." echo "Report bugs to <pgsql-bugs@postgresql.org>."
exit 0 exit 0
fi fi
# ----------
# Check that we have a database
# ----------
if [ -z "$dbname" ]; then if [ -z "$dbname" ]; then
echo "$CMDNAME: missing required argument database name" 1>&2 if [ "$PGUSER" ]; then
echo "Try '$CMDNAME --help' for help." 1>&2 dbname="$PGUSER"
exit 1 else
dbname=`${PATHNAME}pg_id -u -n`
fi
[ "$?" -ne 0 ] && exit 1
fi fi
# ---------- # ----------
# List option # List option, doesn't need langname
# ---------- # ----------
if [ "$list" ]; then if [ "$list" ]; then
sqlcmd="SELECT lanname as \"Name\", lanpltrusted as \"Trusted?\" FROM pg_language WHERE lanispl = TRUE;" sqlcmd="SELECT lanname as \"Name\", lanpltrusted as \"Trusted?\" FROM pg_language WHERE lanispl = TRUE;"
@ -167,6 +164,15 @@ if [ "$list" ]; then
fi fi
# ----------
# We can't go any farther without a langname
# ----------
if [ -z "$langname" ]; then
echo "$CMDNAME: missing required argument language name" 1>&2
echo "Try '$CMDNAME --help' for help." 1>&2
exit 1
fi
# ---------- # ----------
# Check that we have PGLIB # Check that we have PGLIB
# ---------- # ----------
@ -174,14 +180,6 @@ if [ -z "$PGLIB" ]; then
PGLIB='$libdir' PGLIB='$libdir'
fi fi
# ----------
# If not given on the command line, ask for the language
# ----------
if [ -z "$langname" ]; then
$ECHO_N "Language to install in database $dbname: "$ECHO_C
read langname
fi
# ---------- # ----------
# Check if supported and set related values # Check if supported and set related values
# ---------- # ----------