Skip to content
Snippets Groups Projects
  1. May 12, 2009
    • Tom Lane's avatar
      Fix intratransaction memory leaks in xml_recv, xmlconcat, xmlroot, and · 546454f8
      Tom Lane authored
      xml_parse, all arising from the same sloppy usage of parse_xml_decl.
      The original coding had that function returning its output string
      parameters in the libxml context, which is long-lived, and all but one
      of its callers neglected to free the strings afterwards.  The easiest
      and most bulletproof fix is to return the strings in the local palloc
      context instead, since that's short-lived.  This was only costing a
      dozen or two bytes per function call, but that adds up fast if the
      function is called repeatedly ...
      
      Noted while poking at the more general problem of what to do with our
      libxml memory allocation hooks.  Back-patch to 8.3, which has the
      identical coding.
      546454f8
  2. Apr 08, 2009
  3. Mar 27, 2009
  4. Mar 23, 2009
  5. Jan 07, 2009
  6. Jan 01, 2009
  7. Nov 10, 2008
  8. Oct 29, 2008
  9. Oct 14, 2008
  10. Oct 09, 2008
  11. Sep 16, 2008
  12. Aug 26, 2008
  13. Jul 03, 2008
  14. May 12, 2008
    • Alvaro Herrera's avatar
      Restructure some header files a bit, in particular heapam.h, by removing some · f8c4d7db
      Alvaro Herrera authored
      unnecessary #include lines in it.  Also, move some tuple routine prototypes and
      macros to htup.h, which allows removal of heapam.h inclusion from some .c
      files.
      
      For this to work, a new header file access/sysattr.h needed to be created,
      initially containing attribute numbers of system columns, for pg_dump usage.
      
      While at it, make contrib ltree, intarray and hstore header files more
      consistent with our header style.
      f8c4d7db
  15. May 04, 2008
  16. Apr 04, 2008
  17. 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
  18. Mar 24, 2008
  19. Mar 01, 2008
    • Tom Lane's avatar
      Disable the undocumented xmlvalidate() function, which was unintentionally · 3bf822c4
      Tom Lane authored
      left in the code though it was not meant to be provided.  It represents a
      security hole because unprivileged users could use it to look at (at least the
      first line of) any file readable by the backend.  Fortunately, this is only
      possible if the backend was built with XML support, so the damage is at least
      mitigated; and 8.3 probably hasn't propagated into any security-critical uses
      yet anyway.  Per report from Sergey Burladyan.
      3bf822c4
  20. Jan 15, 2008
    • Tom Lane's avatar
      Revise memory management for libxml calls. Instead of keeping libxml's data · ac12412e
      Tom Lane authored
      in whichever context happens to be current during a call of an xml.c function,
      use a dedicated context that will not go away until we explicitly delete it
      (which we do at transaction end or subtransaction abort).  This makes recovery
      after an error much simpler --- we don't have to individually delete the data
      structures created by libxml.  Also, we need to initialize and cleanup libxml
      only once per transaction (if there's no error) instead of once per function
      call, so it should be a bit faster.  We'll need to keep an eye out for
      intra-transaction memory leaks, though.  Alvaro and Tom.
      ac12412e
  21. Jan 12, 2008
  22. Jan 01, 2008
  23. Nov 28, 2007
  24. Nov 27, 2007
  25. Nov 25, 2007
  26. Nov 21, 2007
  27. Nov 15, 2007
  28. Nov 10, 2007
  29. Nov 09, 2007
  30. Nov 08, 2007
  31. Nov 06, 2007
    • Tom Lane's avatar
      Some code review for xml.c: · 5e512971
      Tom Lane authored
      Add some more xml_init() calls that might not be necessary, but seem like a
      good idea to avoid possible problems like we saw in xmlelement().
      Fix unsafe assumption that you can keep using the tupledesc of a relcache
      entry you don't have open.
      Add missing error checks for SearchSysCache failure.
      Get rid of handwritten array traversal in xpath() and O(N^2), broken-for-nulls
      array access code in map_sql_value_to_xml_value(), in favor of using
      deconstruct_array.
      Manually adjust a lot of line breaks in places where the code is otherwise
      gonna look pretty awful after pg_indent hacks it up (original author seems to
      have liked to lay out code for a 200-column window).
      5e512971
  32. Nov 05, 2007
    • Tom Lane's avatar
      Fix xmlelement() to initialize libxml correctly before using it, and to avoid · 85f807d7
      Tom Lane authored
      assuming that evaluation of its input expressions won't change the state of
      libxml.  This requires refactoring xml_init() to not call xmlInitParser(),
      since now not all of its callers want that.  I also tweaked things to avoid
      repeated execution of one-time-only tests inside xml_init(), though this is
      mostly for clarity rather than in hopes of saving any noticeable amount of
      runtime.  Per report from Sheikh Amjad and subsequent discussion.
      In passing, fix a couple of inadequately schema-qualified queries.
      85f807d7
  33. Oct 13, 2007
    • Tom Lane's avatar
      Guard against possible double free during error escape from XML · ff1de5ce
      Tom Lane authored
      functions.  Patch for the reported issue from Kris Jurka, some
      other potential trouble spots plugged by Tom.
      ff1de5ce
    • Tom Lane's avatar
      Fix the inadvertent libpq ABI breakage discovered by Martin Pitt: the · 8468146b
      Tom Lane authored
      renumbering of encoding IDs done between 8.2 and 8.3 turns out to break 8.2
      initdb and psql if they are run with an 8.3beta1 libpq.so.  For the moment
      we can rearrange the order of enum pg_enc to keep the same number for
      everything except PG_JOHAB, which isn't a problem since there are no direct
      references to it in the 8.2 programs anyway.  (This does force initdb
      unfortunately.)
      
      Going forward, we want to fix things so that encoding IDs can be changed
      without an ABI break, and this commit includes the changes needed to allow
      libpq's encoding IDs to be treated as fully independent of the backend's.
      The main issue is that libpq clients should not include pg_wchar.h or
      otherwise assume they know the specific values of libpq's encoding IDs,
      since they might encounter version skew between pg_wchar.h and the libpq.so
      they are using.  To fix, have libpq officially export functions needed for
      encoding name<=>ID conversion and validity checking; it was doing this
      anyway unofficially.
      
      It's still the case that we can't renumber backend encoding IDs until the
      next bump in libpq's major version number, since doing so will break the
      8.2-era client programs.  However the code is now prepared to avoid this
      type of problem in future.
      
      Note that initdb is no longer a libpq client: we just pull in the two
      source files we need directly.  The patch also fixes a few places that
      were being sloppy about checking for an unrecognized encoding name.
      8468146b
Loading