- Feb 15, 2011
-
-
Robert Haas authored
-
- Feb 12, 2011
-
-
Peter Eisentraut authored
- collowner field - CREATE COLLATION - ALTER COLLATION - DROP COLLATION - COMMENT ON COLLATION - integration with extensions - pg_dump support for the above - dependency management - psql tab completion - psql \dO command
-
Robert Haas authored
When the old type is binary coercible to the new type and the using clause does not change the column contents, we can avoid a full table rewrite, though any indexes on the affected columns will still need to be rebuilt. This applies, for example, when changing a varchar column to be of type text. The prior coding assumed that the set of operations that force a rewrite is identical to the set of operations that must be propagated to tables making use of the affected table's rowtype. This is no longer true: even though the tuples in those tables wouldn't need to be modified, the data type change invalidate indexes built using those composite type columns. Indexes on the table we're actually modifying can be invalidated too, of course, but the existing machinery is sufficient to handle that case. Along the way, add some debugging messages that make it possible to understand what operations ALTER TABLE is actually performing in these cases. Noah Misch and Robert Haas
-
- Feb 11, 2011
-
-
Robert Haas authored
Per discussion with Noah Misch, the previous coding, introduced by my commit 65377e0b on 2011-02-06, was really an abuse of RELKIND_COMPOSITE_TYPE, since the caller in typecmds.c is actually passing the name of a domain. So go back having a type name argument, but make the first argument a Relation rather than just a string so we can tell whether it's a table or a foreign table and emit the proper error message.
-
- Feb 09, 2011
-
-
Tom Lane authored
Older versions of gcc tend to throw "variable might be clobbered by `longjmp' or `vfork'" warnings whenever a variable is assigned in more than one place and then used after the end of a PG_TRY block. That's reasonably easy to work around in execute_extension_script, and the overhead of unconditionally saving/restoring the GUC variables seems unlikely to be a serious concern. Also clean up logic in ATExecValidateConstraint to make it easier to read and less likely to provoke "variable might be used uninitialized in this function" warnings.
-
- Feb 08, 2011
-
-
Tom Lane authored
This patch adds the server infrastructure to support extensions. There is still one significant loose end, namely how to make it play nice with pg_upgrade, so I am not yet committing the changes that would make all the contrib modules depend on this feature. In passing, fix a disturbingly large amount of breakage in AlterObjectNamespace() and callers. Dimitri Fontaine, reviewed by Anssi Kääriäinen, Itagaki Takahiro, Tom Lane, and numerous others
-
Peter Eisentraut authored
This adds collation support for columns and domains, a COLLATE clause to override it per expression, and B-tree index support. Peter Eisentraut reviewed by Pavel Stehule, Itagaki Takahiro, Robert Haas, Noah Misch
-
Simon Riggs authored
FK constraints that are marked NOT VALID may later be VALIDATED, which uses an ShareUpdateExclusiveLock on constraint table and RowShareLock on referenced table. Significantly reduces lock strength and duration when adding FKs. New state visible from psql. Simon Riggs, with reviews from Marko Tiikkaja and Robert Haas
-
- Feb 07, 2011
-
-
Itagaki Takahiro authored
We forgot to adjust it when we changed relistemp to relpersistence.
-
- Feb 06, 2011
-
-
Robert Haas authored
If the foreign table's rowtype is being used as the type of a column in another table, we can't just up and change its data type. This was already checked for composite types and ordinary tables, but we previously failed to enforce it for foreign tables.
-
- Feb 04, 2011
-
-
Robert Haas authored
Make sure it's clear that the prohibition on adding a column with a default when the rowtype is used elsewhere is intentional, and be a bit more explicit about the other cases where we perform this check.
-
- Jan 27, 2011
-
-
Robert Haas authored
This reverts commit a06e41de of 2011-01-26. Per discussion, this behavior is not wanted, as it would need to change if we ever made composite types support DEFAULT.
-
- Jan 26, 2011
-
-
Robert Haas authored
Noah Misch, slightly revised.
-
Robert Haas authored
The previous coding prevented ALTER TABLE .. ADD COLUMN from being used with a non-NULL default in situations where the table's rowtype was being used elsewhere. But this is a completely arbitrary restriction since you could do the same operation in multiple steps (add the column, add the default, update the table). Inspired by a patch from Noah Misch, though I didn't use his code.
-
- Jan 25, 2011
-
-
Tom Lane authored
This feature allows a unique or pkey constraint to be created using an already-existing unique index. While the constraint isn't very functionally different from the bare index, it's nice to be able to do that for documentation purposes. The main advantage over just issuing a plain ALTER TABLE ADD UNIQUE/PRIMARY KEY is that the index can be created with CREATE INDEX CONCURRENTLY, so that there is not a long interval where the table is locked against updates. On the way, refactor some of the code in DefineIndex() and index_create() so that we don't have to pass through those functions in order to create the index constraint's catalog entries. Also, in parse_utilcmd.c, pass around the ParseState pointer in struct CreateStmtContext to save on notation, and add error location pointers to some error reports that didn't have one before. Gurjeet Singh, reviewed by Steve Singer and Tom Lane
-
- Jan 21, 2011
-
-
Robert Haas authored
Failure to do so can lead to constraint violations. This was broken by commit 1ddc2703 on 2010-02-07, so back-patch to 9.0. Noah Misch. Regression test by me.
-
- Jan 02, 2011
-
-
Robert Haas authored
Foreign tables are a core component of SQL/MED. This commit does not provide a working SQL/MED infrastructure, because foreign tables cannot yet be queried. Support for foreign table scans will need to be added in a future patch. However, this patch creates the necessary system catalog structure, syntax support, and support for ancillary operations such as COMMENT and SECURITY LABEL. Shigeru Hanada, heavily revised by Robert Haas
-
- Jan 01, 2011
-
-
Bruce Momjian authored
-
- Dec 29, 2010
-
-
Robert Haas authored
The contents of an unlogged table are WAL-logged; thus, they are not available on standby servers and are truncated whenever the database system enters recovery. Indexes on unlogged tables are also unlogged. Unlogged GiST indexes are not currently supported.
-
- Dec 13, 2010
-
-
Robert Haas authored
This commit replaces pg_class.relistemp with pg_class.relpersistence; and also modifies the RangeVar node type to carry relpersistence rather than istemp. It also removes removes rd_istemp from RelationData and instead performs the correct computation based on relpersistence. For clarity, we add three new macros: RelationNeedsWAL(), RelationUsesLocalBuffers(), and RelationUsesTempNamespace(), so that we can clarify the purpose of each check that previous depended on rd_istemp. This is intended as infrastructure for the upcoming unlogged tables patch, as well as for future possible work on global temporary tables.
-
- Nov 25, 2010
-
-
Robert Haas authored
After a SQL object is created, we provide an opportunity for security or logging plugins to get control; for example, a security label provider could use this to assign an initial security label to newly created objects. The basic infrastructure is (hopefully) reusable for other types of events that might require similar treatment. KaiGai Kohei, with minor adjustments.
-
- Nov 23, 2010
-
-
Peter Eisentraut authored
This adds RESTRICT/CASCADE flags to ALTER TYPE ... ADD/DROP/ALTER/ RENAME ATTRIBUTE to control whether to alter typed tables as well.
-
Robert Haas authored
Any flavor of ALTER <whatever> .. SET SCHEMA fails if (1) the object is already in the new schema, (2) either the old or new schema is a temp schema, or (3) either the old or new schema is the TOAST schema. Extraced from a patch by Dimitri Fontaine, with additional hacking by me.
-
- Nov 17, 2010
-
-
Tom Lane authored
In the previous coding, we simply issued ALTER SEQUENCE RESTART commands, which do not roll back on error. This meant that an error between truncating and committing left the sequences out of sync with the table contents, with potentially bad consequences as were noted in a Warning on the TRUNCATE man page. To fix, create a new storage file (relfilenode) for a sequence that is to be reset due to RESTART IDENTITY. If the transaction aborts, we'll automatically revert to the old storage file. This acts just like a rewriting ALTER TABLE operation. A penalty is that we have to take exclusive lock on the sequence, but since we've already got exclusive lock on its owning table, that seems unlikely to be much of a problem. The interaction of this with usual nontransactional behaviors of sequence operations is a bit weird, but it's hard to see what would be completely consistent. Our choice is to discard cached-but-unissued sequence values both when the RESTART is executed, and at rollback if any; but to not touch the currval() state either time. In passing, move the sequence reset operations to happen before not after any AFTER TRUNCATE triggers are fired. The previous ordering was not logically sensible, but was forced by the need to minimize inconsistency if the triggers caused an error. Transactional rollback is a much better solution to that. Patch by Steve Singer, rather heavily adjusted by me.
-
- Oct 25, 2010
-
-
Peter Eisentraut authored
Split the old typenameTypeId() into two functions: A new typenameTypeId() that returns only a type OID, and typenameTypeIdAndMod() that returns type OID and typmod. This isolates call sites better that actually care about the typmod.
-
- Oct 10, 2010
-
-
Tom Lane authored
This patch adds the SQL-standard concept of an INSTEAD OF trigger, which is fired instead of performing a physical insert/update/delete. The trigger function is passed the entire old and/or new rows of the view, and must figure out what to do to the underlying tables to implement the update. So this feature can be used to implement updatable views using trigger programming style rather than rule hacking. In passing, this patch corrects the names of some columns in the information_schema.triggers view. It seems the SQL committee renamed them somewhere between SQL:99 and SQL:2003. Dean Rasheed, reviewed by Bernd Helmle; some additional hacking by me.
-
- Oct 03, 2010
-
-
Tom Lane authored
Actually making this case work, if the column is used in the trigger's WHEN condition, will take some new code that probably isn't appropriate to back-patch. For now, just throw a FEATURE_NOT_SUPPORTED error rather than allowing control to reach the "unexpected object" case. Per bug #5688 from Daniel Grace. Back-patch to 9.0 where the possibility of such a dependency was introduced.
-
- Sep 26, 2010
-
-
Peter Eisentraut authored
Like with tables, this also requires allowing the existence of composite types with zero attributes. reviewed by KaiGai Kohei
-
- Sep 20, 2010
-
-
Magnus Hagander authored
-
- Aug 18, 2010
-
-
Tom Lane authored
The implicitly created sequence was created as owned by the current user, who could be different from the table owner, eg if current user is a superuser or some member of the table's owning role. This caused sanity checks in the SEQUENCE OWNED BY code to spit up. Although possibly we don't need those sanity checks, the safest fix seems to be to make sure the implicit sequence is assigned the same owner role as the table has. (We still do all permissions checks as the current user, however.) Per report from Josh Berkus. Back-patch to 9.0. The bug goes back to the invention of SEQUENCE OWNED BY in 8.2, but the fix requires an API change for DefineRelation(), which seems to have potential for breaking third-party code if done in a minor release. Given the lack of prior complaints, it's probably not worth fixing in the stable branches.
-
- Aug 13, 2010
-
-
Robert Haas authored
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.
-
- Aug 05, 2010
-
-
Robert Haas authored
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.
-
- Aug 03, 2010
-
-
Robert Haas authored
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.
-
- Jul 29, 2010
-
-
Tom Lane authored
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.
-
Simon Riggs authored
Use this to catch a couple of lock level assignments that slipped through manual testing, per Peter Eisentraut.
-
- Jul 28, 2010
-
-
Simon Riggs authored
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.
-
- Jul 26, 2010
-
-
Robert Haas authored
Reviewed by Bernd Helmle.
-
- Jul 23, 2010
-
-
Peter Eisentraut authored
- Prohibit altering column type - Prohibit changing inheritance - Move checks from Exec to Prep phases in ALTER TABLE code backpatched to 9.0
-
- Jul 06, 2010
-
-
Bruce Momjian authored
-
- Jul 01, 2010
-
-
Robert Haas authored
Backpatch to 8.0, where tablespaces were introduced. Guillaume Lelarge
-