foo=> \lo_import '/home/peter/pictures/photo.xcf' 'a picture of me'
lo_import 152801
- The response indicates that the large object received object ID
- 152801 which one ought to remember if one wants to access the
- object ever again. For that reason it is recommended to always
- associate a human-readable comment with every object. Those can
- then be seen with the \lo_list command.
+ The response indicates that the large object received object
+ ID 152801, which can be used to access the newly-created large
+ object in the future. For the sake of readability, it is
+ recommended to always associate a human-readable comment with
+ every object. Both OIDs and comments can be viewed with the
+ \lo_list command.
*
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.47 2007/01/05 22:19:49 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.48 2007/01/20 16:57:31 neilc Exp $
*/
#include "postgres_fe.h"
#include "large_obj.h"
#include "settings.h"
#include "common.h"
+static void
+print_lo_result(const char *fmt,...)
+__attribute__((format(printf, 1, 2)));
+
+static void
+print_lo_result(const char *fmt,...)
+{
+ va_list ap;
+
+ if (!pset.quiet)
+ {
+ if (pset.popt.topt.format == PRINT_HTML)
+ fputs("
", pset.queryFout);
+
+ va_start(ap, fmt);
+ vfprintf(pset.queryFout, fmt, ap);
+ va_end(ap);
+
+ if (pset.popt.topt.format == PRINT_HTML)
+ fputs("\n", pset.queryFout);
+ else
+ fputs("\n", pset.queryFout);
+ }
+
+ if (pset.logfile)
+ {
+ va_start(ap, fmt);
+ vfprintf(pset.logfile, fmt, ap);
+ va_end(ap);
+ fputs("\n", pset.logfile);
+ }
+}
+
/*
* Prepare to do a large-object operation. We *must* be inside a transaction
if (!finish_lo_xact("\\lo_export", own_transaction))
return false;
- fprintf(pset.queryFout, "lo_export\n");
+ print_lo_result("lo_export");
return true;
}
if (!finish_lo_xact("\\lo_import", own_transaction))
return false;
- fprintf(pset.queryFout, "lo_import %u\n", loid);
+ print_lo_result("lo_import %u", loid);
+
sprintf(oidbuf, "%u", loid);
SetVariable(pset.vars, "LASTOID", oidbuf);
if (!finish_lo_xact("\\lo_unlink", own_transaction))
return false;
- fprintf(pset.queryFout, "lo_unlink %u\n", loid);
+ print_lo_result("lo_unlink %u", loid);
return true;
}