summaryrefslogtreecommitdiff
path: root/src/backend/commands
Commit message (Collapse)AuthorAgeFilesLines
* Include the backend ID in the relpath of temporary relations.Robert Haas2010-08-133-9/+9
| | | | | | | | | | | | | | | | | This allows us to reliably remove all leftover temporary relation files on cluster startup without reference to system catalogs or WAL; therefore, we no longer include temporary relations in XLOG_XACT_COMMIT and XLOG_XACT_ABORT WAL records. Since these changes require including a backend ID in each SharedInvalSmgrMsg, the size of the SharedInvalidationMessage.id field has been reduced from two bytes to one, and the maximum number of connections has been reduced from INT_MAX / 4 to 2^23-1. It would be possible to remove these restrictions by increasing the size of SharedInvalidationMessage by 4 bytes, but right now that doesn't seem like a good trade-off. Review by Jaime Casanova and Tom Lane.
* Standardize get_whatever_oid functions for other object types.Robert Haas2010-08-056-443/+244
| | | | | | | | | | | | | | | - Rename TSParserGetPrsid to get_ts_parser_oid. - Rename TSDictionaryGetDictid to get_ts_dict_oid. - Rename TSTemplateGetTmplid to get_ts_template_oid. - Rename TSConfigGetCfgid to get_ts_config_oid. - Rename FindConversionByName to get_conversion_oid. - Rename GetConstraintName to get_constraint_oid. - Add new functions get_opclass_oid, get_opfamily_oid, get_rewrite_oid, get_rewrite_oid_without_relid, get_trigger_oid, and get_cast_oid. The name of each function matches the corresponding catalog. Thanks to KaiGai Kohei for the review.
* Standardize get_whatever_oid functions for object types withRobert Haas2010-08-0511-204/+130
| | | | | | | | | | | | | unqualified names. - Add a missing_ok parameter to get_tablespace_oid. - Avoid duplicating get_tablespace_od guts in objectNamesToOids. - Add a missing_ok parameter to get_database_oid. - Replace get_roleid and get_role_checked with get_role_oid. - Add get_namespace_oid, get_language_oid, get_am_oid. - Refactor existing code to use new interfaces. Thanks to KaiGai Kohei for the review.
* Fix inheritance count tracking in ALTER TABLE .. ADD CONSTRAINT.Robert Haas2010-08-031-1/+10
| | | | | | | | | | | | | | Without this patch, constraints inherited by children of a parent table which itself has multiple inheritance parents can end up with the wrong coninhcount. After dropping the constraint, the children end up with a leftover copy of the constraint that is not dumped and cannot be dropped. There is a similar problem with ALTER TABLE .. ADD COLUMN, but that looks significantly more difficult to resolve, so I'm committing this fix separately. Back-patch to 8.4, which is the first release that has coninhcount. Report by Hank Enting.
* Fix ANALYZE's ancient deficiency of not trying to collect stats for expressionTom Lane2010-08-011-38/+50
| | | | | | | | | | | | | | | indexes when the index column type (the opclass opckeytype) is different from the expression's datatype. When coded, this limitation wasn't worth worrying about because we had no intelligence to speak of in stats collection for the datatypes used by such opclasses. However, now that there's non-toy estimation capability for tsvector queries, it amounts to a bug that ANALYZE fails to do this. The fix changes struct VacAttrStats, and therefore constitutes an API break for custom typanalyze functions. Therefore we can't back-patch it into released branches, but it was agreed that 9.0 isn't yet frozen hard enough to make such a change unacceptable. Ergo, back-patch to 9.0 but no further. The API break had better be mentioned in 9.0 release notes.
* Fix another longstanding problem in copy_relation_data: it was blithelyTom Lane2010-07-291-3/+14
| | | | | | | | | | | assuming that a local char[] array would be aligned on at least a word boundary. There are architectures on which that is pretty much guaranteed to NOT be the case ... and those arches also don't like non-aligned memory accesses, meaning that log_newpage() would crash if it ever got invoked. Even on Intel-ish machines there's a potential for a large performance penalty from doing I/O to an inadequately aligned buffer. So palloc it instead. Backpatch to 8.0 --- 7.4 doesn't have this code.
* Add explicit regression tests for ALTER TABLE lock levels.Simon Riggs2010-07-292-9/+11
| | | | | Use this to catch a couple of lock level assignments that slipped through manual testing, per Peter Eisentraut.
* Reduce lock levels of CREATE TRIGGER and some ALTER TABLE, CREATE RULE actions.Simon Riggs2010-07-284-205/+382
| | | | | | | | | Avoid hard-coding lockmode used for many altering DDL commands, allowing easier future changes of lock levels. Implementation of initial analysis on DDL sub-commands, so that many lock levels are now at ShareUpdateExclusiveLock or ShareRowExclusiveLock, allowing certain DDL not to block reads/writes. First of number of planned changes in this area; additional docs required when full project complete.
* CREATE TABLE IF NOT EXISTS.Robert Haas2010-07-255-9/+32
| | | | Reviewed by Bernd Helmle.
* Add more checks against altering typed tablesPeter Eisentraut2010-07-231-17/+44
| | | | | | | | - Prohibit altering column type - Prohibit changing inheritance - Move checks from Exec to Prep phases in ALTER TABLE code backpatched to 9.0
* Centralize DML permissions-checking logic.Robert Haas2010-07-221-22/+19
| | | | | | | | | | | | Remove bespoke code in DoCopy and RI_Initial_Check, which now instead fabricate call ExecCheckRTPerms with a manufactured RangeTblEntry. This is intended to make it feasible for an enhanced security provider to actually make use of ExecutorCheckPerms_hook, but also has the advantage that RI_Initial_Check can allow use of the fast-path when column-level but not table-level permissions are present. KaiGai Kohei. Reviewed (in an earlier version) by Stephen Frost, and by me. Some further changes to the comments by me.
* Properly replay CREATE TABLESPACE during crash recovery by deletingBruce Momjian2010-07-202-2/+32
| | | | | | | | directory/symlink before creation. Report from Tom Lane. Backpatch to 9.0.
* Simplify missing tablespace replay error hint message, but only in HEADBruce Momjian2010-07-181-3/+3
| | | | so we don't need to re-translate for 9.0.
* Remove duplicate code in DefineOpFamily().Tom Lane2010-07-161-65/+4
| | | | | | | The code was probably meant to be this way all along, since the subroutine CreateOpFamily previously had only one caller. But it wasn't. KaiGai Kohei
* Teach EXPLAIN to print PARAM_EXEC Params as the referenced expressions,Tom Lane2010-07-131-132/+116
| | | | | | | | | | | | | | | | 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-066-30/+35
|
* Allow REASSIGNED OWNED to handle opclasses and opfamilies.Robert Haas2010-07-031-1/+43
| | | | | | | | Backpatch to 8.3, which is as far back as we have opfamilies. The opclass portion could probably be backpatched to 8.2, when REASSIGN OWNED was added, but for now I have not done that. Asko Tiidumaa, with minor adjustments by me.
* Issue 'mkdir' hint when replying CREATE TABLESPACE in recovery mode.Bruce Momjian2010-07-021-3/+4
| | | | Per idea from Fujii Masao
* Allow ALTER TABLE .. SET TABLESPACE to be interrupted.Robert Haas2010-07-011-1/+4
| | | | | | Backpatch to 8.0, where tablespaces were introduced. Guillaume Lelarge
* Deprecate the use of => as an operator name.Robert Haas2010-06-221-1/+11
| | | | | | | | | | In HEAD, emit a warning when an operator named => is defined. In both HEAD and the backbranches (except in 8.2, where contrib modules do not have documentation), document that hstore's text => text operator may be removed in a future release, and encourage the use of the hstore(text, text) function instead. This function only exists in HEAD (previously, it was called tconvert), so backpatch it back to 8.2, when hstore was added. Per discussion.
* Fix ALTER LARGE OBJECT and GRANT ... ON LARGE OBJECT for large OIDs.Robert Haas2010-06-132-27/+5
| | | | | The previous coding failed for OIDs too large to be represented by a signed integer.
* Quote all string values in EXPLAIN (FORMAT YAML) output.Robert Haas2010-06-101-46/+16
| | | | | | | | | | | While my previous attempt seems to always produce valid YAML, it doesn't always produce YAML that means what it appears to mean, because of tokens like "0xa" and "true", which without quotes will be interpreted as integer or Boolean literals. So, instead, just quote everything that's not known to be a number, as we do for JSON. Dean Rasheed, with some changes to the comments by me.
* Attempt to fix EXPLAIN (FORMAT YAML) quoting to behave sanely.Robert Haas2010-06-091-9/+35
| | | | | | | | | The previous code failed to quote in many cases where quoting was necessary - YAML has loads of special characters, including -:[]{},"'|*& - so quote much more aggressively, and only refrain from quoting things where it seems fairly clear that it isn't necessary. Per report from Dean Rasheed.
* Show schema name for REINDEX.Bruce Momjian2010-06-011-2/+3
| | | | Greg Sabino Mullane
* Make CREATE INDEX run expression preprocessing on a proposed index expressionTom Lane2010-05-271-3/+31
| | | | | | | | | | | | | | | | | | | | | before it checks whether the expression is immutable. This covers two cases that were previously handled poorly: 1. SQL function inlining could reduce the apparent volatility of the expression, allowing an expression to be accepted where it previously would not have been. As an example, polymorphic functions must be marked with the worst-case volatility they have for any argument type, but for specific argument types they might not be so volatile, so indexing could be allowed. (Since the planner will refuse to inline functions in cases where the apparent volatility of the expression would increase, this won't break any cases that were accepted before.) 2. A nominally immutable function could have default arguments that are volatile expressions. In such a case insertion of the defaults will increase both the apparent and actual volatility of the expression, so it is *necessary* to check this before allowing the expression to be indexed. Back-patch to 8.4, where default arguments were introduced.
* Modify ShmemInitStruct and ShmemInitHash to throw errors internally,Tom Lane2010-04-281-4/+1
| | | | | | | | | rather than returning NULL for some-but-not-all failures as they used to. Remove now-redundant tests for NULL from call sites. We had to do something about this because many call sites were failing to check for NULL; and changing it like this seems a lot more useful and mistake-proof than adding checks to the call sites without them.
* Introduce wal_level GUC to explicitly control if information needed forHeikki Linnakangas2010-04-283-52/+3
| | | | | | | | | | | | | | | | | | | | | | archival or hot standby should be WAL-logged, instead of deducing that from other options like archive_mode. This replaces recovery_connections GUC in the primary, where it now has no effect, but it's still used in the standby to enable/disable hot standby. Remove the WAL-logging of "unlogged operations", like creating an index without WAL-logging and fsyncing it at the end. Instead, we keep a copy of the wal_mode setting and the settings that affect how much shared memory a hot standby server needs to track master transactions (max_connections, max_prepared_xacts, max_locks_per_xact) in pg_control. Whenever the settings change, at server restart, write a WAL record noting the new settings and update pg_control. This allows us to notice the change in those settings in the standby at the right moment, they used to be included in checkpoint records, but that meant that a changed value was not reflected in the standby until the first checkpoint after the change. Bump PG_CONTROL_VERSION and XLOG_PAGE_MAGIC. Whack XLOG_PAGE_MAGIC back to the sequence it used to follow, before hot standby and subsequent patches changed it to 0x9003.
* Further reductions in Hot Standby conflict processing. TheseSimon Riggs2010-04-221-7/+5
| | | | | | | | | come from the realistion that HEAP2_CLEAN records don't always remove user visible data, so conflict processing for them can be skipped. Confirm validity using Assert checks, clarify circumstances under which we log heap_cleanup_info records. Tuning arises from bug fixing of earlier safety check failures.
* Only send cleanup_info messages if VACUUM removes any tuples.Simon Riggs2010-04-211-3/+6
| | | | | | | There is no other purpose for this message type than to report the latestRemovedXid of removed tuples, prior to index scans. Removes overlooked path for sending invalid latestRemovedXid. Fixes buildfarm failure on centaur.
* Fix oversight in collecting values for cleanup_info records.Simon Riggs2010-04-211-7/+14
| | | | | | | vacuum_log_cleanup_info() now generates log records with a valid latestRemovedXid set in all cases. Also be careful not to zero the value when we do a round of vacuuming part-way through lazy_scan_heap(). Incidentally, this reduces frequency of conflicts in Hot Standby.
* Improve phrasing of warning message for NOTIFY queue getting too full.Tom Lane2010-04-051-4/+4
| | | | Per gripe from Peter.
* Shorten suffix of automatically created indexes to "_excl" when usingSimon Riggs2010-03-221-2/+2
| | | | exclusion constraints, in line with string length of other pre-9.0 suffixes.
* Forbid renaming columns of objects whose column names are system-generated.Robert Haas2010-03-201-1/+19
| | | | KaiGai Kohei, with adjustments to the comments.
* Fix incorrect comment about permissions checking being done in utility.c.Robert Haas2010-03-101-5/+2
| | | | Noted while reviewing a patch from KaiGai Kohei.
* pgindent run for 9.0Bruce Momjian2010-02-2622-618/+636
|
* Add an OR REPLACE option to CREATE LANGUAGE.Tom Lane2010-02-231-24/+59
| | | | | | | | | | | | | | | This operates in the same way as other CREATE OR REPLACE commands, ie, it replaces everything but the ownership and ACL lists of an existing entry, and requires the caller to have owner privileges for that entry. While modifying an existing language has some use in development scenarios, in typical usage all the "replaced" values come from pg_pltemplate so there will be no actual change in the language definition. The reason for adding this is mainly to allow programs to ensure that a language exists without triggering an error if it already does exist. This commit just adds and documents the new option. A followon patch will use it to clean up some unpleasant cases in pg_dump and pg_regress.
* Clean up handling of XactReadOnly and RecoveryInProgress checks.Tom Lane2010-02-204-14/+17
| | | | | | | | | | | | | | | | | | Add some checks that seem logically necessary, in particular let's make real sure that HS slave sessions cannot create temp tables. (If they did they would think that temp tables belonging to the master's session with the same BackendId were theirs. We *must* not allow myTempNamespace to become set in a slave session.) Change setval() and nextval() so that they are only allowed on temp sequences in a read-only transaction. This seems consistent with what we allow for table modifications in read-only transactions. Since an HS slave can't have a temp sequence, this also provides a nicer cure for the setval PANIC reported by Erik Rijkers. Make the error messages more uniform, and have them mention the specific command being complained of. This seems worth the trifling amount of extra code, since people are likely to see such messages a lot more than before.
* Forbid setval() during recovery. This prevents the PANIC reported byHeikki Linnakangas2010-02-191-1/+4
| | | | Erik Rijkers. Patch by Andres Freund.
* Take care to reprocess an uncommitted notify message.Tom Lane2010-02-171-4/+13
| | | | | Oversight in my changes to cope with possible errors during message processing; spotted by Joachim Wieland.
* Stamp HEAD as 9.0devel, and update various places that were referring to 8.5Tom Lane2010-02-172-4/+4
| | | | (hope I got 'em all). Per discussion, this release will be 9.0 not 8.5.
* Make NOTIFY_PAYLOAD_MAX_LENGTH depend explicitly on BLCKSZ andTom Lane2010-02-171-3/+6
| | | | | | NAMEDATALEN, so this code doesn't go nuts with smaller than default BLCKSZ or larger than default NAMEDATALEN. The standard value is still exactly 8000.
* Replace the pg_listener-based LISTEN/NOTIFY mechanism with an in-memory queue.Tom Lane2010-02-161-432/+1507
| | | | | | | | | | | | In addition, add support for a "payload" string to be passed along with each notify event. This implementation should be significantly more efficient than the old one, and is also more compatible with Hot Standby usage. There is not yet any facility for HS slaves to receive notifications generated on the master, although such a thing is possible in future. Joachim Wieland, reviewed by Jeff Davis; also hacked on by me.
* Add query text to auto_explain output.Andrew Dunstan2010-02-161-1/+16
| | | | Still to be done: fix docs and fix regression failures under auto_explain.
* revert to showing buffer counts in explain (buffers)Greg Stark2010-02-161-74/+25
|
* Fix typo in commentAlvaro Herrera2010-02-151-2/+2
|
* Display explain buffers measurements in memory units rather than blocks. ↵Greg Stark2010-02-151-24/+74
| | | | Also show "Total Buffer Usage" to hint that these are totals not averages per loop
* Wrap calls to SearchSysCache and related functions using macros.Robert Haas2010-02-1421-649/+336
| | | | | | | | | | | | The purpose of this change is to eliminate the need for every caller of SearchSysCache, SearchSysCacheCopy, SearchSysCacheExists, GetSysCacheOid, and SearchSysCacheList to know the maximum number of allowable keys for a syscache entry (currently 4). This will make it far easier to increase the maximum number of keys in a future release should we choose to do so, and it makes the code shorter, too. Design and review by Tom Lane.
* Fix up rickety handling of relation-truncation interlocks.Tom Lane2010-02-094-64/+28
| | | | | | | | | | | | | | | | | | | | Move rd_targblock, rd_fsm_nblocks, and rd_vm_nblocks from relcache to the smgr relation entries, so that they will get reset to InvalidBlockNumber whenever an smgr-level flush happens. Because we now send smgr invalidation messages immediately (not at end of transaction) when a relation truncation occurs, this ensures that other backends will reset their values before they next access the relation. We no longer need the unreliable assumption that a VACUUM that's doing a truncation will hold its AccessExclusive lock until commit --- in fact, we can intentionally release that lock as soon as we've completed the truncation. This patch therefore reverts (most of) Alvaro's patch of 2009-11-10, as well as my marginal hacking on it yesterday. We can also get rid of assorted no-longer-needed relcache flushes, which are far more expensive than an smgr flush because they kill a lot more state. In passing this patch fixes smgr_redo's failure to perform visibility-map truncation, and cleans up some rather dubious assumptions in freespace.c and visibilitymap.c about when rd_fsm_nblocks and rd_vm_nblocks can be out of date.
* Rearrange lazy-vacuum code a little bit to reduce the window betweenTom Lane2010-02-091-27/+37
| | | | | | | truncating the table and transaction commit. This isn't really making it safe, but at least there is no good reason to do free space map cleanup within the risk window. Don't lock out cancel interrupts until we have to, either.
* Fix serious performance bug in new implementation of VACUUM FULL:Tom Lane2010-02-081-3/+4
| | | | | cluster_rel necessarily builds an all-new toast table, so it's useless to then go and VACUUM FULL the toast table.