I cleaned those out as well (the echo -n "bug" was in there ;) and moved

them into the scripts dir. I also added a --list option to show already
installed languages.

This whole moving and renaming totally confused CVS and my checked out
copy got completely fried last night. When you apply the source patch,
please make sure that all the directories src/bin/{create|destroy}* as
well as vacuumdb, cleardbdir are gone and that all the scripts (7) are
in
scripts/.

Meanwhile I am still puzzled about what happened with the docs patch.
Because I don't know what you got now, the second attachment contains
the
files

ref/allfiles.sgml
ref/commands.sgml
ref/createlang.sgml
ref/droplang.sgml
doc/src/sgml/Makefile

Peter Eisentraut                  Sernanders väg 10:115
This commit is contained in:
Bruce Momjian 1999-12-05 20:02:49 +00:00
parent 9eb69977fe
commit ed62104ea9
15 changed files with 12100 additions and 382 deletions

View File

@ -1,5 +1,5 @@
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.13 1999/12/04 04:53:15 momjian Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.14 1999/12/05 20:02:42 momjian Exp $
Postgres documentation
Complete list of usable sgml source files in this directory.
-->
@ -100,9 +100,11 @@ Complete list of usable sgml source files in this directory.
<!-- these are in the "utilities" reference chapter -->
<!entity createdb system "createdb.sgml">
<!entity createlang system "createlang.sgml">
<!entity createuser system "createuser.sgml">
<!entity dropdb system "dropdb.sgml">
<!entity dropuser system "dropuser.sgml">
<!entity dropdb system "dropdb.sgml">
<!entity droplang system "droplang.sgml">
<!entity dropuser system "dropuser.sgml">
<!entity ecpgRef system "ecpg-ref.sgml">
<!entity initdb system "initdb.sgml">
<!entity initlocation system "initlocation.sgml">

View File

@ -1,5 +1,5 @@
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/Attic/commands.sgml,v 1.20 1999/12/04 04:53:15 momjian Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/Attic/commands.sgml,v 1.21 1999/12/05 20:02:42 momjian Exp $
Postgres documentation
-->
@ -107,8 +107,10 @@ functions supported by <productname>Postgres</productname>.
</abstract>
&createdb;
&createlang;
&createuser;
&dropdb;
&droplang;
&dropuser;
&ecpgRef;
&pgAccess;

View File

@ -0,0 +1,213 @@
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/createlang.sgml,v 1.3 1999/12/05 20:02:42 momjian Exp $
Postgres documentation
-->
<refentry id="APP-CREATELANG">
<refmeta>
<refentrytitle id="APP-CREATELANG-TITLE">
<application>createlang</application>
</refentrytitle>
<refmiscinfo>Application</refmiscinfo>
</refmeta>
<refnamediv>
<refname id="createlang">
<application>createlang</application>
</refname>
<refpurpose>
Add a new programming language to a <productname>PostgreSQL</productname> database
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<refsynopsisdivinfo>
<date>1999-12-05</date>
</refsynopsisdivinfo>
<synopsis>
createlang [ <replaceable class="parameter">connection options</replaceable> ] [ <replaceable class="parameter">langname</replaceable> [ <replaceable class="parameter">dbname</replaceable> ] ]
createlang [ <replaceable class="parameter">connection options</replaceable> ] --list|-l
</synopsis>
<refsect2 id="R2-APP-CREATELANG-1">
<title>
Inputs
</title>
<para>
<application>createlang</application> accepts the following command line arguments:
<variablelist>
<varlistentry>
<term><replaceable class="parameter">langname</replaceable></term>
<listitem>
<para>
Specifies the name of the backend programming language to be defined.
<application>createlang</application> will prompt for
<replaceable class="parameter">langname</replaceable>
if it is not specified on the command line.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>[-d, --dbname] <replaceable class="parameter">dbname</replaceable></term>
<listitem>
<para>
Specifies to which database the language should be added.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-l, --list</term>
<listitem>
<para>
Shows a list of already installed languages in the target database
(which must be specified).
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<para>
<application>createlang</application> also accepts
the following command line arguments for connection parameters:
<variablelist>
<varlistentry>
<term>-h, --host <replaceable class="parameter">host</replaceable></term>
<listitem>
<para>
Specifies the hostname of the machine on which the
<application>postmaster</application>
is running.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-p, --port <replaceable class="parameter">port</replaceable></term>
<listitem>
<para>
Specifies the Internet TCP/IP port or local Unix domain socket file
extension on which the <application>postmaster</application>
is listening for connections.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-U, --username <replaceable class="parameter">username</replaceable></term>
<listitem>
<para>
Username to connect as.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-W, --password</term>
<listitem>
<para>
Force password prompt.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-e, --echo</term>
<listitem>
<para>
Echo the commands that <application>createlang</application> generates
and sends to the backend.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
<refsect2 id="R2-APP-CREATELANG-2">
<refsect2info>
<date>1998-10-04</date>
</refsect2info>
<title>
Outputs
</title>
<para>
Most error messages are self-explanatory. If not, run
<application>createlang</application> with the <option>--echo</option>
option and see under the respective <acronym>SQL</acronym> command
for details. Check also under <xref linkend="APP-PSQL" endterm="APP-PSQL-title">
for more possibilities.
</para>
<para>
No output is generated if <application>createlang</application> succeeds.
</para>
</refsect2>
</refsynopsisdiv>
<refsect1 id="R1-APP-CREATELANG-1">
<refsect1info>
<date>1999-12-05</date>
</refsect1info>
<title>
Description
</title>
<para>
<application>createlang</application> is a utility for adding a new
programming language to a <productname>PostgreSQL</productname> database.
<application>createlang</application> currently accepts two
languages, <literal>plsql</literal> and <literal>pltcl</literal>.
</para>
<para>
Although backend programming languages can be added directly using
several <acronym>SQL</acronym> commands, it is recommended to use
<application>createlang</application> because it performs a number
of checks and is much easier to use. See
<xref linkend="sql-createlanguage" endterm="sql-createlanguage-title">
for more.
</para>
</refsect1>
<refsect1 id="R1-APP-CREATELANG-2">
<title>
Notes
</title>
<para>
Use <xref linkend="app-droplang" endterm="app-droplang-title">
to remove a language.
</para>
</refsect1>
<refsect1 id="R1-APP-CREATELANG-3">
<title>
Usage
</title>
<para>
To install <literal>pltcl</literal>:
<programlisting>
$ createlang pltcl
</programlisting>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil
End:
-->

View File

@ -1,13 +1,13 @@
#-------------------------------------------------------------------------
#
# Makefile.inc--
# Makefile
# Makefile for src/bin (utility programs)
#
# Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.19 1999/12/04 04:53:16 momjian Exp $
# $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.20 1999/12/05 20:02:43 momjian Exp $
#
#-------------------------------------------------------------------------
@ -15,7 +15,7 @@ SRCDIR= ..
include ../Makefile.global
DIRS = pg_id pg_version psql pg_dump pg_passwd cleardbdir \
createlang destroylang initdb initlocation ipcclean
scripts initdb initlocation ipcclean
ifdef MULTIBYTE
DIRS += pg_encoding

View File

@ -1,29 +0,0 @@
#-------------------------------------------------------------------------
#
# Makefile.inc--
# Makefile for bin/createlang
#
# Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/createlang/Attic/Makefile,v 1.1 1999/05/20 16:50:00 wieck Exp $
#
#-------------------------------------------------------------------------
SRCDIR= ../..
include ../../Makefile.global
all: createlang
createlang: createlang.sh
sed -e 's/__DLSUFFIX__/$(DLSUFFIX)/' \
createlang.sh > createlang
install: createlang
$(INSTALL) $(INSTL_EXE_OPTS) $< $(BINDIR)/$<
clean:
rm -f createlang
dep depend:

View File

@ -1,173 +0,0 @@
#!/bin/sh
#-------------------------------------------------------------------------
#
# createlang.sh--
# Install a procedural language in a database
#
# Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/createlang/Attic/createlang.sh,v 1.2 1999/07/09 17:57:46 momjian Exp $
#
#-------------------------------------------------------------------------
CMDNAME=`basename $0`
# ----------
# Find the default PGLIB directory
# ----------
postconfig_result="`sh -c postconfig 2>/dev/null`"
if [ ! -z "$postconfig_result" ]; then
set -a
eval "$postconfig_result"
set +a
fi
# ----------
# Determine username
# ----------
if [ -z "$USER" ]; then
if [ -z "$LOGNAME" ]; then
if [ -z "`whoami`" ]; then
echo "$CMDNAME: cannot determine user name"
exit 1
fi
else
USER=$LOGNAME
export USER
fi
fi
# ----------
# Get options, language name and dbname
# ----------
dbname=$USER
while [ -n "$1" ]
do
case $1 in
--pglib) PGLIB=$2; shift;;
-a) AUTHSYS=$2; shift;;
-h) PGHOST=$2; shift;;
-p) PGPORT=$2; shift;;
*) langname=$1
if [ -n "$2" ]; then
shift
dbname=$1
fi;;
esac
shift;
done
# ----------
# Check that we have PGLIB
# ----------
if [ -z "$PGLIB" ]; then
echo "Cannot determine PostgreSQL lib directory (PGLIB)."
echo "You must identify the PGLIB either with a --pglib option"
echo "or by setting the PGLIB environment variable."
exit 1
fi
# ----------
# If not given on the commandline, ask for the language
# ----------
if [ -z "$langname" ]; then
echo -n "Language to install in database $dbname: "
read langname
fi
# ----------
# Check if supported and set related values
# ----------
case "$langname" in
plpgsql) lancomp="PL/pgSQL"
trusted="TRUSTED"
handler="plpgsql_call_handler";;
pltcl) lancomp="PL/Tcl"
trusted="TRUSTED"
handler="pltcl_call_handler";;
*) echo "$CMDNAME: unsupported language '$langname'"
echo " supported languages are plpgsql and pltcl"
exit 1;;
esac
# ----------
# Check that the shared object for the call handler is installed
# in PGLIB
# ----------
if [ ! -f $PGLIB/${langname}__DLSUFFIX__ ]; then
echo "Cannot find the file $PGLIB/${langname}__DLSUFFIX__"
echo "This shared object contains the call handler for $lancomp."
echo "By default, only PL/pgSQL is built and installed. Other"
echo "languages must be explicitly enabled at configure."
echo ""
echo "To install PL/Tcl make sure the option --with-tcl is"
echo "given to configure, then recompile and install."
exit 1
fi
# ----------
# Combine psql with options given
# ----------
if [ -z "$AUTHSYS" ]; then
AUTHOPT=""
else
AUTHOPT="-a $AUTHSYS"
fi
if [ -z "$PGHOST" ]; then
PGHOSTOPT=""
else
PGHOSTOPT="-h $PGHOST"
fi
if [ -z "$PGPORT" ]; then
PGPORTOPT=""
else
PGPORTOPT="-p $PGPORT"
fi
MONITOR="psql -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c"
# ----------
# Make sure the language isn't already installed
# ----------
res=`$MONITOR "select oid from pg_language where lanname = '$langname'" $dbname`
if [ $? -ne 0 ]; then
echo "Cannot install language"
exit 1
fi
if [ ! -z "$res" ]; then
echo "The language '$langname' is already installed in database $dbname"
exit 2
fi
# ----------
# Check that there is no function named as the call handler
# ----------
res=`$MONITOR "select oid from pg_proc where proname = '$handler'" $dbname`
if [ ! -z "$res" ]; then
echo "The language $lancomp isn't created up to now but there"
echo "is already a function named '$handler' declared."
echo "Language installation aborted."
exit 1
fi
# ----------
# Create the call handler and the language
# ----------
$MONITOR "create function $handler () returns opaque as '$PGLIB/${langname}__DLSUFFIX__' language 'C'" $dbname
if [ $? -ne 0 ]; then
echo "Language installation failed"
exit 1
fi
$MONITOR "create $trusted procedural language '$langname' handler $handler lancompiler '$lancomp'" $dbname
if [ $? -ne 0 ]; then
echo "Language installation failed"
exit 1
fi
exit 0

View File

@ -1,28 +0,0 @@
#-------------------------------------------------------------------------
#
# Makefile.inc--
# Makefile for bin/destroylang
#
# Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/destroylang/Attic/Makefile,v 1.1 1999/05/20 16:50:02 wieck Exp $
#
#-------------------------------------------------------------------------
SRCDIR= ../..
include ../../Makefile.global
all: destroylang
destroylang: destroylang.sh
cp destroylang.sh destroylang
install: destroylang
$(INSTALL) $(INSTL_EXE_OPTS) $< $(BINDIR)/$<
clean:
rm -f destroylang
dep depend:

View File

@ -1,139 +0,0 @@
#!/bin/sh
#-------------------------------------------------------------------------
#
# createlang.sh--
# Remove a procedural language from a database
#
# Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/destroylang/Attic/destroylang.sh,v 1.1 1999/05/20 16:50:03 wieck Exp $
#
#-------------------------------------------------------------------------
CMDNAME=`basename $0`
# ----------
# Determine username
# ----------
if [ -z "$USER" ]; then
if [ -z "$LOGNAME" ]; then
if [ -z "`whoami`" ]; then
echo "$CMDNAME: cannot determine user name"
exit 1
fi
else
USER=$LOGNAME
export USER
fi
fi
# ----------
# Get options, language name and dbname
# ----------
dbname=$USER
while [ -n "$1" ]
do
case $1 in
-a) AUTHSYS=$2; shift;;
-h) PGHOST=$2; shift;;
-p) PGPORT=$2; shift;;
*) langname=$1
if [ -n "$2" ]; then
shift
dbname=$1
fi;;
esac
shift;
done
# ----------
# If not given on the commandline, ask for the language
# ----------
if [ -z "$langname" ]; then
echo -n "Language to remove from database $dbname: "
read langname
fi
# ----------
# Check if supported and set related values
# ----------
case "$langname" in
plpgsql) lancomp="PL/pgSQL"
handler="plpgsql_call_handler";;
pltcl) lancomp="PL/Tcl"
handler="pltcl_call_handler";;
*) echo "$CMDNAME: unsupported language '$langname'"
echo " supported languages are plpgsql and pltcl"
exit 1;;
esac
# ----------
# Combine psql with options given
# ----------
if [ -z "$AUTHSYS" ]; then
AUTHOPT=""
else
AUTHOPT="-a $AUTHSYS"
fi
if [ -z "$PGHOST" ]; then
PGHOSTOPT=""
else
PGHOSTOPT="-h $PGHOST"
fi
if [ -z "$PGPORT" ]; then
PGPORTOPT=""
else
PGPORTOPT="-p $PGPORT"
fi
MONITOR="psql -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c"
# ----------
# Make sure the language is installed
# ----------
res=`$MONITOR "select oid from pg_language where lanname = '$langname'" $dbname`
if [ $? -ne 0 ]; then
echo "Cannot remove language"
exit 1
fi
if [ -z "$res" ]; then
echo "The language '$langname' isn't installed in database $dbname"
exit 1
fi
# ----------
# Check that there are no functions left defined in that language
# ----------
res=`$MONITOR "select count(proname) from pg_proc P, pg_language L where P.prolang = L.oid and L.lanname = '$langname'" $dbname`
if [ $? -ne 0 ]; then
echo "Cannot remove language"
exit 1
fi
if [ $res -ne 0 ]; then
echo "There are $res functions/trigger procedures actually declared"
echo "in language $lancomp."
echo "Language not removed."
exit 1
fi
# ----------
# Drop the language and the call handler function
# ----------
$MONITOR "drop procedural language '$langname'" $dbname
if [ $? -ne 0 ]; then
echo "Language removal failed"
exit 1
fi
$MONITOR "drop function $handler()" $dbname
if [ $? -ne 0 ]; then
echo "Language removal failed"
exit 1
fi
exit 0

BIN
src/bin/scripts/ID Normal file

Binary file not shown.

View File

@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/scripts/Makefile,v 1.1 1999/12/04 04:53:21 momjian Exp $
# $Header: /cvsroot/pgsql/src/bin/scripts/Makefile,v 1.2 1999/12/05 20:02:48 momjian Exp $
#
#-------------------------------------------------------------------------
@ -16,7 +16,7 @@
SRCDIR=../..
include ../../Makefile.global
SCRIPTS=createdb dropdb createuser dropuser vacuumdb
SCRIPTS=createdb dropdb createuser dropuser createlang droplang vacuumdb
all: $(SCRIPTS)
@ -24,10 +24,17 @@ createdb:
dropdb:
createuser:
dropuser:
createlang: createlang.sh
sed -e 's/__DLSUFFIX__/$(DLSUFFIX)/' createlang.sh > createlang
droplang:
vacuumdb:
install: $(SCRIPTS)
$(INSTALL) $(INSTL_EXE_OPTS) $< $(BINDIR)/$(X)$<
clean:
rm -f createlang
dep depend:

View File

@ -0,0 +1,255 @@
#!/bin/sh
#-------------------------------------------------------------------------
#
# createlang.sh--
# Install a procedural language in a database
#
# Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.1 1999/12/05 20:02:48 momjian Exp $
#
#-------------------------------------------------------------------------
CMDNAME=`basename $0`
PSQLOPT=
dbname=
langname=
echo=
list=
# Check for echo -n vs echo \c
if echo '\c' | grep -s c >/dev/null 2>&1
then
ECHO_N="echo -n"
ECHO_C=""
else
ECHO_N="echo"
ECHO_C='\c'
fi
# ----------
# Find the default PGLIB directory
# ----------
postconfig_result="`sh -c postconfig 2>/dev/null`"
if [ "$postconfig_result" ]; then
set -a
eval "$postconfig_result"
set +a
fi
# ----------
# Get options, language name and dbname
# ----------
while [ $# -gt 0 ]
do
case "$1" in
--help|-\?)
usage=t
break
;;
--list|-l)
list=t
;;
# options passed on to psql
--host|-h)
PSQLOPT="$PSQLOPT -h $2"
shift;;
-h*)
PSQLOPT="$PSQLOPT $1"
;;
--host=*)
PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'`
;;
--port|-p)
PSQLOPT="$PSQLOPT -p $2"
shift;;
-p*)
PSQLOPT="$PSQLOPT $1"
;;
--port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
;;
--user|--username|-U)
PSQLOPT="$PSQLOPT -U '$2'"
shift;;
-U*)
PSQLOPT="$PSQLOPT $1"
;;
--user=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--user=//'`
;;
--username=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
;;
--password|-W)
PSQLOPT="$PSQLOPT -W"
;;
--echo|-e)
echo=t
;;
--dbname|--database|-d)
dbname="$2"
shift;;
-d*)
dbname=`echo $1 | sed 's/^-d//'`
;;
--dbname=*)
dbname=`echo $1 | sed 's/^--dbname=//'`
;;
--database=*)
dbname=`echo $1 | sed 's/^--database=//'`
;;
# misc options
--pglib|-L)
PGLIB="$2"
shift;;
-L*)
PGLIB=`echo $1 | sed 's/^-L//'`
;;
--pglib=*)
PGLIB=`echo $1 | sed 's/^--pglib=//'`
;;
*)
langname="$1"
if [ "$2" ]; then
shift
dbname="$1"
fi
;;
esac
shift
done
if [ "$usage" ]; then
echo "Usage: $CMDNAME [-h server] [-p port] [-U username] [-d dbname] \\"
echo " [-L|--pglib PGLIB] [langname [dbname]]"
exit 0
fi
if [ "$list" ]; then
psql $PSQLOPT -d "$dbname" -c "SELECT lanname, lanpltrusted, lancompiler FROM pg_language WHERE lanispl = 't'"
exit $?
fi
# ----------
# Check that we have a database
# ----------
if [ -z "$dbname" ]; then
echo "$CMDNAME: Missing required argument database name. Try -? for help."
exit 1
fi
# ----------
# Check that we have PGLIB
# ----------
if [ -z "$PGLIB" ]; then
echo "Cannot determine the PostgreSQL lib directory (PGLIB). You must"
echo "identify it either with a --pglib option or by setting the PGLIB"
echo "environment variable."
exit 1
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
# ----------
case "$langname" in
plpgsql)
lancomp="PL/pgSQL"
trusted="TRUSTED "
handler="plpgsql_call_handler"
;;
pltcl)
lancomp="PL/Tcl"
trusted="TRUSTED "
handler="pltcl_call_handler";;
*)
echo "$CMDNAME: Unsupported language '$langname'."
echo "Supported languages are 'plpgsql' and 'pltcl'."
exit 1
;;
esac
# ----------
# Check that the shared object for the call handler is installed
# in PGLIB
# ----------
if [ ! -f $PGLIB/${langname}__DLSUFFIX__ ]; then
echo "Cannot find the file $PGLIB/${langname}__DLSUFFIX__."
echo ""
echo "This file contains the call handler for $lancomp. By default,"
echo "only PL/pgSQL is built and installed; other languages must be"
echo "explicitly enabled at configure time."
echo ""
echo "To install PL/Tcl, make sure the option --with-tcl is given to"
echo "configure, then recompile and install."
exit 1
fi
if [ "$echo" ]; then
PSQLOPT="$PSQLOPT -e"
else
PSQLOPT="$PSQLOPT -q"
fi
PSQL="psql -A -t $PSQLOPT -d $dbname -c"
# ----------
# Make sure the language isn't already installed
# ----------
res=`$PSQL "SELECT oid FROM pg_language WHERE lanname = '$langname'"`
if [ $? -ne 0 ]; then
echo "Language installation failed."
exit 1
fi
if [ "$res" ]; then
echo "The language '$langname' is already installed in database $dbname."
exit 2
fi
# ----------
# Check that there is no function named as the call handler
# ----------
res=`$PSQL "SELECT oid FROM pg_proc WHERE proname = '$handler'"`
if [ ! -z "$res" ]; then
echo "The language $lancomp isn't created up to now but there is"
echo "already a function named '$handler' declared."
echo "Language installation aborted."
exit 1
fi
# ----------
# Create the call handler and the language
# ----------
$PSQL "CREATE FUNCTION $handler () RETURNS OPAQUE AS '$PGLIB/${langname}__DLSUFFIX__' LANGUAGE 'C'"
if [ $? -ne 0 ]; then
echo "Language installation failed."
exit 1
fi
$PSQL "CREATE ${trusted}PROCEDURAL LANGUAGE '$langname' HANDLER $handler LANCOMPILER '$lancomp'"
if [ $? -ne 0 ]; then
echo "Language installation failed."
exit 1
fi
exit 0

210
src/bin/scripts/droplang Normal file
View File

@ -0,0 +1,210 @@
#!/bin/sh
#-------------------------------------------------------------------------
#
# createlang--
# Remove a procedural language from a database
#
# Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.1 1999/12/05 20:02:48 momjian Exp $
#
#-------------------------------------------------------------------------
CMDNAME=`basename $0`
PSQLOPT=
dbname=
langname=
echo=
list=
# Check for echo -n vs echo \c
if echo '\c' | grep -s c >/dev/null 2>&1
then
ECHO_N="echo -n"
ECHO_C=""
else
ECHO_N="echo"
ECHO_C='\c'
fi
# ----------
# Get options, language name and dbname
# ----------
while [ $# -gt 0 ]
do
case "$1" in
--help|-\?)
usage=t
break
;;
--list|-l)
list=t
;;
# options passed on to psql
--host|-h)
PSQLOPT="$PSQLOPT -h $2"
shift;;
-h*)
PSQLOPT="$PSQLOPT $1"
;;
--host=*)
PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'`
;;
--port|-p)
PSQLOPT="$PSQLOPT -p $2"
shift;;
-p*)
PSQLOPT="$PSQLOPT $1"
;;
--port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
;;
--user|--username|-U)
PSQLOPT="$PSQLOPT -U '$2'"
shift;;
-U*)
PSQLOPT="$PSQLOPT $1"
;;
--user=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--user=//'`
;;
--username=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
;;
--password|-W)
PSQLOPT="$PSQLOPT -W"
;;
--echo|-e)
echo=t
;;
--dbname|--database|-d)
dbname="$2"
shift;;
-d*)
dbname=`echo $1 | sed 's/^-d//'`
;;
--dbname=*)
dbname=`echo $1 | sed 's/^--dbname=//'`
;;
--database=*)
dbname=`echo $1 | sed 's/^--database=//'`
;;
*)
langname="$1"
if [ "$2" ]; then
shift
dbname="$1"
fi
;;
esac
shift
done
if [ "$usage" ]; then
echo "Usage: $CMDNAME [-h server] [-p port] [-U username] [-d dbname] [langname [dbname]]"
exit 0
fi
if [ "$list" ]; then
psql $PSQLOPT -d "$dbname" -c "SELECT lanname, lanpltrusted, lancompiler FROM pg_language WHERE lanispl = 't'"
exit $?
fi
# ----------
# Check that we have a database
# ----------
if [ -z "$dbname" ]; then
echo "$CMDNAME: Missing required argument database name. Try -? for help."
exit 1
fi
# ----------
# If not given on the commandline, ask for the language
# ----------
if [ -z "$langname" ]; then
$ECHO_N "Language to remove from database $dbname: "$ECHO_C
read langname
fi
# ----------
# Check if supported and set related values
# ----------
case "$langname" in
plpgsql)
lancomp="PL/pgSQL"
handler="plpgsql_call_handler"
;;
pltcl)
lancomp="PL/Tcl"
handler="pltcl_call_handler"
;;
*)
echo "$CMDNAME: Unsupported language '$langname'."
echo " Supported languages are 'plpgsql' and 'pltcl'."
exit 1
;;
esac
if [ "$echo" ]; then
PSQLOPT="$PSQLOPT -e"
else
PSQLOPT="$PSQLOPT -q"
fi
PSQL="psql -A -t $PSQLOPT -d $dbname -c"
# ----------
# Make sure the language is installed
# ----------
res=`$PSQL "SELECT oid FROM pg_language WHERE lanname = '$langname'"`
if [ $? -ne 0 ]; then
echo "Language removal failed."
exit 1
fi
if [ -z "$res" ]; then
echo "The language '$langname' isn't installed in database $dbname."
exit 1
fi
# ----------
# Check that there are no functions left defined in that language
# ----------
res=`$PSQL "SELECT COUNT(proname) FROM pg_proc P, pg_language L WHERE P.prolang = L.oid AND L.lanname = '$langname'"`
if [ $? -ne 0 ]; then
echo "Language removal failed."
exit 1
fi
if [ $res -ne 0 ]; then
echo "There are $res functions/trigger procedures declared in language"
echo "$lancomp."
echo "Language not removed."
exit 1
fi
# ----------
# Drop the language and the call handler function
# ----------
$PSQL "DROP PROCEDURAL LANGUAGE '$langname'"
if [ $? -ne 0 ]; then
echo "Language removal failed."
exit 1
fi
$PSQL "DROP FUNCTION $handler()"
if [ $? -ne 0 ]; then
echo "Language removal failed."
exit 1
fi
exit 0

11375
src/bin/scripts/tags Normal file

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.1 1999/12/04 04:53:21 momjian Exp $
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.2 1999/12/05 20:02:49 momjian Exp $
#
#-------------------------------------------------------------------------
@ -48,9 +48,15 @@ do
--quiet|-q)
PSQLOPT="$PSQLOPT -o /dev/null"
;;
--dbname|--database|-d)
dbname="$2"
shift;;
-d*)
dbname=`echo $1 | sed 's/^-d//'`
;;
--dbname=*)
dbname=`echo $1 | sed 's/^--dbname=//'`
;;
--database=*)
dbname=`echo $1 | sed 's/^--database=//'`
;;
# options converted into SQL command
--analyze|-z)
analyze="analyze"

View File

@ -0,0 +1,17 @@
***************
*** 80,86 ****
dbname=`echo $1 | sed 's/^--dbname=//'`
;;
--database=*)
! dbname=`echo $1 | sed 's/^-database=//'`
;;
# options converted into SQL command
--analyze|-z)
--- 80,86 ----
dbname=`echo $1 | sed 's/^--dbname=//'`
;;
--database=*)
! dbname=`echo $1 | sed 's/^--database=//'`
;;
# options converted into SQL command
--analyze|-z)