mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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:
@ -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
|
||||
|
@ -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:
|
@ -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
|
||||
|
@ -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:
|
@ -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
BIN
src/bin/scripts/ID
Normal file
Binary file not shown.
@ -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:
|
||||
|
255
src/bin/scripts/createlang.sh
Normal file
255
src/bin/scripts/createlang.sh
Normal 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
210
src/bin/scripts/droplang
Normal 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
11375
src/bin/scripts/tags
Normal file
File diff suppressed because it is too large
Load Diff
@ -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"
|
||||
|
17
src/bin/scripts/vacuumdb.rej
Normal file
17
src/bin/scripts/vacuumdb.rej
Normal 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)
|
Reference in New Issue
Block a user