1. 21 1月, 2015 2 次提交
    • R
      Disable abbreviated keys on Windows. · 1be4eb1b
      Robert Haas 提交于
      Most of the Windows buildfarm members (bowerbird, hamerkop, currawong,
      jacana, brolga) are unhappy with yesterday's abbreviated keys patch,
      although there are some (narwhal, frogmouth) that seem OK with it.
      Since there's no obvious pattern to explain why some are working and
      others are failing, just disable this across-the-board on Windows for
      now.  This is a bit unfortunate since the optimization will be a big
      win in some cases, but we can't leave the buildfarm broken.
      1be4eb1b
    • B
      tools/ccsym: update for modern versions of gcc · f259e71d
      Bruce Momjian 提交于
      This dumps the predefined preprocessor macros
      f259e71d
  2. 20 1月, 2015 6 次提交
    • R
      Add strxfrm_l to list of functions where Windows adds an underscore. · f32a1fa4
      Robert Haas 提交于
      Per buildfarm failure on bowerbird after last night's commit
      4ea51cdf.
      
      Peter Geoghegan
      f32a1fa4
    • T
      In pg_regress, remove the temporary installation upon successful exit. · aa719391
      Tom Lane 提交于
      This results in a very substantial reduction in disk space usage during
      "make check-world", since that sequence involves creation of numerous
      temporary installations.  It should also help a bit in the buildfarm, even
      though the buildfarm script doesn't create as many temp installations,
      because the current script misses deleting some of them; and anyway it
      seems better to do this once in one place rather than expecting that
      script to get it right every time.
      
      In 9.4 and HEAD, also undo the unwise choice in commit b1aebbb6
      to report strerror(errno) after a rmtree() failure.  rmtree has already
      reported that, possibly for multiple failures with distinct errnos; and
      what's more, by the time it returns there is no good reason to assume
      that errno still reflects the last reportable error.  So reporting errno
      here is at best redundant and at worst badly misleading.
      
      Back-patch to all supported branches, so that future revisions of the
      buildfarm script can rely on this behavior.
      aa719391
    • T
      Adjust "pgstat wait timeout" message to be a translatable LOG message. · 75b48e1f
      Tom Lane 提交于
      Per discussion, change the log level of this message to be LOG not WARNING.
      The main point of this change is to avoid causing buildfarm run failures
      when the stats collector is exceptionally slow to respond, which it not
      infrequently is on some of the smaller/slower buildfarm members.
      
      This change does lose notice to an interactive user when his stats query
      is looking at out-of-date stats, but the majority opinion (not necessarily
      that of yours truly) is that WARNING messages would probably not get
      noticed anyway on heavily loaded production systems.  A LOG message at
      least ensures that the problem is recorded somewhere where bulk auditing
      for the issue is possible.
      
      Also, instead of an untranslated "pgstat wait timeout" message, provide
      a translatable and hopefully more understandable message "using stale
      statistics instead of current ones because stats collector is not
      responding".  The original text was written hastily under the assumption
      that it would never really happen in practice, which we now know to be
      unduly optimistic.
      
      Back-patch to all active branches, since we've seen the buildfarm issue
      in all branches.
      75b48e1f
    • A
      Fix various shortcomings of the new PrivateRefCount infrastructure. · 2d115e47
      Andres Freund 提交于
      As noted by Tom Lane the improvements in 4b4b680c had the problem
      that in some situations we searched, entered and modified entries in
      the private refcount hash while holding a spinlock. I had tried to
      keep the logic entirely local to PinBuffer_Locked(), but that's not
      really possible given it's called with a spinlock held...
      
      Besides being disadvantageous from a performance point of view, this
      also has problems with error handling safety. If we failed inserting
      an entry into the hashtable due to an out of memory error, we'd error
      out with a held spinlock. Not good.
      
      Change the way private refcounts are manipulated: Before a buffer can
      be tracked an entry has to be reserved using
      ReservePrivateRefCountEntry(); then, if a entry is not found using
      GetPrivateRefCountEntry(), it can be entered with
      NewPrivateRefCountEntry().
      
      Also take advantage of the fact that PinBuffer_Locked() currently is
      never called for buffers that already have been pinned by the current
      backend and don't search the private refcount entries for preexisting
      local pins. That results in a small, but measurable, performance
      improvement.
      
      Additionally make ReleaseBuffer() always call UnpinBuffer() for shared
      buffers. That avoids duplicating work in an eventual UnpinBuffer()
      call that already has been done in ReleaseBuffer() and also saves some
      code.
      
      Per discussion with Tom Lane.
      
      Discussion: 15028.1418772313@sss.pgh.pa.us
      2d115e47
    • R
      Use abbreviated keys for faster sorting of text datums. · 4ea51cdf
      Robert Haas 提交于
      This commit extends the SortSupport infrastructure to allow operator
      classes the option to provide abbreviated representations of Datums;
      in the case of text, we abbreviate by taking the first few characters
      of the strxfrm() blob.  If the abbreviated comparison is insufficent
      to resolve the comparison, we fall back on the normal comparator.
      This can be much faster than the old way of doing sorting if the
      first few bytes of the string are usually sufficient to resolve the
      comparison.
      
      There is the potential for a performance regression if all of the
      strings to be sorted are identical for the first 8+ characters and
      differ only in later positions; therefore, the SortSupport machinery
      now provides an infrastructure to abort the use of abbreviation if
      it appears that abbreviation is producing comparatively few distinct
      keys.  HyperLogLog, a streaming cardinality estimator, is included in
      this commit and used to make that determination for text.
      
      Peter Geoghegan, reviewed by me.
      4ea51cdf
    • R
      Typo fix. · 1605291b
      Robert Haas 提交于
      Etsuro Fujita
      1605291b
  3. 19 1月, 2015 5 次提交
  4. 18 1月, 2015 1 次提交
  5. 17 1月, 2015 5 次提交
    • A
      Replace walsender's latch with the general shared latch. · ff44fba4
      Andres Freund 提交于
      Relying on the normal shared latch simplifies interrupt/signal
      handling because we can rely on all signal handlers setting the proc
      latch. That in turn allows us to avoid the use of
      ImmediateInterruptOK, which arguably isn't correct because
      WaitLatchOrSocket isn't declared to be immediately interruptible.
      
      Also change sections that wait on the walsender's latch to notice
      interrupts quicker/more reliably and make them more consistent with
      each other.
      
      This is part of a larger "get rid of ImmediateInterruptOK" series.
      
      Discussion: 20150115020335.GZ5245@awork2.anarazel.de
      ff44fba4
    • T
      Show sort ordering options in EXPLAIN output. · 20af53d7
      Tom Lane 提交于
      Up to now, EXPLAIN has contented itself with printing the sort expressions
      in a Sort or Merge Append plan node.  This patch improves that by
      annotating the sort keys with COLLATE, DESC, USING, and/or NULLS FIRST/LAST
      whenever nondefault sort ordering options are used.  The output is now a
      reasonably close approximation of an ORDER BY clause equivalent to the
      plan's ordering.
      
      Marius Timmer, Lukas Kreft, and Arne Scheffer; reviewed by Mike Blackwell.
      Some additional hacking by me.
      20af53d7
    • H
      Advance backend's advertised xmin more aggressively. · 94028691
      Heikki Linnakangas 提交于
      Currently, a backend will reset it's PGXACT->xmin value when it doesn't
      have any registered snapshots left. That covered the common case that a
      transaction in read committed mode runs several queries, one after each
      other, as there would be no snapshots active between those queries.
      However, if you hold cursors across each of the query, we didn't get a
      chance to reset xmin.
      
      To make that better, keep all the registered snapshots in a pairing heap,
      ordered by xmin so that it's always quick to find the snapshot with the
      smallest xmin. That allows us to advance PGXACT->xmin whenever the oldest
      snapshot is deregistered, even if there are others still active.
      
      Per discussion originally started by Jeff Davis back in 2009 and more
      recently by Robert Haas.
      94028691
    • T
      Improve new caching logic in tbm_add_tuples(). · 779fdcde
      Tom Lane 提交于
      For no significant extra complexity, we can cache knowledge that the
      target page is lossy, and save a hash_search per iteration in that
      case as well.  This probably makes little difference, since the extra
      rechecks that must occur when pages are lossy are way more expensive
      than anything we can save here ... but we might as well do it if we're
      going to cache anything.
      779fdcde
    • A
      Make tbm_add_tuples more efficient by caching the last acccessed page. · f5ae3ba4
      Andres Freund 提交于
      When adding a large number of tuples to a TID bitmap using
      tbm_add_tuples() sometimes a lot of time was spent looking up a page's
      entry in the bitmap's internal hashtable.
      
      Improve efficiency by caching the last accessed page, while iterating
      over the passed in tuples, hoping consecutive tuples will often be on
      the same page.  In many cases that's a good bet, and in the rest the
      added overhead isn't big.
      
      Discussion: 54479A85.8060309@sigaev.ru
      
      Author: Teodor Sigaev
      Reviewed-By: David Rowley
      f5ae3ba4
  6. 16 1月, 2015 6 次提交
    • H
      Another attempt at fixing Windows Norwegian locale. · aa1d2fc5
      Heikki Linnakangas 提交于
      Previous fix mapped "Norwegian (Bokmål)" locale, which contains a non-ASCII
      character, to the pure ASCII alias "norwegian-bokmal". However, it turns
      out that more recent versions of the CRT library, in particular MSVCR110
      (Visual Studio 2012), changed the behaviour of setlocale() so that if
      you pass "norwegian-bokmal" to setlocale, it returns "Norwegian_Norway".
      
      That meant trouble, when setlocale(..., NULL) first returned
      "Norwegian (Bokmål)_Norway", which we mapped to "norwegian-bokmal_Norway",
      but another call to setlocale(..., "norwegian-bokmal_Norway") returned
      "Norwegian_Norway". That caused PostgreSQL to think that they are different
      locales, and therefore not compatible. That caused initdb to fail at
      CREATE DATABASE.
      
      Older CRT versions seem to accept "Norwegian_Norway" too, so change the
      mapping to return "Norwegian_Norway" instead of "norwegian-bokmal".
      
      Backpatch to 9.2 like the previous attempt. We haven't made a release that
      includes the previous fix yet, so we don't need to worry about changing the
      locale of existing clusters from "norwegian-bokmal" to "Norwegian_Norway".
      (Doing any mapping like this at all requires changing the locale of
      existing databases; the release notes need to include instructions for
      that).
      aa1d2fc5
    • N
      Update "pg_regress --no-locale" for Darwin and Windows. · 28df6a0d
      Noah Misch 提交于
      Commit 894459e5 revealed this option to
      be broken for NLS builds on Darwin, but "make -C contrib/unaccent check"
      and the buildfarm client rely on it.  Fix that configuration by
      redefining the option to imply LANG=C on Darwin.  In passing, use LANG=C
      instead of LANG=en on Windows; since only postmaster startup uses that
      value, testers are unlikely to notice the change.  Back-patch to 9.0,
      like the predecessor commit.
      28df6a0d
    • T
      Fix use-of-already-freed-memory problem in EvalPlanQual processing. · c480cb9d
      Tom Lane 提交于
      Up to now, the "child" executor state trees generated for EvalPlanQual
      rechecks have simply shared the ResultRelInfo arrays used for the original
      execution tree.  However, this leads to dangling-pointer problems, because
      ExecInitModifyTable() is all too willing to scribble on some fields of the
      ResultRelInfo(s) even when it's being run in one of those child trees.
      This trashes those fields from the perspective of the parent tree, because
      even if the generated subtree is logically identical to what was in use in
      the parent, it's in a memory context that will go away when we're done
      with the child state tree.
      
      We do however want to share information in the direction from the parent
      down to the children; in particular, fields such as es_instrument *must*
      be shared or we'll lose the stats arising from execution of the children.
      So the simplest fix is to make a copy of the parent's ResultRelInfo array,
      but not copy any fields back at end of child execution.
      
      Per report from Manuel Kniep.  The added isolation test is based on his
      example.  In an unpatched memory-clobber-enabled build it will reliably
      fail with "ctid is NULL" errors in all branches back to 9.1, as a
      consequence of junkfilter->jf_junkAttNo being overwritten with $7f7f.
      This test cannot be run as-is before that for lack of WITH syntax; but
      I have no doubt that some variant of this problem can arise in older
      branches, so apply the code change all the way back.
      c480cb9d
    • H
      Fix thinko in re-setting wal_log_hints flag from a parameter-change record. · 49b04188
      Heikki Linnakangas 提交于
      The flag is supposed to be copied from the record. Same issue with
      track_commit_timestamps, but that's master-only.
      
      Report and fix by Petr Jalinek. Backpatch to 9.4, where wal_log_hints was
      added.
      49b04188
    • T
      Rearrange explain.c's API so callers need not embed sizeof(ExplainState). · 8e166e16
      Tom Lane 提交于
      The folly of the previous arrangement was just demonstrated: there's no
      convenient way to add fields to ExplainState without breaking ABI, even
      if callers have no need to touch those fields.  Since we might well need
      to do that again someday in back branches, let's change things so that
      only explain.c has to have sizeof(ExplainState) compiled into it.  This
      costs one extra palloc() per EXPLAIN operation, which is surely pretty
      negligible.
      8e166e16
    • T
      Improve performance of EXPLAIN with large range tables. · a5cd70dc
      Tom Lane 提交于
      As of 9.3, ruleutils.c goes to some lengths to ensure that table and column
      aliases used in its output are unique.  Of course this takes more time than
      was required before, which in itself isn't fatal.  However, EXPLAIN was set
      up so that recalculation of the unique aliases was repeated for each
      subexpression printed in a plan.  That results in O(N^2) time and memory
      consumption for large plan trees, which did not happen in older branches.
      
      Fortunately, the expensive work is the same across a whole plan tree,
      so there is no need to repeat it; we can do most of the initialization
      just once per query and re-use it for each subexpression.  This buys
      back most (not all) of the performance loss since 9.2.
      
      We need an extra ExplainState field to hold the precalculated deparse
      context.  That's no problem in HEAD, but in the back branches, expanding
      sizeof(ExplainState) seems risky because third-party extensions might
      have local variables of that struct type.  So, in 9.4 and 9.3, introduce
      an auxiliary struct to keep sizeof(ExplainState) the same.  We should
      refactor the APIs to avoid such local variables in future, but that's
      material for a separate HEAD-only commit.
      
      Per gripe from Alexey Bashtanov.  Back-patch to 9.3 where the issue
      was introduced.
      a5cd70dc
  7. 15 1月, 2015 6 次提交
    • R
      pg_standby: Avoid writing one byte beyond the end of the buffer. · 0b49642b
      Robert Haas 提交于
      Previously, read() might have returned a length equal to the buffer
      length, and then the subsequent store to buf[len] would write a
      zero-byte one byte past the end.  This doesn't seem likely to be
      a security issue, but there's some chance it could result in
      pg_standby misbehaving.
      
      Spotted by Coverity; patch by Michael Paquier, reviewed by me.
      0b49642b
    • A
      Blindly try to fix a warning in s_lock.h when compiling with gcc on HPPA. · 6cfd5086
      Andres Freund 提交于
      The possibly, depending on compiler settings, generated warning was
      "warning: `S_UNLOCK' redefined".
      
      The hppa spinlock implementation doesn't follow the rules of s_lock.h
      and provides a gcc specific implementation outside of the the part of
      the file that's supposed to do that.  It does so to avoid duplication
      between the HP compiler and gcc. That unfortunately means that
      S_UNLOCK is already defined when the HPPA specific section is reached.
      
      Undefine the generic fallback S_UNLOCK definition inside the HPPA
      section. That's far from pretty, but has the big advantage of being
      simple. If somebody is interested to fix this in a prettier way...
      
      This presumably got broken in the course of 0709b7ee.
      
      Discussion: 20150114225919.GY5245@awork2.anarazel.de
      
      Per complaint from Tom Lane.
      6cfd5086
    • R
      docs: Add missing <literal> markup. · 73a8f517
      Robert Haas 提交于
      Michael Paquier
      73a8f517
    • R
      vacuumlo: Avoid unlikely memory leak. · 4a0a5f21
      Robert Haas 提交于
      Spotted by Coverity.  This isn't likely to matter in practice, but
      there's no harm in fixing it.
      
      Michael Paquier
      4a0a5f21
    • A
      Add a default local latch for use in signal handlers. · 59f71a0d
      Andres Freund 提交于
      To do so, move InitializeLatchSupport() into the new common process
      initialization functions, and add a new global variable MyLatch.
      
      MyLatch is usable as soon InitPostmasterChild() has been called
      (i.e. very early during startup). Initially it points to a process
      local latch that exists in all processes. InitProcess/InitAuxiliaryProcess
      then replaces that local latch with PGPROC->procLatch. During shutdown
      the reverse happens.
      
      This is primarily advantageous for two reasons: For one it simplifies
      dealing with the shared process latch, especially in signal handlers,
      because instead of having to check for MyProc, MyLatch can be used
      unconditionally. For another, a later patch that makes FEs/BE
      communication use latches, now can rely on the existence of a latch,
      even before having gone through InitProcess.
      
      Discussion: 20140927191243.GD5423@alap3.anarazel.de
      59f71a0d
    • T
      Allow CFLAGS from configure's environment to override automatic CFLAGS. · 85a2a890
      Tom Lane 提交于
      Previously, configure would add any switches that it chose of its own
      accord to the end of the user-specified CFLAGS string.  Since most
      compilers process these left-to-right, this meant that configure's choices
      would override the user-specified flags in case of conflicts.  We'd rather
      that worked the other way around, so adjust the logic to put the user's
      string at the end not the beginning.
      
      There does not seem to be a need for a similar behavior change for CPPFLAGS
      or LDFLAGS: in those, the earlier switches tend to win (think -I or -L
      behavior) so putting the user's string at the front is fine.
      
      Backpatch to 9.4 but not earlier.  I'm not planning to run buildfarm member
      guar on older branches, and it seems a bit risky to change this behavior
      in long-stable branches.
      85a2a890
  8. 14 1月, 2015 4 次提交
    • T
      Remove duplicate specification of -Ae for HP-UX C compiler. · fd3d894e
      Tom Lane 提交于
      Autoconf has known about automatically selecting -Ae when needed for
      quite some time now, so remove the redundant addition in template/hpux.
      Noted while setting up buildfarm member pademelon.
      fd3d894e
    • A
      Remove some dead IsUnderPostmaster code from bootstrap.c. · 0139dea8
      Andres Freund 提交于
      Since commit 626eb021 has introduced the auxiliary process
      infrastructure, bootstrap_signals() was never used when forked from
      postmaster.
      
      Remove the IsUnderPostmaster specific code, and add a appropriate
      assertion.
      0139dea8
    • A
      Commonalize process startup code. · 31c45316
      Andres Freund 提交于
      Move common code, that was duplicated in every postmaster child/every
      standalone process, into two functions in miscinit.c.  Not only does
      that already result in a fair amount of net code reduction but it also
      makes it much easier to remove more duplication in the future. The
      prime motivation wasn't code deduplication though, but easier addition
      of new common code.
      31c45316
    • A
      Make logging_collector=on work with non-windows EXEC_BACKEND again. · 2be82dcf
      Andres Freund 提交于
      Commit b94ce6e8 reordered postmaster's startup sequence so that the
      tempfile directory is only cleaned up after all the necessary state
      for pg_ctl is collected.  Unfortunately the chosen location is after
      the syslogger has been started; which normally is fine, except for
      !WIN32 EXEC_BACKEND builds, which pass information to children via
      files in the temp directory.
      
      Move the call to RemovePgTempFiles() to just before the syslogger has
      started. That's the first child we fork.
      
      Luckily EXEC_BACKEND is pretty much only used by endusers on windows,
      which has a separate method to pass information to children. That
      means the real world impact of this bug is very small.
      
      Discussion: 20150113182344.GF12272@alap3.anarazel.de
      
      Backpatch to 9.1, just as the previous commit was.
      2be82dcf
  9. 13 1月, 2015 5 次提交
    • H
      Spell the X072 feature correctly, was missing "with". · e922a130
      Heikki Linnakangas 提交于
      Also use lower-case for a few more features, to be consistent with the
      others and with the SQL spec.
      e922a130
    • H
      Silence Coverity warnings about unused return values from pushJsonbValue() · e37d474f
      Heikki Linnakangas 提交于
      Similar warnings from backend were silenced earlier by commit c8315930,
      but there were a few more contrib/hstore.
      
      Michael Paquier
      e37d474f
    • A
      Add barriers to the latch code. · 14e8803f
      Andres Freund 提交于
      Since their introduction latches have required barriers in SetLatch
      and ResetLatch - but when they were introduced there wasn't any
      barrier abstraction. Instead latches were documented to rely on the
      callsites to provide barrier semantics.
      
      Now that the barrier support looks halfway complete, add the necessary
      barriers to both latch implementations.
      
      Also remove a now superflous lock acquisition from syncrep.c and a
      superflous (and insufficient) barrier from freelist.c. There might be
      other cases that can now be simplified, but those are the only ones
      I've seen on a quick scan.
      
      We might want to backpatch this at some later point, but right now the
      barrier infrastructure in the backbranches isn't totally on par with
      master.
      
      Discussion: 20150112154026.GB2092@awork2.anarazel.de
      14e8803f
    • A
      Allow latches to wait for socket writability without waiting for readability. · 4bad60e3
      Andres Freund 提交于
      So far WaitLatchOrSocket() required to pass in WL_SOCKET_READABLE as
      that solely was used to indicate error conditions, like EOF. Waiting
      for WL_SOCKET_WRITEABLE would have meant to busy wait upon socket
      errors.
      
      Adjust the API to signal errors by returning the socket as readable,
      writable or both, depending on WL_SOCKET_READABLE/WL_SOCKET_WRITEABLE
      being specified.  It would arguably be nicer to return WL_SOCKET_ERROR
      but that's not possible on platforms and would probably also result in
      more complex callsites.
      
      This previously had explicitly been forbidden in e42a21b9, as
      there was no strong use case at that point. We now are looking into
      making FE/BE communication use latches, so changing this makes sense.
      
      There also are some portability concerns because there cases of older
      platforms where select(2) is known to, in violation of POSIX, not
      return a socket as writable after the peer has closed it.  So far the
      platforms where that's the case provide a working poll(2). If we find
      one where that's not the case, we'll need to add a workaround for that
      platform.
      
      Discussion: 20140927191243.GD5423@alap3.anarazel.de
      Reviewed-By: Heikki Linnakangas, Noah Misch
      4bad60e3
    • H
      Fix typos in comment. · 3dfce376
      Heikki Linnakangas 提交于
      Plus some tiny wordsmithing of not-quite-typos.
      3dfce376