Skip to content
Snippets Groups Projects
  1. Feb 15, 2011
  2. Feb 12, 2011
    • Peter Eisentraut's avatar
      DDL support for collations · b313bca0
      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
      b313bca0
    • Robert Haas's avatar
      Teach ALTER TABLE .. SET DATA TYPE to avoid some table rewrites. · d31e2a49
      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
      d31e2a49
  3. Feb 11, 2011
    • Robert Haas's avatar
      Tweak find_composite_type_dependencies API a bit more. · 2c20ba1f
      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.
      2c20ba1f
  4. Feb 09, 2011
    • Tom Lane's avatar
      Suppress some compiler warnings in recent commits. · 375e5b0a
      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.
      375e5b0a
  5. Feb 08, 2011
    • Tom Lane's avatar
      Core support for "extensions", which are packages of SQL objects. · d9572c4e
      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
      d9572c4e
    • Peter Eisentraut's avatar
      Per-column collation support · 414c5a2e
      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
      414c5a2e
    • Simon Riggs's avatar
      Extend ALTER TABLE to allow Foreign Keys to be added without initial validation. · 722bf701
      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
      722bf701
  6. Feb 07, 2011
  7. Feb 06, 2011
    • Robert Haas's avatar
      Tighten ALTER FOREIGN TABLE .. SET DATA TYPE checks. · 65377e0b
      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.
      65377e0b
  8. Feb 04, 2011
    • Robert Haas's avatar
      Clarify comment in ATRewriteTable(). · 9e7e1172
      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.
      9e7e1172
  9. Jan 27, 2011
  10. Jan 26, 2011
  11. Jan 25, 2011
    • Tom Lane's avatar
      Implement ALTER TABLE ADD UNIQUE/PRIMARY KEY USING INDEX. · 88452d5b
      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
      88452d5b
  12. Jan 21, 2011
  13. Jan 02, 2011
    • Robert Haas's avatar
      Basic foreign table support. · 0d692a0d
      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
      0d692a0d
  14. Jan 01, 2011
  15. Dec 29, 2010
    • Robert Haas's avatar
      Support unlogged tables. · 53dbc27c
      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.
      53dbc27c
  16. Dec 13, 2010
    • Robert Haas's avatar
      Generalize concept of temporary relations to "relation persistence". · 5f7b58fa
      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.
      5f7b58fa
  17. Nov 25, 2010
    • Robert Haas's avatar
      Object access hook framework, with post-creation hook. · cc1ed40d
      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.
      cc1ed40d
  18. Nov 23, 2010
  19. Nov 17, 2010
    • Tom Lane's avatar
      Make TRUNCATE ... RESTART IDENTITY restart sequences transactionally. · 511e902b
      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.
      511e902b
  20. Oct 25, 2010
    • Peter Eisentraut's avatar
      Refactor typenameTypeId() · 35670340
      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.
      35670340
  21. Oct 10, 2010
    • Tom Lane's avatar
      Support triggers on views. · 2ec993a7
      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.
      2ec993a7
  22. Oct 03, 2010
    • Tom Lane's avatar
      Throw an appropriate error if ALTER COLUMN TYPE finds a dependent trigger. · 1f0b62e8
      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.
      1f0b62e8
  23. Sep 26, 2010
  24. Sep 20, 2010
  25. Aug 18, 2010
    • Tom Lane's avatar
      Fix failure of "ALTER TABLE t ADD COLUMN c serial" when done by non-owner. · b5565bca
      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.
      b5565bca
  26. Aug 13, 2010
    • Robert Haas's avatar
      Include the backend ID in the relpath of temporary relations. · debcec7d
      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.
      debcec7d
  27. Aug 05, 2010
    • Robert Haas's avatar
      Standardize get_whatever_oid functions for object types with · 2a6ef344
      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.
      2a6ef344
  28. Aug 03, 2010
    • Robert Haas's avatar
      Fix inheritance count tracking in ALTER TABLE .. ADD CONSTRAINT. · 31b6fc06
      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.
      31b6fc06
  29. Jul 29, 2010
    • Tom Lane's avatar
      Fix another longstanding problem in copy_relation_data: it was blithely · 984d56b8
      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.
      984d56b8
    • Simon Riggs's avatar
      Add explicit regression tests for ALTER TABLE lock levels. · 04e17bae
      Simon Riggs authored
      Use this to catch a couple of lock level assignments that slipped
      through manual testing, per Peter Eisentraut.
      04e17bae
  30. Jul 28, 2010
    • Simon Riggs's avatar
      Reduce lock levels of CREATE TRIGGER and some ALTER TABLE, CREATE RULE actions. · 2dbbda02
      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.
      2dbbda02
  31. Jul 26, 2010
  32. Jul 23, 2010
  33. Jul 06, 2010
  34. Jul 01, 2010
Loading