1. 03 1月, 2016 6 次提交
    • T
      Fix overly-strict assertions in spgtextproc.c. · 7157fe80
      Tom Lane 提交于
      spg_text_inner_consistent is capable of reconstructing an empty string
      to pass down to the next index level; this happens if we have an empty
      string coming in, no prefix, and a dummy node label.  (In practice, what
      is needed to trigger that is insertion of a whole bunch of empty-string
      values.)  Then, we will arrive at the next level with in->level == 0
      and a non-NULL (but zero length) in->reconstructedValue, which is valid
      but the Assert tests weren't expecting it.
      
      Per report from Andreas Seltenreich.  This has no impact in non-Assert
      builds, so should not be a problem in production, but back-patch to
      all affected branches anyway.
      
      In passing, remove a couple of useless variable initializations and
      shorten the code by not duplicating DatumGetPointer() calls.
      7157fe80
    • T
      Adjust back-branch release note description of commits a2a718b22 et al. · df35af2c
      Tom Lane 提交于
      As pointed out by Michael Paquier, recovery_min_apply_delay didn't exist
      in 9.0-9.3, making the release note text not very useful.  Instead make it
      talk about recovery_target_xid, which did exist then.
      
      9.0 is already out of support, but we can fix the text in the newer
      branches' copies of its release notes.
      df35af2c
    • T
      Make copyright.pl cope with nonstandard case choices in copyright notices. · de7c8dbe
      Tom Lane 提交于
      The need for this is shown by the files it missed in Bruce's recent run.
      I fixed it so that it will actually adjust the case when needed.
      
      In passing, also make it skip .po files, since those will just get
      overwritten anyway from the translation repository.
      de7c8dbe
    • T
      Update copyright for 2016 · 48c9f288
      Tom Lane 提交于
      On closer inspection, the reason copyright.pl was missing files is
      that it is looking for 'Copyright (c)' and they had 'Copyright (C)'.
      Fix that, and update a couple more that grepping for that revealed.
      48c9f288
    • T
      Update copyright for 2016 · ad08bf5c
      Tom Lane 提交于
      Manually fix some copyright lines missed by the automated script.
      ad08bf5c
    • B
      Update copyright for 2016 · ee943004
      Bruce Momjian 提交于
      Backpatch certain files through 9.1
      ee943004
  2. 02 1月, 2016 3 次提交
    • N
      Cover heap_page_prune_opt()'s cleanup lock tactic in README. · dfcd9cb3
      Noah Misch 提交于
      Jeff Janes, reviewed by Jim Nasby.
      dfcd9cb3
    • T
      Teach flatten_reloptions() to quote option values safely. · c7e27bec
      Tom Lane 提交于
      flatten_reloptions() supposed that it didn't really need to do anything
      beyond inserting commas between reloption array elements.  However, in
      principle the value of a reloption could be nearly anything, since the
      grammar allows a quoted string there.  Any restrictions on it would come
      from validity checking appropriate to the particular option, if any.
      
      A reloption value that isn't a simple identifier or number could thus lead
      to dump/reload failures due to syntax errors in CREATE statements issued
      by pg_dump.  We've gotten away with not worrying about this so far with
      the core-supported reloptions, but extensions might allow reloption values
      that cause trouble, as in bug #13840 from Kouhei Sutou.
      
      To fix, split the reloption array elements explicitly, and then convert
      any value that doesn't look like a safe identifier to a string literal.
      (The details of the quoting rule could be debated, but this way is safe
      and requires little code.)  While we're at it, also quote reloption names
      if they're not safe identifiers; that may not be a likely problem in the
      field, but we might as well try to be bulletproof here.
      
      It's been like this for a long time, so back-patch to all supported
      branches.
      
      Kouhei Sutou, adjusted some by me
      c7e27bec
    • T
      Add some more defenses against silly estimates to gincostestimate(). · 3c93a60f
      Tom Lane 提交于
      A report from Andy Colson showed that gincostestimate() was not being
      nearly paranoid enough about whether to believe the statistics it finds in
      the index metapage.  The problem is that the metapage stats (other than the
      pending-pages count) are only updated by VACUUM, and in the worst case
      could still reflect the index's original empty state even when it has grown
      to many entries.  We attempted to deal with that by scaling up the stats to
      match the current index size, but if nEntries is zero then scaling it up
      still gives zero.  Moreover, the proportion of pages that are entry pages
      vs. data pages vs. pending pages is unlikely to be estimated very well by
      scaling if the index is now orders of magnitude larger than before.
      
      We can improve matters by expanding the use of the rule-of-thumb estimates
      I introduced in commit 7fb008c5: if the index has grown by more
      than a cutoff amount (here set at 4X growth) since VACUUM, then use the
      rule-of-thumb numbers instead of scaling.  This might not be exactly right
      but it seems much less likely to produce insane estimates.
      
      I also improved both the scaling estimate and the rule-of-thumb estimate
      to account for numPendingPages, since it's reasonable to expect that that
      is accurate in any case, and certainly pages that are in the pending list
      are not either entry or data pages.
      
      As a somewhat separate issue, adjust the estimation equations that are
      concerned with extra fetches for partial-match searches.  These equations
      suppose that a fraction partialEntries / numEntries of the entry and data
      pages will be visited as a consequence of a partial-match search.  Now,
      it's physically impossible for that fraction to exceed one, but our
      estimate of partialEntries is mostly bunk, and our estimate of numEntries
      isn't exactly gospel either, so we could arrive at a silly value.  In the
      example presented by Andy we were coming out with a value of 100, leading
      to insane cost estimates.  Clamp the fraction to one to avoid that.
      
      Like the previous patch, back-patch to all supported branches; this
      problem can be demonstrated in one form or another in all of them.
      3c93a60f
  3. 01 1月, 2016 5 次提交
    • N
      Fix comments about WAL rule "write xlog before data" versus pg_multixact. · 3cd1ba14
      Noah Misch 提交于
      Recovery does not achieve its goal of zeroing all pg_multixact entries
      whose accompanying WAL records never reached disk.  Remove that claim
      and justify its expendability.  Detail the need for TrimMultiXact(),
      which has little in common with the TrimCLOG() rationale.  Merge two
      tightly-related comments.  Stop presenting pg_multixact as specific to
      heap_lock_tuple(); PostgreSQL 9.3 extended its use to heap_update().
      
      Noticed while investigating a report from Andres Freund.
      3cd1ba14
    • P
      doc: Remove redundant duplicate URLs from ulink elements · 253de19b
      Peter Eisentraut 提交于
      Empty ulink elements default to displaying the URL, so there is no need
      to specify the URL again.  This was already done for most occurrences,
      but some cases didn't follow this convention.
      253de19b
    • P
    • T
      Add a comment noting that FDWs don't have to implement EXCEPT or LIMIT TO. · 5f36096b
      Tom Lane 提交于
      postgresImportForeignSchema pays attention to IMPORT's EXCEPT and LIMIT TO
      options, but only as an efficiency hack, not for correctness' sake.  The
      FDW documentation does explain that, but someone using postgres_fdw.c
      as a coding guide might not remember it, so let's add a comment here.
      Per question from Regina Obe.
      5f36096b
    • T
      Fix ALTER OPERATOR to update dependencies properly. · 0dab5ef3
      Tom Lane 提交于
      Fix an oversight in commit 321eed5f: replacing an operator's
      selectivity functions needs to result in a corresponding update in
      pg_depend.  We have a function that can handle that, but it was not
      called by AlterOperator().
      
      To fix this without enlarging pg_operator.h's #include list beyond
      what clients can safely include, split off the function definitions
      into a new file pg_operator_fn.h, similarly to what we've done for
      some other catalog header files.  It's not entirely clear whether
      any client-side code needs to include pg_operator.h, but it seems
      prudent to assume that there is some such code somewhere.
      0dab5ef3
  4. 31 12月, 2015 2 次提交
    • T
      Dept of second thoughts: the !scan_all exit mustn't increase scanned_pages. · e5d06f2b
      Tom Lane 提交于
      In the extreme edge case where contended pages are the only ones that
      escape being scanned, the previous commit would have allowed us to think
      that relfrozenxid could be advanced, which is exactly wrong.
      e5d06f2b
    • T
      Avoid useless truncation attempts during VACUUM. · e8429082
      Tom Lane 提交于
      VACUUM can skip heap pages altogether when there's a run of consecutive
      pages that are all-visible according to the visibility map.  This causes it
      to not update its nonempty_pages count, just as if those pages were empty,
      which means that at the end we will think they are candidates for deletion.
      Thus, we may take the table's AccessExclusive lock only to find that no
      pages are really truncatable.  This usually causes no real problems on a
      master server, thanks to the lock being acquired only conditionally; but on
      hot-standby servers, the same lock must be acquired unconditionally which
      can result in unnecessary query cancellations.
      
      To improve matters, force examination of the table's last page whenever
      we reach there with a nonempty_pages count that would allow a truncation
      attempt.  If it's not empty, we'll advance nonempty_pages and thereby
      prevent the truncation attempt.
      
      If we are unable to acquire cleanup lock on that page, there's no need to
      force it, unless we're doing an anti-wraparound vacuum.  We can just check
      for tuples with a shared buffer lock and then give up.  (When we are doing
      an anti-wraparound vacuum, and decide it's okay to skip the page because it
      contains no freezable tuples, this patch still improves matters because
      nonempty_pages is properly updated, which it was not before.)
      
      Since only the last page is special-cased in this way, we might attempt a
      truncation that will release many fewer pages than the normal heuristic
      would suggest; at worst, only one page would be truncated.  But that seems
      all right, because the situation won't repeat during the next vacuum.
      The real problem with the old logic is that the useless truncation attempt
      happens every time we vacuum, so long as the state of the last few dozen
      pages doesn't change.
      
      This is a longstanding deficiency, but since the consequences aren't very
      severe in most scenarios, I'm not going to risk a back-patch.
      
      Jeff Janes and Tom Lane
      e8429082
  5. 30 12月, 2015 3 次提交
    • T
      Minor hacking on contrib/cube documentation. · e5e5267a
      Tom Lane 提交于
      Improve markup, particularly of the table of functions; add or improve
      examples for some of the functions; wordsmith some of the function
      descriptions.
      e5e5267a
    • T
      Add some comments about division of labor between rewriter and planner. · efe4c9d7
      Tom Lane 提交于
      The rationale for the way targetlist processing is done wasn't clearly
      stated anywhere, and I for one had forgotten some of the details.  Having
      just painfully re-learned them, add some breadcrumbs for the next person.
      efe4c9d7
    • T
      Put back one copyObject() in rewriteTargetView(). · fd195257
      Tom Lane 提交于
      Commit 6f8cb1e2 tried to centralize rewriteTargetView's copying
      of a target view's Query struct.  However, it ignored the fact that the
      jointree->quals field was used twice.  This only accidentally failed to
      fail immediately because the same ChangeVarNodes mutation is applied in
      both cases, so that we end up with logically identical expression trees
      for both uses (and, as the code stands, the second ChangeVarNodes call
      actually does nothing).  However, we end up linking *physically*
      identical expression trees into both an RTE's securityQuals list and
      the WithCheckOption list.  That's pretty dangerous, mainly because
      prepsecurity.c is utterly cavalier about further munging such structures
      without copying them first.
      
      There may be no live bug in HEAD as a consequence of the fact that we apply
      preprocess_expression in between here and prepsecurity.c, and that will
      make a copy of the tree anyway.  Or it may just be that the regression
      tests happen to not trip over it.  (I noticed this only because things
      fell over pretty badly when I tried to relocate the planner's call of
      expand_security_quals to before expression preprocessing.)  In any case
      it's very fragile because if anyone tried to make the securityQuals and
      WithCheckOption trees diverge before we reach preprocess_expression, it
      would not work.  The fact that the current code will preprocess
      securityQuals and WithCheckOptions lists at completely different times in
      different query levels does nothing to increase my trust that that can't
      happen.
      
      In view of the fact that 9.5.0 is almost upon us and the aforesaid commit
      has seen exactly zero field testing, the prudent course is to make an extra
      copy of the quals so that the behavior is not different from what has been
      in the field during beta.
      fd195257
  6. 29 12月, 2015 7 次提交
    • J
      Rename (new|old)estCommitTs to (new|old)estCommitTsXid · 241448b2
      Joe Conway 提交于
      The variables newestCommitTs and oldestCommitTs sound as if they are
      timestamps, but in fact they are the transaction Ids that correspond
      to the newest and oldest timestamps rather than the actual timestamps.
      Rename these variables to reflect that they are actually xids: to wit
      newestCommitTsXid and oldestCommitTsXid respectively. Also modify
      related code in a similar fashion, particularly the user facing output
      emitted by pg_controldata and pg_resetxlog.
      
      Complaint and patch by me, review by Tom Lane and Alvaro Herrera.
      Backpatch to 9.5 where these variables were first introduced.
      241448b2
    • T
      Code and docs review for cube kNN support. · 81ee726d
      Tom Lane 提交于
      Commit 33bd250f could have done with
      some more review:
      
      Adjust coding so that compilers unfamiliar with elog/ereport don't complain
      about uninitialized values.
      
      Fix misuse of PG_GETARG_INT16 to retrieve arguments declared as "integer"
      at the SQL level.  (This was evidently copied from cube_ll_coord and
      cube_ur_coord, but those were wrong too.)
      
      Fix non-style-guide-conforming error messages.
      
      Fix underparenthesized if statements, which pgindent would have made a
      hash of, and remove some unnecessary parens elsewhere.
      
      Run pgindent over new code.
      
      Revise documentation: repeated accretion of more operators without any
      rethinking of the text already there had left things in a bit of a mess.
      Merge all the cube operators into one table and adjust surrounding text
      appropriately.
      
      David Rowley and Tom Lane
      81ee726d
    • A
      Document brin_summarize_new_pages · ac443d10
      Alvaro Herrera 提交于
      Pointer out by Jeff Janes
      ac443d10
    • T
      Document the exponentiation operator as associating left to right. · 54aaafe9
      Tom Lane 提交于
      Common mathematical convention is that exponentiation associates right to
      left.  We aren't going to change the parser for this, but we could note
      it in the operator's description.  (It's already noted in the operator
      precedence/associativity table, but users might not look there.)
      Per bug #13829 from Henrik Pauli.
      54aaafe9
    • T
      Fix omission of -X (--no-psqlrc) in some psql invocations. · 870df2b3
      Tom Lane 提交于
      As of commit d5563d7d, psql -c no longer implies -X, but not all of
      our regression testing scripts had gotten that memo.
      
      To ensure consistency of results across different developers, make
      sure that *all* invocations of psql in all scripts in our tree
      use -X, even where this is not what previously happened.
      
      Michael Paquier and Tom Lane
      870df2b3
    • A
      doc: pg_committs -> pg_commit_ts · 151c4ffe
      Alvaro Herrera 提交于
      Reported by: Alain Laporte (#13836)
      151c4ffe
    • T
      Update documentation about pseudo-types. · 731dfc7d
      Tom Lane 提交于
      Tone down an overly strong statement about which pseudo-types PLs are
      likely to allow.  Add "event_trigger" to the list, as well as
      "pg_ddl_command" in 9.5/HEAD.  Back-patch to 9.3 where event_trigger
      was added.
      731dfc7d
  7. 28 12月, 2015 2 次提交
    • A
      Fix translation domain in pg_basebackup · fc995bfd
      Alvaro Herrera 提交于
      For some reason, we've been overlooking the fact that pg_receivexlog
      and pg_recvlogical are using wrong translation domains all along,
      so their output hasn't ever been translated.  The right domain is
      pg_basebackup, not their own executable names.
      
      Noticed by Ioseph Kim, who's been working on the Korean translation.
      
      Backpatch pg_receivexlog to 9.2 and pg_recvlogical to 9.4.
      fc995bfd
    • A
      Add forgotten CHECK_FOR_INTERRUPT calls in pgcrypto's crypt() · 743229a6
      Alvaro Herrera 提交于
      Both Blowfish and DES implementations of crypt() can take arbitrarily
      long time, depending on the number of rounds specified by the caller;
      make sure they can be interrupted.
      
      Author: Andreas Karlsson
      Reviewer: Jeff Janes
      
      Backpatch to 9.1.
      743229a6
  8. 27 12月, 2015 2 次提交
    • T
      Include typmod when complaining about inherited column type mismatches. · fec1ad94
      Tom Lane 提交于
      MergeAttributes() rejects cases where columns to be merged have the same
      type but different typmod, which is correct; but the error message it
      printed didn't show either typmod, which is unhelpful.  Changing this
      requires using format_type_with_typemod() in place of TypeNameToString(),
      which will have some minor side effects on the way some type names are
      printed, but on balance this is an improvement: the old code sometimes
      printed one type according to one set of rules and the other type according
      to the other set, which could be confusing in its own way.
      
      Oddly, there were no regression test cases covering any of this behavior,
      so add some.
      
      Complaint and fix by Amit Langote
      fec1ad94
    • T
      Fix brin_summarize_new_values() to check index type and ownership. · 3d2b31e3
      Tom Lane 提交于
      brin_summarize_new_values() did not check that the passed OID was for
      an index at all, much less that it was a BRIN index, and would fail in
      obscure ways if it wasn't (possibly damaging data first?).  It also
      lacked any permissions test; by analogy to VACUUM, we should only allow
      the table's owner to summarize.
      
      Noted by Jeff Janes, fix by Michael Paquier and me
      3d2b31e3
  9. 25 12月, 2015 3 次提交
  10. 24 12月, 2015 7 次提交
    • T
      Docs: fix erroneously-given function name. · 71dd092c
      Tom Lane 提交于
      pg_replication_session_is_setup() exists nowhere; apparently this is
      meant to refer to pg_replication_origin_session_is_setup().
      
      Adrien Nayrat
      71dd092c
    • T
      Fix factual and grammatical errors in comments for struct _tableInfo. · 96cd61a1
      Tom Lane 提交于
      Amit Langote, further adjusted by me
      96cd61a1
    • T
      Docs typo fix. · bee172fc
      Tom Lane 提交于
      Michael Paquier
      bee172fc
    • T
      Avoid VACUUM FULL altogether in initdb. · 01e386a3
      Tom Lane 提交于
      Commit ed7b3b38 purported to remove initdb's use of VACUUM FULL,
      as had been agreed to in a pghackers discussion back in Dec 2014.
      But it missed this one ...
      01e386a3
    • T
      Improve handling of password reuse in src/bin/scripts programs. · ff402ae1
      Tom Lane 提交于
      This reverts most of commit 83dec5a7 in favor of having connectDatabase()
      store the possibly-reusable password in a static variable, similar to the
      coding we've had for a long time in pg_dump's version of that function.
      To avoid possible problems with unwanted password reuse, make callers
      specify whether it's reasonable to attempt to re-use the password.
      This is a wash for cases where re-use isn't needed, but it is far simpler
      for callers that do want that.  Functionally there should be no difference.
      
      Even though we're past RC1, it seems like a good idea to back-patch this
      into 9.5, like the prior commit.  Otherwise, if there are any third-party
      users of connectDatabase(), they'll have to deal with an API change in
      9.5 and then another one in 9.6.
      
      Michael Paquier
      ff402ae1
    • T
      In pg_dump, remember connection passwords no matter how we got them. · 1aa41e3e
      Tom Lane 提交于
      When pg_dump prompts the user for a password, it remembers the password
      for possible re-use by parallel worker processes.  However, libpq might
      have extracted the password from a connection string originally passed
      as "dbname".  Since we don't record the original form of dbname but
      break it down to host/port/etc, the password gets lost.  Fix that by
      retrieving the actual password from the PGconn.
      
      (It strikes me that this whole approach is rather broken, as it will also
      lose other information such as options that might have been present in
      the connection string.  But we'll leave that problem for another day.)
      
      In passing, get rid of rather silly use of malloc() for small fixed-size
      arrays.
      
      Back-patch to 9.3 where parallel pg_dump was introduced.
      
      Report and fix by Zeus Kronion, adjusted a bit by Michael Paquier and me
      1aa41e3e
    • R
      Read from the same worker repeatedly until it returns no tuple. · bc7fcab5
      Robert Haas 提交于
      The original coding read tuples from workers in round-robin fashion,
      but performance testing shows that it works much better to read enough
      to empty one queue before moving on to the next.  I believe the
      reason for this is that, with the old approach, we could easily wake
      up a worker repeatedly to write only one new tuple into the shm_mq
      each time.  With this approach, by the time the process gets scheduled,
      it has a decent chance of being able to fill the entire buffer in
      one go.
      
      Patch by me.  Dilip Kumar helped with performance testing.
      bc7fcab5