1. 31 Dec, 2014 5 commits
    • Tom Lane's avatar
      Docs: improve descriptions of ISO week-numbering date features. · 2f03ae69
      Tom Lane authored
      Use the phraseology "ISO 8601 week-numbering year" in place of just
      "ISO year", and make related adjustments to other terminology.
      
      The point of this change is that it seems some people see "ISO year"
      and think "standard year", whereupon they're surprised when constructs
      like to_char(..., "IYYY-MM-DD") produce nonsensical results.  Perhaps
      hanging a few more adjectives on it will discourage them from jumping
      to false conclusions.  I put in an explicit warning against that
      specific usage, too, though the main point is to discourage people
      who haven't read this far down the page.
      
      In passing fix some nearby markup and terminology inconsistencies.
      2f03ae69
    • Tom Lane's avatar
      Print more information about getObjectIdentityParts() failures. · a486841e
      Tom Lane authored
      This might help us debug what's happening on some buildfarm members.
      
      In passing, reduce the message from ereport to elog --- it doesn't seem
      like this should be a user-facing case, so not worth translating.
      a486841e
    • Tom Lane's avatar
      Improve consistency of parsing of psql's magic variables. · 28551797
      Tom Lane authored
      For simple boolean variables such as ON_ERROR_STOP, psql has for a long
      time recognized variant spellings of "on" and "off" (such as "1"/"0"),
      and it also made a point of warning you if you'd misspelled the setting.
      But these conveniences did not exist for other keyword-valued variables.
      In particular, though ECHO_HIDDEN and ON_ERROR_ROLLBACK include "on" and
      "off" as possible values, none of the alternative spellings for those were
      recognized; and to make matters worse the code would just silently assume
      "on" was meant for any unrecognized spelling.  Several people have reported
      getting bitten by this, so let's fix it.  In detail, this patch:
      
      * Allows all spellings recognized by ParseVariableBool() for ECHO_HIDDEN
      and ON_ERROR_ROLLBACK.
      
      * Reports a warning for unrecognized values for COMP_KEYWORD_CASE, ECHO,
      ECHO_HIDDEN, HISTCONTROL, ON_ERROR_ROLLBACK, and VERBOSITY.
      
      * Recognizes all values for all these variables case-insensitively;
      previously there was a mishmash of case-sensitive and case-insensitive
      behaviors.
      
      Back-patch to all supported branches.  There is a small risk of breaking
      existing scripts that were accidentally failing to malfunction; but the
      consensus is that the chance of detecting real problems and preventing
      future mistakes outweighs this.
      28551797
    • Alvaro Herrera's avatar
      Add missing pstrdup calls · ba66c9d0
      Alvaro Herrera authored
      The one for the OCLASS_COLLATION case was noticed by
      CLOBBER_CACHE_ALWAYS buildfarm members; the others I spotted by manual
      code inspection.
      
      Also remove a redundant check.
      ba66c9d0
    • Robert Haas's avatar
      Don't tab-complete COMMENT ON ... IS with IS. · c168c885
      Robert Haas authored
      Ian Barwick
      c168c885
  2. 30 Dec, 2014 6 commits
    • Alvaro Herrera's avatar
      pg_event_trigger_dropped_objects: Add name/args output columns · 72dd233d
      Alvaro Herrera authored
      These columns can be passed to pg_get_object_address() and used to
      reconstruct the dropped objects identities in a remote server containing
      similar objects, so that the drop can be replicated.
      
      Reviewed by Stephen Frost, Heikki Linnakangas, Abhijit Menon-Sen, Andres
      Freund.
      72dd233d
    • Alvaro Herrera's avatar
      Add pg_identify_object_as_address · a6762014
      Alvaro Herrera authored
      This function returns object type and objname/objargs arrays, which can
      be passed to pg_get_object_address.  This is especially useful because
      the textual representation can be copied to a remote server in order to
      obtain the corresponding OID-based address.  In essence, this function
      is the inverse of recently added pg_get_object_address().
      
      Catalog version bumped due to the addition of the new function.
      
      Also add docs to pg_get_object_address.
      a6762014
    • Alvaro Herrera's avatar
      Fix object_address expected output · 5b447ad3
      Alvaro Herrera authored
      Per pink buildfarm
      5b447ad3
    • Alvaro Herrera's avatar
      Use TypeName to represent type names in certain commands · 3f88672a
      Alvaro Herrera authored
      In COMMENT, DROP, SECURITY LABEL, and the new pg_get_object_address
      function, we were representing types as a list of names, same as other
      objects; but types are special objects that require their own
      representation to be totally accurate.  In the original COMMENT code we
      had a note about fixing it which was lost in the course of c10575ff.
      Change all those places to use TypeName instead, as suggested by that
      comment.
      
      Right now the original coding doesn't cause any bugs, so no backpatch.
      It is more problematic for proposed future code that operate with object
      addresses from the SQL interface; type details such as array-ness are
      lost when working with the degraded representation.
      
      Thanks to Petr Jelínek and Dimitri Fontaine for offlist help on finding
      a solution to a shift/reduce grammar conflict.
      3f88672a
    • Heikki Linnakangas's avatar
      Revert the GinMaxItemSize calculation so that we fit 3 tuples per page. · 930fd684
      Heikki Linnakangas authored
      Commit 36a35c55 changed the divisor from 3 to 6, for no apparent reason.
      Reducing GinMaxItemSize like that created a dump/reload hazard: loading a
      9.3 database to 9.4 might fail with "index row size XXX exceeds maximum 1352
      for index ..." error. Revert the change.
      
      While we're at it, make the calculation slightly more accurate. It used to
      divide the available space on page by three, then subtract
      sizeof(ItemIdData), and finally round down. That's not totally accurate; the
      item pointers for the three items are packed tight right after the page
      header, but there is alignment padding after the item pointers. Change the
      calculation to reflect that, like BTMaxItemSize does. I tested this with
      different block sizes on systems with 4- and 8-byte alignment, and the value
      after the final MAXALIGN_DOWN was the same with both methods on all
      configurations. So this does not make any difference currently, but let's be
      tidy.
      
      Also add a comment explaining what the macro does.
      
      This fixes bug #12292 reported by Robert Thaler. Backpatch to 9.4, where the
      bug was introduced.
      930fd684
    • Tatsuo Ishii's avatar
      Fix resource leak pointed out by Coverity. · 3b5a89c4
      Tatsuo Ishii authored
      3b5a89c4
  3. 29 Dec, 2014 1 commit
    • Tom Lane's avatar
      Assorted minor fixes for psql metacommand docs. · ae17897c
      Tom Lane authored
      Document the long forms of \H \i \ir \o \p \r \w ... apparently, we have
      a long and dishonorable history of leaving out the unabbreviated names of
      psql backslash commands.
      
      Avoid saying "Unix shell"; we can just say "shell" with equal clarity,
      and not leave Windows users wondering whether the feature works for them.
      
      Improve consistency of documentation of \g \o \w metacommands.  There's
      no reason to use slightly different wording or markup for each one.
      ae17897c
  4. 28 Dec, 2014 1 commit
  5. 26 Dec, 2014 3 commits
    • Alvaro Herrera's avatar
      Restrict name list len for domain constraints · 6630420f
      Alvaro Herrera authored
      This avoids an ugly-looking "cache lookup failure" message.
      
      Ugliness pointed out by Andres Freund.
      6630420f
    • Alvaro Herrera's avatar
      Remove event trigger from object_address test · 289121a4
      Alvaro Herrera authored
      It is causing trouble when run in parallel mode, because dropping the
      function other sessions are running concurrently causes them to fail due
      to inability to find the function.
      
      Per buildfarm, as noted by Tom Lane.
      289121a4
    • Alvaro Herrera's avatar
      Grab heavyweight tuple lock only before sleeping · 0e5680f4
      Alvaro Herrera authored
      We were trying to acquire the lock even when we were subsequently
      not sleeping in some other transaction, which opens us up unnecessarily
      to deadlocks.  In particular, this is troublesome if an update tries to
      lock an updated version of a tuple and finds itself doing EvalPlanQual
      update chain walking; more than two sessions doing this concurrently
      will find themselves sleeping on each other because the HW tuple lock
      acquisition in heap_lock_tuple called from EvalPlanQualFetch races with
      the same tuple lock being acquired in heap_update -- one of these
      sessions sleeps on the other one to finish while holding the tuple lock,
      and the other one sleeps on the tuple lock.
      
      Per trouble report from Andrew Sackville-West in
      http://www.postgresql.org/message-id/20140731233051.GN17765@andrew-ThinkPad-X230
      
      His scenario can be simplified down to a relatively simple
      isolationtester spec file which I don't include in this commit; the
      reason is that the current isolationtester is not able to deal with more
      than one blocked session concurrently and it blocks instead of raising
      the expected deadlock.  In the future, if we improve isolationtester, it
      would be good to include the spec file in the isolation schedule.  I
      posted it in
      http://www.postgresql.org/message-id/20141212205254.GC1768@alvh.no-ip.org
      
      Hat tip to Mark Kirkwood, who helped diagnose the trouble.
      0e5680f4
  6. 25 Dec, 2014 9 commits
    • Noah Misch's avatar
      Have config_sspi_auth() permit IPv6 localhost connections. · 8d9cb0bc
      Noah Misch authored
      Windows versions later than Windows Server 2003 map "localhost" to ::1.
      Account for that in the generated pg_hba.conf, fixing another oversight
      in commit f6dc6dd5.  Back-patch to 9.0,
      like that commit.
      
      David Rowley and Noah Misch
      8d9cb0bc
    • Andres Freund's avatar
      Blindly fix a dtrace probe in lwlock.c for a removed local variable. · 740a4ec7
      Andres Freund authored
      Per buildfarm member locust.
      740a4ec7
    • Tom Lane's avatar
      Temporarily revert "Move pg_lzcompress.c to src/common." · 966115c3
      Tom Lane authored
      This reverts commit 60838df9.
      That change needs a bit more thought to be workable.  In view of
      the potentially machine-dependent stuff that went in today,
      we need all of the buildfarm to be testing those other changes.
      966115c3
    • Andres Freund's avatar
      Lockless StrategyGetBuffer clock sweep hot path. · d72731a7
      Andres Freund authored
      StrategyGetBuffer() has proven to be a bottleneck in a number of
      buffer acquisition heavy workloads. To some degree this has already
      been alleviated by 5d7962c6, but it still can be quite a heavy
      bottleneck.  The problem is that in unfortunate usage patterns a
      single StrategyGetBuffer() call will have to look at a large number of
      buffers - in turn making it likely that the process will be put to
      sleep while still holding the spinlock.
      
      Replace most of the usage of the buffer_strategy_lock spinlock for the
      clock sweep by a atomic nextVictimBuffer variable. That variable,
      modulo NBuffers, is the current hand of the clock sweep. The buffer
      clock-sweep then only needs to acquire the spinlock after a
      wraparound. And even then only in the process that did the wrapping
      around. That alleviates nearly all the contention on the relevant
      spinlock, although significant contention on the cacheline can still
      exist.
      
      Reviewed-By: Robert Haas and Amit Kapila
      
      Discussion: 20141010160020.GG6670@alap3.anarazel.de,
          20141027133218.GA2639@awork2.anarazel.de
      d72731a7
    • Andres Freund's avatar
      Improve LWLock scalability. · ab5194e6
      Andres Freund authored
      The old LWLock implementation had the problem that concurrent lock
      acquisitions required exclusively acquiring a spinlock. Often that
      could lead to acquirers waiting behind the spinlock, even if the
      actual LWLock was free.
      
      The new implementation doesn't acquire the spinlock when acquiring the
      lock itself. Instead the new atomic operations are used to atomically
      manipulate the state. Only the waitqueue, used solely in the slow
      path, is still protected by the spinlock. Check lwlock.c's header for
      an explanation about the used algorithm.
      
      For some common workloads on larger machines this can yield
      significant performance improvements. Particularly in read mostly
      workloads.
      
      Reviewed-By: Amit Kapila and Robert Haas
      Author: Andres Freund
      
      Discussion: 20130926225545.GB26663@awork2.anarazel.de
      ab5194e6
    • Andres Freund's avatar
      Convert the PGPROC->lwWaitLink list into a dlist instead of open coding it. · 7882c3b0
      Andres Freund authored
      Besides being shorter and much easier to read it changes the logic in
      LWLockRelease() to release all shared lockers when waking up any. This
      can yield some significant performance improvements - and the fairness
      isn't really much worse than before, as we always allowed new shared
      lockers to jump the queue.
      7882c3b0
    • Andres Freund's avatar
      Add capability to suppress CONTEXT: messages to elog machinery. · 570bd2b3
      Andres Freund authored
      Hiding context messages usually is not a good idea - except for rather
      verbose debugging/development utensils like LOG_DEBUG. There the
      amount of repeated context messages just bloat the log without adding
      information.
      570bd2b3
    • Fujii Masao's avatar
      Remove duplicate include of slot.h. · 4a559319
      Fujii Masao authored
      Back-patch to 9.4, where this problem was added.
      4a559319
    • Fujii Masao's avatar
      Move pg_lzcompress.c to src/common. · 60838df9
      Fujii Masao authored
      Exposing compression and decompression APIs of pglz makes possible its
      use by extensions and contrib modules. pglz_decompress contained a call
      to elog to emit an error message in case of corrupted data. This function
      is changed to return a status code to let its callers return an error instead.
      
      This commit is required for upcoming WAL compression feature so that
      the WAL reader facility can decompress the WAL data by using pglz_decompress.
      
      Michael Paquier
      60838df9
  7. 24 Dec, 2014 5 commits
  8. 23 Dec, 2014 6 commits
    • Tom Lane's avatar
      Remove failing collation case from object_address regression test. · 3e227535
      Tom Lane authored
      Per buildfarm, this test case does not yield consistent results.
      I don't think it's useful enough to figure out a workaround, either.
      3e227535
    • Alvaro Herrera's avatar
      Revert "Use a bitmask to represent role attributes" · a609d967
      Alvaro Herrera authored
      This reverts commit 1826987a.
      
      The overall design was deemed unacceptable, in discussion following the
      previous commit message; we might find some parts of it still
      salvageable, but I don't want to be on the hook for fixing it, so let's
      wait until we have a new patch.
      a609d967
    • Alvaro Herrera's avatar
      Add SQL-callable pg_get_object_address · d7ee82e5
      Alvaro Herrera authored
      This allows access to get_object_address from SQL, which is useful to
      obtain OID addressing information from data equivalent to that emitted
      by the parser.  This is necessary infrastructure of a project to let
      replication systems propagate object dropping events to remote servers,
      where the schema might be different than the server originating the
      DROP.
      
      This patch also adds support for OBJECT_DEFAULT to get_object_address;
      that is, it is now possible to refer to a column's default value.
      
      Catalog version bumped due to the new function.
      
      Reviewed by Stephen Frost, Heikki Linnakangas, Robert Haas, Andres
      Freund, Abhijit Menon-Sen, Adam Brightwell.
      d7ee82e5
    • Alvaro Herrera's avatar
      Use a bitmask to represent role attributes · 1826987a
      Alvaro Herrera authored
      The previous representation using a boolean column for each attribute
      would not scale as well as we want to add further attributes.
      
      Extra auxilliary functions are added to go along with this change, to
      make up for the lost convenience of access of the old representation.
      
      Catalog version bumped due to change in catalogs and the new functions.
      
      Author: Adam Brightwell, minor tweaks by Álvaro
      Reviewed by: Stephen Frost, Andres Freund, Álvaro Herrera
      1826987a
    • Alvaro Herrera's avatar
      get_object_address: separate domain constraints from table constraints · 7eca575d
      Alvaro Herrera authored
      Apart from enabling comments on domain constraints, this enables a
      future project to replicate object dropping to remote servers: with the
      current mechanism there's no way to distinguish between the two types of
      constraints, so there's no way to know what to drop.
      
      Also added support for the domain constraint comments in psql's \dd and
      pg_dump.
      
      Catalog version bumped due to the change in ObjectType enum.
      7eca575d
    • Peter Eisentraut's avatar
      Change local_preload_libraries to PGC_USERSET · 584e35d1
      Peter Eisentraut authored
      This allows it to be used with ALTER ROLE SET.
      
      Although the old setting of PGC_BACKEND prevented changes after session
      start, after discussion it was more useful to allow ALTER ROLE SET
      instead and just document that changes during a session have no effect.
      This is similar to how session_preload_libraries works already.
      
      An alternative would be to change things to allow PGC_BACKEND and
      PGC_SU_BACKEND settings to be changed by ALTER ROLE SET.  But that might
      need further research (e.g., log_connections would probably not work).
      
      based on patch by Kyotaro Horiguchi
      584e35d1
  9. 22 Dec, 2014 4 commits