1. 21 Apr, 2011 2 commits
    • Robert Haas's avatar
      Allow ALTER TABLE name {OF type | NOT OF}. · 68739ba8
      Robert Haas authored
      This syntax allows a standalone table to be made into a typed table,
      or a typed table to be made standalone.  This is possibly a mildly
      useful feature in its own right, but the real motivation for this
      change is that we need it to make pg_upgrade work with typed tables.
      This doesn't actually fix that problem, but it's necessary
      infrastructure.
      
      Noah Misch
      68739ba8
    • Tom Lane's avatar
      Fix bugs in indexing of in-doubt HOT-updated tuples. · 520bcd9c
      Tom Lane authored
      If we find a DELETE_IN_PROGRESS HOT-updated tuple, it is impossible to know
      whether to index it or not except by waiting to see if the deleting
      transaction commits.  If it doesn't, the tuple might again be LIVE, meaning
      we have to index it.  So wait and recheck in that case.
      
      Also, we must not rely on ii_BrokenHotChain to decide that it's possible to
      omit tuples from the index.  That could result in omitting tuples that we
      need, particularly in view of yesterday's fixes to not necessarily set
      indcheckxmin (but it's broken even without that, as per my analysis today).
      Since this is just an extremely marginal performance optimization, dropping
      the test shouldn't hurt.
      
      These cases are only expected to happen in system catalogs (they're
      possible there due to early release of RowExclusiveLock in most
      catalog-update code paths).  Since reindexing of a system catalog isn't a
      particularly performance-critical operation anyway, there's no real need to
      be concerned about possible performance degradation from these changes.
      
      The worst aspects of this bug were introduced in 9.0 --- 8.x will always
      wait out a DELETE_IN_PROGRESS tuple.  But I think dropping index entries
      on the strength of ii_BrokenHotChain is dangerous even without that, so
      back-patch removal of that optimization to 8.3 and 8.4.
      520bcd9c
  2. 20 Apr, 2011 6 commits
    • Tom Lane's avatar
      Set indcheckxmin true when REINDEX fixes an invalid or not-ready index. · 9ad7e155
      Tom Lane authored
      Per comment from Greg Stark, it's less clear that HOT chains don't conflict
      with the index than it would be for a valid index.  So, let's preserve the
      former behavior that indcheckxmin does get set when there are
      potentially-broken HOT chains in this case.  This change does not cause any
      pg_index update that wouldn't have happened anyway, so we're not
      re-introducing the previous bug with pg_index updates, and surely the case
      is not significant from a performance standpoint; so let's be as
      conservative as possible.
      9ad7e155
    • Tom Lane's avatar
      Make plan_cluster_use_sort cope with no IndexOptInfo for the target index. · 5b8e4429
      Tom Lane authored
      The original coding assumed that such a case represents caller error, but
      actually get_relation_info will omit generating an IndexOptInfo for any
      index it thinks is unsafe to use.  Therefore, handle this case by returning
      "true" to indicate that a seqscan-and-sort is the preferred way to
      implement the CLUSTER operation.  New bug in 9.1, no backpatch needed.
      Per bug #5985 from Daniel Grace.
      5b8e4429
    • Peter Eisentraut's avatar
      Fix PL/Python traceback for error in separate file · 395fcac2
      Peter Eisentraut authored
      It assumed that the lineno from the traceback always refers to the
      PL/Python function.  If you created a PL/Python function that imports
      some code, runs it, and that code raises an exception, PLy_traceback
      would get utterly confused.
      
      Now we look at the file name reported with the traceback and only
      print the source line if it came from the PL/Python function.
      
      Jan Urbański
      395fcac2
    • Bruce Momjian's avatar
      Pg_upgrade C comment addition. · 0262251c
      Bruce Momjian authored
      Document why we do the missing new database check during the check
      phase.
      0262251c
    • Heikki Linnakangas's avatar
      Quotes in strings injected into bki file need to escaped. In particular, · 2b919118
      Heikki Linnakangas authored
      "People's Republic of China" locale on Windows was causing initdb to fail.
      
      This fixes bug #5818 reported by yulei. On master, this makes the mapping
      of "People's Republic of China" to just "China" obsolete. In 9.0 and 8.4,
      just fix the escaping. Earlier versions didn't have locale names in bki
      file.
      2b919118
    • Bruce Momjian's avatar
      Throw error for mismatched pg_upgrade clusters · 7228d029
      Bruce Momjian authored
      If someone removes the 'postgres' database from the old cluster and the
      new cluster has a 'postgres' database, the number of databases will not
      match.  We actually could upgrade such a setup, but it would violate the
      1-to-1 mapping of database counts, so we throw an error instead.
      
      Previously they got an error during the upgrade, and not at the check
      stage; PG 9.0.4 does the same.
      7228d029
  3. 19 Apr, 2011 11 commits
  4. 18 Apr, 2011 4 commits
  5. 17 Apr, 2011 6 commits
    • Tom Lane's avatar
      Fix assorted infelicities in collation handling in psql's describe.c. · c29abc8b
      Tom Lane authored
      In \d, be more careful to print collation only if it's not the default for
      the column's data type.  Avoid assuming that the name "default" is magic.
      
      Fix \d on a composite type so that it will print per-column collations.
      It's no longer the case that a composite type cannot have modifiers.
      (In consequence, the expected outputs for composite-type regression tests
      change.)
      
      Fix \dD so that it will print collation for a domain, again only if it's
      not the same as the base type's collation.
      c29abc8b
    • Tom Lane's avatar
      Document COLLATE option in CREATE TYPE reference page. · 2d461712
      Tom Lane authored
      Curiously, it was already documented in ALTER TYPE ADD ATTRIBUTE, but
      not here.
      2d461712
    • Tom Lane's avatar
      Fix pg_dump to handle collations applied to columns of composite types. · acfa1f45
      Tom Lane authored
      CREATE TYPE and ALTER TYPE ADD ATTRIBUTE handle this, so I suppose it's
      an intended feature, but pg_dump didn't know about it.
      acfa1f45
    • Tom Lane's avatar
      Add check for matching column collations in ALTER TABLE ... INHERIT. · 49a642ab
      Tom Lane authored
      The other DDL operations that create an inheritance relationship were
      checking for collation match already, but this one got missed.
      
      Also fix comments that failed to mention collation checks.
      49a642ab
    • Tom Lane's avatar
      Support a COLLATE clause in plpgsql variable declarations. · c9473258
      Tom Lane authored
      This allows the usual rules for assigning a collation to a local variable
      to be overridden.  Per discussion, it seems appropriate to support this
      rather than forcing all local variables to have the argument-derived
      collation.
      c9473258
    • Tom Lane's avatar
      foreach() and list_delete() don't mix. · 88dc6fa7
      Tom Lane authored
      Fix crash when releasing duplicate entries in the encoding conversion cache
      list, caused by releasing the current entry of the list being chased by
      foreach().  We have a standard idiom for handling such cases, but this
      loop wasn't using it.
      
      This got broken in my recent rewrite of GUC assign hooks.  Not sure how
      I missed this when testing the modified code, but I did.  Per report from
      Peter.
      88dc6fa7
  6. 16 Apr, 2011 5 commits
    • Tom Lane's avatar
      Add an Assert that indexam.c isn't used on an index awaiting reindexing. · d2f60a3a
      Tom Lane authored
      This might have caught the recent embarrassment over trying to modify
      pg_index while its indexes were being rebuilt.
      
      Noah Misch
      d2f60a3a
    • Tom Lane's avatar
      Simplify reindex_relation's API. · 2d3320d3
      Tom Lane authored
      For what seem entirely historical reasons, a bitmask "flags" argument was
      recently added to reindex_relation without subsuming its existing boolean
      argument into that bitmask.  This seems a bit bizarre, so fold them
      together.
      2d3320d3
    • Tom Lane's avatar
      Clean up collation processing in prepunion.c. · 121f49a0
      Tom Lane authored
      This area was a few bricks shy of a load, and badly under-commented too.
      We have to ensure that the generated targetlist entries for a set-operation
      node expose the correct collation for each entry, since higher-level
      processing expects the tlist to reflect the true ordering of the plan's
      output.
      
      This hackery wouldn't be necessary if SortGroupClause carried collation
      info ... but making it do so would inject more pain in the parser than
      would be saved here.  Still, we might want to rethink that sometime.
      121f49a0
    • Peter Eisentraut's avatar
      Set client encoding explicitly in plpython_unicode test · 5809a645
      Peter Eisentraut authored
      This will (hopefully) eliminate the need for the
      plpython_unicode_0.out expected file.
      5809a645
    • Tom Lane's avatar
      Prevent incorrect updates of pg_index while reindexing pg_index itself. · 4b6106cc
      Tom Lane authored
      The places that attempt to change pg_index.indcheckxmin during a reindexing
      operation cannot be executed safely if pg_index itself is the subject of
      the operation.  This is the explanation for a couple of recent reports of
      VACUUM FULL failing with
      	ERROR:  duplicate key value violates unique constraint "pg_index_indexrelid_index"
      	DETAIL:  Key (indexrelid)=(2678) already exists.
      
      However, there isn't any real need to update indcheckxmin in such a
      situation, if we assume that pg_index can never contain a truly broken HOT
      chain.  This assumption holds if new indexes are never created on it during
      concurrent operations, which is something we don't consider safe for any
      system catalog, not just pg_index.  Accordingly, modify the code to not
      manipulate indcheckxmin when reindexing any system catalog.
      
      Back-patch to 8.3, where HOT was introduced.  The known failure scenarios
      involve 9.0-style VACUUM FULL, so there might not be any real risk before
      9.0, but let's not assume that.
      4b6106cc
  7. 15 Apr, 2011 6 commits