Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
26a23e33
Commit
26a23e33
authored
26 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
Add enable_plpgsql from Oliver.
parent
2d116769
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pl/plpgsql/enable_plpgsql
+68
-0
68 additions, 0 deletions
src/pl/plpgsql/enable_plpgsql
with
68 additions
and
0 deletions
src/pl/plpgsql/enable_plpgsql
0 → 100644
+
68
−
0
View file @
26a23e33
#!/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 diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment