summaryrefslogtreecommitdiff
path: root/src/backend/utils/fmgr
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright for 2009.Bruce Momjian2009-01-013-6/+6
|
* Support window functions a la SQL:2008.Tom Lane2008-12-281-1/+74
| | | | Hitoshi Harada, with some kibitzing from Heikki and Tom.
* Remove inappropriate memory context switch in shutdown_MultiFuncCall().Tom Lane2008-11-301-2/+1
| | | | | | | This was a thinko introduced in a patch from last February; it results in memory leakage if an SRF is shut down before the actual end of query, because subsequent code will be running in a longer-lived context than it's expecting to be.
* Allow SQL-language functions to return the output of an INSERT/UPDATE/DELETETom Lane2008-10-311-2/+4
| | | | | | | | | RETURNING clause, not just a SELECT as formerly. A side effect of this patch is that when a set-returning SQL function is used in a FROM clause, performance is improved because the output is collected into a tuplestore within the function, rather than using the less efficient value-per-call mechanism.
* Be more tense about not creating tuplestores with randomAccess = true unlessTom Lane2008-10-291-1/+5
| | | | | | | | backwards scan could actually happen. In particular, pass a flag to materialize-mode SRFs that tells them whether they need to require random access. In passing, also suppress unneeded backward-scan overhead for a Portal's holdStore tuplestore. Per my proposal about reducing I/O costs for tuplestores.
* Extend ExecMakeFunctionResult() to support set-returning functions that returnTom Lane2008-10-281-3/+2
| | | | | | | | | via a tuplestore instead of value-per-call. Refactor a few things to reduce ensuing code duplication with nodeFunctionscan.c. This represents the reasonably noncontroversial part of my proposed patch to switch SQL functions over to returning tuplestores. For the moment, SQL functions still do things the old way. However, this change enables PL SRFs to be called in targetlists (observe changes in plperl regression results).
* If a loadable module has wrong values in its magic block, spell outTom Lane2008-09-031-18/+93
| | | | | exactly what they are in the complaint message. Marko Kreen, some editorialization by me.
* Move exprType(), exprTypmod(), expression_tree_walker(), and related routinesTom Lane2008-08-252-4/+4
| | | | | | into nodes/nodeFuncs, so as to reduce wanton cross-subsystem #includes inside the backend. There's probably more that should be done along this line, but this is a start anyway.
* Implement SQL-spec RETURNS TABLE syntax for functions.Tom Lane2008-07-181-6/+8
| | | | | | | (Unlike the original submission, this patch treats TABLE output parameters as being entirely equivalent to OUT parameters -- tgl) Pavel Stehule
* Add a "provariadic" column to pg_proc to eliminate the remarkably expensiveTom Lane2008-07-161-4/+6
| | | | | | | | | | need to deconstruct proargmodes for each pg_proc entry inspected by FuncnameGetCandidates(). Fixes function lookup performance regression caused by yesterday's variadic-functions patch. In passing, make pg_proc.probin be NULL, rather than a dummy value '-', in cases where it is not actually used for the particular type of function. This should buy back some of the space cost of the extra column.
* Support "variadic" functions, which can accept a variable number of argumentsTom Lane2008-07-161-3/+5
| | | | | | | | | | | | | | so long as all the trailing arguments are of the same (non-array) type. The function receives them as a single array argument (which is why they have to all be the same type). It might be useful to extend this facility to aggregates, but this patch doesn't do that. This patch imposes a noticeable slowdown on function lookup --- a follow-on patch will fix that by adding a redundant column to pg_proc. Pavel Stehule
* Change xlog.h to xlogdefs.h in bufpage.h, and fix fallout.Alvaro Herrera2008-06-061-1/+2
|
* Add support for tracking call counts and elapsed runtime for user-definedTom Lane2008-05-152-10/+41
| | | | | | | | | | functions. Note that because this patch changes FmgrInfo, any external C functions you might be testing with 8.4 will need to be recompiled. Patch by Martin Pihlak, some editorialization by me (principally, removing tracking of getrusage() numbers)
* Restructure some header files a bit, in particular heapam.h, by removing someAlvaro Herrera2008-05-121-2/+1
| | | | | | | | | | | | 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.
* Allow float8, int8, and related datatypes to be passed by value on machinesTom Lane2008-04-212-26/+71
| | | | | | | | | | where Datum is 8 bytes wide. Since this will break old-style C functions (those still using version 0 calling convention) that have arguments or results of these types, provide a configure option to disable it and retain the old pass-by-reference behavior. Likewise, provide a configure option to disable the recently-committed float4 pass-by-value change. Zoltan Boszormenyi, plus configurability stuff by me.
* Modify the float4 datatype to be pass-by-val. Along the way, remove the lastAlvaro Herrera2008-04-182-18/+32
| | | | | | | | | | | | | | | uses of the long-deprecated float32 in contrib/seg; the definitions themselves are still there, but no longer used. fmgr/README updated to match. I added a CREATE FUNCTION to account for existing seg_center() code in seg.c too, and some tests for it and the neighbor functions. At the same time, remove checks for NULL which are not needed (because the functions are declared STRICT). I had to do some adjustments to contrib's btree_gist too. The choices for representation there are not ideal for changing the underlying types :-( Original patch by Zoltan Boszormenyi, with some adjustments by me.
* Clean up a few places where Datums were being treated as pointers (and viceAlvaro Herrera2008-04-171-4/+4
| | | | | | versa) without going through DatumGetPointer. Gavin Sherry, with Feng Tian.
* Simplify and standardize conversions between TEXT datums and ordinary CTom Lane2008-03-252-13/+8
| | | | | | | | | | | | | | | | | | | | 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
* Make source code READMEs more consistent. Add CVS tags to all README files.Bruce Momjian2008-03-201-9/+14
|
* Fix several memory leaks when rescanning SRFs. Arrange for an SRF'sNeil Conway2008-02-291-10/+19
| | | | | | | | | | | | | | | | | | "multi_call_ctx" to be a distinct sub-context of the EState's per-query context, and delete the multi_call_ctx as soon as the SRF finishes execution. This avoids leaking SRF memory until the end of the current query, which is particularly egregious when the SRF is scanned multiple times. This change also fixes a leak of the fields of the AttInMetadata struct in shutdown_MultiFuncCall(). Also fix a leak of the SRF result TupleDesc when rescanning a FunctionScan node. The TupleDesc is allocated in the per-query context for every call to ExecMakeTableFunctionResult(), so we should free it after calling that function. Since the SRF might choose to return a non-expendable TupleDesc, we only free the TupleDesc if it is not being reference-counted. Backpatch to 8.3 and 8.2 stable branches.
* Refactor backend makefiles to remove lots of duplicate codePeter Eisentraut2008-02-191-9/+2
|
* Make standard maintenance operations (including VACUUM, ANALYZE, REINDEX,Tom Lane2008-01-031-19/+24
| | | | | | | | | | | | | | | | | | | and CLUSTER) execute as the table owner rather than the calling user, using the same privilege-switching mechanism already used for SECURITY DEFINER functions. The purpose of this change is to ensure that user-defined functions used in index definitions cannot acquire the privileges of a superuser account that is performing routine maintenance. While a function used in an index is supposed to be IMMUTABLE and thus not able to do anything very interesting, there are several easy ways around that restriction; and even if we could plug them all, there would remain a risk of reading sensitive information and broadcasting it through a covert channel such as CPU usage. To prevent bypassing this security measure, execution of SET SESSION AUTHORIZATION and SET ROLE is now forbidden within a SECURITY DEFINER context. Thanks to Itagaki Takahiro for reporting this vulnerability. Security: CVE-2007-6600
* Update copyrights in source tree to 2008.Bruce Momjian2008-01-013-6/+6
|
* pgindent run for 8.3.Bruce Momjian2007-11-151-7/+7
|
* Arrange for SET LOCAL's effects to persist until the end of the current topTom Lane2007-09-111-5/+3
| | | | | | | | | | | | | | transaction, unless rolled back or overridden by a SET clause for the same variable attached to a surrounding function call. Per discussion, these seem the best semantics. Note that this is an INCOMPATIBLE CHANGE: in 8.0 through 8.2, SET LOCAL's effects disappeared at subtransaction commit (leading to behavior that made little sense at the SQL level). I took advantage of the opportunity to rewrite and simplify the GUC variable save/restore logic a little bit. The old idea of a "tentative" value is gone; it was a hangover from before we had a stack. Also, we no longer need a stack entry for every nesting level, but only for those in which a variable's value actually changed.
* Implement function-local GUC parameter settings, as per recent discussion.Tom Lane2007-09-031-18/+73
| | | | | | | There are still some loose ends: I didn't do anything about the SET FROM CURRENT idea yet, and it's not real clear whether we are happy with the interaction of SET LOCAL with function-local settings. The documentation is a bit spartan, too.
* Fix security definer functions with polymorphic arguments. This case hasTom Lane2007-07-311-1/+2
| | | | | never worked because fmgr_security_definer() neglected to pass the fn_expr information through. Per report from Viatcheslav Kalinin.
* Add casts to suppress warnings about m68k-specific kluge in fmgr.c.Tom Lane2007-07-131-75/+141
|
* Some of our port-specific dynloader implementations are careful toTom Lane2007-07-121-3/+3
| | | | | | | define pg_dlsym() as returning a PGFunction pointer, not just any pointer-to-function. But many are not. Suppress compiler warnings on platforms that aren't careful by inserting explicit casts at the two call sites that didn't have a cast already. Per Stefan.
* Remove unused "caller" argument from stringToQualifiedNameList.Alvaro Herrera2007-06-261-2/+2
|
* Fix up text concatenation so that it accepts all the reasonable cases thatTom Lane2007-06-061-13/+26
| | | | | | | | 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.
* Support varlena fields with single-byte headers and unaligned storage.Tom Lane2007-04-061-4/+13
| | | | | | | | | 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
* Support enum data types. Along the way, use macros for the values ofTom Lane2007-04-021-13/+29
| | | | | pg_type.typtype whereever practical. Tom Dunstan, with some kibitzing from Tom Lane.
* Fix array coercion expressions to ensure that the correct volatility isTom Lane2007-03-271-3/+9
| | | | | | | | | 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.
* Combine cmin and cmax fields of HeapTupleHeaders into a single field, byTom Lane2007-02-091-4/+4
| | | | | | | | | | keeping private state in each backend that has inserted and deleted the same tuple during its current top-level transaction. This is sufficient since there is no need to be able to determine the cmin/cmax from any other transaction. This gets us back down to 23-byte headers, removing a penalty paid in 8.0 to support subtransactions. Patch by Heikki Linnakangas, with minor revisions by moi, following a design hashed out awhile back on the pghackers list.
* Replace some strncpy() by strlcpy().Peter Eisentraut2007-02-071-3/+2
|
* Wording cleanup for error messages. Also change can't -> cannot.Bruce Momjian2007-02-011-2/+2
| | | | | | | | | | | | | | 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".
* Update CVS HEAD for 2007 copyright. Back branches are typically notBruce Momjian2007-01-053-6/+6
| | | | back-stamped for this.
* Message style improvementsPeter Eisentraut2006-10-061-2/+2
|
* pgindent run for 8.2.Bruce Momjian2006-10-042-36/+36
|
* Replace strncpy with strlcpy in selected places that seem possibly relevantTom Lane2006-09-271-6/+2
| | | | | | | to performance. (A wholesale effort to get rid of strncpy should be undertaken sometime, but not during beta.) This commit also fixes dynahash.c to correctly truncate overlength string keys for hashtables, so that its callers don't have to anymore.
* Seems some C compilers think 'restrict' is a fully reserved word.Tom Lane2006-08-161-4/+4
| | | | Per buildfarm results from warthog.
* Add server support for "plugin" libraries that can be used for add-on tasksTom Lane2006-08-151-78/+192
| | | | | | | | | | | | | | | | | | such as debugging and performance measurement. This consists of two features: a table of "rendezvous variables" that allows separately-loaded shared libraries to communicate, and a new GUC setting "local_preload_libraries" that allows libraries to be loaded into specific sessions without explicit cooperation from the client application. To make local_preload_libraries as flexible as possible, we do not restrict its use to superusers; instead, it is restricted to load only libraries stored in $libdir/plugins/. The existing LOAD command has also been modified to allow non-superusers to LOAD libraries stored in this directory. This patch also renames the existing GUC variable preload_libraries to shared_preload_libraries (after a suggestion by Simon Riggs) and does some code refactoring in dfmgr.c to improve clarity. Korry Douglas, with a little help from Tom Lane.
* Add a feature for automatic initialization and finalization of dynamicallyTom Lane2006-08-081-3/+24
| | | | | | | | | loaded libraries: call functions _PG_init() and _PG_fini() if the library defines such symbols. Hence we no longer need to specify an initialization function in preload_libraries: we can assume that the library used the _PG_init() convention, instead. This removes one source of pilot error in use of preloaded libraries. Original patch by Ralf Engelschall, preload_libraries changes by me.
* Sort reference of include files, "A" - "F".Bruce Momjian2006-07-111-2/+2
|
* Fix problems with cached tuple descriptors disappearing while still in useTom Lane2006-06-161-6/+5
| | | | | | | | | | by creating a reference-count mechanism, similar to what we did a long time ago for catcache entries. The back branches have an ugly solution involving lots of extra copies, but this way is more efficient. Reference counting is only applied to tupdescs that are actually in caches --- there seems no need to use it for tupdescs that are generated in the executor, since they'll go away during plan shutdown by virtue of being in the per-query memory context. Neil Conway and Tom Lane
* Prepare code to be built by MSVC:Bruce Momjian2006-06-071-1/+5
| | | | | | | | | | o remove many WIN32_CLIENT_ONLY defines o add WIN32_ONLY_COMPILER define o add 3rd argument to open() for portability o add include/port/win32_msvc directory for system includes Magnus Hagander
* Make PG_MODULE_MAGIC required in shared libraries that are loaded intoTom Lane2006-05-311-9/+9
| | | | | the server. Per discussion, there seems no point in a waiting period before making this required.
* Code review for magic-block patch. Remove separate header file pgmagic.h,Tom Lane2006-05-302-43/+52
| | | | | | | | | | as this seems only likely to create headaches for module developers. Put the macro in the pre-existing fmgr.h file instead. Avoid being too cute about how many fields we can cram into a word, and avoid trying to fetch from a library we've already unlinked. Along the way, it occurred to me that the magic block really ought to be 'const' so it can be stored in the program text area. Do the same for the existing data blocks for PG_FUNCTION_INFO_V1 functions.
* Add pgmagic header block to store compile-time constants:Bruce Momjian2006-05-301-2/+45
| | | | | | | | | | | | | | | | | | | | | It now only checks four things: Major version number (7.4 or 8.1 for example) NAMEDATALEN FUNC_MAX_ARGS INDEX_MAX_KEYS The three constants were chosen because: 1. We document them in the config page in the docs 2. We mark them as changable in pg_config_manual.h 3. Changing any of these will break some of the more popular modules: FUNC_MAX_ARGS changes fmgr interface, every module uses this NAMEDATALEN changes syscache interface, every PL as well as tsearch uses this INDEX_MAX_KEYS breaks tsearch and anything using GiST. Martijn van Oosterhout