|
3 | 3 | *
|
4 | 4 | * Copyright 2000-2002 by PostgreSQL Global Development Group
|
5 | 5 | *
|
6 |
| - * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.23 2002/10/15 02:24:16 tgl Exp $ |
| 6 | + * $Header: /cvsroot/pgsql/src/bin/psql/large_obj.c,v 1.24 2003/03/20 06:43:35 momjian Exp $ |
7 | 7 | */
|
8 | 8 | #include "postgres_fe.h"
|
9 | 9 | #include "large_obj.h"
|
@@ -40,15 +40,20 @@ _my_notice_handler(void *arg, const char *message)
|
40 | 40 | static bool
|
41 | 41 | handle_transaction(void)
|
42 | 42 | {
|
43 |
| - const char *var = GetVariable(pset.vars, "LO_TRANSACTION"); |
44 | 43 | PGresult *res;
|
45 |
| - bool commit; |
| 44 | + bool commit = false; |
46 | 45 | PQnoticeProcessor old_notice_hook;
|
47 | 46 |
|
48 |
| - if (var && strcmp(var, "nothing") == 0) |
| 47 | + switch (SwitchVariable(pset.vars, "LO_TRANSACTION", |
| 48 | + "nothing", |
| 49 | + "commit", |
| 50 | + NULL)) |
| 51 | + { |
| 52 | + case 1: |
49 | 53 | return true;
|
50 |
| - |
51 |
| - commit = (var && strcmp(var, "commit") == 0); |
| 54 | + case 2: |
| 55 | + commit = true; |
| 56 | + } |
52 | 57 |
|
53 | 58 | notice[0] = '\0';
|
54 | 59 | old_notice_hook = PQsetNoticeProcessor(pset.db, _my_notice_handler, NULL);
|
@@ -87,11 +92,9 @@ do_lo_export(const char *loid_arg, const char *filename_arg)
|
87 | 92 | {
|
88 | 93 | PGresult *res;
|
89 | 94 | int status;
|
90 |
| - bool own_transaction = true; |
91 |
| - const char *var = GetVariable(pset.vars, "LO_TRANSACTION"); |
| 95 | + bool own_transaction; |
92 | 96 |
|
93 |
| - if (var && strcmp(var, "nothing") == 0) |
94 |
| - own_transaction = false; |
| 97 | + own_transaction = VariableEquals(pset.vars, "LO_TRANSACTION", "nothing"); |
95 | 98 |
|
96 | 99 | if (!pset.db)
|
97 | 100 | {
|
@@ -154,11 +157,9 @@ do_lo_import(const char *filename_arg, const char *comment_arg)
|
154 | 157 | Oid loid;
|
155 | 158 | char oidbuf[32];
|
156 | 159 | unsigned int i;
|
157 |
| - bool own_transaction = true; |
158 |
| - const char *var = GetVariable(pset.vars, "LO_TRANSACTION"); |
| 160 | + bool own_transaction; |
159 | 161 |
|
160 |
| - if (var && strcmp(var, "nothing") == 0) |
161 |
| - own_transaction = false; |
| 162 | + own_transaction = VariableEquals(pset.vars, "LO_TRANSACTION", "nothing"); |
162 | 163 |
|
163 | 164 | if (!pset.db)
|
164 | 165 | {
|
@@ -271,11 +272,10 @@ do_lo_unlink(const char *loid_arg)
|
271 | 272 | int status;
|
272 | 273 | Oid loid = atooid(loid_arg);
|
273 | 274 | char buf[256];
|
274 |
| - bool own_transaction = true; |
275 |
| - const char *var = GetVariable(pset.vars, "LO_TRANSACTION"); |
276 | 275 |
|
277 |
| - if (var && strcmp(var, "nothing") == 0) |
278 |
| - own_transaction = false; |
| 276 | + bool own_transaction; |
| 277 | + |
| 278 | + own_transaction = VariableEquals(pset.vars, "LO_TRANSACTION", "nothing"); |
279 | 279 |
|
280 | 280 | if (!pset.db)
|
281 | 281 | {
|
|
0 commit comments