Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5d8c674

Browse files
committed
Fix script to handle autocommit = 'off' by prepending autocommit 'on' to
the start of the psql commandline. This is better than adding BEGIN/ENDbecause it handles multiple queries well, and allows the return code forpsql to return the proper value.
1 parentfacb720 commit5d8c674

File tree

8 files changed

+20
-20
lines changed

8 files changed

+20
-20
lines changed

‎src/bin/scripts/clusterdb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
#
1313
# IDENTIFICATION
14-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/clusterdb,v 1.4 2002/09/27 17:51:10 momjian Exp $
14+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/clusterdb,v 1.5 2002/10/16 03:24:09 momjian Exp $
1515
#
1616
#-------------------------------------------------------------------------
1717

@@ -176,7 +176,7 @@ do
176176
idx=`echo$tabs| cut -d: -f3`
177177
query="$query CLUSTER$idx ON$nspc.$tab;"
178178
done
179-
${PATHNAME}psql$PSQLOPT$ECHOOPT -c"$query" -d$db
179+
${PATHNAME}psql$PSQLOPT$ECHOOPT -c"SET autocommit = 'on';$query" -d$db
180180
if ["$?"-ne 0 ]
181181
then
182182
echo"$CMDNAME: While clustering$db, the following failed:$query"1>&2

‎src/bin/scripts/createdb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#
1313
#
1414
# IDENTIFICATION
15-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.25 2002/09/03 21:45:43 petere Exp $
15+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.26 2002/10/16 03:24:09 momjian Exp $
1616
#
1717
#-------------------------------------------------------------------------
1818

@@ -189,7 +189,7 @@ withstring=
189189
["$TEMPLATE" ]&& withstring="$withstring TEMPLATE =\"$TEMPLATE\""
190190
["$withstring" ]&& withstring=" WITH$withstring"
191191

192-
${PATHNAME}psql$PSQLOPT -d template1 -c"CREATE DATABASE\"$dbname\"$withstring"
192+
${PATHNAME}psql$PSQLOPT -d template1 -c"SET autocommit = 'on';CREATE DATABASE\"$dbname\"$withstring"
193193
if ["$?"-ne 0 ];then
194194
echo"$CMDNAME: database creation failed"1>&2
195195
exit 1
@@ -200,7 +200,7 @@ fi
200200

201201
dbcomment=`echo"$dbcomment"| sed"s/'/\\\\\'/g"`
202202

203-
${PATHNAME}psql$PSQLOPT -d"$dbname" -c"COMMENT ON DATABASE\"$dbname\" IS '$dbcomment'"
203+
${PATHNAME}psql$PSQLOPT -d"$dbname" -c"SET autocommit = 'on';COMMENT ON DATABASE\"$dbname\" IS '$dbcomment'"
204204
if ["$?"-ne 0 ];then
205205
echo"$CMDNAME: comment creation failed (database was created)"1>&2
206206
exit 1

‎src/bin/scripts/createlang.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
# Portions Copyright (c) 1994, Regents of the University of California
99
#
10-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.39 2002/09/24 23:14:25 tgl Exp $
10+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.40 2002/10/16 03:24:09 momjian Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -270,7 +270,7 @@ fi
270270
# Create the call handler and the language
271271
# ----------
272272
if ["$handlerexists"= no ];then
273-
sqlcmd="CREATE FUNCTION\"$handler\" () RETURNS LANGUAGE_HANDLER AS '$PGLIB/${object}' LANGUAGE C;"
273+
sqlcmd="SET autocommit = 'on';CREATE FUNCTION\"$handler\" () RETURNS LANGUAGE_HANDLER AS '$PGLIB/${object}' LANGUAGE C;"
274274
if ["$showsql"= yes ];then
275275
echo"$sqlcmd"
276276
fi
@@ -281,7 +281,7 @@ if [ "$handlerexists" = no ]; then
281281
fi
282282
fi
283283

284-
sqlcmd="CREATE${trusted}LANGUAGE\"$langname\" HANDLER\"$handler\";"
284+
sqlcmd="SET autocommit = 'on';CREATE${trusted}LANGUAGE\"$langname\" HANDLER\"$handler\";"
285285
if ["$showsql"= yes ];then
286286
echo"$sqlcmd"
287287
fi
@@ -297,7 +297,7 @@ fi
297297
# seems best to disable public USAGE for an untrusted one.
298298
# ----------
299299
iftest -z"$trusted";then
300-
sqlcmd="REVOKE ALL ON LANGUAGE\"$langname\" FROM PUBLIC;"
300+
sqlcmd="SET autocommit = 'on';REVOKE ALL ON LANGUAGE\"$langname\" FROM PUBLIC;"
301301
if ["$showsql"= yes ];then
302302
echo"$sqlcmd"
303303
fi

‎src/bin/scripts/createuser

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#
1010
#
1111
# IDENTIFICATION
12-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.26 2002/06/20 20:29:42 momjian Exp $
12+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.27 2002/10/16 03:24:09 momjian Exp $
1313
#
1414
# Note - this should NOT be setuid.
1515
#
@@ -253,7 +253,7 @@ SUBQUERY=
253253
["$CanAddUser"= t ]&& QUERY="$QUERY CREATEUSER"
254254
["$CanAddUser"= f ]&& QUERY="$QUERY NOCREATEUSER"
255255

256-
${PATHNAME}psql -c"$QUERY" -d template1$PSQLOPT
256+
${PATHNAME}psql -c"SET autocommit = 'on';$QUERY" -d template1$PSQLOPT
257257
if ["$?"-ne 0 ];then
258258
echo"$CMDNAME: creation of user\"$NewUser\" failed"1>&2
259259
exit 1

‎src/bin/scripts/dropdb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
#
1313
# IDENTIFICATION
14-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.16 2002/06/20 20:29:42 momjian Exp $
14+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.17 2002/10/16 03:24:09 momjian Exp $
1515
#
1616
#-------------------------------------------------------------------------
1717

@@ -138,7 +138,7 @@ fi
138138

139139
dbname=`echo"$dbname"| sed's/\"/\\\"/g'`
140140

141-
${PATHNAME}psql$PSQLOPT -d template1 -c"DROP DATABASE\"$dbname\""
141+
${PATHNAME}psql$PSQLOPT -d template1 -c"SET autocommit = 'on';DROP DATABASE\"$dbname\""
142142
if ["$?"-ne 0 ];then
143143
echo"$CMDNAME: database removal failed"1>&2
144144
exit 1

‎src/bin/scripts/droplang

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
# Portions Copyright (c) 1994, Regents of the University of California
99
#
10-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.24 2002/08/10 16:57:32 petere Exp $
10+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.25 2002/10/16 03:24:09 momjian Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -229,7 +229,7 @@ fi
229229
# ----------
230230
# Drop the language
231231
# ----------
232-
sqlcmd="DROP LANGUAGE\"$langname\";"
232+
sqlcmd="SET autocommit = 'on';DROP LANGUAGE\"$langname\";"
233233
if ["$showsql"= yes ];then
234234
echo"$sqlcmd"
235235
fi
@@ -256,7 +256,7 @@ if [ "$?" -ne 0 ]; then
256256
exit 1
257257
fi
258258

259-
sqlcmd="DROP FUNCTION\"$handler\" ();"
259+
sqlcmd="SET autocommit = 'on';DROP FUNCTION\"$handler\" ();"
260260
if ["$showsql"= yes ];then
261261
echo"$sqlcmd"
262262
fi

‎src/bin/scripts/dropuser

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#
1010
#
1111
# IDENTIFICATION
12-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.18 2002/06/20 20:29:42 momjian Exp $
12+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.19 2002/10/16 03:24:09 momjian Exp $
1313
#
1414
# Note - this should NOT be setuid.
1515
#
@@ -148,7 +148,7 @@ fi
148148

149149
DelUser=`echo"$DelUser"| sed's/\"/\\\"/g'`
150150

151-
${PATHNAME}psql$PSQLOPT -d template1 -c"DROP USER\"$DelUser\""
151+
${PATHNAME}psql$PSQLOPT -d template1 -c"SET autocommit = 'on';DROP USER\"$DelUser\""
152152

153153
if ["$?"-ne 0 ];then
154154
echo"$CMDNAME: deletion of user\"$DelUser\" failed"1>&2

‎src/bin/scripts/vacuumdb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#
1313
#
1414
# IDENTIFICATION
15-
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.23 2002/08/10 16:57:32 petere Exp $
15+
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.24 2002/10/16 03:24:09 momjian Exp $
1616
#
1717
#-------------------------------------------------------------------------
1818

@@ -169,7 +169,7 @@ fi
169169
fordbin$dbname
170170
do
171171
["$alldb"-a"$quiet"-ne 1 ]&&echo"Vacuuming$db"
172-
${PATHNAME}psql$PSQLOPT$ECHOOPT -c"VACUUM$full$verbose$analyze$table" -d$db
172+
${PATHNAME}psql$PSQLOPT$ECHOOPT -c"SET autocommit = 'on';VACUUM$full$verbose$analyze$table" -d$db
173173
if ["$?"-ne 0 ];then
174174
echo"$CMDNAME: vacuum$table$db failed"1>&2
175175
exit 1

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp