summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt
AgeCommit message (Collapse)Author
2005-05-09Complete the following TODO items:Neil Conway
* Add session start time to pg_stat_activity * Add the client IP address and port to pg_stat_activity Original patch from Magnus Hagander, code review by Neil Conway. Catalog version bumped. This patch sends the client IP address and port number in every statistics message; that's not ideal, but will be fixed up shortly.
2005-05-07Add comment on C locale test for upper/lower/initcap().Bruce Momjian
2005-05-02Check the file system on postmaster startup and report any unreferencedBruce Momjian
files in the server log. Heikki Linnakangas
2005-05-01Change CREATE TYPE to require datatype output and send functions to haveTom Lane
only one argument. (Per recent discussion, the option to accept multiple arguments is pretty useless for user-defined types, and would be a likely source of security holes if it was used.) Simplify call sites of output/send functions to not bother passing more than one argument.
2005-04-30Make record_out and record_send extract type information from the passedTom Lane
record object itself, rather than relying on a second OID argument to be correct. This patch just changes the function behavior and not the catalogs, so it's OK to back-patch to 8.0. Will remove the now-redundant second argument in pg_proc in a separate patch in HEAD only.
2005-04-30GCC 4.0 includes a new warning option, -Wformat-literal, that emitsNeil Conway
a warning when a variable is used as a format string for printf() and similar functions (if the variable is derived from untrusted data, it could include unexpected formatting sequences). This emits too many warnings to be enabled by default, but it does flag a few dubious constructs in the Postgres tree. This patch fixes up the obvious variants: functions that are passed a variable format string but no additional arguments. Most of these are harmless (e.g. the ruleutils stuff), but there is at least one actual bug here: if you create a trigger named "%sfoo", pg_dump will read uninitialized memory and fail to dump the trigger correctly.
2005-04-29Restructure LOCKTAG as per discussions of a couple months ago.Tom Lane
Essentially, we shoehorn in a lockable-object-type field by taking a byte away from the lockmethodid, which can surely fit in one byte instead of two. This allows less artificial definitions of all the other fields of LOCKTAG; we can get rid of the special pg_xactlock pseudo-relation, and also support locks on individual tuples and general database objects (including shared objects). None of those possibilities are actually exploited just yet, however. I removed pg_xactlock from pg_class, but did not force initdb for that change. At this point, relkind 's' (SPECIAL) is unused and could be removed entirely.
2005-04-28Implement sharable row-level locks, and use them for foreign key referencesTom Lane
to eliminate unnecessary deadlocks. This commit adds SELECT ... FOR SHARE paralleling SELECT ... FOR UPDATE. The implementation uses a new SLRU data structure (managed much like pg_subtrans) to represent multiple- transaction-ID sets. When more than one transaction is holding a shared lock on a particular row, we create a MultiXactId representing that set of transactions and store its ID in the row's XMAX. This scheme allows an effectively unlimited number of row locks, just as we did before, while not costing any extra overhead except when a shared lock actually has to be shared. Still TODO: use the regular lock manager to control the grant order when multiple backends are waiting for a row lock. Alvaro Herrera and Tom Lane.
2005-04-25Remove support for OR'd indexscans internal to a single IndexScan planTom Lane
node, as this behavior is now better done as a bitmap OR indexscan. This allows considerable simplification in nodeIndexscan.c itself as well as several planner modules concerned with indexscan plan generation. Also we can improve the sharing of code between regular and bitmap indexscans, since they are now working with nigh-identical Plan nodes.
2005-04-23Repair two TIME WITH TIME ZONE bugs found by Dennis Vshivkov. ComparisonTom Lane
of timetz values misbehaved in --enable-integer-datetime cases, and EXTRACT(EPOCH) subtracted the zone instead of adding it in all cases. Backpatch to all supported releases (except --enable-integer-datetime code does not exist in 7.2).
2005-04-20Fix mis-display of negative fractional seconds in interval values forTom Lane
--enable-integer-datetimes case. Per report from Oliver Siegmar.
2005-04-19Attached patch gets rid of the global timezone in the following steps:Bruce Momjian
* Changes the APIs to the timezone functions to take a pg_tz pointer as an argument, representing the timezone to use for the selected operation. * Adds a global_timezone variable that represents the current timezone in the backend as set by SET TIMEZONE (or guc, or env, etc). * Implements a hash-table cache of loaded tables, so we don't have to read and parse the TZ file everytime we change a timezone. While not necesasry now (we don't change timezones very often), I beleive this will be necessary (or at least good) when "multiple timezones in the same query" is eventually implemented. And code-wise, this was the time to do it. There are no user-visible changes at this time. Implementing the "multiple zones in one query" is a later step... This also gets rid of some of the cruft needed to "back out a timezone change", since we previously couldn't check a timezone unless it was activated first. Passes regression tests on win32, linux (slackware 10) and solaris x86. Magnus Hagander
2005-04-18record_in and record_recv must be careful to return a separatelyTom Lane
pfree'able result, since some callers expect to be able to pfree the result of a pass-by-reference function. Per report from Chris Trawick.
2005-04-14Completion of project to use fixed OIDs for all system catalogs andTom Lane
indexes. Replace all heap_openr and index_openr calls by heap_open and index_open. Remove runtime lookups of catalog OID numbers in various places. Remove relcache's support for looking up system catalogs by name. Bulky but mostly very boring patch ...
2005-04-14First phase of project to use fixed OIDs for all system catalogs andTom Lane
indexes. Extend the macros in include/catalog/*.h to carry the info about hand-assigned OIDs, and adjust the genbki script and bootstrap code to make the relations actually get those OIDs. Remove the small number of RelOid_pg_foo macros that we had in favor of a complete set named like the catname.h and indexing.h macros. Next phase will get rid of internal use of names for looking up catalogs and indexes; but this completes the changes forcing an initdb, so it looks like a good place to commit. Along the way, I made the shared relations (pg_database etc) not be 'bootstrap' relations any more, so as to reduce the number of hardwired entries and simplify changing those relations in future. I'm not sure whether they ever really needed to be handled as bootstrap relations, but it seems to work fine to not do so now.
2005-04-12Add aggsortop column to pg_aggregate, so that MIN/MAX optimization canTom Lane
be supported for all datatypes. Add CREATE AGGREGATE and pg_dump support too. Add specialized min/max aggregates for bpchar, instead of depending on text's min/max, because otherwise the possible use of bpchar indexes cannot be recognized. initdb forced because of catalog changes.
2005-04-07Add a "USING" clause to DELETE, which is equivalent to the FROM clauseNeil Conway
in UPDATE. We also now issue a NOTICE if a query has _any_ implicit range table entries -- in the past, we would only warn about implicit RTEs in SELECTs with at least one explicit RTE. As a result of the warning change, 25 of the regression tests had to be updated. I also took the opportunity to remove some bogus whitespace differences between some of the float4 and float8 variants. I believe I have correctly updated all the platform-specific variants, but let me know if that's not the case. Original patch for DELETE ... USING from Euler Taveira de Oliveira, reworked by Neil Conway.
2005-04-06Apply the "nodeAgg" optimization to more of the builtin transitionNeil Conway
functions. This patch optimizes int2_sum(), int4_sum(), float4_accum() and float8_accum() to avoid needing to copy the transition function's state for each input tuple of the aggregate. In an extreme case (e.g. SELECT sum(int2_col) FROM table where table has a single column), it improves performance by about 20%. For more complex queries or tables with wider rows, the relative performance improvement will not be as significant.
2005-04-06Merge Resdom nodes into TargetEntry nodes to simplify code and save aTom Lane
few palloc's. I also chose to eliminate the restype and restypmod fields entirely, since they are redundant with information stored in the node's contained expression; re-examining the expression at need seems simpler and more reliable than trying to keep restype/restypmod up to date. initdb forced due to change in contents of stored rules.
2005-04-04This patch changes int2_avg_accum() and int4_avg_accum() use the nodeAggNeil Conway
performance hack Tom introduced recently. This means we can avoid copying the transition array for each input tuple if these functions are invoked as aggregate transition functions. To test the performance improvement, I created a 1 million row table with a single int4 column. Without the patch, SELECT avg(col) FROM table took about 4.2 seconds (after the data was cached); with the patch, it took about 3.2 seconds. Naturally, the performance improvement for a less trivial query (or a table with wider rows) would be relatively smaller.
2005-04-01Second try at making examine_variable and friends behave sanely inTom Lane
cases with binary-compatible relabeling. My first try was implicitly assuming that all operators scalarineqsel is used for have binary- compatible datatypes on both sides ... which is very wrong of course. Per report from Michael Fuhr.
2005-04-01Fix wrong week returnded by date_trunc('week') for early dates inBruce Momjian
January --- would return wrong year for 2005-01-01 and 2006-01-01. per report from Robert Creager. Backpatch to 8.0.X.
2005-03-29Officially decouple FUNC_MAX_ARGS from INDEX_MAX_KEYS, and set theTom Lane
former to 100 by default. Clean up some of the less necessary dependencies on FUNC_MAX_ARGS; however, the biggie (FunctionCallInfoData) remains.
2005-03-29Convert oidvector and int2vector into variable-length arrays. ThisTom Lane
change saves a great deal of space in pg_proc and its primary index, and it eliminates the former requirement that INDEX_MAX_KEYS and FUNC_MAX_ARGS have the same value. INDEX_MAX_KEYS is still embedded in the on-disk representation (because it affects index tuple header size), but FUNC_MAX_ARGS is not. I believe it would now be possible to increase FUNC_MAX_ARGS at little cost, but haven't experimented yet. There are still a lot of vestigial references to FUNC_MAX_ARGS, which I will clean up in a separate pass. However, getting rid of it altogether would require changing the FunctionCallInfoData struct, and I'm not sure I want to buy into that.
2005-03-27First steps towards index scans with heap access decoupled from indexTom Lane
access: define new index access method functions 'amgetmulti' that can fetch multiple TIDs per call. (The functions exist but are totally untested as yet.) Since I was modifying pg_am anyway, remove the no-longer-needed 'rel' parameter from amcostestimate functions, and also remove the vestigial amowner column that was creating useless work for Alvaro's shared-object-dependencies project. Initdb forced due to changes in pg_am.
2005-03-26Fix a pair of related issues with estimation of inequalities that involveTom Lane
binary-compatible relabeling of one or both operands. examine_variable should avoid stripping RelabelType from non-variable expressions, so that they will continue to have the correct type; and convert_to_scalar should just use that type and ignore the other input type. This isn't perfect but it beats failing entirely. Per example from Michael Fuhr.
2005-03-26Prevent to_char(interval) from dumping core on month-related formatsTom Lane
when a zero-month interval is given. Per discussion with Karel. Also, some desultory const-labeling of constant tables. More could be done along that line.
2005-03-25Fix to_date to behave reasonably when CC and YY fields are both used.Tom Lane
Karel Zak
2005-03-24array_map can't use the fn_extra field of the provided fcinfo struct asTom Lane
its private storage, because that belongs to the function that it is supposed to call. Per report from Ezequiel Tolnay.
2005-03-21Fix quote_ident to use quote_identifier rather than its own, not quiteTom Lane
up-to-speed logic; in particular this will cause it to quote names that match keywords. Remove unnecessary multibyte cruft from quote_literal (all backend-internal encodings are 8-bit-safe).
2005-03-16Add missing include for new lc_ctype_is_c() function.Bruce Momjian
Per Neil.
2005-03-16Prevent locale-aware handling of upper, lower, and initcap when theBruce Momjian
locale is C. Backpatch to 8.0.X because some operating systems were throwing errors for such operations, rather than ignoring the locale when it was C.
2005-03-12Adjust the API for aggregate function calls so that a C-coded functionTom Lane
can tell whether it is being used as an aggregate or not. This allows such a function to avoid re-pallocing a pass-by-reference transition value; normally it would be unsafe for a function to scribble on an input, but in the aggregate case it's safe to reuse the old transition value. Make int8inc() do this. This gets a useful improvement in the speed of COUNT(*), at least on narrow tables (it seems to be swamped by I/O when the table rows are wide). Per a discussion in early December with Neil Conway. I also fixed int_aggregate.c to check this, thereby turning it into something approaching a supportable technique instead of being a crude hack.
2005-03-07Rename canonical encodings, per Peter:Bruce Momjian
UNICODE => UTF8 ALT => WIN866 WIN => WIN1251 TCVN => WIN1258 The old codes continue to work.
2005-03-06Revise hash join code so that we can increase the number of batchesTom Lane
on-the-fly, and thereby avoid blowing out memory when the planner has underestimated the hash table size. Hash join will now obey the work_mem limit with some faithfulness. Per my recent proposal (hash aggregate part isn't done yet though).
2005-02-28Implement max() and min() aggregates for array types. Patch from KojuNeil Conway
Iijima, reviewed by Neil Conway. Catalog version number bumped, regression tests updated.
2005-02-27Add explicit casts between int4 and boolean. Patch from Sean Chittenden,Neil Conway
editorializing by Neil Conway. Catalog version bumped.
2005-02-23This patch optimizes the md5_text() function (which is used toNeil Conway
implement the md5() SQL-level function). The old code did the following: 1. de-toast the datum 2. convert it to a cstring via textout() 3. get the length of the cstring via strlen() Since we are treating the datum context as a blob of binary data, the latter two steps are unnecessary. Once the data has been detoasted, we can just use it as-is, and derive its length from the varlena metadata. This patch improves some run-of-the-mill md5() computations by just under 10% in my limited tests, and passes the regression tests. I also noticed that md5_text() wasn't checking the return value of md5_hash(); encountering OOM at precisely the right moment could result in returning a random md5 hash. This patch corrects that. A better fix would be to make md5_hash() only return on success (and/or allocate via palloc()), but since it's used in the frontend as well I don't see an easy way to do that.
2005-02-11Adjust input routines for float4, float8 and oid to reject the empty stringNeil Conway
as valid input (it was previously treated as 0). This input was deprecated in 8.0 (and a warning was emitted). Regression tests updated.
2005-02-01Adjust estimate_num_groups() to not clamp per-relation group countTom Lane
estimate to less than the number of values estimated for any one grouping Var, as suggested by Manfred. This is intuitively right, and what's more it puts the plan choices in the subselect regression test back the way they were before ...
2005-02-01Sync inet formatting code with recent BIND releases. In particular,Tom Lane
fix bug with inconsistent selection of default mask length for "class D" addresses. Per report from Steve Atkins.
2005-01-28When dealing with multiple grouping columns coming from the same table,Tom Lane
clamp the estimated number of groups to table row count over 10, instead of table row count; this reflects a heuristic that people probably won't group over a near-unique set of columns, and the knowledge that we don't currently have any way to estimate the correlation of the columns better than guessing. This change creates a trivial plan change in one of the regression tests.
2005-01-13get_names_for_var didn't do recursion for unnamed JOIN vars quite right;Tom Lane
got it wrong when the JOIN was in an outer query level. Per example from Laurie Burrow. Also fix same issue in markTargetListOrigin. I think the latter is only a latent bug since we currently don't apply markTargetListOrigin except at the outer level ... but should do it right anyway.
2005-01-13Remove unportable assumption that it's okay to use the target bufferTom Lane
of an sprintf() as a source string. Demonstrably does not work with recent gcc and/or glibc on some platforms.
2005-01-11interval_out failed to mention 'ago' for negative intervals in SQL andTom Lane
GERMAN datestyles. Ancient bug reported by Terry Lee Tucker.
2005-01-09Undo an unadvertised change in the API of pg_atoi. In all previousTom Lane
releases, a nonzero 'c' argument meant that the input string could be terminated by either that character or \0. Recent refactoring broke that, causing the thing to scan for 'c' only. This went undetected because no part of the main code actually passes nonzero 'c'. However it broke tsearch2 and possibly other user-written code that assumed the old definition. Per report from Tom Hebbron.
2005-01-01Some more missed copyright notices. Many of these look like theyTom Lane
should have been caught by the src/tools/copyright script ... why weren't they?
2005-01-01Update copyrights that were missed.Bruce Momjian
2004-12-31Tag appropriate files for rc3PostgreSQL Daemon
Also performed an initial run through of upgrading our Copyright date to extend to 2005 ... first run here was very simple ... change everything where: grep 1996-2004 && the word 'Copyright' ... scanned through the generated list with 'less' first, and after, to make sure that I only picked up the right entries ...
2004-12-20Add support for Latin9 encoding in to_ascii(). Jaime CasanovaTom Lane