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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
dnl file : m4/pgsql.m4
dnl author : Constantin Michael <constantin@codesynthesis.com>
dnl copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
dnl license : GNU GPL v2; see accompanying LICENSE file
dnl
dnl PGSQL
dnl
AC_DEFUN([PGSQL], [
# Client.
#
AC_MSG_CHECKING([for pgsql client program])
AC_ARG_WITH(
[pgsql-client],
[AC_HELP_STRING([--with-pgsql-client=path], [PostgreSQL client program path (psql by default)])],
[case $withval in
yes)
pgsql_client=psql
;;
no)
AC_MSG_RESULT([])
AC_MSG_ERROR([need pgsql client to run the tests])
;;
*)
pgsql_client=$withval
;;
esac],
[pgsql_client=psql])
$pgsql_client --version 2>/dev/null 1>&2
if test x"$?" = x0; then
AC_MSG_RESULT([$pgsql_client])
else
AC_MSG_RESULT([no])
AC_MSG_ERROR([pgsql client is not found; consider using --with-pgsql-client=PATH])
fi
# User.
#
AC_MSG_CHECKING([for pgsql database user])
AC_ARG_WITH(
[pgsql-user],
[AC_HELP_STRING([--with-pgsql-user=login], [PostgreSQL database user (odb_test by default). The user must be able to login without specifying a password.])],
[case $withval in
yes)
pgsql_user=odb_test
pgsql_user_set=yes
;;
no)
pgsql_user_set=no
;;
*)
pgsql_user=$withval
pgsql_user_set=yes
;;
esac],
[pgsql_user=odb_test
pgsql_user_set=yes])
if test x$pgsql_user_set = xyes; then
AC_MSG_RESULT(['$pgsql_user'])
else
AC_MSG_RESULT([none])
fi
# Database name.
#
AC_MSG_CHECKING([for pgsql database name])
AC_ARG_WITH(
[pgsql-db],
[AC_HELP_STRING([--with-pgsql-db=name], [PostgreSQL database name (odb_test by default). Note that all data in this database WILL BE LOST!])],
[case $withval in
yes)
pgsql_db=odb_test
pgsql_db_set=yes
;;
no)
pgsql_db_set=no
;;
*)
pgsql_db=$withval
pgsql_db_set=yes
;;
esac],
[pgsql_db=odb_test
pgsql_db_set=yes])
if test x$pgsql_db_set = xyes; then
AC_MSG_RESULT(['$pgsql_db'])
else
AC_MSG_RESULT([none])
fi
# Host.
#
AC_MSG_CHECKING([for pgsql database host])
AC_ARG_WITH(
[pgsql-host],
[AC_HELP_STRING([--with-pgsql-host=host], [PostgreSQL database host (localhost by default)])],
[case $withval in
yes)
pgsql_host=
pgsql_host_set=yes
;;
no)
pgsql_host_set=no
;;
*)
pgsql_host=$withval
pgsql_host_set=yes
;;
esac],
[pgsql_host_set=no])
if test x$pgsql_host_set = xyes; then
AC_MSG_RESULT(['$pgsql_host'])
else
AC_MSG_RESULT([localhost])
fi
# Port.
#
AC_MSG_CHECKING([for pgsql database port])
AC_ARG_WITH(
[pgsql-port],
[AC_HELP_STRING([--with-pgsql-port=port], [PostgreSQL database port (standard PostgreSQL port by default)])],
[case $withval in
yes)
pgsql_port=0
pgsql_port_set=yes
;;
no)
pgsql_port_set=no
;;
*)
pgsql_port=$withval
pgsql_port_set=yes
;;
esac],
[pgsql_port_set=no])
if test x$pgsql_port_set = xyes; then
AC_MSG_RESULT(['$pgsql_port'])
else
AC_MSG_RESULT([default])
fi
# Create options file.
#
AC_CONFIG_COMMANDS([pgsql.options],
[
rm -f db.options
echo '#! /bin/sh' >db-driver
echo 'opt=' >>db-driver
if test x$pgsql_user_set = xyes; then
echo "--username '$pgsql_user'" >>db.options
echo 'opt="$opt --username='"$pgsql_user"'"' >>db-driver
fi
if test x$pgsql_db_set = xyes; then
echo "--dbname '$pgsql_db'" >>db.options
echo 'opt="$opt --dbname='"$pgsql_db"'"' >>db-driver
fi
if test x$pgsql_host_set = xyes; then
echo "--host '$pgsql_host'" >>db.options
echo 'opt="$opt --host='"$pgsql_host"'"' >>db-driver
fi
if test x$pgsql_port_set = xyes; then
echo "--port '$pgsql_port'" >>db.options
echo 'opt="$opt --port='"$pgsql_port"'"' >>db-driver
fi
echo 'opt="$opt --quiet"' >>db-driver
echo 'PGOPTIONS=--client-min-messages=warning' >>db-driver
echo 'export PGOPTIONS' >>db-driver
echo 'if test x$[]1 != x; then' >>db-driver
echo " exec $pgsql_client "'$opt <$[]1' >>db-driver
echo "else" >>db-driver
echo " exec $pgsql_client "'$opt' >>db-driver
echo "fi" >>db-driver
chmod +x db-driver
],
[
pgsql_client="$pgsql_client"
pgsql_user="$pgsql_user"
pgsql_user_set="$pgsql_user_set"
pgsql_db="$pgsql_db"
pgsql_db_set="$pgsql_db_set"
pgsql_host="$pgsql_host"
pgsql_host_set="$pgsql_host_set"
pgsql_port="$pgsql_port"
pgsql_port_set="$pgsql_port_set"
])
])dnl
|