Bug 1177: Change "unix_socket_directory" paramter for PostgreSQL 9.3. 47/7847/1
authorShigeru Yasuda <s-yasuda@da.jp.nec.com>
Tue, 10 Jun 2014 02:33:25 +0000 (11:33 +0900)
committerShigeru Yasuda <s-yasuda@da.jp.nec.com>
Tue, 10 Jun 2014 02:33:25 +0000 (11:33 +0900)
"unix_socket_directory" parameter in postgresql.conf was renamed to
"unix_socket_directories" in PostgreSQL 9.3. This patch makes db_setup
script define "unix_socket_directories" parameter to specify UNIX socket
directory when it detects PostgreSQL 9.3 or later.

Change-Id: I3dda6064eaadfc24baee87da12ab0ef8675c78f6
Signed-off-by: Shigeru Yasuda <s-yasuda@da.jp.nec.com>
coordinator/cmds/dbm/common/dbm_functions.in
coordinator/cmds/dbm/db_control/db_setup.in
coordinator/cmds/dbm/db_control/postgresql.conf.single.in

index 43312c68f41978994e57217df42f9a025cba37b9..d2861142915af659b0413de1d248606165065637 100644 (file)
@@ -444,16 +444,40 @@ copy_postgresql_file()
 #      copy postgresql.conf
 #
 # * input
-#         Nothing
+#      arg1: PostgreSQL major version number
+#      arg2: PostgreSQL minor version number
 #
 # * output
-#         0: Success
-#         1: Failure
+#      0: Success
+#      1: Failure
 #
 copy_postgresql_conf()
 {
+       local major=$1
+       local minor=$2
+
+       # Determine parameter that specifies UNIX domain socket path.
+       local uds
+       if [ "$major" -gt 9 -o \( "$major" -eq 9 -a "$minor" -ge 3 \) ]; then
+               uds="unix_socket_directories"
+       else
+               uds="unix_socket_directory"
+       fi
+
+       # Update postgresql.conf.
+       local tmp="${POSTFILE}_tmp.$$"
+       sed -e "s,%unix_socket_directory%,$uds," $SINGLEPOSTFILE > $tmp
+       if [ $? -ne 0 ]; then
+               rm -f $tmp
+               return 1
+       fi
+
        # Install postgresql.conf.
-       copy_postgresql_file $SINGLEPOSTFILE $POSTFILE || return 1
+       copy_postgresql_file $tmp $POSTFILE
+       local status=$?
+       rm -f $tmp
+
+       return $status
 }
 
 # create_setting_file()
index 90e40310a4da5aad242c9aa93bdea49b7c922546..0f1ceb0d1898ceb22873025975791e5c116503f1 100644 (file)
@@ -395,7 +395,7 @@ create_db()
        runas_suuser "$PGINST/bin/initdb -D $PGDATA -U $PGUSER \
                -E UNICODE --no-locale" > /dev/null 2> $TMPLOGFILE
        [ $? -ne 0 ] && db_setup_error initdb
-       copy_postgresql_conf 2> $TMPLOGFILE
+       copy_postgresql_conf $PGSQL_MAJOR $PGSQL_MINOR 2> $TMPLOGFILE
        [ $? -ne 0 ] && data_copy_error
 
        # Start PostgreSQL.
@@ -443,6 +443,9 @@ create_db()
 #      0:  Success
 #      1:  The given command cannot be used.
 #
+#      Major and minor version are set to PGSQL_MAJOR and PGSQL_MINOR
+#      respectively.
+#
 check_pgsql_version()
 {
        [ -x "$1" ] || return 1
@@ -450,19 +453,21 @@ check_pgsql_version()
        [ -z "$vstr" ] && return 1
        log_output $$ INFO $0 "$1 --version: $vstr" $LOGFILE
 
-       # Check major version.
-       local maj=`echo $vstr |
+       # Determine version.
+       PGSQL_MAJOR=`echo $vstr |
                   sed -e 's/^.*(PostgreSQL) \([0-9]\{1,\}\)\..*$/\1/'`
-       [ -z "$maj" ] && return 1
-       [ "$maj" -lt $PGSQL_VERSION_MAJOR ] && return 1
-       [ "$maj" -gt $PGSQL_VERSION_MAJOR ] && return 0
-       [ -z "$PGSQL_VERSION_MINOR" ] && return 0
+       [ -z "$PGSQL_MAJOR" ] && return 1
+       PGSQL_MINOR=`echo $vstr |
+          sed -e 's/^.*(PostgreSQL) [0-9]\{1,\}\.\([0-9]\{1,\}\)\(\.[0-9]\{1,\}\)\{0,1\}$/\1/'`
+       [ -z "$PGSQL_MINOR" ] && return 1
+
+       # Check major version.
+       [ "$PGSQL_MAJOR" -lt $PGSQL_VERSION_MAJOR ] && return 1
+       [ "$PGSQL_MAJOR" -gt $PGSQL_VERSION_MAJOR ] && return 0
 
        # Check minor version.
-       local min=`echo $vstr |
-          sed -e 's/^.*(PostgreSQL) [0-9]\{1,\}\.\([0-9]\{1,\}\)\(\.[0-9]\{1,\}\)\{0,1\}$/\1/'`
-       [ -z "$min" ] && return 1
-       [ "$min" -lt "$PGSQL_VERSION_MINOR" ] && return 1
+       [ -z "$PGSQL_VERSION_MINOR" ] && return 0
+       [ "$PGSQL_MINOR" -lt "$PGSQL_VERSION_MINOR" ] && return 1
 
        return 0
 }
index e9481effb1ad5b8f3d93a9c7124ab0a46a343429..7cbdc880688680c973589b3b18e198a578a0b954 100644 (file)
@@ -24,7 +24,7 @@ max_connections                       = 100
 superuser_reserved_connections = 4
 
 # Directory to store UNIX domain socket file.
-unix_socket_directory  = '%INST_LOCALSTATEDIR%/run/dbm'
+%unix_socket_directory%        = '%INST_LOCALSTATEDIR%/run/dbm'
 
 #
 # Resource Settings