Skip to content
Snippets Groups Projects
  1. Jan 24, 2012
  2. Jan 19, 2012
    • Robert Haas's avatar
      Add bitwise AND, OR, and NOT operators for macaddr data type. · cc53a1e7
      Robert Haas authored
      Brendan Jurd, reviewed by Fujii Masao
      cc53a1e7
    • Magnus Hagander's avatar
      Separate state from query string in pg_stat_activity · 4f42b546
      Magnus Hagander authored
      This separates the state (running/idle/idleintransaction etc) into
      it's own field ("state"), and leaves the query field containing just
      query text.
      
      The query text will now mean "current query" when a query is running
      and "last query" in other states. Accordingly,the field has been
      renamed from current_query to query.
      
      Since backwards compatibility was broken anyway to make that, the procpid
      field has also been renamed to pid - along with the same field in
      pg_stat_replication for consistency.
      
      Scott Mead and Magnus Hagander, review work from Greg Smith
      4f42b546
  3. Jan 16, 2012
    • Robert Haas's avatar
      Prevent adding relations to a concurrently dropped schema. · 1575fbcb
      Robert Haas authored
      In the previous coding, it was possible for a relation to be created
      via CREATE TABLE, CREATE VIEW, CREATE SEQUENCE, CREATE FOREIGN TABLE,
      etc.  in a schema while that schema was meanwhile being concurrently
      dropped.  This led to a pg_class entry with an invalid relnamespace
      value.  The same problem could occur if a relation was moved using
      ALTER .. SET SCHEMA while the target schema was being concurrently
      dropped.  This patch prevents both of those scenarios by locking the
      schema to which the relation is being added using AccessShareLock,
      which conflicts with the AccessExclusiveLock taken by DROP.
      
      As a desirable side effect, this also prevents the use of CREATE OR
      REPLACE VIEW to queue for an AccessExclusiveLock on a relation on which
      you have no rights: that will now fail immediately with a permissions
      error, before trying to obtain a lock.
      
      We need similar protection for all other object types, but as everything
      other than relations uses a slightly different set of code paths, I'm
      leaving that for a separate commit.
      
      Original complaint (as far as I could find) about CREATE by Nikhil
      Sontakke; risk for ALTER .. SET SCHEMA pointed out by Tom Lane;
      further details by Dan Farina; patch by me; review by Hitoshi Harada.
      1575fbcb
  4. Jan 12, 2012
    • Tom Lane's avatar
      Fix CLUSTER/VACUUM FULL for toast values owned by recently-updated rows. · 21b446dd
      Tom Lane authored
      In commit 7b0d0e93, I made CLUSTER and
      VACUUM FULL try to preserve toast value OIDs from the original toast table
      to the new one.  However, if we have to copy both live and recently-dead
      versions of a row that has a toasted column, those versions may well
      reference the same toast value with the same OID.  The patch then led to
      duplicate-key failures as we tried to insert the toast value twice with the
      same OID.  (The previous behavior was not very desirable either, since it
      would have silently inserted the same value twice with different OIDs.
      That wastes space, but what's worse is that the toast values inserted for
      already-dead heap rows would not be reclaimed by subsequent ordinary
      VACUUMs, since they go into the new toast table marked live not deleted.)
      
      To fix, check if the copied OID already exists in the new toast table, and
      if so, assume that it stores the desired value.  This is reasonably safe
      since the only case where we will copy an OID from a previous toast pointer
      is when toast_insert_or_update was given that toast pointer and so we just
      pulled the data from the old table; if we got two different values that way
      then we have big problems anyway.  We do have to assume that no other
      backend is inserting items into the new toast table concurrently, but
      that's surely safe for CLUSTER and VACUUM FULL.
      
      Per bug #6393 from Maxim Boguk.  Back-patch to 9.0, same as the previous
      patch.
      21b446dd
  5. Jan 11, 2012
  6. Jan 07, 2012
    • Peter Eisentraut's avatar
      Rename the internal structures of the CREATE TABLE (LIKE ...) facility · db49517c
      Peter Eisentraut authored
      The original implementation of this interpreted it as a kind of
      "inheritance" facility and named all the internal structures
      accordingly.  This turned out to be very confusing, because it has
      nothing to do with the INHERITS feature.  So rename all the internal
      parser infrastructure, update the comments, adjust the error messages,
      and split up the regression tests.
      db49517c
    • Tom Lane's avatar
      Use __sync_lock_test_and_set() for spinlocks on ARM, if available. · 0a41e865
      Tom Lane authored
      Historically we've used the SWPB instruction for TAS() on ARM, but this
      is deprecated and not available on ARMv6 and later.  Instead, make use
      of a GCC builtin if available.  We'll still fall back to SWPB if not,
      so as not to break existing ports using older GCC versions.
      
      Eventually we might want to try using __sync_lock_test_and_set() on some
      other architectures too, but for now that seems to present only risk and
      not reward.
      
      Back-patch to all supported versions, since people might want to use any
      of them on more recent ARM chips.
      
      Martin Pitt
      0a41e865
    • Robert Haas's avatar
      Slightly reorganize struct SnapshotData. · 1fc3d18f
      Robert Haas authored
      This squeezes out a bunch of alignment padding, reducing the size
      from 72 to 56 bytes on my machine.  At least in my testing, this
      didn't produce any measurable performance improvement, but the space
      savings seem like enough justification.
      
      Andres Freund
      1fc3d18f
    • Robert Haas's avatar
      Improve behavior of concurrent ALTER TABLE, and do some refactoring. · 1489e2f2
      Robert Haas authored
      ALTER TABLE (and ALTER VIEW, ALTER SEQUENCE, etc.) now use a
      RangeVarGetRelid callback to check permissions before acquiring a table
      lock.  We also now use the same callback for all forms of ALTER TABLE,
      rather than having separate, almost-identical callbacks for ALTER TABLE
      .. SET SCHEMA and ALTER TABLE .. RENAME, and no callback at all for
      everything else.
      
      I went ahead and changed the code so that no form of ALTER TABLE works
      on foreign tables; you must use ALTER FOREIGN TABLE instead.  In 9.1,
      it was possible to use ALTER TABLE .. SET SCHEMA or ALTER TABLE ..
      RENAME on a foreign table, but not any other form of ALTER TABLE, which
      did not seem terribly useful or consistent.
      
      Patch by me; review by Noah Misch.
      1489e2f2
  7. Jan 06, 2012
    • Robert Haas's avatar
      Make the number of CLOG buffers adaptive, based on shared_buffers. · 33aaa139
      Robert Haas authored
      Previously, this was hardcoded: we always had 8.  Performance testing
      shows that isn't enough, especially on big SMP systems, so we allow it
      to scale up as high as 32 when there's adequate memory.  On the flip
      side, when shared_buffers is very small, drop the number of CLOG buffers
      down to as little as 4, so that we can start the postmaster even
      when very little shared memory is available.
      
      Per extensive discussion with Simon Riggs, Tom Lane, and others on
      pgsql-hackers.
      33aaa139
  8. Jan 05, 2012
  9. Jan 03, 2012
  10. Jan 02, 2012
    • Tom Lane's avatar
      Use LWSYNC in place of SYNC/ISYNC in PPC spinlocks, where possible. · 631beeac
      Tom Lane authored
      This is allegedly a win, at least on some PPC implementations, according
      to the PPC ISA documents.  However, as with LWARX hints, some PPC
      platforms give an illegal-instruction failure.  Use the same trick as
      before of assuming that PPC64 platforms will accept it; we might need to
      refine that based on experience, but there are other projects doing
      likewise according to google.
      
      I did not add an assembler compatibility test because LWSYNC has been
      around much longer than hint bits, and it seems unlikely that any
      toolchains currently in use don't recognize it.
      631beeac
    • Tom Lane's avatar
      Use 4-byte slock_t on both PPC and PPC64. · 8496c6cd
      Tom Lane authored
      Previously we defined slock_t as 8 bytes on PPC64, but the TAS assembly
      code uses word-wide operations regardless, so that the second word was
      just wasted space.  There doesn't appear to be any performance benefit
      in adding the second word, so get rid of it to simplify the code.
      8496c6cd
    • Tom Lane's avatar
      Use mutex hint bit in PPC LWARX instructions, where possible. · 5cfa8dd3
      Tom Lane authored
      The hint bit makes for a small but measurable performance improvement
      in access to contended spinlocks.
      
      On the other hand, some PPC chips give an illegal-instruction failure.
      There doesn't seem to be a completely bulletproof way to tell whether the
      hint bit will cause an illegal-instruction failure other than by trying
      it; but most if not all 64-bit PPC machines should accept it, so follow
      the Linux kernel's lead and assume it's okay to use it in 64-bit builds.
      Of course we must also check whether the assembler accepts the command,
      since even with a recent CPU the toolchain could be old.
      
      Patch by Manabu Ori, significantly modified by me.
      5cfa8dd3
    • Bruce Momjian's avatar
      Update copyright notices for year 2012. · e126958c
      Bruce Momjian authored
      e126958c
  11. Dec 31, 2011
  12. Dec 27, 2011
    • Peter Eisentraut's avatar
      Remove support for on_exit() · d383c23f
      Peter Eisentraut authored
      All supported platforms support the C89 standard function atexit()
      (SunOS 4 probably being the last one not to), and supporting both
      makes the code clumsy.
      d383c23f
  13. Dec 25, 2011
    • Tom Lane's avatar
      Rethink representation of index clauses' mapping to index columns. · 472d3935
      Tom Lane authored
      In commit e2c2c2e8 I made use of nested
      list structures to show which clauses went with which index columns, but
      on reflection that's a data structure that only an old-line Lisp hacker
      could love.  Worse, it adds unnecessary complication to the many places
      that don't much care which clauses go with which index columns.  Revert
      to the previous arrangement of flat lists of clauses, and instead add a
      parallel integer list of column numbers.  The places that care about the
      pairing can chase both lists with forboth(), while the places that don't
      care just examine one list the same as before.
      
      The only real downside to this is that there are now two more lists that
      need to be passed to amcostestimate functions in case they care about
      column matching (which btcostestimate does, so not passing the info is not
      an option).  Rather than deal with 11-argument amcostestimate functions,
      pass just the IndexPath and expect the functions to extract fields from it.
      That gets us down to 7 arguments which is better than 11, and it seems
      more future-proof against likely additions to the information we keep
      about an index path.
      472d3935
  14. Dec 24, 2011
    • Tom Lane's avatar
      Improve planner's handling of duplicated index column expressions. · e2c2c2e8
      Tom Lane authored
      It's potentially useful for an index to repeat the same indexable column
      or expression in multiple index columns, if the columns have different
      opclasses.  (If they share opclasses too, the duplicate column is pretty
      useless, but nonetheless we've allowed such cases since 9.0.)  However,
      the planner failed to cope with this, because createplan.c was relying on
      simple equal() matching to figure out which index column each index qual
      is intended for.  We do have that information available upstream in
      indxpath.c, though, so the fix is to not flatten the multi-level indexquals
      list when putting it into an IndexPath.  Then we can rely on the sublist
      structure to identify target index columns in createplan.c.  There's a
      similar issue for index ORDER BYs (the KNNGIST feature), so introduce a
      multi-level-list representation for that too.  This adds a bit more
      representational overhead, but we might more or less buy that back by not
      having to search for matching index columns anymore in createplan.c;
      likewise btcostestimate saves some cycles.
      
      Per bug #6351 from Christian Rudolph.  Likely symptoms include the "btree
      index keys must be ordered by attribute" failure shown there, as well as
      "operator MMMM is not a member of opfamily NNNN".
      
      Although this is a pre-existing problem that can be demonstrated in 9.0 and
      9.1, I'm not going to back-patch it, because the API changes in the planner
      seem likely to break things such as index plugins.  The corner cases where
      this matters seem too narrow to justify possibly breaking things in a minor
      release.
      e2c2c2e8
  15. Dec 23, 2011
  16. Dec 22, 2011
    • Robert Haas's avatar
      Catversion bump for commit 0e4611c0. · 99b60fc0
      Robert Haas authored
      It changed the format of stored rules.
      99b60fc0
    • Robert Haas's avatar
      Add a security_barrier option for views. · 0e4611c0
      Robert Haas authored
      When a view is marked as a security barrier, it will not be pulled up
      into the containing query, and no quals will be pushed down into it,
      so that no function or operator chosen by the user can be applied to
      rows not exposed by the view.  Views not configured with this
      option cannot provide robust row-level security, but will perform far
      better.
      
      Patch by KaiGai Kohei; original problem report by Heikki Linnakangas
      (in October 2009!).  Review (in earlier versions) by Noah Misch and
      others.  Design advice by Tom Lane and myself.  Further review and
      cleanup by me.
      0e4611c0
    • Peter Eisentraut's avatar
      Add ALTER DOMAIN ... RENAME · f90dd280
      Peter Eisentraut authored
      You could already rename domains using ALTER TYPE, but with this new
      command it is more consistent with how other commands treat domains as
      a subcategory of types.
      f90dd280
  17. Dec 21, 2011
    • Robert Haas's avatar
      Improve behavior of concurrent CLUSTER. · cbe24a6d
      Robert Haas authored
      In the previous coding, a user could queue up for an AccessExclusiveLock
      on a table they did not have permission to cluster, thus potentially
      interfering with access by authorized users who got stuck waiting behind
      the AccessExclusiveLock.  This approach avoids that.  cluster() has the
      same permissions-checking requirements as REINDEX TABLE, so this commit
      moves the now-shared callback to tablecmds.c and renames it, per
      discussion with Noah Misch.
      cbe24a6d
    • Robert Haas's avatar
      Take fewer snapshots. · d573e239
      Robert Haas authored
      When a PORTAL_ONE_SELECT query is executed, we can opportunistically
      reuse the parse/plan shot for the execution phase.  This cuts down the
      number of snapshots per simple query from 2 to 1 for the simple
      protocol, and 3 to 2 for the extended protocol.  Since we are only
      reusing a snapshot taken early in the processing of the same protocol
      message, the change shouldn't be user-visible, except that the remote
      possibility of the planning and execution snapshots being different is
      eliminated.
      
      Note that this change does not make it safe to assume that the parse/plan
      snapshot will certainly be reused; that will currently only happen if
      PortalStart() decides to use the PORTAL_ONE_SELECT strategy.  It might
      be worth trying to provide some stronger guarantees here in the future,
      but for now we don't.
      
      Patch by me; review by Dimitri Fontaine.
      d573e239
  18. Dec 19, 2011
    • Peter Eisentraut's avatar
      Add support for privileges on types · 72920557
      Peter Eisentraut authored
      This adds support for the more or less SQL-conforming USAGE privilege
      on types and domains.  The intent is to be able restrict which users
      can create dependencies on types, which restricts the way in which
      owners can alter types.
      
      reviewed by Yeb Havinga
      72920557
    • Alvaro Herrera's avatar
      Forgot catversion bump on previous patch · 05e992e9
      Alvaro Herrera authored
      Per Tom
      05e992e9
    • Tom Lane's avatar
      Rename updateNodeLink to spgUpdateNodeLink. · 8f57b064
      Tom Lane authored
      On reflection, the original name seems way too generic for a global
      symbol.  A quick check shows this is the only exported function name
      in SP-GiST that doesn't begin with "spg" or contain "SpGist", so the
      rest of them seem all right.
      8f57b064
    • Alvaro Herrera's avatar
      Allow CHECK constraints to be declared ONLY · 61d81bd2
      Alvaro Herrera authored
      This makes them enforceable only on the parent table, not on children
      tables.  This is useful in various situations, per discussion involving
      people bitten by the restrictive behavior introduced in 8.4.
      
      Message-Id:
      8762mp93iw.fsf@comcast.net
      CAFaPBrSMMpubkGf4zcRL_YL-AERUbYF_-ZNNYfb3CVwwEqc9TQ@mail.gmail.com
      
      Authors: Nikhil Sontakke, Alex Hunsaker
      Reviewed by Robert Haas and myself
      61d81bd2
    • Tom Lane's avatar
      Teach SP-GiST to do index-only scans. · 92203624
      Tom Lane authored
      Operator classes can specify whether or not they support this; this
      preserves the flexibility to use lossy representations within an index.
      
      In passing, move constant data about a given index into the rd_amcache
      cache area, instead of doing fresh lookups each time we start an index
      operation.  This is mainly to try to make sure that spgcanreturn() has
      insignificant cost; I still don't have any proof that it matters for
      actual index accesses.  Also, get rid of useless copying of FmgrInfo
      pointers; we can perfectly well use the relcache's versions in-place.
      92203624
  19. Dec 18, 2011
    • Tom Lane's avatar
      Replace simple constant pg_am.amcanreturn with an AM support function. · 3695a555
      Tom Lane authored
      The need for this was debated when we put in the index-only-scan feature,
      but at the time we had no near-term expectation of having AMs that could
      support such scans for only some indexes; so we kept it simple.  However,
      the SP-GiST AM forces the issue, so let's fix it.
      
      This patch only installs the new API; no behavior actually changes.
      3695a555
    • Tom Lane's avatar
      Remove bogus entries in gist point_ops operator class. · 5577ca5b
      Tom Lane authored
      These entries could never be matched to an index clause because they don't
      have the index datatype on the left-hand side of the operator.  (Their
      commutators are in the opclass, which is sensible, but that doesn't mean
      these operators should be.)  Spotted by a test that I recently added to
      opr_sanity to catch exactly this type of thinko.  AFAICT there is no code
      in gistproc.c that is specifically meant to cover these cases, so nothing
      to remove at that level.
      5577ca5b
  20. Dec 17, 2011
    • Tom Lane's avatar
      Add SP-GiST (space-partitioned GiST) index access method. · 8daeb5dd
      Tom Lane authored
      SP-GiST is comparable to GiST in flexibility, but supports non-balanced
      partitioned search structures rather than balanced trees.  As described at
      PGCon 2011, this new indexing structure can beat GiST in both index build
      time and query speed for search problems that it is well matched to.
      
      There are a number of areas that could still use improvement, but at this
      point the code seems committable.
      
      Teodor Sigaev and Oleg Bartunov, with considerable revisions by Tom Lane
      8daeb5dd
    • Robert Haas's avatar
      Various micro-optimizations for GetSnapshopData(). · 0d76b60d
      Robert Haas authored
      Heikki Linnakangas had the idea of rearranging GetSnapshotData to
      avoid checking for sub-XIDs when no top-level XID is present.  This
      patch does that plus further a bit of further, related rearrangement.
      Benchmarking show a significant improvement on unlogged tables at
      higher concurrency levels, and mostly indifferent result on permanent
      tables (which are presumably bottlenecked elsewhere).  Most of the
      benefit seems to come from using the new NormalTransactionIdPrecedes()
      macro rather than the function call TransactionIdPrecedes().
      0d76b60d
  21. Dec 16, 2011
    • Andrew Dunstan's avatar
      include_if_exists facility for config file. · 6d09b210
      Andrew Dunstan authored
      This works the same as include, except that an error is not thrown
      if the file is missing. Instead the fact that it's missing is
      logged.
      
      Greg Smith, reviewed by Euler Taveira de Oliveira.
      6d09b210
    • Robert Haas's avatar
      Improve behavior of concurrent rename statements. · 74a1d4fe
      Robert Haas authored
      Previously, renaming a table, sequence, view, index, foreign table,
      column, or trigger checked permissions before locking the object, which
      meant that if permissions were revoked during the lock wait, we would
      still allow the operation.  Similarly, if the original object is dropped
      and a new one with the same name is created, the operation will be allowed
      if we had permissions on the old object; the permissions on the new
      object don't matter.  All this is now fixed.
      
      Along the way, attempting to rename a trigger on a foreign table now gives
      the same error message as trying to create one there in the first place
      (i.e. that it's not a table or view) rather than simply stating that no
      trigger by that name exists.
      
      Patch by me; review by Noah Misch.
      74a1d4fe
    • Robert Haas's avatar
      Fix typo. · f6835ea9
      Robert Haas authored
      f6835ea9
Loading