aboutsummaryrefslogtreecommitdiff
path: root/src/include/utils/builtins.h
Commit message (Collapse)AuthorAge
...
* When reporting the server as not responding, if the hostname wasBruce Momjian2010-11-24
| | | | | | | | | supplied, also print the IP address. This allows IPv4 and IPv6 failures to be distinguished. Also useful when a hostname resolves to multiple IP addresses. Also, remove use of inet_ntoa() and use our own inet_net_ntop() in all places, including in libpq, because it is thread-safe.
* Add new SQL function, format(text).Robert Haas2010-11-20
| | | | | | | | | | | 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.
* Expose quote_literal_cstr() from core.Robert Haas2010-11-20
| | | | | | | | | This eliminates the need for inefficient implementions of this functionality in both contrib/dblink and contrib/tablefunc, so remove them. The upcoming patch implementing an in-core format() function will also require this functionality. In passing, add some regression tests.
* Speed up conversion of signed integers to C strings.Robert Haas2010-11-19
| | | | | | | A hand-coded implementation turns out to be much faster than calling printf(). In passing, add a few more regresion tests. Andres Freund, with assorted, mostly cosmetic changes.
* Add pg_describe_object functionAlvaro Herrera2010-11-18
| | | | | This function is useful to obtain textual descriptions of objects as stored in pg_depend.
* Remove cvs keywords from all files.Magnus Hagander2010-09-20
|
* Install a data-type-based solution for protecting pg_get_expr().REL9_1_ALPHA1Tom Lane2010-09-03
| | | | | | | | | | | | Since the code underlying pg_get_expr() is not secure against malformed input, and can't practically be made so, we need to prevent miscreants from feeding arbitrary data to it. We can do this securely by declaring pg_get_expr() to take a new datatype "pg_node_tree" and declaring the system catalog columns that hold nodeToString output to be of that type. There is no way at SQL level to create a non-null value of type pg_node_tree. Since the backend-internal operations that fill those catalog columns operate below the SQL level, they are oblivious to the datatype relabeling and don't need any changes.
* Add string functions: concat(), concat_ws(), left(), right(), and reverse().Itagaki Takahiro2010-08-24
| | | | Pavel Stehule, reviewed by me.
* Add three-parameter forms of array_to_string and string_to_array, to allowTom Lane2010-08-10
| | | | | | | | | | | | | | | | 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
* Remove the single-argument form of string_agg(). It added nothing much inTom Lane2010-08-05
| | | | | | | | 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.
* Add options to force quoting of all identifiers.Robert Haas2010-07-22
| | | | | | | | | | I've added a quote_all_identifiers GUC which affects the behavior of the backend, and a --quote-all-identifiers argument to pg_dump and pg_dumpall which sets the GUC and also affects the quoting done internally by those applications. Design by Tom Lane; review by Alex Hunsaker; in response to bug #5488 filed by Hartmut Goebel.
* Teach EXPLAIN to print PARAM_EXEC Params as the referenced expressions,Tom Lane2010-07-13
| | | | | | | | | | | | | | | | rather than just $N. This brings the display of nestloop-inner-indexscan plans back to where it's been, and incidentally improves the display of SubPlan parameters as well. In passing, simplify the EXPLAIN code by having it deal primarily in the PlanState tree rather than separately searching Plan and PlanState trees. This is noticeably cleaner for subplans, and about a wash elsewhere. One small difference from previous behavior is that EXPLAIN will no longer qualify local variable references in inner-indexscan plan nodes, since it no longer sees such nodes as possibly referencing multiple tables. Vars referenced through PARAM_EXEC Params are still forcibly qualified, though, so I don't think the display is any more confusing than before. Adjust a couple of examples in the documentation to match this behavior.
* pgindent run for 9.0, second runBruce Momjian2010-07-06
|
* Fix ALTER LARGE OBJECT and GRANT ... ON LARGE OBJECT for large OIDs.Robert Haas2010-06-13
| | | | | The previous coding failed for OIDs too large to be represented by a signed integer.
* pgindent run for 9.0Bruce Momjian2010-02-26
|
* Create a "relation mapping" infrastructure to support changing the relfilenodesTom Lane2010-02-07
| | | | | | | | | | | | | | | | | | | | | | | of shared or nailed system catalogs. This has two key benefits: * The new CLUSTER-based VACUUM FULL can be applied safely to all catalogs. * We no longer have to use an unsafe reindex-in-place approach for reindexing shared catalogs. CLUSTER on nailed catalogs now works too, although I left it disabled on shared catalogs because the resulting pg_index.indisclustered update would only be visible in one database. Since reindexing shared system catalogs is now fully transactional and crash-safe, the former special cases in REINDEX behavior have been removed; shared catalogs are treated the same as non-shared. This commit does not do anything about the recently-discussed problem of deadlocks between VACUUM FULL/CLUSTER on a system catalog and other concurrent queries; will address that in a separate patch. As a stopgap, parallel_schedule has been tweaked to run vacuum.sql by itself, to avoid such failures during the regression tests.
* Add string_agg aggregate functions. The one argument version concatenatesItagaki Takahiro2010-02-01
| | | | | | | 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.
* Add get_bit/set_bit functions for bit strings, paralleling those for bytea,Tom Lane2010-01-25
| | | | | | | | | 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
* Add pg_table_size() and pg_indexes_size() to provide more user-friendlyTom Lane2010-01-19
| | | | | | wrappers around the pg_relation_size() function. Bernd Helmle, reviewed by Greg Smith
* Update copyright for the year 2010.Bruce Momjian2010-01-02
|
* Allow read only connections during recovery, known as Hot Standby.Simon Riggs2009-12-19
| | | | | | | | | | | | Enabled by recovery_connections = on (default) and forcing archive recovery using a recovery.conf. Recovery processing now emulates the original transactions as they are replayed, providing full locking and MVCC behaviour for read only queries. Recovery must enter consistent state before connections are allowed, so there is a delay, typically short, before connections succeed. Replay of recovering transactions can conflict and in some cases deadlock with queries during recovery; these result in query cancellation after max_standby_delay seconds have expired. Infrastructure changes have minor effects on normal running, though introduce four new types of WAL record. New test mode "make standbycheck" allows regression tests of static command behaviour on a standby server while in recovery. Typical and extreme dynamic behaviours have been checked via code inspection and manual testing. Few port specific behaviours have been utilised, though primary testing has been on Linux only so far. This commit is the basic patch. Additional changes will follow in this release to enhance some aspects of behaviour, notably improved handling of conflicts, deadlock detection and query cancellation. Changes to VACUUM FULL are also required. Simon Riggs, with significant and lengthy review by Heikki Linnakangas, including streamlined redesign of snapshot creation and two-phase commit. Important contributions from Florian Pflug, Mark Kirkwood, Merlin Moncure, Greg Stark, Gianni Ciolli, Gabriele Bartolini, Hannu Krosing, Robert Haas, Tatsuo Ishii, Hiroyuki Yamada plus support and feedback from many other community members.
* Remove regex_flavor GUC, so that regular expressions are always "advanced"Tom Lane2009-10-21
| | | | | | | | | style by default. Per discussion, there seems to be hardly anything that really relies on being able to change the regex flavor, so the ability to select it via embedded options ought to be enough for any stragglers. Also, if we didn't remove the GUC, we'd really be morally obligated to mark the regex functions non-immutable, which'd possibly create performance issues.
* Use pg_get_triggerdef in pg_dumpPeter Eisentraut2009-10-09
| | | | | | | | | | | Add a variant of pg_get_triggerdef with a second argument "pretty" that causes the output to be formatted in the way pg_dump used to do. Use this variant in pg_dump with server versions >= 8.5. This insulates pg_dump from most future trigger feature additions, such as the upcoming column triggers patch. Author: Itagaki Takahiro <itagaki.takahiro@oss.ntt.co.jp>
* Fix/improve bytea and boolean support in PL/PythonPeter Eisentraut2009-09-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before, PL/Python converted data between SQL and Python by going through a C string representation. This broke for bytea in two ways: - On input (function parameters), you would get a Python string that contains bytea's particular external representation with backslashes etc., instead of a sequence of bytes, which is what you would expect in a Python environment. This problem is exacerbated by the new bytea output format. - On output (function return value), null bytes in the Python string would cause truncation before the data gets stored into a bytea datum. This is now fixed by converting directly between the PostgreSQL datum and the Python representation. The required generalized infrastructure also allows for other improvements in passing: - When returning a boolean value, the SQL datum is now true if and only if Python considers the value that was passed out of the PL/Python function to be true. Previously, this determination was left to the boolean data type input function. So, now returning 'foo' results in true, because Python considers it true, rather than false because PostgreSQL considers it false. - On input, we can convert the integer and float types directly to their Python equivalents without having to go through an intermediate string representation. original patch by Caleb Welton, with updates by myself
* Support hex-string input and output for type BYTEA.Tom Lane2009-08-04
| | | | | | | | | | | | | 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
* Implement has_sequence_privilege()Joe Conway2009-08-03
| | | | | | | Add family of functions that did not exist earlier, mainly due to historical omission. Original patch by Abhijit Menon-Sen, with review and modifications by Joe Conway. catversion.h bumped.
* Improve unique-constraint-violation error messages to include the exactTom Lane2009-08-01
| | | | | | | | | values being complained of. In passing, also remove the arbitrary length limitation in the similar error detail message for foreign key violations. Itagaki Takahiro
* Support deferrable uniqueness constraints.Tom Lane2009-07-29
| | | | | | | | | | The current implementation fires an AFTER ROW trigger for each tuple that looks like it might be non-unique according to the index contents at the time of insertion. This works well as long as there aren't many conflicts, but won't scale to massive unique-key reassignments. Improving that case is a TODO item. Dean Rasheed
* Make backend header files C++ safePeter Eisentraut2009-07-16
| | | | | | | | | | | This alters various incidental uses of C++ key words to use other similar identifiers, so that a C++ compiler won't choke outright. You still (probably) need extern "C" { }; around the inclusion of backend headers. based on a patch by Kurt Harriman <harriman@acm.org> Also add a script cpluspluscheck to check for C++ compatibility in the future. As of right now, this passes without error for me.
* More sensible character_octet_lengthPeter Eisentraut2009-07-07
| | | | | | | For character types with typmod, character_octet_length columns in the information schema now show the maximum character length times the maximum length of a character in the server encoding, instead of some huge value as before.
* Accept 'on' and 'off' as input for boolean data type, unifying the syntaxPeter Eisentraut2009-03-09
| | | | | | that the data type and GUC accepts. ITAGAKI Takahiro
* Clean up some loose ends from the column privileges patch: addTom Lane2009-02-06
| | | | | | | | | | | | | | | | | | | | | | has_column_privilege and has_any_column_privilege SQL functions; fix the information_schema views that are supposed to pay attention to column privileges; adjust pg_stats to show stats for any column you have select privilege on; and fix COPY to allow copying a subset of columns if the user has suitable per-column privileges for all the columns. To improve efficiency of some of the information_schema views, extend the has_xxx_privilege functions to allow inquiring about the OR of a set of privileges in just one call. This is just exposing capability that already existed in the underlying aclcheck routines. In passing, make the information_schema views report the owner's own privileges as being grantable, since Postgres assumes this even when the grant option bit is not set in the ACL. This is a longstanding oversight. Also, make the new has_xxx_privilege functions for foreign data objects follow the same coding conventions used by the older ones. Stephen Frost and Tom Lane
* Update copyright for 2009.Bruce Momjian2009-01-01
|
* Support window functions a la SQL:2008.Tom Lane2008-12-28
| | | | Hitoshi Harada, with some kibitzing from Heikki and Tom.
* SQL/MED catalog manipulation facilitiesPeter Eisentraut2008-12-19
| | | | | | | | This doesn't do any remote or external things yet, but it gives modules like plproxy and dblink a standardized and future-proof system for managing their connection information. Martin Pihlak and Peter Eisentraut
* Default values for function argumentsPeter Eisentraut2008-12-04
| | | | Pavel Stehule, with some tweaks by Peter Eisentraut
* suppress_redundant_updates_trigger function.Andrew Dunstan2008-11-03
|
* Add pg_typeof() function.Tom Lane2008-11-03
| | | | Brendan Jurd
* Implement comparison of generic records (composite types), and invent aTom Lane2008-10-13
| | | | | | | | | | | | | pseudo-type record[] to represent arrays of possibly-anonymous composite types. Since composite datums carry their own type identification, no extra knowledge is needed at the array level. The main reason for doing this right now is that it is necessary to support the general case of detection of cycles in recursive queries: if you need to compare more than one column to detect a cycle, you need to compare a ROW() to an array built from ROW()s, at least if you want to do it as the spec suggests. Add some documentation and regression tests concerning the cycle detection issue.
* Fix up ruleutils.c for CTE features. The main problem was thatTom Lane2008-10-06
| | | | | | | | | | | | | | | | get_name_for_var_field didn't have enough context to interpret a reference to a CTE query's output. Fixing this requires separate hacks for the regular deparse case (pg_get_ruledef) and for the EXPLAIN case, since the available context information is quite different. It's pretty nearly parallel to the existing code for SUBQUERY RTEs, though. Also, add code to make sure we qualify a relation name that matches a CTE name; else the CTE will mistakenly capture the reference when reloading the rule. In passing, fix a pre-existing problem with get_name_for_var_field not working on variables in targetlists of SubqueryScan plan nodes. Although latent all along, this wasn't a problem until we made EXPLAIN VERBOSE try to print targetlists. To do this, refactor the deparse_context_for_plan API so that the special case for SubqueryScan is all on ruleutils.c's side.
* Remove obsolete internal functions istrue, isfalse, isnottrue, isnotfalse,Peter Eisentraut2008-10-05
| | | | | nullvalue, nonvalue. A long time ago, these were used to implement the SQL constructs IS TRUE, etc.
* Add relation fork support to pg_relation_size() function. You can now passHeikki Linnakangas2008-10-03
| | | | | | | | | | | | | name of a fork ('main' or 'fsm', at the moment) to pg_relation_size() to get the size of a specific fork. Defaults to 'main', if none given. While we're at it, modify pg_relation_size to take a regclass as argument, instead of separate variants taking oid and name. This change is transparent to typical use where the table name is passed as a string literal, like pg_relation_size('table'), but will break queries like pg_relation_size(namecol), where namecol is of type name. text-type input still works, and using a non-schema-qualified table name is not very reliable anyway, so this is unlikely to break anyone's queries in practice.
* Implement a psql command "\ef" to edit the definition of a function.Tom Lane2008-09-06
| | | | | | | In support of that, create a backend function pg_get_functiondef(). The psql command is functional but maybe a bit rough around the edges... Abhijit Menon-Sen
* Implement SQL-spec RETURNS TABLE syntax for functions.Tom Lane2008-07-18
| | | | | | | (Unlike the original submission, this patch treats TABLE output parameters as being entirely equivalent to OUT parameters -- tgl) Pavel Stehule
* Add a function pg_get_keywords() to let clients find out the set of keywordsTom Lane2008-07-03
| | | | known to the SQL parser. Dave Page
* Clean up some problems with redundant cross-type arithmetic operators. AddTom Lane2008-06-17
| | | | | | | | | | | | | int2-and-int8 implementations of the basic arithmetic operators +, -, *, /. This doesn't really add any new functionality, but it avoids "operator is not unique" failures that formerly occurred in these cases because the parser couldn't decide whether to promote the int2 to int4 or int8. We could alternatively have removed the existing cross-type operators, but experimentation shows that the cost of an additional type coercion expression node is noticeable compared to such cheap operators; so let's not give up any performance here. On the other hand, I removed the int2-and-int4 modulo (%) operators since they didn't seem as important from a performance standpoint. Per a complaint last January from ykhuang.
* Alter the xxx_pattern_ops opclasses to use the regular equality operator ofTom Lane2008-05-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Re-enable pg_terminate_backend() using SIGTERM. SIGTERM testing stillBruce Momjian2008-04-17
| | | | needed.
* Revert addition of pg_terminate_backend() because of race conditions.Bruce Momjian2008-04-15
|
* Add pg_terminate_backend() to allow terminating only a single session.Bruce Momjian2008-04-15
|