summaryrefslogtreecommitdiff
path: root/src/backend/utils
AgeCommit message (Collapse)Author
2007-10-24Set read_only = TRUE while evaluating input queries for ts_rewrite()Tom Lane
and ts_stat(), per my recent suggestion. Also add a possibly-not-needed- but-can't-hurt check for NULL SPI_tuptable, before we try to dereference same.
2007-10-24Remove the aggregate form of ts_rewrite(), since it doesn't work as desiredTom Lane
if there are zero rows to aggregate over, and the API seems both conceptually and notationally ugly anyway. We should look for something that improves on the tsquery-and-text-SELECT version (which is also pretty ugly but at least it works...), but it seems that will take query infrastructure that doesn't exist today. (Hm, I wonder if there's anything in or near SQL2003 window functions that would help?) Per discussion.
2007-10-23Fix two-argument form of ts_rewrite() so it actually works for cases whereTom Lane
a later rewrite rule should change a subtree modified by an earlier one. Per my gripe of a few days ago.
2007-10-23Fix several bugs in tsvectorin, including crash due to uninitialized field andTom Lane
miscomputation of required palloc size. The crash could only occur if the input contained lexemes both with and without positions, which is probably not common in practice. The miscomputation would definitely result in wasted space. Also fix some inconsistent coding around alignment of strings and positions in a tsvector value; these errors could also lead to crashes given mixed with/without position data and a machine that's picky about alignment. And be more careful about checking for overflow of string offsets. Patch is only against HEAD --- I have not looked to see if same bugs are in back-branch contrib/tsearch2 code.
2007-10-21Fix shared tsvector/tsquery input code so that we don't say "syntax error inTom Lane
tsvector" when we are really parsing a tsquery. Report the bogus input, too. Make styles of some related error messages more consistent.
2007-10-20Adjust error message to agree with documentation. The tsearch documentationTom Lane
uniformly calls these things weights, not classes.
2007-10-15Fix pg_wchar_table[] to match revised ordering of the encoding ID enum.Tom Lane
Add some comments so hopefully the next poor sod doesn't fall into the same trap. (Wrong comments are worse than none at all...)
2007-10-15Include NOLOGIN roles in the 'flat' password file. In the originalTom Lane
coding this was seen as useless, but the problem with not including them is that the error message will often be something about authentication failure, rather than the more helpful one about 'role is not permitted to log in'. Per discussion.
2007-10-13Migrate the former contrib/txid module into core. This will make it easierTom Lane
for Slony and Skytools to depend on it. Per discussion.
2007-10-13Guard against possible double free during error escape from XMLTom Lane
functions. Patch for the reported issue from Kris Jurka, some other potential trouble spots plugged by Tom.
2007-10-13Fix the inadvertent libpq ABI breakage discovered by Martin Pitt: theTom Lane
renumbering of encoding IDs done between 8.2 and 8.3 turns out to break 8.2 initdb and psql if they are run with an 8.3beta1 libpq.so. For the moment we can rearrange the order of enum pg_enc to keep the same number for everything except PG_JOHAB, which isn't a problem since there are no direct references to it in the 8.2 programs anyway. (This does force initdb unfortunately.) Going forward, we want to fix things so that encoding IDs can be changed without an ABI break, and this commit includes the changes needed to allow libpq's encoding IDs to be treated as fully independent of the backend's. The main issue is that libpq clients should not include pg_wchar.h or otherwise assume they know the specific values of libpq's encoding IDs, since they might encounter version skew between pg_wchar.h and the libpq.so they are using. To fix, have libpq officially export functions needed for encoding name<=>ID conversion and validity checking; it was doing this anyway unofficially. It's still the case that we can't renumber backend encoding IDs until the next bump in libpq's major version number, since doing so will break the 8.2-era client programs. However the code is now prepared to avoid this type of problem in future. Note that initdb is no longer a libpq client: we just pull in the two source files we need directly. The patch also fixes a few places that were being sloppy about checking for an unrecognized encoding name.
2007-10-13Fix ALTER COLUMN TYPE to preserve the tablespace and reloptions of indexesTom Lane
it affects. The original coding neglected tablespace entirely (causing the indexes to move to the database's default tablespace) and for an index belonging to a UNIQUE or PRIMARY KEY constraint, it would actually try to assign the parent table's reloptions to the index :-(. Per bug #3672 and subsequent investigation. 8.0 and 8.1 did not have reloptions, but the tablespace bug is present.
2007-10-11Fix the plan-invalidation mechanism to treat regclass constants that refer toTom Lane
a relation as a reason to invalidate a plan when the relation changes. This handles scenarios such as dropping/recreating a sequence that is referenced by nextval('seq') in a cached plan. Rather than teach plancache.c all about digging through plan trees to find regclass Consts, we charge the planner's setrefs.c with making a list of the relation OIDs on which each plan depends. That way the list can be built cheaply during a plan tree traversal that has to happen anyway. Per bug #3662 and subsequent discussion.
2007-09-27Add virtual transaction IDs to CSVLOG output, so that messages coming fromTom Lane
the same transaction can be identified even when no regular XID was assigned. This seems essential after addition of the lazy-XID patch. Also some minor code cleanup in write_csvlog().
2007-09-26Minor improvements in backup and recovery:Tom Lane
- create a separate archive_mode GUC, on which archive_command is dependent - %r option in recovery.conf sends last restartpoint to recovery command - %r used in pg_standby, updated README - minor other code cleanup in pg_standby - doc on Warm Standby now mentions pg_standby and %r - log_restartpoints recovery option emits LOG message at each restartpoint - end of recovery now displays last transaction end time, as requested by Warren Little; also shown at each restartpoint - restart archiver if needed to carry away WAL files at shutdown Simon Riggs
2007-09-26In the integer-datetimes case, date2timestamp and date2timestamptz needTom Lane
to check for overflow because the legal range of type date is actually wider than timestamp's. Problem found by Neil Conway.
2007-09-25Just-in-time background writing strategy. This code avoids re-scanningTom Lane
buffers that cannot possibly need to be cleaned, and estimates how many buffers it should try to clean based on moving averages of recent allocation requests and density of reusable buffers. The patch also adds a couple more columns to pg_stat_bgwriter to help measure the effectiveness of the bgwriter. Greg Smith, building on his own work and ideas from several other people, in particular a much older patch from Itagaki Takahiro.
2007-09-24Add comments re text <-> bytea internal equivalence in convert routines.Andrew Dunstan
2007-09-24Use correct PG_GETARG macro in pg_convertAndrew Dunstan
2007-09-24Simplify and rename some GUC variables, per various recent discussions:Tom Lane
* stats_start_collector goes away; we always start the collector process, unless prevented by a problem with setting up the stats UDP socket. * stats_reset_on_server_start goes away; it seems useless in view of the availability of pg_stat_reset(). * stats_block_level and stats_row_level are merged into a single variable "track_counts", which controls all reports sent to the collector process. * stats_command_string is renamed to track_activities. * log_autovacuum is renamed to log_autovacuum_min_duration to better reflect its meaning. The log_autovacuum change is not a compatibility issue since it didn't exist before 8.3 anyway. The other changes need to be release-noted.
2007-09-23Fix bugs in XML binary I/O functions. Heikki and TomTom Lane
2007-09-22Fix bogus calculation of potential output string length in translate().Tom Lane
2007-09-22Although I'd misdiagnosed the reason for the recent failures onTom Lane
buildfarm member grebe, I see no reason to revert the 1-byte-header-friendly changes I made in varlena.c. Instead, tweak the code a little bit to get more advantage out of that.
2007-09-22Doh --- what's really happening on buildfarm member grebe is that itsTom Lane
malloc returns NULL for malloc(0). Defend against that case.
2007-09-22Go back to using a separate method for doing ILIKE for single byteAndrew Dunstan
character encodings that doesn't involve calling lower(). This should cure the performance regression in this case complained of by Guillaume Smet. It still leaves the horrid performance for multi-byte encodings introduced in 8.2, but there's no obvious solution for that in sight.
2007-09-22Fix varlena.c routines to allow 1-byte-header text values. This is nowTom Lane
demonstrably necessary for text_substring() since regexp_split functions may pass it such a value; and we might as well convert the whole file at once. Per buildfarm results (though I wonder why most machines aren't showing a failure).
2007-09-21Fix regex, LIKE, and some other second-rank text-manipulation functionsTom Lane
to not cause needless copying of text datums that have 1-byte headers. Greg Stark, in response to performance gripe from Guillaume Smet and ITAGAKI Takahiro.
2007-09-21Change tqual.c tests to use !TransactionIdIsCurrentTransactionId, rather thanTom Lane
TransactionIdDidAbort, when handling the case that xmin is one of the current transaction's XIDs and the tuple has been deleted. xmax must also be one of the current transaction's XIDs, since no one else can see it yet, and it's cheaper to look at local state than shared state to find out if xmax aborted. Per an idea of Heikki's.
2007-09-20Solaris portability fix that was previously made in contrib/tsearch2Tom Lane
but got lost from the version committed to main tree. Per Greg Stark.
2007-09-20Cleanup items from csvlog changes, per ITAGAKI Takahiro.Andrew Dunstan
2007-09-20Fix msvc warnings, patch by Hannes Eder <Hannes@HannesEder.net>Teodor Sigaev
2007-09-20HOT updates. When we update a tuple without changing any of its indexedTom Lane
columns, and the new version can be stored on the same heap page, we no longer generate extra index entries for the new version. Instead, index searches follow the HOT-chain links to ensure they find the correct tuple version. In addition, this patch introduces the ability to "prune" dead tuples on a per-page basis, without having to do a complete VACUUM pass to recover space. VACUUM is still needed to clean up dead index entries, however. Pavan Deolasee, with help from a bunch of other people.
2007-09-19Prevent corr() from returning the wrong results for negative correlationNeil Conway
values. The previous coding essentially assumed that x = sqrt(x*x), which does not hold for x < 0. Thanks to Jie Zhang at Greenplum and Gavin Sherry for reporting this issue.
2007-09-18Close previously open holes for invalidly encoded data to enter theAndrew Dunstan
database via builtin functions, as recently discussed on -hackers. chr() now returns a character in the database encoding. For UTF8 encoded databases the argument is treated as a Unicode code point. For other multi-byte encodings the argument must designate a strict ascii character, or an error is raised, as is also the case if the argument is 0. ascii() is adjusted so that it remains the inverse of chr(). The two argument form of convert() is gone, and the three argument form now takes a bytea first argument and returns a bytea. To cover this loss three new functions are introduced: . convert_from(bytea, name) returns text - converts the first argument from the named encoding to the database encoding . convert_to(text, name) returns bytea - converts the first argument from the database encoding to the named encoding . length(bytea, name) returns int - gives the length of the first argument in characters in the named encoding
2007-09-17Remove extra tab in postgresql.confBruce Momjian
2007-09-16Fix overflow in extract(epoch from interval) for intervals exceeding 68 years.Tom Lane
Seems to have been introduced in 8.1 by careless SECS_PER_DAY search-and-replace.
2007-09-13Fix typo in typecasting.Teodor Sigaev
patch from ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp>
2007-09-11Include hash table name in all the internal-error elog messages inTom Lane
dynahash.c. Sergey Koposov's current open problem shows the possible usefulness of this, and it doesn't add much code.
2007-09-11Remove QueryOperand->istrue flag, it was used only in cover rankingTeodor Sigaev
(ts_rank_cd). Use palloc'ed array in ranking instead of flag.
2007-09-11Refactor from Heikki Linnakangas <heikki@enterprisedb.com>:Teodor Sigaev
* Defined new struct WordEntryPosVector that holds a uint16 length and a variable size array of WordEntries. This replaces the previous convention of a variable size uint16 array, with the first element implying the length. WordEntryPosVector has the same layout in memory, but is more readable in source code. The POSDATAPTR and POSDATALEN macros are still used, though it would now be more readable to access the fields in WordEntryPosVector directly. * Removed needfree field from DocRepresentation. It was always set to false. * Miscellaneous other commenting and refactoring
2007-09-11Rename recently-added pg_stat_activity column from txn_start to xact_start,Tom Lane
for consistency with other column names such as in pg_stat_database.
2007-09-11Arrange for SET LOCAL's effects to persist until the end of the current topTom Lane
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.
2007-09-10Change void* opaque argument to Datum type, add argument'sTeodor Sigaev
name to PushFunction type definition. Per suggestion by Tome Lane <tgl@sss.pgh.pa.us>
2007-09-10Revert temporary patch that made synchronous_commit default to OFF.Tom Lane
2007-09-10Set the correct context (PGC_SIGHUP) for log_autovacuum, per ITAGAKI Takahiro.Tom Lane
Fix grammatical errors in its description.
2007-09-10Code review for GUC revert-values-if-removed-from-postgresql.conf patch;Tom Lane
and in passing, fix some bogosities dating from the custom_variable_classes patch. Fix guc-file.l to correctly check changes in custom_variable_classes that are attempted concurrently with additions/removals of custom variables, and don't allow the new setting to be applied in advance of checking it. Clean up messy and undocumented situation for string variables with NULL boot_val. Fix DefineCustomVariable functions to initialize boot_val correctly. Prevent find_option from inserting bogus placeholders for custom variables that are simply inquired about rather than being set.
2007-09-08Replace the former method of determining snapshot xmax --- to wit, callingTom Lane
ReadNewTransactionId from GetSnapshotData --- with a "latestCompletedXid" variable that is updated during transaction commit or abort. Since latestCompletedXid is written only in places that had to lock ProcArrayLock exclusively anyway, and is read only in places that had to lock ProcArrayLock shared anyway, it adds no new locking requirements to the system despite being cluster-wide. Moreover, removing ReadNewTransactionId from snapshot acquisition eliminates the need to take both XidGenLock and ProcArrayLock at the same time. Since XidGenLock is sometimes held across I/O this can be a significant win. Some preliminary benchmarking suggested that this patch has no effect on average throughput but can significantly improve the worst-case transaction times seen in pgbench. Concept by Florian Pflug, implementation by Tom Lane.
2007-09-07Improvements from Heikki Linnakangas <heikki@enterprisedb.com>Teodor Sigaev
- change the alignment requirement of lexemes in TSVector slightly. Lexeme strings were always padded to 2-byte aligned length to make sure that if there's position array (uint16[]) it has the right alignment. The patch changes that so that the padding is not done when there's no positions. That makes the storage of tsvectors without positions slightly more compact. - added some #include "miscadmin.h" lines I missed in the earlier when I added calls to check_stack_depth(). - Reimplement the send/recv functions, and added a comment above them describing the on-wire format. The CRC is now recalculated in tsquery as well per previous discussion.
2007-09-07Improving various checks by Heikki Linnakangas <heikki@enterprisedb.com>Teodor Sigaev
- add code to check that the query tree is well-formed. It was indeed possible to send malformed queries in binary mode, which produced all kinds of strange results. - make the left-field a uint32. There's no reason to arbitrarily limit it to 16-bits, and it won't increase the disk/memory footprint either now that QueryOperator and QueryOperand are separate structs. - add check_stack_depth() call to all recursive functions I found. Some of them might have a natural limit so that you can't force arbitrarily deep recursions, but check_stack_depth() is cheap enough that seems best to just stick it into anything that might be a problem.
2007-09-07Refactoring by Heikki Linnakangas <heikki@enterprisedb.com> withTeodor Sigaev
small editorization by me - Brake the QueryItem struct into QueryOperator and QueryOperand. Type was really the only common field between them. QueryItem still exists, and is used in the TSQuery struct as before, but it's now a union of the two. Many other changes fell from that, like separation of pushval_asis function into pushValue, pushOperator and pushStop. - Moved some structs that were for internal use only from header files to the right .c-files. - Moved tsvector parser to a new tsvector_parser.c file. Parser code was about half of the size of tsvector.c, it's also used from tsquery.c, and it has some data structures of its own, so it seems better to separate it. Cleaned up the API so that TSVectorParserState is not accessed from outside tsvector_parser.c. - Separated enumerations (#defines, really) used for QueryItem.type field and as return codes from gettoken_query. It was just accidental code sharing. - Removed ParseQueryNode struct used internally by makepol and friends. push*-functions now construct QueryItems directly. - Changed int4 variables to just ints for variables like "i" or "array size", where the storage-size was not significant.