Removed the automatic installation of built procedural languages

from initdb again.

Added two new commands, createlang and destroylang to bin. These
hopefully end this damned mklang.sql discussion.

Jan
This commit is contained in:
Jan Wieck 1999-05-20 16:50:08 +00:00
parent 33773af95b
commit 3de11d6526
8 changed files with 382 additions and 26 deletions

View File

@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.17 1998/12/18 17:53:21 momjian Exp $
# $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.18 1999/05/20 16:49:59 wieck Exp $
#
#-------------------------------------------------------------------------
@ -15,7 +15,8 @@ SRCDIR= ..
include ../Makefile.global
DIRS = pg_id pg_version psql pg_dump pg_passwd cleardbdir createdb \
createuser destroydb destroyuser initdb vacuumdb initlocation ipcclean
createlang createuser destroydb destroylang destroyuser initdb \
vacuumdb initlocation ipcclean
ifdef MULTIBYTE
DIRS += pg_encoding

View File

@ -0,0 +1,29 @@
#-------------------------------------------------------------------------
#
# 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

@ -0,0 +1,173 @@
#!/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.1 1999/05/20 16:50:00 wieck 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 1
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

@ -0,0 +1,28 @@
#-------------------------------------------------------------------------
#
# 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

@ -0,0 +1,139 @@
#!/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

View File

@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/initdb/Makefile,v 1.12 1999/05/12 10:35:43 wieck Exp $
# $Header: /cvsroot/pgsql/src/bin/initdb/Makefile,v 1.13 1999/05/20 16:50:05 wieck Exp $
#
#-------------------------------------------------------------------------
@ -18,7 +18,6 @@ all: initdb
initdb: initdb.sh
sed -e 's/__MULTIBYTE__/$(MULTIBYTE)/' \
-e 's/__DLSUFFIX__/$(DLSUFFIX)/' \
initdb.sh > initdb
install: initdb

View File

@ -26,7 +26,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.59 1999/05/12 10:35:43 wieck Exp $
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.60 1999/05/20 16:50:06 wieck Exp $
#
#-------------------------------------------------------------------------
@ -491,26 +491,6 @@ echo "CREATE RULE \"_RETpg_indexes\" AS ON SELECT TO pg_indexes DO INSTEAD \
AND I.oid = X.indexrelid;" | \
postgres $PGSQL_OPT template1 > /dev/null
if [ -f $PGLIB/plpgsql__DLSUFFIX__ ] ; then
echo "Installing PL/pgSQL as trusted procedural language"
echo "CREATE FUNCTION plpgsql_call_handler () RETURNS opaque \
AS '$PGLIB/plpgsql__DLSUFFIX__' LANGUAGE 'C';" | \
postgres $PGSQL_OPT template1 > /dev/null
echo "CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' \
HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL';" | \
postgres $PGSQL_OPT template1 > /dev/null
fi
if [ -f $PGLIB/pltcl__DLSUFFIX__ ] ; then
echo "Installing PL/Tcl as trusted procedural language"
echo "CREATE FUNCTION pltcl_call_handler () RETURNS opaque \
AS '$PGLIB/pltcl__DLSUFFIX__' LANGUAGE 'C';" | \
postgres $PGSQL_OPT template1 > /dev/null
echo "CREATE TRUSTED PROCEDURAL LANGUAGE 'pltcl' \
HANDLER pltcl_call_handler LANCOMPILER 'PL/Tcl';" | \
postgres $PGSQL_OPT template1 > /dev/null
fi
echo "Loading pg_description"
echo "copy pg_description from '$TEMPLATE_DESCR'" | \
postgres $PGSQL_OPT template1 > /dev/null

View File

@ -1,5 +1,5 @@
#!/bin/sh
# $Header: /cvsroot/pgsql/src/test/regress/Attic/regress.sh,v 1.27 1999/05/07 02:31:43 momjian Exp $
# $Header: /cvsroot/pgsql/src/test/regress/Attic/regress.sh,v 1.28 1999/05/20 16:50:08 wieck Exp $
#
if [ $# -eq 0 ]
then
@ -63,6 +63,13 @@ if [ $? -ne 0 ]; then
exit 1
fi
echo "=============== installing PL/pgSQL... ================="
createlang $HOST plpgsql regression
if [ $? -ne 0 ]; then
echo createlang failed
exit 1
fi
echo "=============== running regression queries... ================="
echo "" > regression.diffs
for i in `cat sql/tests` $mbtests