This is the latest version of the large object regression test I have been
working on.  Note that a prerequisite for this version of the test is the
patch I made to psql to make it not output on \lo_* commands in quiet mode
is required (also attached, it's small).

Sorry that it still makes use of the sed trickery like the copy test does,
but:

1) I think the server side lo_(import|export) functions need to be tested
as well as the psql variants

2) ISTM that making assumptions about the working directory of psql
during
the regression tests would open a can of worms, especially wrt VPATH
builds where the data files could be in a completely separate tree from
the regression tests.


Thoughts?

-- 
Why did the Roman Empire collapse?
What is the Latin for office automation?
Index: src/bin/psql/large_obj.c
===================================================================
RCS file: 
/home/jeremyd/local/postgres/cvsuproot/pgsql/src/bin/psql/large_obj.c,v
retrieving revision 1.46
diff -c -r1.46 large_obj.c
*** src/bin/psql/large_obj.c    29 Aug 2006 15:19:51 -0000      1.46
--- src/bin/psql/large_obj.c    25 Sep 2006 23:02:33 -0000
***************
*** 12,17 ****
--- 12,54 ----
  #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("<p>", pset.queryFout);
+                       // XXX should probably use html_escaped_print here
+                       // but I know the strings have no bad chars
+               }
+ 
+               va_start(ap, fmt);
+               vfprintf(pset.queryFout, fmt, ap);
+               va_end(ap);
+ 
+               if (pset.popt.topt.format == PRINT_HTML)
+                       fputs("</p>\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
***************
*** 129,135 ****
        if (!finish_lo_xact("\\lo_export", own_transaction))
                return false;
  
!       fprintf(pset.queryFout, "lo_export\n");
  
        return true;
  }
--- 166,172 ----
        if (!finish_lo_xact("\\lo_export", own_transaction))
                return false;
  
!       print_lo_result("lo_export");
  
        return true;
  }
***************
*** 189,195 ****
        if (!finish_lo_xact("\\lo_import", own_transaction))
                return false;
  
!       fprintf(pset.queryFout, "lo_import %u\n", loid);
        sprintf(oidbuf, "%u", loid);
        SetVariable(pset.vars, "LASTOID", oidbuf);
  
--- 226,233 ----
        if (!finish_lo_xact("\\lo_import", own_transaction))
                return false;
  
!       print_lo_result("lo_import %u", loid);
! 
        sprintf(oidbuf, "%u", loid);
        SetVariable(pset.vars, "LASTOID", oidbuf);
  
***************
*** 225,231 ****
        if (!finish_lo_xact("\\lo_unlink", own_transaction))
                return false;
  
!       fprintf(pset.queryFout, "lo_unlink %u\n", loid);
  
        return true;
  }
--- 263,269 ----
        if (!finish_lo_xact("\\lo_unlink", own_transaction))
                return false;
  
!       print_lo_result("lo_unlink %u", loid);
  
        return true;
  }

Attachment: largeobj-regress-v2.patch.gz
Description: Binary data

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

Reply via email to