summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/arrayfuncs.c
AgeCommit message (Collapse)Author
2011-02-01Fix wrong error reports in 'number of array dimensions exceeds theItagaki Takahiro
maximum allowed' messages, that have reported one-less dimensions. Alexey Klyukin
2011-01-17Fix miscalculation of itemsafter in array_set_slice().Tom Lane
If the slice to be assigned to was before the existing array lower bound (requiring at least one null element to spring into existence to fill the gap), the code miscalculated how many entries needed to be copied from the old array's null bitmap. This could result in trashing the array's data area (as seen in bug #5840 from Karsten Loesing), or worse. This has been broken since we first allowed the behavior of assigning to non-adjacent slices, in 8.2. Back-patch to all affected versions.
2011-01-09Use array_contains_nulls instead of ARR_HASNULL on user-supplied arrays.Tom Lane
This applies the fix for bug #5784 to remaining places where we wish to reject nulls in user-supplied arrays. In all these places, there's no reason not to allow a null bitmap to be present, so long as none of the current elements are actually null. I did not change some other places where we are looking at system catalog entries or aggregate transition values, as the presence of a null bitmap in such an array would be suspicious.
2011-01-08Add array_contains_nulls() function in arrayfuncs.c.Tom Lane
This will support fixing contrib/intarray (and probably other places) so that they don't have to fail on arrays that contain a null bitmap but no live null entries.
2011-01-01Stamp copyrights for year 2011.Bruce Momjian
2010-10-30Provide hashing support for arrays.Tom Lane
The core of this patch is hash_array() and associated typcache infrastructure, which works just about exactly like the existing support for array comparison. In addition I did some work to ensure that the planner won't think that an array type is hashable unless its element type is hashable, and similarly for sorting. This includes adding a datatype parameter to op_hashjoinable and op_mergejoinable, and adding an explicit "hashable" flag to SortGroupClause. The lack of a cross-check on the element type was a pre-existing bug in mergejoin support --- but it didn't matter so much before, because if you couldn't sort the element type there wasn't any good alternative to failing anyhow. Now that we have the alternative of hashing the array type, there are cases where we can avoid a failure by being picky at the planner stage, so it's time to be picky. The issue of exactly how to combine the per-element hash values to produce an array hash is still open for discussion, but the rest of this is pretty solid, so I'll commit it as-is.
2010-09-20Remove cvs keywords from all files.Magnus Hagander
2010-08-21Use a non-locale-dependent definition of isspace() in array_in/array_out.Tom Lane
array_in discards unquoted leading and trailing whitespace in array values, while array_out is careful to quote array elements that contain whitespace. This is problematic when the definition of "whitespace" varies between locales: array_in could drop characters that were meant to be part of the value. To avoid that, lock down "whitespace" to mean only the traditional six ASCII space characters. This change also works around a bug in OS X and some older BSD systems, in which isspace() could return true for character fragments in UTF8 locales. (There may be other places in PG where that bug could cause problems, but this is the only one complained of so far; see recent report from Steven Schlansker.) Back-patch to 9.0, but not further. Given the lack of previous reports of trouble, changing this behavior in stable branches seems to offer more risk of breaking applications than reward of avoiding problems.
2010-08-11The sanity check added to array_recv() wa a bit too tight; we mustHeikki Linnakangas
continue to accept an empty array with dimension information. array_send() can output such arrays. Per report from Vladimir Shakhov.
2010-02-26pgindent run for 9.0Bruce Momjian
2010-01-02Update copyright for the year 2010.Bruce Momjian
2009-12-19binary migration: pg_migratorBruce Momjian
Add comments about places where system oids have to be preserved for binary migration.
2009-09-04Tigthen binary receive functions so that they reject values that the textHeikki Linnakangas
input functions don't accept either. While the backend can handle such values fine, they can cause trouble in clients and in pg_dump/restore. This is followup to the original issue on time datatype reported by Andrew McNamara a while ago. Like that one, none of these seem worth back-patching.
2009-06-22Revert dubious message wording change.Tom Lane
2009-06-21Message fixesPeter Eisentraut
2009-06-20Fix things so that array_agg_finalfn does not modify or free its inputTom Lane
ArrayBuildState, per trouble report from Merlin Moncure. By adopting this fix, we are essentially deciding that aggregate final-functions should not modify their inputs ever. Adjust documentation and comments to match that conclusion.
2009-06-118.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef listBruce Momjian
provided by Andrew.
2009-04-15Substitute extraneous underscores with spaces.Alvaro Herrera
2009-04-09Remove SQL-compatibility function cardinality(). It is not exactly clearTom Lane
how this ought to behave for multi-dimensional arrays. Per discussion, not having it at all seems better than having it with what might prove to be the wrong behavior. We can always add it later when we have consensus on the correct behavior.
2009-04-05Change cardinality() into a C-code function, instead of a SQL-languageTom Lane
alias for array_length(v,1). The efficiency gain here is doubtless negligible --- what I'm interested in is making sure that if we have second thoughts about the definition, we will not have to force a post-beta initdb to change the implementation.
2009-01-30Fix unnest() to handle a toasted input array safely. Per report fromTom Lane
Alvaro.
2009-01-01Update copyright for 2009.Bruce Momjian
2008-12-28Support window functions a la SQL:2008.Tom Lane
Hitoshi Harada, with some kibitzing from Heikki and Tom.
2008-11-14Implement the basic form of UNNEST, ie unnest(anyarray) returns setofTom Lane
anyelement. This lacks the WITH ORDINALITY option, as well as the multiple input arrays option added in the most recent SQL specs. But it's still a pretty useful subset of the spec's functionality, and it is enough to allow obsoleting contrib/intagg.
2008-11-12array_length() function, and for SQL compatibility also cardinality()Peter Eisentraut
function as a special case. This version still has the suspicious behavior of returning null for an empty array (rather than zero), but this may need a wholesale revision of empty array behavior, currently under discussion. Jim Nasby, Robert Haas, Peter Eisentraut
2008-11-04ADD array_ndims functionPeter Eisentraut
Author: Robert Haas <robertmhaas@gmail.com>
2008-07-21Code review for array_fill patch: fix inadequate check for array size overflowTom Lane
and bogus documentation (dimension arrays are int[] not anyarray). Also the errhint() messages seem to be really errdetail(), since there is nothing heuristic about them. Some other trivial cosmetic improvements.
2008-07-16Add array_fill() to create arrays initialized with a value.Bruce Momjian
Pavel Stehule
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-28Add generate_subscripts, a series-generation function which generates anAlvaro Herrera
array's subscripts. Pavel Stehule, some editorialization by me.
2008-04-11Fix several datatype input functions that were allowing unused bytes in theirTom Lane
results to contain uninitialized, unpredictable values. While this was okay as far as the datatypes themselves were concerned, it's a problem for the parser because occurrences of the "same" literal might not be recognized as equal by datumIsEqual (and hence not by equal()). It seems sufficient to fix this in the input functions since the only critical use of equal() is in the parser's comparisons of ORDER BY and DISTINCT expressions. Per a trouble report from Marc Cousin. Patch all the way back. Interestingly, array_in did not have the bug before 8.2, which may explain why the issue went unnoticed for so long.
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-02-29Remove long-unused and broken TCL_ARRAYS.Alvaro Herrera
2008-01-01Update copyrights in source tree to 2008.Bruce Momjian
2007-04-06Support varlena fields with single-byte headers and unaligned storage.Tom Lane
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
2007-03-27Fix array coercion expressions to ensure that the correct volatility isTom Lane
seen by code inspecting the expression. The best way to do this seems to be to drop the original representation as a function invocation, and instead make a special expression node type that represents applying the element-type coercion function to each array element. In this way the element function is exposed and will be checked for volatility. Per report from Guillaume Smet.
2007-02-27Replace direct assignments to VARATT_SIZEP(x) with SET_VARSIZE(x, len).Tom Lane
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
2007-01-05Update CVS HEAD for 2007 copyright. Back branches are typically notBruce Momjian
back-stamped for this.
2006-11-08Tweak accumArrayResult() to double the size of its working arrays whenTom Lane
more space is needed, instead of incrementing by a fixed amount; the old method wastes lots of space and time when the ultimate size is large. Per gripe from Tatsuo.
2006-10-06Message style improvementsPeter Eisentraut
2006-10-04pgindent run for 8.2.Bruce Momjian
2006-09-29Allow assignment to array elements not contiguous with those alreadyTom Lane
present; intervening positions are filled with nulls. This behavior is required by SQL99 but was not implementable before 8.2 due to lack of support for nulls in arrays. I have only made it work for the one-dimensional case, which is all that SQL99 requires. It seems quite complex to get it right in higher dimensions, and since we never allowed extension at all in higher dimensions, I think that must count as a future feature addition not a bug fix.
2006-09-10If we're going to advertise the array overlap/containment operators,Tom Lane
we probably should make them work reliably for all arrays. Fix code to handle NULLs and multidimensional arrays, move it into arrayfuncs.c. GIN is still restricted to indexing arrays with no null elements, however.
2006-07-14Remove 576 references of include files that were not needed.Bruce Momjian
2006-07-11Sort reference of include files, "A" - "F".Bruce Momjian
2006-04-04Modify all callers of datatype input and receive functions so that if theseTom Lane
functions are not strict, they will be called (passing a NULL first parameter) during any attempt to input a NULL value of their datatype. Currently, all our input functions are strict and so this commit does not change any behavior. However, this will make it possible to build domain input functions that centralize checking of domain constraints, thereby closing numerous holes in our domain support, as per previous discussion. While at it, I took the opportunity to introduce convenience functions InputFunctionCall, OutputFunctionCall, etc to use in code that calls I/O functions. This eliminates a lot of grotty-looking casts, but the main motivation is to make it easier to grep for these places if we ever need to touch them again.
2006-03-05Update copyright for 2006. Update scripts.Bruce Momjian
2005-11-22Re-run pgindent, fixing a problem where comment lines after a blankBruce Momjian
comment line where output as too long, and update typedefs for /lib directory. Also fix case where identifiers were used as variable names in the backend, but as typedefs in ecpg (favor the backend for indenting). Backpatch to 8.1.X.
2005-11-19Change array comparison rules to consider dimensionality information,Tom Lane
not only the array contents, before claiming two arrays are equal. Per recent discussion.
2005-11-17Make SQL arrays support null elements. This commit fixes the core arrayTom Lane
functionality, but I still need to make another pass looking at places that incidentally use arrays (such as ACL manipulation) to make sure they are null-safe. Contrib needs work too. I have not changed the behaviors that are still under discussion about array comparison and what to do with lower bounds.