Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-11-13Improve readability and error detection of array_in().Tom Lane
Rewrite array_in() and its subroutines so that we make only one pass over the input text, rather than two. This requires potentially re-pallocing the working arrays values[] and nulls[] larger than our initial guess, but that cost will hopefully be made up by avoiding duplicate parsing. In any case this coding seems much clearer and more straightforward than what we had before. This also fixes array_in() to reject non-rectangular input (that is, different brace depths in different parts of the input) more reliably than before, and to give a better error message when it does so. This is analogous to the plpython and plperl fixes in 0553528e7 and f47004add. Like those PLs, we now accept input such as '{{},{}}' as a valid representation of an empty array, which we did not before. Additionally, reject explicit array subscripts that are outside the integer range (previously you just got whatever atoi() converted them to), and make some other minor improvements in error reporting. Although this is arguably a bug fix, it's also a behavioral change that might trip somebody up, so no back-patch. Tom Lane, Heikki Linnakangas, and Jian He. Thanks to Alexander Lakhin for the initial report and for review/testing. Discussion: https://postgr.es/m/2794005.1683042087@sss.pgh.pa.us
2020-06-25Doc: correct nitpicky mistakes in array_position/array_positions examples.Tom Lane
Daniel Gustafsson and Erik Rijkers, per report from nick@cleaton Discussion: https://postgr.es/m/159275646273.679.16940709892308114570@wrigleys.postgresql.org
2018-09-21docs: remove use of escape strings and use bytea hex outputBruce Momjian
standard_conforming_strings defaulted to 'on' in PG 9.1. bytea_output defaulted to 'hex' in PG 9.0. Reported-by: André Hänsel Discussion: https://postgr.es/m/12e601d447ac$345994a0$9d0cbde0$@webkr.de Backpatch-through: 9.3
2017-11-23Convert documentation to DocBook XMLPeter Eisentraut
Since some preparation work had already been done, the only source changes left were changing empty-element tags like <xref linkend="foo"> to <xref linkend="foo"/>, and changing the DOCTYPE. The source files are still named *.sgml, but they are actually XML files now. Renaming could be considered later. In the build system, the intermediate step to convert from SGML to XML is removed. Everything is build straight from the source files again. The OpenSP (or the old SP) package is no longer needed. The documentation toolchain instructions are updated and are much simpler now. Peter Eisentraut, Alexander Lakhin, Jürgen Purtz
2017-10-17Don't use SGML empty tagsPeter Eisentraut
For DocBook XML compatibility, don't use SGML empty tags (</>) anymore, replace by the full tag name. Add a warning option to catch future occurrences. Alexander Lakhin, Jürgen Purtz
2017-09-30Support arrays over domains.Tom Lane
Allowing arrays with a domain type as their element type was left un-done in the original domain patch, but not for any very good reason. This omission leads to such surprising results as array_agg() not working on a domain column, because the parser can't identify a suitable output type for the polymorphic aggregate. In order to fix this, first clean up the APIs of coerce_to_domain() and some internal functions in parse_coerce.c so that we consistently pass around a CoercionContext along with CoercionForm. Previously, we sometimes passed an "isExplicit" boolean flag instead, which is strictly less information; and coerce_to_domain() didn't even get that, but instead had to reverse-engineer isExplicit from CoercionForm. That's contrary to the documentation in primnodes.h that says that CoercionForm only affects display and not semantics. I don't think this change fixes any live bugs, but it makes things more consistent. The main reason for doing it though is that now build_coercion_expression() receives ccontext, which it needs in order to be able to recursively invoke coerce_to_target_type(). Next, reimplement ArrayCoerceExpr so that the node does not directly know any details of what has to be done to the individual array elements while performing the array coercion. Instead, the per-element processing is represented by a sub-expression whose input is a source array element and whose output is a target array element. This simplifies life in parse_coerce.c, because it can build that sub-expression by a recursive invocation of coerce_to_target_type(). The executor now handles the per-element processing as a compiled expression instead of hard-wired code. The main advantage of this is that we can use a single ArrayCoerceExpr to handle as many as three successive steps per element: base type conversion, typmod coercion, and domain constraint checking. The old code used two stacked ArrayCoerceExprs to handle type + typmod coercion, which was pretty inefficient, and adding yet another array deconstruction to do domain constraint checking seemed very unappetizing. In the case where we just need a single, very simple coercion function, doing this straightforwardly leads to a noticeable increase in the per-array-element runtime cost. Hence, add an additional shortcut evalfunc in execExprInterp.c that skips unnecessary overhead for that specific form of expression. The runtime speed of simple cases is within 1% or so of where it was before, while cases that previously required two levels of array processing are significantly faster. Finally, create an implicit array type for every domain type, as we do for base types, enums, etc. Everything except the array-coercion case seems to just work without further effort. Tom Lane, reviewed by Andrew Dunstan Discussion: https://postgr.es/m/9852.1499791473@sss.pgh.pa.us
2017-09-06Escape < and & in SGMLPeter Eisentraut
This is not required in SGML, but will be in XML, so this is a step to prepare for the conversion to XML. (It is still not required to escape >, but we did it here in some cases for symmetry.) Add a command-line option to osx/onsgmls calls to warn about unescaped occurrences in the future. Author: Alexander Law <exclusion@gmail.com> Author: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2015-12-23Allow omitting one or both boundaries in an array slice specifier.Tom Lane
Omitted boundaries represent the upper or lower limit of the corresponding array subscript. This allows simpler specification of many common use-cases. (Revised version of commit 9246af6799819847faa33baf441251003acbb8fe) YUriy Zhuravlev
2015-12-18Revert 9246af6799819847faa33baf441251003acbb8fe becauseTeodor Sigaev
I miss too much. Patch is returned to commitfest process.
2015-12-18Allow to omit boundaries in array subscriptTeodor Sigaev
Allow to omiy lower or upper or both boundaries in array subscript for selecting slice of array. Author: YUriy Zhuravlev
2015-07-09Improve documentation about array concat operator vs. underlying functions.Tom Lane
The documentation implied that there was seldom any reason to use the array_append, array_prepend, and array_cat functions directly. But that's not really true, because they can help make it clear which case is meant, which the || operator can't do since it's overloaded to represent all three cases. Add some discussion and examples illustrating the potentially confusing behavior that can ensue if the parser misinterprets what was meant. Per a complaint from Michael Herold. Back-patch to 9.2, which is where || started to behave this way.
2015-03-30Change array_offset to return subscripts, not offsetsAlvaro Herrera
... and rename it and its sibling array_offsets to array_position and array_positions, to account for the changed behavior. Having the functions return subscripts better matches existing practice, and is better suited to using the result value as a subscript into the array directly. For one-based arrays, the new definition is identical to what was originally committed. (We use the term "subscript" in the documentation, which is what we use whenever we talk about arrays; but the functions themselves are named using the word "position" to match the standard-defined POSITION() functions.) Author: Pavel Stěhule Behavioral problem noted by Dean Rasheed.
2015-03-18array_offset() and array_offsets()Alvaro Herrera
These functions return the offset position or positions of a value in an array. Author: Pavel Stěhule Reviewed by: Jim Nasby
2014-01-21Add a cardinality function for arrays.Robert Haas
Unlike our other array functions, this considers the total number of elements across all dimensions, and returns 0 rather than NULL when the array has no elements. But it seems that both of those behaviors are almost universally disliked, so hopefully that's OK. Marko Tiikkaja, reviewed by Dean Rasheed and Pavel Stehule
2012-06-22Document that && can be used to search arrays.Robert Haas
Also, add some cross-links to the indexing documentation, so it's easier to notice that && and other array operators have index support. Ryan Kelly, edited by me.
2011-06-02Use proper SGML doc entities rather than angle-brackets.Bruce Momjian
Marco Nenciarini
2011-03-11In docs, rename "backwards compatibility" to "backward compatibility"Bruce Momjian
for consistency.
2011-02-06remove tags.Bruce Momjian
2010-09-20Remove cvs keywords from all files.Magnus Hagander
2009-06-17Proofreading for Bruce's recent round of documentation proofreading.Tom Lane
Most of those changes were good, but some not so good ...
2009-04-27Proofreading adjustments for first two parts of documentation (TutorialBruce Momjian
and SQL).
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-10-29Since SQL:2003, the array size specification in the SQL ARRAY syntax hasPeter Eisentraut
been optional.
2008-04-28Add generate_subscripts, a series-generation function which generates anAlvaro Herrera
array's subscripts. Pavel Stehule, some editorialization by me.
2008-04-27Add SGML ID attributes to the arrays subsections, and a few index entries forAlvaro Herrera
them.
2008-03-26Fix bad spelling and worse grammar in recent doc commits. PropagateTom Lane
pg_dump --ignore-version comments into pg_dumpall and pg_restore pages.
2008-03-26Improve documentation for odd array slice behavior.Bruce Momjian
2007-06-07Fix array_dims() example to be consistent with the data previously shown.Tom Lane
Christian Rossow
2007-05-11Support arrays of composite types, including the rowtypes of regular tablesTom Lane
and views (but not system catalogs, nor sequences or toast tables). Get rid of the hardwired convention that a type's array type is named exactly "_type", instead using a new column pg_type.typarray to provide the linkage. (It still will be named "_type", though, except in odd corner cases such as maximum-length type names.) Along the way, make tracking of owner and schema dependencies for types more uniform: a type directly created by the user has these dependencies, while a table rowtype or auto-generated array type does not have them, but depends on its parent object instead. David Fetter, Andrew Dunstan, Tom Lane
2007-04-06Fix some now-obsolete comments about the space used by various dataTom Lane
types.
2007-03-02Fix broken markup, improve wording.Tom Lane
2007-02-20Spell check on array patch.Bruce Momjian
2007-02-20Update array slice documentation to be clearer.Bruce Momjian
2007-02-01Consistenly use colons before '<programlisting>' blocks, whereBruce Momjian
appropriate.
2007-01-31Update documentation on may/can/might:Bruce Momjian
Standard English uses "may", "can", and "might" in different ways: may - permission, "You may borrow my rake." can - ability, "I can lift that log." might - possibility, "It might rain today." Unfortunately, in conversational English, their use is often mixed, as in, "You may use this variable to do X", when in fact, "can" is a better choice. Similarly, "It may crash" is better stated, "It might crash". Also update two error messages mentioned in the documenation to match.
2007-01-31Add missing colon.Bruce Momjian
2007-01-30Update documentation for backslashes to mention escape string syntaxBruce Momjian
more, and standard_conforming_strings less, because in the future non-E strings will not treat backslashes specially. Also use E'' strings where backslashes are used in examples. (The existing examples would have drawn warnings.) Backpatch to 8.2.X.
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-05-09Revert documentation mention of array dimension checking, in next paragraph.Bruce Momjian
2006-05-09Mention array dimmensions are not enforced either.Bruce Momjian
2006-04-23Removes or minimizes some documentation mentions of backwardBruce Momjian
compatibility for release 7.2 and earlier. I have not altered any mentions of release 7.3 or later. The release notes were not modified, so the changes are still documented, just not in the main docs.
2005-11-19Change array_push and array_cat so that they retain the lower bound ofTom Lane
the array (for array_push) or higher-dimensional array (for array_cat) rather than decrementing it as before. This avoids generating lower bounds other than one for any array operation within the SQL spec. Per recent discussion. Interestingly, this seems to have been the original behavior, because while updating the docs I noticed that a large fraction of relevant examples were *wrong* for the old behavior and are now right. Is it worth correcting this in the back-branch docs?
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.
2005-11-04Spellchecking run, final cleanupsPeter Eisentraut
2005-11-04Avoid referring to a specific version of the SQL standard except whereTom Lane
necessary, and be careful to refer to the right version where it is useful to do so. This partially reverts an ill-considered search and replace from a few months ago.
2005-07-14This doc patch replaces all inappropriate references to SQL:1999 when itNeil Conway
is used as if it were the latest (and/or still valid) SQL standard. SQL:2003 is used in its place. Patch from Simon Riggs.
2005-02-06Document array behavior for out-of-range subscripts.Tom Lane
2004-12-23A small pass of docs review and copy-editing.Tom Lane
2004-12-13Spell checker runPeter Eisentraut
2004-11-27Update of conformance information to SQL:2003Peter Eisentraut
by Troels Arvin, Simon Riggs, Elein Mustain Make spelling of SQL standard names uniform.