Skip to content
Snippets Groups Projects
  1. Jun 05, 2012
    • Tom Lane's avatar
      Fix some more bugs in contrib/xml2's xslt_process(). · d9b31e48
      Tom Lane authored
      It failed to check for error return from xsltApplyStylesheet(), as reported
      by Peter Gagarinov.  (So far as I can tell, libxslt provides no convenient
      way to get a useful error message in failure cases.  There might be some
      inconvenient way, but considering that this code is deprecated it's hard to
      get enthusiastic about putting lots of work into it.  So I just made it say
      "failed to apply stylesheet", in line with the existing error checks.)
      
      While looking at the code I also noticed that the string returned by
      xsltSaveResultToString was never freed, resulting in a session-lifespan
      memory leak.
      
      Back-patch to all supported versions.
      d9b31e48
  2. Jul 20, 2011
    • Tom Lane's avatar
      Rewrite libxml error handling to be more robust. · cacd42d6
      Tom Lane authored
      libxml reports some errors (like invalid xmlns attributes) via the error
      handler hook, but still returns a success indicator to the library caller.
      This causes us to miss some errors that are important to report.  Since the
      "generic" error handler hook doesn't know whether the message it's getting
      is for an error, warning, or notice, stop using that and instead start
      using the "structured" error handler hook, which gets enough information
      to be useful.
      
      While at it, arrange to save and restore the error handler hook setting in
      each libxml-using function, rather than assuming we can set and forget the
      hook.  This should improve the odds of working nicely with third-party
      libraries that also use libxml.
      
      In passing, volatile-ize some local variables that get modified within
      PG_TRY blocks.  I noticed this while testing with an older gcc version
      than I'd previously tried to compile xml.c with.
      
      Florian Pflug and Tom Lane, with extensive review/testing by Noah Misch
      cacd42d6
  3. Apr 10, 2011
  4. Sep 20, 2010
  5. Aug 11, 2010
  6. Jul 06, 2010
  7. Mar 03, 2010
    • Tom Lane's avatar
      Make contrib/xml2 use core xml.c's error handler, when available (that is, · 5e47403b
      Tom Lane authored
      in versions >= 8.3).  The core code is more robust and efficient than what
      was there before, and this also reduces risks involved in swapping different
      libxml error handler settings.
      
      Before 8.3, there is still some risk of problems if add-on modules such as
      Perl invoke libxml without setting their own error handler.  Given the lack
      of reports I'm not sure there's a risk in practice, so I didn't take the
      step of actually duplicating the core code into older contrib/xml2 branches.
      Instead I just tweaked the existing code to ensure it didn't leave a dangling
      pointer to short-lived memory when throwing an error.
      5e47403b
  8. Mar 01, 2010
    • Tom Lane's avatar
      Fix contrib/xml2 so regression test still works when it's built without libxslt. · d6a6f8c6
      Tom Lane authored
      This involves modifying the module to have a stable ABI, that is, the
      xslt_process() function still exists even without libxslt.  It throws a
      runtime error if called, but doesn't prevent executing the CREATE FUNCTION
      call.  This is a good thing anyway to simplify cross-version upgrades.
      d6a6f8c6
    • Tom Lane's avatar
      Remove xmlCleanupParser calls from contrib/xml2. · a1020909
      Tom Lane authored
      These are unnecessary and probably dangerous.  I don't see any immediate
      risk situations in the core XML support or contrib/xml2 itself, but there
      could be issues with external uses of libxml2, and in any case it's an
      accident waiting to happen.
      a1020909
  9. Feb 28, 2010
  10. Jul 10, 2009
    • Tom Lane's avatar
      Fix xslt_process() to ensure that it inserts a NULL terminator after the · e7370bab
      Tom Lane authored
      last pair of parameter name/value strings, even when there are MAXPARAMS
      of them.  Aboriginal bug in contrib/xml2, noted while studying bug #4912
      (though I'm not sure whether there's something else involved in that
      report).
      
      This might be thought a security issue, since it's a potential backend
      crash; but considering that untrustworthy users shouldn't be allowed
      to get their hands on xslt_process() anyway, it's probably not worth
      getting excited about.
      e7370bab
  11. Jun 11, 2009
  12. Jan 07, 2009
  13. May 17, 2008
    • Andrew Dunstan's avatar
      Add $PostgreSQL$ markers to a lot of files that were missing them. · 53972b46
      Andrew Dunstan authored
      This particular batch was just for *.c and *.h file.
      
      The changes were made with the following 2 commands:
      
      find . \( \( -name 'libstemmer' -o -name 'expected' -o -name 'ppport.h' \) -prune \) -o  \( -name '*.[ch]'  \) \( -exec grep -q '\$PostgreSQL' {} \; -o -print \) | while read file ; do head -n 1 < $file | grep -q '^/\*' && echo $file; done | xargs -l sed -i -e '1s/^\// /' -e '1i/*\n * $PostgreSQL:$ \n *'
      
      find . \( \( -name 'libstemmer' -o -name 'expected' -o -name 'ppport.h' \) -prune \) -o  \( -name '*.[ch]'  \) \( -exec grep -q '\$PostgreSQL' {} \; -o -print \) | xargs -l sed -i -e '1i/*\n * $PostgreSQL:$ \n */'
      53972b46
  14. May 08, 2008
  15. May 04, 2008
  16. Mar 25, 2008
    • Tom Lane's avatar
      Simplify and standardize conversions between TEXT datums and ordinary C · 220db7cc
      Tom Lane authored
      strings.  This patch introduces four support functions cstring_to_text,
      cstring_to_text_with_len, text_to_cstring, and text_to_cstring_buffer, and
      two macros CStringGetTextDatum and TextDatumGetCString.  A number of
      existing macros that provided variants on these themes were removed.
      
      Most of the places that need to make such conversions now require just one
      function or macro call, in place of the multiple notational layers that used
      to be needed.  There are no longer any direct calls of textout or textin,
      and we got most of the places that were using handmade conversions via
      memcpy (there may be a few still lurking, though).
      
      This commit doesn't make any serious effort to eliminate transient memory
      leaks caused by detoasting toasted text objects before they reach
      text_to_cstring.  We changed PG_GETARG_TEXT_P to PG_GETARG_TEXT_PP in a few
      places where it was easy, but much more could be done.
      
      Brendan Jurd and Tom Lane
      220db7cc
  17. Jul 16, 2007
  18. Feb 28, 2007
    • Tom Lane's avatar
      Replace direct assignments to VARATT_SIZEP(x) with SET_VARSIZE(x, len). · 234a02b2
      Tom Lane authored
      Get rid of VARATT_SIZE and VARATT_DATA, which were simply redundant with
      VARSIZE and VARDATA, and as a consequence almost no code was using the
      longer names.  Rename the length fields of struct varlena and various
      derived structures to catch anyplace that was accessing them directly;
      and clean up various places so caught.  In itself this patch doesn't
      change any behavior at all, but it is necessary infrastructure if we hope
      to play any games with the representation of varlena headers.
      Greg Stark and Tom Lane
      234a02b2
  19. Sep 11, 2006
  20. May 31, 2006
  21. Mar 01, 2006
    • Neil Conway's avatar
      This patch makes the error message strings throughout the backend · 8e5a10d4
      Neil Conway authored
      more compliant with the error message style guide. In particular,
      errdetail should begin with a capital letter and end with a period,
      whereas errmsg should not. I also fixed a few related issues in
      passing, such as fixing the repeated misspelling of "lexeme" in
      contrib/tsearch2 (per Tom's suggestion).
      8e5a10d4
  22. Oct 15, 2005
  23. Oct 07, 2004
  24. Aug 29, 2004
  25. Mar 05, 2004
    • Bruce Momjian's avatar
    • Bruce Momjian's avatar
      Thanks to the generous support of Torchbox (http://www.torchbox.com), I · adca025c
      Bruce Momjian authored
      have been able to significantly improve the contrib/xml XPath
      integration code.
      
      New features:
      
      * XPath set-returning function allows multiple results from an several
      XPath queries to be used as a virtual table.
      * Using libxslt, XSLT transformations (with and without parameters) are
      supported. (Caution: This support allows generic URL fetching from
      within the backend as well).
      
      I've removed the old code so that it is all libxml based. Rather than
      attach as a patch, I've put the tar.gz (10k!) at
      http://www.azuli.co.uk/pgxml-1.0.tar.gz
      (all files in archive are xml/....).
      
      I think this is worth replacing the contrib version with, even though
      the function names have changed (though the same functionality is
      there), because it includes a SRF and some SPI usage, in addition to
      linking to an external library. And it isn't a big module! Obviously, I
      understand that people might prefer to move it elsewhere, or might have
      reservations about replacing an existing contrib module with an
      incompatible one. I'm open to suggestions.
      
      John Gray
      adca025c
Loading