|
3 | 3 | *
|
4 | 4 | * Copyright (c) 2000-2007, PostgreSQL Global Development Group
|
5 | 5 | *
|
6 |
| - * $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.47 2007/01/05 22:19:49 momjian Exp $ |
| 6 | + * $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.48 2007/01/20 16:57:31 neilc Exp $ |
7 | 7 | */
|
8 | 8 | #include "postgres_fe.h"
|
9 | 9 | #include "large_obj.h"
|
|
12 | 12 | #include "settings.h"
|
13 | 13 | #include "common.h"
|
14 | 14 |
|
| 15 | +static void |
| 16 | +print_lo_result(const char *fmt,...) |
| 17 | +__attribute__((format(printf, 1, 2))); |
| 18 | + |
| 19 | +static void |
| 20 | +print_lo_result(const char *fmt,...) |
| 21 | +{ |
| 22 | + va_list ap; |
| 23 | + |
| 24 | + if (!pset.quiet) |
| 25 | + { |
| 26 | + if (pset.popt.topt.format == PRINT_HTML) |
| 27 | + fputs("<p>", pset.queryFout); |
| 28 | + |
| 29 | + va_start(ap, fmt); |
| 30 | + vfprintf(pset.queryFout, fmt, ap); |
| 31 | + va_end(ap); |
| 32 | + |
| 33 | + if (pset.popt.topt.format == PRINT_HTML) |
| 34 | + fputs("</p>\n", pset.queryFout); |
| 35 | + else |
| 36 | + fputs("\n", pset.queryFout); |
| 37 | + } |
| 38 | + |
| 39 | + if (pset.logfile) |
| 40 | + { |
| 41 | + va_start(ap, fmt); |
| 42 | + vfprintf(pset.logfile, fmt, ap); |
| 43 | + va_end(ap); |
| 44 | + fputs("\n", pset.logfile); |
| 45 | + } |
| 46 | +} |
| 47 | + |
15 | 48 |
|
16 | 49 | /*
|
17 | 50 | * Prepare to do a large-object operation. We *must* be inside a transaction
|
@@ -129,7 +162,7 @@ do_lo_export(const char *loid_arg, const char *filename_arg)
|
129 | 162 | if (!finish_lo_xact("\\lo_export", own_transaction))
|
130 | 163 | return false;
|
131 | 164 |
|
132 |
| - fprintf(pset.queryFout, "lo_export\n"); |
| 165 | + print_lo_result("lo_export"); |
133 | 166 |
|
134 | 167 | return true;
|
135 | 168 | }
|
@@ -189,7 +222,8 @@ do_lo_import(const char *filename_arg, const char *comment_arg)
|
189 | 222 | if (!finish_lo_xact("\\lo_import", own_transaction))
|
190 | 223 | return false;
|
191 | 224 |
|
192 |
| - fprintf(pset.queryFout, "lo_import %u\n", loid); |
| 225 | + print_lo_result("lo_import %u", loid); |
| 226 | + |
193 | 227 | sprintf(oidbuf, "%u", loid);
|
194 | 228 | SetVariable(pset.vars, "LASTOID", oidbuf);
|
195 | 229 |
|
@@ -225,7 +259,7 @@ do_lo_unlink(const char *loid_arg)
|
225 | 259 | if (!finish_lo_xact("\\lo_unlink", own_transaction))
|
226 | 260 | return false;
|
227 | 261 |
|
228 |
| - fprintf(pset.queryFout, "lo_unlink %u\n", loid); |
| 262 | + print_lo_result("lo_unlink %u", loid); |
229 | 263 |
|
230 | 264 | return true;
|
231 | 265 | }
|
|
0 commit comments