aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/xml.c
Commit message (Collapse)AuthorAge
...
* Simplify and standardize conversions between TEXT datums and ordinary CTom Lane2008-03-25
| | | | | | | | | | | | | | | | | | | | 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
* Fix various infelicities that have snuck into usage of errdetail() andTom Lane2008-03-24
| | | | | | friends. Avoid double translation of some messages, ensure other messages are exposed for translation (and make them follow the style guidelines), avoid unsafe passing of an unpredictable message text as a format string.
* Disable the undocumented xmlvalidate() function, which was unintentionallyTom Lane2008-03-01
| | | | | | | | | 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.
* Revise memory management for libxml calls. Instead of keeping libxml's dataTom Lane2008-01-15
| | | | | | | | | | | 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.
* It turns out the LIBXML_TEST_VERSION macro calls xmlInitParser().Tom Lane2008-01-12
| | | | | | | Therefore we must xmlCleanupParser(), or we risk leaving behind dangling pointers to whatever memory context is current when xml_init() is called. This seems to fix bug #3860, though we might still want the more invasive solution being worked on by Alvaro.
* Fix two places in xml.c that neglected to check the return values ofNeil Conway2008-01-12
| | | | SPI_prepare() and SPI_cursor_open(), to silence a Coverity warning.
* Minor perf tweak for _SPI_strdup(): if we're going to call strlen()Neil Conway2008-01-12
| | | | anyway, it is faster to memcpy() than to strcpy().
* Update copyrights in source tree to 2008.Bruce Momjian2008-01-01
|
* Fix XML Schema structure for char types without length (bug #3782)Peter Eisentraut2007-11-28
|
* Suppress compiler warning.Tom Lane2007-11-27
|
* Make casts from xml to text independent of the XML option setting, thusPeter Eisentraut2007-11-27
| | | | | immutable and indexable. Also fix the volatility settings of some other XML-related functions.
* Use double quotes for quoting xml attributes.Peter Eisentraut2007-11-25
|
* Fix bogus length calculation that could lead to crash if the stringTom Lane2007-11-20
| | | | | | happened to be right up against the end of memory, per report from Matt Magoffin. While at it, avoid useless multiple copying of string by not depending on xmlStrncatNew.
* Re-run pgindent with updated list of typedefs. (Updated README shouldBruce Momjian2007-11-15
| | | | avoid this problem in the future.)
* pgindent run for 8.3.Bruce Momjian2007-11-15
|
* Add missing closing / in xsd:restriction, and remove some unnecessaryTom Lane2007-11-10
| | | | | spaces for consistency. Per bug #3734 from Ben Leslie; fix by Euler Taveira de Oliveira.
* xmlGetUTF8Char()'s second argument is both input and output. FixTom Lane2007-11-10
| | | | | | uninitialized value, and avoid invoking the function nine separate times in the pg_xmlIsNameChar macro. Should resolve buildfarm failures. Per report from Ben Leslie.
* Allow XML processing instructions starting with "xml" while prohibitingPeter Eisentraut2007-11-09
| | | | those being exactly "xml". Bug #3735 from Ben Leslie
* After conferencing again with Bruce, put in more accurate XML error message.Peter Eisentraut2007-11-08
|
* Improve error messagePeter Eisentraut2007-11-08
|
* Some code review for xml.c:Tom Lane2007-11-06
| | | | | | | | | | | | | | 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).
* Fix xmlelement() to initialize libxml correctly before using it, and to avoidTom Lane2007-11-05
| | | | | | | | | | 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.
* Guard against possible double free during error escape from XMLTom Lane2007-10-13
| | | | | functions. Patch for the reported issue from Kris Jurka, some other potential trouble spots plugged by Tom.
* Fix the inadvertent libpq ABI breakage discovered by Martin Pitt: theTom Lane2007-10-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix bugs in XML binary I/O functions. Heikki and TomTom Lane2007-09-23
|
* Fix map_sql_typecoll_to_xmlschema_types() to not fail on droppedTom Lane2007-07-13
| | | | | columns, per my gripe earlier today. Make it look a bit less like someone's first effort at backend coding.
* Compute max and min int8 values using unsigned arithmetic, in hopes ofTom Lane2007-07-12
| | | | suppressing Sun Studio compiler warnings. Per Stefan.
* Fix up text concatenation so that it accepts all the reasonable cases thatTom Lane2007-06-06
| | | | | | | | were accepted by prior Postgres releases. This takes care of the loose end left by the preceding patch to downgrade implicit casts-to-text. To avoid breaking desirable behavior for array concatenation, introduce a new polymorphic pseudo-type "anynonarray" --- the added concatenation operators are actually text || anynonarray and anynonarray || text.
* XPath fixes:Peter Eisentraut2007-05-21
| | | | | | | | | | | | | | | - Function renamed to "xpath". - Function is now strict, per discussion. - Return empty array in case when XPath expression detects nothing (previously, NULL was returned in such case), per discussion. - (bugfix) Work with fragments with prologue: select xpath('/a', '<?xml version="1.0"?><a /><b />'); // now XML datum is always wrapped with dummy <x>...</x>, XML prologue simply goes away (if any). - Some cleanup. Nikolay Samokhvalov Some code cleanup and documentation work by myself.
* Support varlena fields with single-byte headers and unaligned storage.Tom Lane2007-04-06
| | | | | | | | | This commit breaks any code that assumes that the mere act of forming a tuple (without writing it to disk) does not "toast" any fields. While all available regression tests pass, I'm not totally sure that we've fixed every nook and cranny, especially in contrib. Greg Stark with some help from Tom Lane
* Update XML error message text for missing libxml; update regressionBruce Momjian2007-04-05
| | | | output to match.
* Improve documentation/warning when --with-libxml is not used in theBruce Momjian2007-04-05
| | | | installation.
* Support enum data types. Along the way, use macros for the values ofTom Lane2007-04-02
| | | | | pg_type.typtype whereever practical. Tom Dunstan, with some kibitzing from Tom Lane.
* Mapping schemas and databases to XML and XML Schema.Peter Eisentraut2007-04-01
| | | | Refactor and document the remaining mapping code.
* Commit newest version of xmlpath().Bruce Momjian2007-03-22
| | | | Nikolay Samokhvalov
* Add xmlpath() to evaluate XPath expressions, with namespaces support.Bruce Momjian2007-03-22
| | | | Nikolay Samokhvalov
* Make use of plancache module for SPI plans. In particular, since plpgsqlTom Lane2007-03-15
| | | | | | | | | | | | uses SPI plans, this finally fixes the ancient gotcha that you can't drop and recreate a temp table used by a plpgsql function. Along the way, clean up SPI's API a little bit by declaring SPI plan pointers as "SPIPlanPtr" instead of "void *". This is cosmetic but helps to forestall simple programming mistakes. (I have changed some but not all of the callers to match; there are still some "void *"'s in contrib and the PL's. This is intentional so that we can see if anyone's compiler complains about it.)
* Add resetStringInfo(), which clears the content of a StringInfo, andNeil Conway2007-03-03
| | | | | | fixup various places in the tree that were clearing a StringInfo by hand. Making this function a part of the API simplifies client code slightly, and avoids needlessly peeking inside the StringInfo interface.
* Fix date/time formats for XML Schema output.Peter Eisentraut2007-03-01
| | | | Pavel Stehule
* Replace direct assignments to VARATT_SIZEP(x) with SET_VARSIZE(x, len).Tom Lane2007-02-27
| | | | | | | | | | | 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
* Better fix for determining minimum and maximum int64 values that doesn'tPeter Eisentraut2007-02-16
| | | | require stdint.h and works for "busted" int64.
* Add stdint.h includePeter Eisentraut2007-02-16
|
* Functions for mapping table data and table schemas to XML (a.k.a. XML export)Peter Eisentraut2007-02-16
|
* Un-break build on ANSI compilers (like msvc) by moving Assert to positionMagnus Hagander2007-02-13
| | | | after variable declarations.
* Add support for optionally escaping periods when converting SQL identifiersPeter Eisentraut2007-02-11
| | | | to XML names, which will be required for supporting XML export.
* Add proper mapping of boolean type data to XML Schema.Peter Eisentraut2007-02-10
|
* Implement XMLSERIALIZE for real. Analogously, make the xml to text castPeter Eisentraut2007-02-03
| | | | | | | | | observe the xmloption. Reorganize the representation of the XML option in the parse tree and the API to make it easier to manage and understand. Add regression tests for parsing back XML expressions.
* Reactivate libxml memory management via palloc, now that I think I'vePeter Eisentraut2007-01-27
| | | | | classified the conditions under which this is safe to do (see source code comment).
* Add trailing zero byte in Unicode codepoint conversion.Peter Eisentraut2007-01-27
|
* Various fixes in the logic of XML functions:Peter Eisentraut2007-01-25
| | | | | | | | | | | | | | | | - Add new SQL command SET XML OPTION (also available via regular GUC) to control the DOCUMENT vs. CONTENT option in implicit parsing and serialization operations. - Subtle corrections in the handling of the standalone property in xmlroot(). - Allow xmlroot() to work on content fragments. - Subtle corrections in the handling of the version property in xmlconcat(). - Code refactoring for producing XML declarations.