summaryrefslogtreecommitdiffstats
path: root/tests/pllua
blob: 2821122be2d01ff0ac3383bfe9b26017ca41eeab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh

# this test is due to:
# http://redmine.alpinelinux.org/issues/503

# pllua test is from:
# http://pllua.projects.postgresql.org/

apk_add postgresql pllua
/etc/init.d/postgresql start

# create db and pllua language
psql -U postgres -c 'create database aptstest'
psql -U postgres -f /usr/share/postgresql/contrib/pllua.sql aptstest

# create function
psql -U postgres -d aptstest -c '
CREATE FUNCTION hello(name text) RETURNS text AS $$
	return string.format("hello:%s", name)
$$ LANGUAGE pllua;
'

# test that lua function works
psql -U postgres -d aptstest -c "SELECT hello('lua');" | grep 'hello:lua'

# cleanup
psql -U postgres -c 'drop database aptstest'
/etc/init.d/postgresql stop
apk_del pllua postgresql