1. 31 Aug, 2015 6 commits
    • Tom Lane's avatar
      Actually, it's not that hard to merge the Windows pqsignal code ... · f333204b
      Tom Lane authored
      ... just need to typedef sigset_t and provide sigemptyset/sigfillset,
      which are easy enough.
      f333204b
    • Tom Lane's avatar
      Remove theoretically-unnecessary special case for icc. · 2c713d6e
      Tom Lane authored
      Intel's icc is generally able to swallow asm blocks written for gcc.
      We have a few places that don't seem to know that, though.  Experiment
      with removing the special case for icc in ia64_get_bsp(); if the buildfarm
      likes this, I'll try more cleanup.  This is a good test case because it
      involves a "stop" notation that seems like it might not be very portable.
      2c713d6e
    • Tom Lane's avatar
      Remove support for Unix systems without the POSIX signal APIs. · a65e0864
      Tom Lane authored
      Remove configure's checks for HAVE_POSIX_SIGNALS, HAVE_SIGPROCMASK, and
      HAVE_SIGSETJMP.  These APIs are required by the Single Unix Spec v2
      (POSIX 1997), which we generally consider to define our minimum required
      set of Unix APIs.  Moreover, no buildfarm member has reported not having
      them since 2012 or before, which means that even if the code is still live
      somewhere, it's untested --- and we've made plenty of signal-handling
      changes of late.  So just take these APIs as given and save the cycles for
      configure probes for them.
      
      However, we can't remove as much C code as I'd hoped, because the Windows
      port evidently still uses the non-POSIX code paths for signal masking.
      Since we're largely emulating these BSD-style APIs for Windows anyway, it
      might be a good thing to switch over to POSIX-like notation and thereby
      remove a few more #ifdefs.  But I'm not in a position to code or test that.
      In the meantime, we can at least make things a bit more transparent by
      testing for WIN32 explicitly in these places.
      a65e0864
    • Bruce Momjian's avatar
      psql: print longtable as a possible \pset option · 8f7d044b
      Bruce Momjian authored
      For some reason this message was not updated when the longtable option
      was added.
      
      Backpatch through 9.3
      8f7d044b
    • Magnus Hagander's avatar
      Small grammar fix · 93370076
      Magnus Hagander authored
      Josh Kupershmidt
      93370076
    • Tom Lane's avatar
      Remove long-dead support for platforms without sig_atomic_t. · 0f19d0f1
      Tom Lane authored
      C89 requires <signal.h> to define sig_atomic_t, and there is no evidence
      in the buildfarm that any supported platforms don't comply.  Remove the
      configure test to stop wasting build cycles on a purely historical issue.
      (Once upon a time, we cared about supporting C89-compliant compilers on
      machines with pre-C89 system headers, but that use-case has been dead for
      quite a few years.)
      
      I have some other fixes planned in this area, but let's start with this
      to see if the buildfarm produces any surprising results.
      0f19d0f1
  2. 30 Aug, 2015 1 commit
    • Joe Conway's avatar
      Fix sepgsql regression tests. · 794e2558
      Joe Conway authored
      The regression tests for sepgsql were broken by changes in the
      base distro as-shipped policies. Specifically, definition of
      unconfined_t in the system default policy was changed to bypass
      multi-category rules, which the regression test depended on.
      Fix that by defining a custom privileged domain
      (sepgsql_regtest_superuser_t) and using it instead of system's
      unconfined_t domain. The new sepgsql_regtest_superuser_t domain
      performs almost like the current unconfined_t, but restricted by
      multi-category policy as the traditional unconfined_t was.
      
      The custom policy module is a self defined domain, and so should not
      be affected by related future system policy changes. However, it still
      uses the unconfined_u:unconfined_r pair for selinux-user and role.
      Those definitions have not been changed for several years and seem
      less risky to rely on than the unconfined_t domain. Additionally, if
      we define custom user/role, they would need to be manually defined
      at the operating system level, adding more complexity to an already
      non-standard and complex regression test.
      
      Back-patch to 9.3. The regression tests will need more work before
      working correctly on 9.2. Starting with 9.2, sepgsql has had dependencies
      on libselinux versions that are only available on newer distros with
      the changed set of policies (e.g. RHEL 7.x). On 9.1 sepgsql works
      fine with the older distros with original policy set (e.g. RHEL 6.x),
      and on which the existing regression tests work fine. We might want
      eventually change 9.1 sepgsql regression tests to be more independent
      from the underlying OS policies, however more work will be needed to
      make that happen and it is not clear that it is worth the effort.
      
      Kohei KaiGai with review by Adam Brightwell and me, commentary by
      Stephen, Alvaro, Tom, Robert, and others.
      794e2558
  3. 29 Aug, 2015 1 commit
    • Tom Lane's avatar
      Fix s_lock.h PPC assembly code to be compatible with native AIX assembler. · c41a1215
      Tom Lane authored
      On recent AIX it's necessary to configure gcc to use the native assembler
      (because the GNU assembler hasn't been updated to handle AIX 6+).  This
      caused PG builds to fail with assembler syntax errors, because we'd try
      to compile s_lock.h's gcc asm fragment for PPC, and that assembly code
      relied on GNU-style local labels.  We can't substitute normal labels
      because it would fail in any file containing more than one inlined use of
      tas().  Fortunately, that code is stable enough, and the PPC ISA is simple
      enough, that it doesn't seem like too much of a maintenance burden to just
      hand-code the branch offsets, removing the need for any labels.
      
      Note that the AIX assembler only accepts "$" for the location counter
      pseudo-symbol.  The usual GNU convention is "."; but it appears that all
      versions of gas for PPC also accept "$", so in theory this patch will not
      break any other PPC platforms.
      
      This has been reported by a few people, but Steve Underwood gets the credit
      for being the first to pursue the problem far enough to understand why it
      was failing.  Thanks also to Noah Misch for additional testing.
      c41a1215
  4. 28 Aug, 2015 3 commits
  5. 27 Aug, 2015 1 commit
  6. 26 Aug, 2015 4 commits
    • Tom Lane's avatar
      Speed up HeapTupleSatisfiesMVCC() by replacing the XID-in-progress test. · 8a7d0701
      Tom Lane authored
      Rather than consulting TransactionIdIsInProgress to see if an in-doubt
      transaction is still running, consult XidInMVCCSnapshot.  That requires
      the same or fewer cycles as TransactionIdIsInProgress, and what's far
      more important, it does not access shared data structures (at least in the
      no-subxip-overflow case) so it incurs no contention.  Furthermore, we would
      have had to check XidInMVCCSnapshot anyway before deciding that we were
      allowed to see the tuple.
      
      There should never be a case where XidInMVCCSnapshot says a transaction is
      done while TransactionIdIsInProgress says it's still running.  The other
      way around is quite possible though.  The result of that difference is that
      HeapTupleSatisfiesMVCC will no longer set hint bits on tuples whose source
      transactions recently finished but are still running according to our
      snapshot.  The main cost of delaying the hint-bit setting is that repeated
      visits to a just-committed tuple, by transactions none of which have
      snapshots new enough to see the source transaction as done, will each
      execute TransactionIdIsCurrentTransactionId, which they need not have done
      before.  However, that's normally just a small overhead, and no contention
      costs are involved; so it seems well worth the benefit of removing
      TransactionIdIsInProgress calls during the life of the source transaction.
      
      The core idea for this patch is due to Jeff Janes, who also did the legwork
      proving its performance benefits.  His original proposal was to swap the
      order of TransactionIdIsInProgress and XidInMVCCSnapshot calls in some
      cases within HeapTupleSatisfiesMVCC.  That was a bit messy though.
      The idea that we could dispense with calling TransactionIdIsInProgress
      altogether was mine, as is the final patch.
      8a7d0701
    • Bruce Momjian's avatar
      release notes: abbreviated key speedup only for varchar/text · 16d4f94e
      Bruce Momjian authored
      Report by Peter Geoghegan
      
      Backpatch through 9.5
      16d4f94e
    • Bruce Momjian's avatar
      9.5 release notes: mention lack of char() sort improvements · 8190f2df
      Bruce Momjian authored
      Report by Peter Geoghegan
      
      Backpatch through 9.5
      8190f2df
    • Joe Conway's avatar
      Reestablish alignment of pg_controldata output. · 56c8ce8f
      Joe Conway authored
      Until 9.4, pg_controldata output was all aligned. At some point
      during 9.5 development, a new item was added, namely
      "Current track_commit_timestamp setting:" which is two characters
      too long to be aligned with the rest of the output. Fix this by
      removing the noise word "Current" and adding the requisite number
      of padding spaces. Since the six preceding items are also similar
      in nature, remove "Current" and pad those as well in order to
      maintain overall consistency. Backpatch to 9.5 where new offending
      item was added.
      56c8ce8f
  7. 25 Aug, 2015 4 commits
    • Tom Lane's avatar
      Docs: be explicit about datatype matching for lead/lag functions. · 94324abf
      Tom Lane authored
      The default argument, if given, has to be of exactly the same datatype
      as the first argument; but this was not stated in so many words, and
      the error message you get about it might not lead your thought in the
      right direction.  Per bug #13587 from Robert McGehee.
      
      A quick scan says that these are the only two built-in functions with two
      anyelement arguments and no other polymorphic arguments.  There are plenty
      of cases of, eg, anyarray and anyelement, but those seem less likely to
      confuse.  For instance this doesn't seem terribly hard to figure out:
      "function array_remove(integer[], numeric) does not exist".  So I've
      contented myself with fixing these two cases.
      94324abf
    • Tom Lane's avatar
      Further tweak wording of error messages about bad CONTINUE/EXIT statements. · 781ed2bf
      Tom Lane authored
      Per discussion, a little more verbosity seems called for.
      781ed2bf
    • Tom Lane's avatar
      Limit the verbosity of memory context statistics dumps. · 7b5ef8f2
      Tom Lane authored
      We had a report from Stefan Kaltenbrunner of a case in which postmaster
      log files overran available disk space because multiple backends spewed
      enormous context stats dumps upon hitting an out-of-memory condition.
      Given the lack of similar reports, this isn't a common problem, but it
      still seems worth doing something about.  However, we don't want to just
      blindly truncate the output, because that might prevent diagnosis of OOM
      problems.  What seems like a workable compromise is to limit the dump to
      100 child contexts per parent, and summarize the space used within any
      additional child contexts.  That should help because practical cases where
      the dump gets long will typically be huge numbers of siblings under the
      same parent context; while the additional debugging value from seeing
      details about individual siblings beyond 100 will not be large, we hope.
      Anyway it doesn't take much code or memory space to do this, so let's try
      it like this and see how things go.
      
      Since the summarization mechanism requires passing totals back up anyway,
      I took the opportunity to add a "grand total" line to the end of the
      printout.
      7b5ef8f2
    • Tom Lane's avatar
      Fix potential platform dependence in gist regression test. · e39c4afc
      Tom Lane authored
      The results of the KNN-search test cases were indeterminate, as they asked
      the system to sort pairs of points that are exactly equidistant from the
      query reference point.  It's a bit surprising that we've seen no
      platform-specific failures from this in the buildfarm.  Perhaps IEEE-float
      math is well enough standardized that no such failures will ever occur on
      supported platforms ... but since this entire regression test has yet to be
      shipped in any non-alpha release, that seems like an unduly optimistic
      assumption.  Tweak the queries so that the correct output is uniquely
      defined.
      
      (The other queries in this test are also underdetermined; but it looks like
      they are regurgitating index rows in insertion order, so for the moment
      assume that that behavior is stable enough.)
      
      Per Greg Stark's experiments with VAX.  Back-patch to 9.5 where this test
      script was introduced.
      e39c4afc
  8. 23 Aug, 2015 6 commits
    • Tom Lane's avatar
      Tweak wording of syntax error messages about bad CONTINUE/EXIT statements. · 18391a8f
      Tom Lane authored
      Try to avoid any possible confusion about what these messages mean.
      18391a8f
    • Tom Lane's avatar
      Reduce number of bytes examined by convert_one_string_to_scalar(). · aad663a0
      Tom Lane authored
      Previously, convert_one_string_to_scalar() would examine up to 20 bytes of
      the input string, producing a scalar conversion with theoretical precision
      far greater than is of any possible use considering the other limitations
      on the accuracy of the resulting selectivity estimate.  (I think this
      choice might pre-date the caller-level logic that strips any common prefix
      of the strings; before that, there could have been value in scanning the
      strings far enough to use all the precision available in a double.)
      
      Aside from wasting cycles to little purpose, this choice meant that the
      "denom" variable could grow to as much as 256^21 = 3.74e50, which could
      overflow in some non-IEEE float arithmetics.  While we don't really support
      any machines with non-IEEE arithmetic anymore, this still seems like quite
      an unnecessary platform dependency.  Limit the scan to 12 bytes instead,
      thus limiting "denom" to 256^13 = 2.03e31, a value more likely to be
      computable everywhere.
      
      Per testing by Greg Stark, which showed overflow failures in our standard
      regression tests on VAX.
      aad663a0
    • Tom Lane's avatar
      Avoid use of float arithmetic in bipartite_match.c. · 44ed65a5
      Tom Lane authored
      Since the distances used in this algorithm are small integers (not more
      than the size of the U set, in fact), there is no good reason to use float
      arithmetic for them.  Use short ints instead: they're smaller, faster, and
      require no special portability assumptions.
      
      Per testing by Greg Stark, which disclosed that the code got into an
      infinite loop on VAX for lack of IEEE-style float infinities.  We don't
      really care all that much whether Postgres can run on a VAX anymore,
      but there seems sufficient reason to change this code anyway.
      
      In passing, make a few other small adjustments to make the code match
      usual Postgres coding style a bit better.
      44ed65a5
    • Kevin Grittner's avatar
      Fix typo in C comment. · 5956b7f9
      Kevin Grittner authored
      Merlin Moncure
      Backpatch to 9.5, where the misspelling was introduced
      5956b7f9
    • Peter Eisentraut's avatar
      Improve whitespace · b3862715
      Peter Eisentraut authored
      b3862715
    • Peter Eisentraut's avatar
      Improve spelling · 6103b3f3
      Peter Eisentraut authored
      6103b3f3
  9. 22 Aug, 2015 3 commits
    • Heikki Linnakangas's avatar
      Add hint to run "pgbench -i", if test tables don't exist. · e7b90c52
      Heikki Linnakangas authored
      Fabien Coelho, reviewed by Julien Rouhaud
      e7b90c52
    • Tom Lane's avatar
      Avoid O(N^2) behavior when enlarging SPI tuple table in spi_printtup(). · 6e5d9f27
      Tom Lane authored
      For no obvious reason, spi_printtup() was coded to enlarge the tuple
      pointer table by just 256 slots at a time, rather than doubling the size at
      each reallocation, as is our usual habit.  For very large SPI results, this
      makes for O(N^2) time spent in repalloc(), which of course soon comes to
      dominate the runtime.  Use the standard doubling approach instead.
      
      This is a longstanding performance bug, so back-patch to all active
      branches.
      
      Neil Conway
      6e5d9f27
    • Tom Lane's avatar
      Detect mismatched CONTINUE and EXIT statements at plpgsql compile time. · fcdfce68
      Tom Lane authored
      With a bit of tweaking of the compile namestack data structure, we can
      verify at compile time whether a CONTINUE or EXIT is legal.  This is
      surely better than leaving it to runtime, both because earlier is better
      and because we can issue a proper error pointer.  Also, we can get rid
      of the ad-hoc old way of detecting the problem, which only took care of
      CONTINUE not EXIT.
      
      Jim Nasby, adjusted a bit by me
      fcdfce68
  10. 21 Aug, 2015 8 commits
    • Stephen Frost's avatar
      Clean up roles from roleattributes test · 072710df
      Stephen Frost authored
      Having the roles remain after the test ends up causing repeated 'make
      installcheck' runs to fail and may be risky from a security perspective
      also, so remove them at the end of the test.
      072710df
    • Alvaro Herrera's avatar
      Do not allow *timestamp to be passed as NULL · e68be16b
      Alvaro Herrera authored
      The code had bugs that would cause crashes if NULL was passed as that
      argument (originally intended to mean not to bother returning its
      value), and after inspection it turns out that nothing seems interested
      in the case that *ts is NULL anyway.  Therefore, remove the partial
      checks intended to support that case.
      
      Author: Michael Paquier
      though I didn't include a proposed Assert.
      
      Backpatch to 9.5.
      e68be16b
    • Alvaro Herrera's avatar
      Remove ExecGetScanType function · 8c3d63c5
      Alvaro Herrera authored
      This became unused in a191a169.
      8c3d63c5
    • Tom Lane's avatar
      Fix plpython crash when returning string representation of a RECORD result. · f469f634
      Tom Lane authored
      PLyString_ToComposite() blithely overwrote proc->result.out.d, even though
      for a composite result type the other union variant proc->result.out.r is
      the one that should be valid.  This could result in a crash if out.r had
      in fact been filled in (proc->result.is_rowtype == 1) and then somebody
      later attempted to use that data; as per bug #13579 from Paweł Michalak.
      
      Just to add insult to injury, it didn't work for RECORD results anyway,
      because record_in() would refuse the case.
      
      Fix by doing the I/O function lookup in a local PLyTypeInfo variable,
      as we were doing already in PLyObject_ToComposite().  This is not a great
      technique because any fn_extra data allocated by the input function will
      be leaked permanently (thanks to using TopMemoryContext as fn_mcxt).
      But that's a pre-existing issue that is much less serious than a crash,
      so leave it to be fixed separately.
      
      This bug would be a potential security issue, except that plpython is
      only available to superusers and the crash requires coding the function
      in a way that didn't work before today's patches.
      
      Add regression test cases covering all the supported methods of converting
      composite results.
      
      Back-patch to 9.1 where the faulty coding was introduced.
      f469f634
    • Tom Lane's avatar
      Allow record_in() and record_recv() to work for transient record types. · 09b3d272
      Tom Lane authored
      If we have the typmod that identifies a registered record type, there's no
      reason that record_in() should refuse to perform input conversion for it.
      Now, in direct SQL usage, record_in() will always be passed typmod = -1
      with type OID RECORDOID, because no typmodin exists for type RECORD, so the
      case can't arise.  However, some InputFunctionCall users such as PLs may be
      able to supply the right typmod, so we should allow this to support them.
      
      Note: the previous coding and comment here predate commit 59c016aa.
      There has been no case since 8.1 in which the passed type OID wouldn't be
      valid; and if it weren't, this error message wouldn't be apropos anyway.
      Better to let lookup_rowtype_tupdesc complain about it.
      
      Back-patch to 9.1, as this is necessary for my upcoming plpython fix.
      I'm committing it separately just to make it a bit more visible in the
      commit history.
      09b3d272
    • Stephen Frost's avatar
      Rename 'cmd' to 'cmd_name' in CreatePolicyStmt · 3c997887
      Stephen Frost authored
      To avoid confusion, rename CreatePolicyStmt's 'cmd' to 'cmd_name',
      parse_policy_command's 'cmd' to 'polcmd', and AlterPolicy's 'cmd_datum'
      to 'polcmd_datum', per discussion with Noah and as a follow-up to his
      correction of copynodes/equalnodes handling of the CreatePolicyStmt
      'cmd' field.
      
      Back-patch to 9.5 where the CreatePolicyStmt was introduced, as we
      are still only in alpha.
      3c997887
    • Stephen Frost's avatar
      In AlterRole, make bypassrls an int · 7ec8296e
      Stephen Frost authored
      When reworking bypassrls in AlterRole to operate the same way the other
      attribute handling is done, I missed that the variable was incorrectly a
      bool rather than an int.  This meant that on platforms with an unsigned
      char, we could end up with incorrect behavior during ALTER ROLE.
      
      Pointed out by Andres thanks to tests he did changing our bool to be the
      one from stdbool.h which showed this and a number of other issues.
      
      Add regression tests to test CREATE/ALTER role for the various role
      attributes.  Arrange to leave roles behind for testing pg_dumpall, but
      none which have the LOGIN attribute.
      
      Back-patch to 9.5 where the AlterRole bug exists.
      7ec8296e
    • Peter Eisentraut's avatar
      doc: Whitespace and formatting fixes · 90a1d0aa
      Peter Eisentraut authored
      90a1d0aa
  11. 20 Aug, 2015 1 commit
  12. 19 Aug, 2015 2 commits
    • Peter Eisentraut's avatar
      Update config.guess and config.sub · 960ea971
      Peter Eisentraut authored
      960ea971
    • Kevin Grittner's avatar
      Fix bug in calculations of hash join buckets. · 1cac8c98
      Kevin Grittner authored
      Commit 8cce08f1 used a left-shift
      on a literal of 1 that could (in large allocations) be shifted by
      31 or more bits.  This was assigned to a local variable that was
      already declared to be a long to protect against overruns of int,
      but the literal in this shift needs to be declared long to allow it
      to work correctly in some compilers.
      
      Backpatch to 9.5, where the bug was introduced.
      
      Report and patch by KaiGai Kohei, slighly modified based on
      discussion.
      1cac8c98