summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/varlena.c
AgeCommit message (Collapse)Author
2013-03-14Extend format() to handle field width and left/right alignment.Tom Lane
This change adds some more standard sprintf() functionality to format(). Pavel Stehule, reviewed by Dean Rasheed and Kyotaro Horiguchi
2013-01-25Fix concat() and format() to handle VARIADIC-labeled arguments correctly.Tom Lane
Previously, the VARIADIC labeling was effectively ignored, but now these functions act as though the array elements had all been given as separate arguments. Pavel Stehule
2013-01-01Update copyrights for 2013Bruce Momjian
Fully update git head, and update back branches in ./COPYRIGHT and legal.sgml files.
2012-09-06Allow embedded spaces without quoting in unix_socket_directories entries.Tom Lane
This fix removes an unnecessary incompatibility with the old behavior of the unix_socket_directory parameter. Since pathnames with embedded spaces are fairly popular on some platforms, the incompatibility could be significant in practice. We'll still strip unquoted leading/trailing spaces, however. No docs update since the documentation already implied that it worked like this. Per bug #7514 from Murray Cumming.
2012-08-10Support having multiple Unix-domain sockets per postmaster.Tom Lane
Replace unix_socket_directory with unix_socket_directories, which is a list of socket directories, and adjust postmaster's code to allow zero or more Unix-domain sockets to be created. This is mostly a straightforward change, but since the Unix sockets ought to be created after the TCP/IP sockets for safety reasons (better chance of detecting a port number conflict), AddToDataDirLockFile needs to be fixed to support out-of-order updates of data directory lockfile lines. That's a change that had been foreseen to be necessary someday anyway. Honza Horak, reviewed and revised by Tom Lane
2012-06-10Run pgindent on 9.2 source tree in preparation for first 9.3Bruce Momjian
commit-fest.
2012-05-25Fix string truncation to be multibyte-aware in text_name and bpchar_name.Tom Lane
Previously, casts to name could generate invalidly-encoded results. Also, make these functions match namein() more exactly, by consistently using palloc0() instead of ad-hoc zeroing code. Back-patch to all supported branches. Karl Schnaitter and Tom Lane
2012-04-13Rename bytea_agg to string_agg and add delimiter argumentPeter Eisentraut
Per mailing list discussion, we would like to keep the bytea functions parallel to the text functions, so rename bytea_agg to string_agg, which already exists for text. Also, to satisfy the rule that we don't want aggregate functions of the same name with a different number of arguments, add a delimiter argument, just like string_agg for text already has.
2012-01-01Update copyright notices for year 2012.Bruce Momjian
2011-12-23Add bytea_agg, parallel to string_agg.Robert Haas
Pavel Stehule
2011-12-21Shave a few cycles in string_agg().Robert Haas
Pavel Stehule
2011-12-10Miscellaneous cleanup to silence compiler warnings seen on Mingw.Andrew Dunstan
Remove some dead code, conditionally declare some items or call some code, and fix one or two declarations.
2011-08-29Fix concat_ws() to not insert a separator after leading NULL argument(s).Tom Lane
Per bug #6181 from Itagaki Takahiro. Also do some marginal code cleanup and improve error handling.
2011-08-23Use consistent format for reporting GetLastError()Peter Eisentraut
Use something like "error code %lu" for reporting GetLastError() values on Windows. Previously, a mix of different wordings and formats were in use.
2011-07-08Message style improvementsPeter Eisentraut
2011-07-05Message style tweaksPeter Eisentraut
2011-06-09Pgindent run before 9.1 beta2.Bruce Momjian
2011-05-23Fix integer overflow in text_format function, reported by Dean Rasheed.Heikki Linnakangas
In the passing, clarify the comment on why text_format_nv wrapper is needed.
2011-04-10pgindent run before PG 9.1 beta 1.Bruce Momjian
2011-04-10Add collation support on Windows (MSVC build)Peter Eisentraut
There is not yet support in initdb to populate the pg_collation catalog, but if that is done manually, the rest should work.
2011-03-22Improve reporting of run-time-detected indeterminate-collation errors.Tom Lane
pg_newlocale_from_collation does not have enough context to give an error message that's even a little bit useful, so move the responsibility for complaining up to its callers. Also, reword ERRCODE_INDETERMINATE_COLLATION error messages in a less jargony, more message-style-guide-compliant fashion.
2011-02-08Per-column collation supportPeter Eisentraut
This adds collation support for columns and domains, a COLLATE clause to override it per expression, and B-tree index support. Peter Eisentraut reviewed by Pavel Stehule, Itagaki Takahiro, Robert Haas, Noah Misch
2011-01-18Avoid detoast in texteq/textne/byteaeq/byteane for unequal-length strings.Tom Lane
We can get the length of a compressed or out-of-line datum without actually detoasting it. If the lengths of two strings are unequal, we can then conclude they are unequal without detoasting. That saves considerable work in an admittedly less-common case, without costing anything much when the optimization doesn't apply. Noah Misch
2011-01-01Stamp copyrights for year 2011.Bruce Momjian
2010-12-21Use memcmp() rather than strncmp() when shorter string length is known.Robert Haas
It appears that this will be faster for all but the shortest strings; at least one some platforms, memcmp() can use word-at-a-time comparisons. Noah Misch, somewhat pared down.
2010-11-23Remove useless whitespace at end of linesPeter Eisentraut
2010-11-20Add new SQL function, format(text).Robert Haas
Currently, three conversion format specifiers are supported: %s for a string, %L for an SQL literal, and %I for an SQL identifier. The latter two are deliberately designed not to overlap with what sprintf() already supports, in case we want to add more of sprintf()'s functionality here later. Patch by Pavel Stehule, heavily revised by me. Reviewed by Jeff Janes and, in earlier versions, by Itagaki Takahiro and Tom Lane.
2010-09-20Remove cvs keywords from all files.Magnus Hagander
2010-08-24Add string functions: concat(), concat_ws(), left(), right(), and reverse().Itagaki Takahiro
Pavel Stehule, reviewed by me.
2010-08-10Add three-parameter forms of array_to_string and string_to_array, to allowTom Lane
better handling of NULL elements within the arrays. The third parameter is a string that should be used to represent a NULL element, or should be translated into a NULL element, respectively. If the third parameter is NULL it behaves the same as the two-parameter form. There are two incompatible changes in the behavior of the two-parameter form of string_to_array. First, it will return an empty (zero-element) array rather than NULL when the input string is of zero length. Second, if the field separator is NULL, the function splits the string into individual characters, rather than returning NULL as before. These two changes make this form fully compatible with the behavior of the new three-parameter form. Pavel Stehule, reviewed by Brendan Jurd
2010-08-05Remove the single-argument form of string_agg(). It added nothing much inTom Lane
functionality, while creating an ambiguity in usage with ORDER BY that at least two people have already gotten seriously confused by. Also, add an opr_sanity test to check that we don't in future violate the newly minted policy of not having built-in aggregates with the same name and different numbers of parameters. Per discussion of a complaint from Thom Brown.
2010-02-26pgindent run for 9.0Bruce Momjian
2010-02-08Create an official API function for C functions to use to check if they areTom Lane
being called as aggregates, and to get the aggregate transition state memory context if needed. Use it instead of poking directly into AggState and WindowAggState in places that shouldn't know so much. We should have done this in 8.4, probably, but better late than never. Revised version of a patch by Hitoshi Harada.
2010-02-01Add string_agg aggregate functions. The one argument version concatenatesItagaki Takahiro
the input values into a string. The two argument version also does the same thing, but inserts delimiters between elements. Original patch by Pavel Stehule, reviewed by David E. Wheeler and me.
2010-01-25Add get_bit/set_bit functions for bit strings, paralleling those for bytea,Tom Lane
and implement OVERLAY() for bit strings and bytea. In passing also convert text OVERLAY() to a true built-in, instead of relying on a SQL function. Leonardo F, reviewed by Kevin Grittner
2010-01-02Update copyright for the year 2010.Bruce Momjian
2009-08-04Support hex-string input and output for type BYTEA.Tom Lane
Both hex format and the traditional "escape" format are automatically handled on input. The output format is selected by the new GUC variable bytea_output. As committed, bytea_output defaults to HEX, which is an *incompatible change*. We will keep it this way for awhile for testing purposes, but should consider whether to switch to the more backwards-compatible default of ESCAPE before 8.5 is released. Peter Eisentraut
2009-06-118.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef listBruce Momjian
provided by Andrew.
2009-04-23varstr_cmp and any comparison function that piggybacks on it can returnHeikki Linnakangas
any negative or positive number, not just -1 or 1. Fix comment on varstr_cmp and citext test case accordingly. As pointed out by Zdenek Kotala, and buildfarm member gothic moth.
2009-01-01Update copyright for 2009.Bruce Momjian
2008-09-07Reimplement text_position and related functions to use Boyer-Moore-HorspoolTom Lane
searching instead of naive matching. In the worst case this has the same O(M*N) complexity as the naive method, but the worst case is hard to hit, and the average case is very fast, especially with longer patterns. David Rowley
2008-05-27Alter the xxx_pattern_ops opclasses to use the regular equality operator ofTom Lane
the associated datatype as their equality member. This means that these opclasses can now support plain equality comparisons along with LIKE tests, thus avoiding the need for an extra index in some applications. This optimization was not possible when the pattern opclasses were first introduced, because we didn't insist that text equality meant bitwise equality; but we do now, so there is no semantic difference between regular and pattern equality operators. I removed the name_pattern_ops opclass altogether, since it's really useless: name's regular comparisons are just strcmp() and are unlikely to become something different. Instead teach indxpath.c that btree name_ops can be used for LIKE whether or not the locale is C. This might lead to a useful speedup in LIKE queries on the system catalogs in non-C locales. The ~=~ and ~<>~ operators are gone altogether. (It would have been nice to keep them for backward compatibility's sake, but since the pg_amop structure doesn't allow multiple equality operators per opclass, there's no way.) A not-immediately-obvious incompatibility is that the sort order within bpchar_pattern_ops indexes changes --- it had been identical to plain strcmp, but is now trailing-blank-insensitive. This will impact in-place upgrades, if those ever happen. Per discussions a couple months ago.
2008-05-12Restructure some header files a bit, in particular heapam.h, by removing someAlvaro Herrera
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.
2008-04-12Clean up a few places where Datums were being treated as pointers withoutTom Lane
going through DatumGetPointer or some other "official" conversion macro. Not actually a bug, since Datum the same size as pointer is the only supported case at the moment, but good cleanup for the future. Gavin Sherry
2008-03-25Simplify and standardize conversions between TEXT datums and ordinary CTom Lane
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
2008-03-13Fix varstr_cmp's special case for UTF8 encoding on Windows so that stringsTom Lane
that are reported as "equal" by wcscoll() are checked to see if they really are bitwise equal, and are sorted per strcmp() if not. We made this happen a couple of years ago in the regular code path, but it unaccountably got left out of the Windows/UTF8 case (probably brain fade on my part at the time). As in the prior set of changes, affected users may need to reindex indexes on textual columns. Backpatch as far as 8.2, which is the oldest release we are still supporting on Windows.
2008-01-01Update copyrights in source tree to 2008.Bruce Momjian
2007-11-15Re-run pgindent with updated list of typedefs. (Updated README shouldBruce Momjian
avoid this problem in the future.)
2007-11-15pgindent run for 8.3.Bruce Momjian
2007-09-22Although I'd misdiagnosed the reason for the recent failures onTom Lane
buildfarm member grebe, I see no reason to revert the 1-byte-header-friendly changes I made in varlena.c. Instead, tweak the code a little bit to get more advantage out of that.