aboutsummaryrefslogtreecommitdiff
path: root/src/backend
Commit message (Collapse)AuthorAge
...
* Reduce the need for frontend programs to include "postgres.h" by refactoringTom Lane2008-03-27
| | | | | | | | | | | | inclusions in src/include/catalog/*.h files. The main idea here is to push function declarations for src/backend/catalog/*.c files into separate headers, rather than sticking them into the corresponding catalog definition file as has been done in the past. This commit only carries out that idea fully for pg_proc, pg_type and pg_conversion, but that's enough for the moment --- if pg_list.h ever becomes unsafe for frontend code to include, we'll need to work a bit more. Zdenek Kotala
* Move the HTSU_Result enum definition into snapshot.h, to avoid includingAlvaro Herrera2008-03-26
| | | | | | tqual.h into heapam.h. This makes all inclusion of tqual.h explicit. I also sorted alphabetically the includes on some source files.
* Rename snapmgmt.c/h to snapmgr.c/h, for consistency with other files.Alvaro Herrera2008-03-26
| | | | Per complaint from Tom Lane.
* Separate snapshot management code from tuple visibility code, create aAlvaro Herrera2008-03-26
| | | | | | | | | | | | | snapmgmt.c file for the former. The header files have also been reorganized in three parts: the most basic snapshot definitions are now in a new file snapshot.h, and the also new snapmgmt.h keeps the definitions for snapmgmt.c. tqual.h has been reduced to the bare minimum. This patch is just a first step towards managing live snapshots within a transaction; there is no functionality change. Per my proposal to pgsql-patches on 20080318191940.GB27458@alvh.no-ip.org and subsequent discussion.
* Simplify and standardize conversions between TEXT datums and ordinary CTom Lane2008-03-25
| | | | | | | | | | | | | | | | | | | | 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
* Add a new tuplestore API function, tuplestore_putvalues(). This isNeil Conway2008-03-25
| | | | | | | identical to tuplestore_puttuple(), except it operates on arrays of Datums + nulls rather than a fully-formed HeapTuple. In several places that use the tuplestore API, this means we can avoid creating a HeapTuple altogether, saving a copy.
* When a relation has been proven empty by constraint exclusion, propagate thatTom Lane2008-03-24
| | | | | | | | knowledge up through any joins it participates in. We were doing that already in some special cases but not in the general case. Also, defend against zero row estimates for the input relations in cost_mergejoin --- this fix may have eliminated the only scenario in which that can happen, but be safe. Per report from Alex Solovey.
* Use new errdetail_log() mechanism to provide a less klugy way of reportingTom Lane2008-03-24
| | | | | large numbers of dependencies on a role that couldn't be dropped. Per a comment from Alvaro.
* Fix various infelicities that have snuck into usage of errdetail() andTom Lane2008-03-24
| | | | | | friends. Avoid double translation of some messages, ensure other messages are exposed for translation (and make them follow the style guidelines), avoid unsafe passing of an unpredictable message text as a format string.
* Adjust the recent patch for reporting of deadlocked queries so that we reportTom Lane2008-03-24
| | | | | | | | query texts only to the server log. This eliminates the issue of possible leaking of security-sensitive data in other sessions' queries. Since the log is presumed secure, we can now log the queries of all sessions involved in the deadlock, whether or not they belong to the same user as the one reporting the failure.
* Add a new ereport auxiliary function errdetail_log(), which works the same asTom Lane2008-03-24
| | | | | | | | errdetail except the string goes only to the server log, replacing the normal errdetail there. This provides a reasonably clean way of dealing with error details that are too security-sensitive or too bulky to send to the client. This commit just adds the infrastructure --- actual uses to follow.
* Avoid a useless tuple copy within nodeMaterial. Neil ConwayTom Lane2008-03-23
|
* Create a function quote_nullable(), which works the same as quote_literal()Tom Lane2008-03-23
| | | | | | | | | except that it returns the string 'NULL', rather than a SQL null, when called with a null argument. This is often a much more useful behavior for constructing dynamic queries. Add more discussion to the documentation about how to use these functions. Brendan Jurd
* Refactor to_char/to_date formatting code; primarily, replace DCH_processorTom Lane2008-03-22
| | | | | with two new functions DCH_to_char and DCH_from_char that have less confusing APIs. Brendan Jurd
* Add server side lo_import(filename, oid) function.Tatsuo Ishii2008-03-22
|
* Remove TypeName struct's timezone flag, which has been write-only storageTom Lane2008-03-21
| | | | | for a very long time --- in current usage it's entirely redundant with the name field.
* Give an explicit error for serial[], rather than silently ignoringTom Lane2008-03-21
| | | | the array decoration as the code had been doing.
* Report the current queries of all backends involved in a deadlockTom Lane2008-03-21
| | | | | | | | | | | | | | | (if they'd be visible to the current user in pg_stat_activity). This might look like it's subject to race conditions, but it's actually pretty safe because at the time DeadLockReport() is constructing the report, we haven't yet aborted our transaction and so we can expect that everyone else involved in the deadlock is still blocked on some lock. (There are corner cases where that might not be true, such as a statement timeout triggering in another backend before we finish reporting; but at worst we'd report a misleading activity string, so it seems acceptable considering the usefulness of reporting the queries.) Original patch by Itagaki Takahiro, heavily modified by me.
* More README src cleanups.Bruce Momjian2008-03-21
|
* Get rid of a bunch of #ifdef HAVE_INT64_TIMESTAMP conditionals by inventingTom Lane2008-03-21
| | | | | | | | | | a new typedef TimeOffset to represent an intermediate time value. It's either int64 or double as appropriate, and in most usages will be measured in microseconds or seconds the same as Timestamp. We don't call it Timestamp, though, since the value doesn't necessarily represent an absolute time instant. Warren Turkal
* Arrange for an explicit cast applied to an ARRAY[] constructor to be appliedTom Lane2008-03-20
| | | | | | | | | | directly to all the member expressions, instead of the previous implementation where the ARRAY[] constructor would infer a common element type and then we'd coerce the finished array after the fact. This has a number of benefits, one being that we can allow an empty ARRAY[] construct so long as its element type is specified by such a cast. Brendan Jurd, minor fixes by me.
* Add a couple of missing FreeQueryDesc calls. Noticed while testing aAlvaro Herrera2008-03-20
| | | | framework to keep track of snapshots in use.
* Make source code READMEs more consistent. Add CVS tags to all README files.Bruce Momjian2008-03-20
|
* Add the missing cyrillic "Yo" characters ('e' and 'E' with two dots) to theHeikki Linnakangas2008-03-20
| | | | | | | | | | | | | | | ISO_8859-5 <-> MULE_INTERNAL conversion tables. This was discovered when trying to convert a string containing those characters from ISO_8859-5 to Windows-1251, because we use MULE_INTERNAL/KOI8R as an intermediate encoding between those two. While the missing "Yo" was just an omission in the conversion tables, there are a few other characters like the "Numero" sign ("No" as a single character) that exists in all the other cyrillic encodings (win1251, ISO_8859-5 and cp866), but not in KOI8R. Added comments about that. Patch by Sergey Burladyan. Back-patch to 7.4.
* Remove another useless snapshot creation.Alvaro Herrera2008-03-19
|
* Support ALTER TYPE RENAME. Petr JelinekTom Lane2008-03-19
|
* We no longer need a snapshot set after opening the finishing transaction: thisAlvaro Herrera2008-03-19
| | | | | is redundant because autovacuum now always analyzes a single table per transaction.
* Fix regexp substring matching (substring(string from pattern)) for the cornerTom Lane2008-03-19
| | | | | | | | | | | | case where there is a match to the pattern overall but the user has specified a parenthesized subexpression and that subexpression hasn't got a match. An example is substring('foo' from 'foo(bar)?'). This should return NULL, since (bar) isn't matched, but it was mistakenly returning the whole-pattern match instead (ie, 'foo'). Per bug #4044 from Rui Martins. This has been broken since the beginning; patch in all supported versions. The old behavior was sufficiently inconsistent that it's impossible to believe anyone is depending on it.
* Arrange to "inline" SQL functions that appear in a query's FROM clause,Tom Lane2008-03-18
| | | | | | | are declared to return set, and consist of just a single SELECT. We can replace the FROM-item with a sub-SELECT and then optimize much as if we were dealing with a view. Patch from Richard Rowell, cleaned up by me.
* Catch all errors in for and while loops in makefiles. Don't ignore anyPeter Eisentraut2008-03-18
| | | | | | errors in any commands, including in various clean targets that have so far been handled inconsistently. make -i is available to ignore all errors in a consistent and official way.
* Move elog(DEBUG4) call outside the locked area, per suggestion from Tom Lane.Alvaro Herrera2008-03-18
|
* Advance multiple array keys rightmost-first instead of leftmost-firstTom Lane2008-03-18
| | | | | | during a bitmap index scan. This cannot affect the query results (since we're just dumping the TIDs into a bitmap) but it might offer some advantage in locality of access to the index. Per Greg Stark.
* Enable probes to work with Mac OS X Leopard and other OSes that willPeter Eisentraut2008-03-17
| | | | | | | | | | | support DTrace in the future. Switch from using DTRACE_PROBEn macros to the dynamically generated macros. Use "dtrace -h" to create a header file that contains the dynamically generated macros to be used in the source code instead of the DTRACE_PROBEn macros. A dummy header file is generated for builds without DTrace support. Author: Robert Lor <Robert.Lor@sun.com>
* We need to rebuild objfiles.txt when one of the subdirectories' objfiles.txtPeter Eisentraut2008-03-17
| | | | changed in case a new file got added.
* Fix postgres --describe-config for guc enums, breakage noted by Alvaro.Magnus Hagander2008-03-17
| | | | | While at it, rename option lookup functions to make names clearer, per discussion with Tom.
* Revert thinko introduced into prefix_selectivity() by my recent patch:Tom Lane2008-03-17
| | | | | make_greater_string needs the < procedure not the >= one. Spotted by Peter.
* Move ProcState definition into sinvaladt.c from sinvaladt.h, since it's notAlvaro Herrera2008-03-17
| | | | | | needed anywhere after my previous patch. Noticed by Tom Lane. Also, remove #include <signal.h> from sinval.c.
* Grab some low-hanging fruit in the new hash index build code.Tom Lane2008-03-17
| | | | | | | oprofile shows that a nontrivial amount of time is being spent in repeated calls to index_getprocinfo, which really only needs to be called once. So do that, and inline _hash_datum2hashkey to make it work.
* Fix TransactionIdIsCurrentTransactionId() to use binary search instead ofTom Lane2008-03-17
| | | | | | | | | linear search when checking child-transaction XIDs. This makes for an important speedup in transactions that have large numbers of children, as in a recent example from Craig Ringer. We can also get rid of an ugly kluge that represented lists of TransactionIds as lists of OIDs. Heikki Linnakangas
* When creating a large hash index, pre-sort the index entries by estimatedTom Lane2008-03-16
| | | | | | | | | | bucket number, so as to ensure locality of access to the index during the insertion step. Without this, building an index significantly larger than available RAM takes a very long time because of thrashing. On the other hand, sorting is just useless overhead when the index does fit in RAM. We choose to sort when the initial index size exceeds effective_cache_size. This is a revised version of work by Tom Raney and Shreya Bhargava.
* Modify interactions between sinval.c and sinvaladt.c. The code that actuallyAlvaro Herrera2008-03-16
| | | | | | | | deals with the queue, including locking etc, is all in sinvaladt.c. This means that the struct definition of the queue, and the queue pointer, are now internal "implementation details" inside sinvaladt.c. Per my proposal dated 25-Jun-2007 and followup discussion.
* Some cleanups of enum-guc code, per comments from Tom.Magnus Hagander2008-03-16
|
* Change hash index creation so that rather than always establishing exactlyTom Lane2008-03-15
| | | | | | | | | | | two buckets at the start, we create a number of buckets appropriate for the estimated size of the table. This avoids a lot of expensive bucket-split actions during initial index build on an already-populated table. This is one of the two core ideas of Tom Raney and Shreya Bhargava's patch to reduce hash index build time. I'm committing it separately to make it easier for people to test the effects of this separately from the effects of their other core idea (pre-sorting the index entries by bucket number).
* Fix inappropriately-timed memory context switch in autovacuum_do_vac_analyze.Tom Lane2008-03-14
| | | | | | This accidentally failed to fail before 8.3, because the context we were switching back to was long-lived anyway; but it sure looks risky as can be now. Well spotted by Pavan Deolasee.
* Fix vacuum so that autovacuum is really not cancelled when doing an emergencyAlvaro Herrera2008-03-14
| | | | | | job (i.e. to prevent Xid wraparound problems.) Bug reported by ITAGAKI Takahiro in 20080314103837.63D3.52131E4D@oss.ntt.co.jp, though I didn't use his patch.
* Fix varstr_cmp's special case for UTF8 encoding on Windows so that stringsTom Lane2008-03-13
| | | | | | | | | | | | that are reported as "equal" by wcscoll() are checked to see if they really are bitwise equal, and are sorted per strcmp() if not. We made this happen a couple of years ago in the regular code path, but it unaccountably got left out of the Windows/UTF8 case (probably brain fade on my part at the time). As in the prior set of changes, affected users may need to reindex indexes on textual columns. Backpatch as far as 8.2, which is the oldest release we are still supporting on Windows.
* Fix heap_page_prune's problem with failing to send cache invalidationTom Lane2008-03-13
| | | | | | | | | | | messages if the calling transaction aborts later on. Collapsing out line pointer redirects is a done deal as soon as we complete the page update, so syscache *must* be notified even if the VACUUM FULL as a whole doesn't complete. To fix, add some functionality to inval.c to allow the pending inval messages to be sent immediately while heap_page_prune is still running. The implementation is a bit chintzy: it will only work in the context of VACUUM FULL. But that's all we need now, and it can always be extended later if needed. Per my trouble report of a week ago.
* Fix pg_plan_queries() to restore the previous setting of ActiveSnapshotTom Lane2008-03-12
| | | | | | | | | | | (probably NULL) before exiting. Up to now it's just left the variable as it set it, which means that after we're done processing the current client message, ActiveSnapshot is probably pointing at garbage (because this function is typically run in MessageContext which will get reset). There doesn't seem to have been any code path in which that mattered before 8.3, but now the plancache module might try to use the stale value if the next client message is a Bind for a prepared statement that is in need of replanning. Per report from Alex Hunsaker.
* Fix LISTEN/NOTIFY race condition reported by Laurent Birtz, by postponingTom Lane2008-03-12
| | | | | | | | | | | | | | | | | | pg_listener modifications commanded by LISTEN and UNLISTEN until the end of the current transaction. This allows us to hold the ExclusiveLock on pg_listener until after commit, with no greater risk of deadlock than there was before. Aside from fixing the race condition, this gets rid of a truly ugly kludge that was there before, namely having to ignore HeapTupleBeingUpdated failures during NOTIFY. There is a small potential incompatibility, which is that if a transaction issues LISTEN or UNLISTEN and then looks into pg_listener before committing, it won't see any resulting row insertion or deletion, where before it would have. It seems unlikely that anyone would be depending on that, though. This patch also disallows LISTEN and UNLISTEN inside a prepared transaction. That case had some pretty undesirable properties already, such as possibly allowing pg_listener entries to be made for PIDs no longer present, so disallowing it seems like a better idea than trying to maintain the behavior.
* Make TransactionIdIsInProgress check transam.c's single-item XID status cacheTom Lane2008-03-11
| | | | | | | | before it goes groveling through the ProcArray. In situations where the same recently-committed transaction ID is checked repeatedly by tqual.c, this saves a lot of shared-memory searches. And it's cheap enough that it shouldn't hurt noticeably when it doesn't help. Concept and patch by Simon, some minor tweaking and comment-cleanup by Tom.