git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2d11676)
Add enable_plpgsql from Oliver.
1998年12月13日 05:22:58 +0000 (05:22 +0000)
1998年12月13日 05:22:58 +0000 (05:22 +0000)
src/pl/plpgsql/enable_plpgsql [new file with mode: 0644] patch | blob

diff --git a/src/pl/plpgsql/enable_plpgsql b/src/pl/plpgsql/enable_plpgsql
new file mode 100644 (file)
index 0000000..efd2cf1
--- /dev/null
+++ b/src/pl/plpgsql/enable_plpgsql
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+# Enable the PL procedural language for PostgreSQL in one or more
+# existing databases.
+#
+# This script should be run by the PostgreSQL superuser
+
+enable_database() {
+ if ! psql -d 1ドル -qtc "select count(*) from pg_language where lanname='plpgsql'" >$TMPFIL2 2>&1
+ then
+ echo "Cannot connect to 1ドル"
+ exit 2
+ fi
+ if [ `cat $TMPFIL2` -eq 0 ]
+ then
+ if ! psql -d 1ドル <$sqlfile
+ then
+ echo "Failed to add PL to 1ドル"
+ exit 2
+ fi
+ echo "PL added to 1ドル"
+ else
+ echo "PL is already enabled in 1ドル"
+ fi
+
+}
+
+# Execution starts here
+
+TMPFILE=`mktemp /tmp/enable_pgpl.XXXXXX`
+TMPFIL2=`mktemp /tmp/enable_pgpl.XXXXXX`
+trap "rm $TMPFILE $TMPFIL2" EXIT
+
+sqlfile=${PGLIB:=/usr/local/pgsql/lib}/mklang_pl.sql
+if [ ! -f $sqlfile ]
+then
+ echo "Cannot find mklang_pl.sql"
+ exit 2
+fi
+
+if [ -z "1ドル" ]
+then
+ echo "Syntax: 0ドル --all | database ..."
+ exit 1
+fi
+
+if [ 1ドル = "--all" ]
+then
+ if ! psql -t -c "select datname from pg_database order by datname" >$TMPFILE
+ then
+ echo Cannot select databases
+ exit 2
+ fi
+ for db in `cat $TMPFILE`
+ do
+ enable_database $db
+ done
+else
+ while [ -n "1ドル" ]
+ do
+ db=1ドル
+ enable_database $db
+ shift
+ done
+fi
+
+
+
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /