1. 08 1月, 2016 9 次提交
    • T
      Marginal cleanup of GROUPING SETS code in grouping_planner(). · a54676ac
      Tom Lane 提交于
      Improve comments and make it a shade less messy.  I think we might want
      to move all of this somewhere else later, but it needs to be more
      readable first.
      
      In passing, re-pgindent the file, affecting some recently-added comments
      concerning parallel query planning.
      a54676ac
    • T
      Delay creation of subplan tlist until after create_plan(). · c44d0138
      Tom Lane 提交于
      Once upon a time it was necessary for grouping_planner() to determine
      the tlist it wanted from the scan/join plan subtree before it called
      query_planner(), because query_planner() would actually make a Plan using
      that.  But we refactored things a long time ago to delay construction of
      the Plan tree till later, so there's no need to build that tlist until
      (and indeed unless) we're ready to plaster it onto the Plan.  The only
      thing query_planner() cares about is what Vars are going to be needed for
      the tlist, and it can perfectly well get that by looking at the real tlist
      rather than some masticated version.
      
      Well, actually, there is one minor glitch in that argument, which is that
      make_subplanTargetList also adds Vars appearing only in HAVING to the
      tlist it produces.  So now we have to account for HAVING explicitly in
      build_base_rel_tlists.  But that just adds a few lines of code, and
      I doubt it moves the needle much on processing time; we might be doing
      pull_var_clause() twice on the havingQual, but before we had it scanning
      dummy tlist entries instead.
      
      This is a very small down payment on rationalizing grouping_planner
      enough so it can be refactored.
      c44d0138
    • A
      Fix order of arguments to va_start() · f81c966d
      Alvaro Herrera 提交于
      f81c966d
    • T
      Fix unobvious interaction between -X switch and subdirectory creation. · b41fb650
      Tom Lane 提交于
      Turns out the only reason initdb -X worked is that pg_mkdir_p won't
      whine if you point it at something that's a symlink to a directory.
      Otherwise, the attempt to create pg_xlog/ just like all the other
      subdirectories would have failed.  Let's be a little more explicit
      about what's happening.  Oversight in my patch for bug #13853
      (mea culpa for not testing -X ...)
      b41fb650
    • A
      Add win32security to LIBOBJS · fa838b55
      Alvaro Herrera 提交于
      This seems to fix Mingw's compile that was broken in a9676139, as
      evidenced by buildfarm.
      fa838b55
    • T
      Use plain mkdir() not pg_mkdir_p() to create subdirectories of PGDATA. · 33b054bc
      Tom Lane 提交于
      When we're creating subdirectories of PGDATA during initdb, we know darn
      well that the parent directory exists (or should exist) and that the new
      subdirectory doesn't (or shouldn't).  There is therefore no need to use
      anything more complicated than mkdir().  Using pg_mkdir_p() just opens us
      up to unexpected failure modes, such as the one exhibited in bug #13853
      from Nuri Boardman.  It's not very clear why pg_mkdir_p() went wrong there,
      but it is clear that we didn't need to be trying to create parent
      directories in the first place.  We're not even saving any code, as proven
      by the fact that this patch nets out at minus five lines.
      
      Since this is a response to a field bug report, back-patch to all branches.
      33b054bc
    • A
      pgstat: add WAL receiver status view & SRF · b1a9bad9
      Alvaro Herrera 提交于
      This new view provides insight into the state of a running WAL receiver
      in a HOT standby node.
      The information returned includes the PID of the WAL receiver process,
      its status (stopped, starting, streaming, etc), start LSN and TLI, last
      received LSN and TLI, timestamp of last message send and receipt, latest
      end-of-WAL LSN and time, and the name of the slot (if any).
      
      Access to the detailed data is only granted to superusers; others only
      get the PID.
      
      Author: Michael Paquier
      Reviewer: Haribabu Kommi
      b1a9bad9
    • T
      Remove vestigial CHECK_FOR_INTERRUPTS call. · 6b1a837f
      Tom Lane 提交于
      Commit e710b65c inserted code in md5_crypt_verify to disable and later
      re-enable interrupts, with a CHECK_FOR_INTERRUPTS call as part of the
      second step, to process any interrupts that had been held off.  Commit
      6647248e removed the interrupt disable/re-enable code, but left behind
      the CHECK_FOR_INTERRUPTS, even though this is now an entirely random,
      pointless place for one.  md5_crypt_verify doesn't run long enough to
      need such a check, and if it did, this would still be the wrong place
      to put one.
      6b1a837f
    • T
      Provide more detail in postmaster log for password authentication failures. · 5e0b5dca
      Tom Lane 提交于
      We tell people to examine the postmaster log if they're unsure why they are
      getting auth failures, but actually only a few relatively-uncommon failure
      cases were given their own log detail messages in commit 64e43c59.
      Expand on that so that every failure case detected within md5_crypt_verify
      gets a specific log detail message.  This should cover pretty much every
      ordinary password auth failure cause.
      
      So far I've not noticed user demand for a similar level of auth detail
      for the other auth methods, but sooner or later somebody might want to
      work on them.  This is not that patch, though.
      5e0b5dca
  2. 07 1月, 2016 3 次提交
    • A
      Windows: Make pg_ctl reliably detect service status · a9676139
      Alvaro Herrera 提交于
      pg_ctl is using isatty() to verify whether the process is running in a
      terminal, and if not it sends its output to Windows' Event Log ... which
      does the wrong thing when the output has been redirected to a pipe, as
      reported in bug #13592.
      
      To fix, make pg_ctl use the code we already have to detect service-ness:
      in the master branch, move src/backend/port/win32/security.c to src/port
      (with suitable tweaks so that it runs properly in backend and frontend
      environments); pg_ctl already has access to pgport so it Just Works.  In
      older branches, that's likely to cause trouble, so instead duplicate the
      required code in pg_ctl.c.
      
      Author: Michael Paquier
      Bug report and diagnosis: Egon Kocjan
      Backpatch: all supported branches
      a9676139
    • T
      In initdb's post-bootstrap phase, drop temp tables explicitly. · dad08994
      Tom Lane 提交于
      Although these temp tables will get removed from template1 at the end of
      the standalone-backend run, that's too late to keep them from getting
      copied into the template0 and postgres databases, now that we use only a
      single backend run for the whole sequence.  While no real harm is done
      by the extra copies (since they'd be deleted on first use of the temp
      schema), it's still unsightly, and it would mean some wasted cycles for
      every database creation for the life of the installation.
      
      Oversight in commit c4a8812c.  Noticed by Amit Langote.
      dad08994
    • T
      Comment typo fix. · 4bf87169
      Tom Lane 提交于
      Per Amit Langote.
      4bf87169
  3. 06 1月, 2016 10 次提交
    • T
      Fix typo in create_transform.sgml. · 65681d08
      Tatsuo Ishii 提交于
      65681d08
    • A
      Add scale(numeric) · abb17339
      Alvaro Herrera 提交于
      Author: Marko Tiikkaja
      abb17339
    • T
      Remove some ancient and unmaintained encoding-conversion test cruft. · 419400c5
      Tom Lane 提交于
      In commit 92119191 I claimed that we weren't testing encoding
      conversion functions, but further poking around reveals that we did
      have an equivalent though hard-wired set of tests in conversion.sql.
      AFAICS there is no advantage to doing it like that as compared to letting
      the catalog contents drive the test, so let the opr_sanity addition stand
      and remove the now-redundant tests in conversion.sql.
      
      Also, remove some infrastructure in src/backend/utils/mb/conversion_procs
      for building conversion.sql's list of tests.  That was unmaintained, and
      had not corresponded to the actual contents of conversion.sql since 2007
      or perhaps even further back.
      419400c5
    • T
      Sort $(wildcard) output where needed for reproducible build output. · 3343ea9e
      Tom Lane 提交于
      The order of inclusion of .o files makes a difference in linker output;
      not a functional difference, but still a bitwise difference, which annoys
      some packagers who would like reproducible builds.
      
      Report and patch by Christoph Berg
      3343ea9e
    • A
      Make pg_receivexlog silent with 9.3 and older servers · 4aecd22d
      Alvaro Herrera 提交于
      A pointless and confusing error message is shown to the user when
      attempting to identify a 9.3 or older remote server with a 9.5/9.6
      pg_receivexlog, because the return signature of IDENTIFY_SYSTEM was
      changed in 9.4.  There's no good reason for the warning message, so
      shuffle code around to keep it quiet.
      
      (pg_recvlogical is also affected by this commit, but since it obviously
      cannot work with 9.3 that doesn't actually matter much.)
      
      Backpatch to 9.5.
      
      Reported by Marco Nenciarini, who also wrote the initial patch.  Further
      tweaked by Robert Haas and Fujii Masao; reviewed by Michael Paquier and
      Craig Ringer.
      4aecd22d
    • T
      In opr_sanity regression test, check for unexpected uses of cstring. · 92119191
      Tom Lane 提交于
      In light of commit ea0d494d, it seems like a good idea to add
      a regression test that will complain about random functions taking or
      returning cstring.  Only I/O support functions and encoding conversion
      functions should be declared that way.
      
      While at it, add some checks that encoding conversion functions are
      declared properly.  Since pg_conversion isn't populated manually,
      it's not quite as necessary to check its contents as it is for catalogs
      like pg_proc; but one thing we definitely have not tested in the past
      is whether the identified conproc for a conversion actually does that
      conversion vs. some other one.
      92119191
    • T
      Make the to_reg*() functions accept text not cstring. · ea0d494d
      Tom Lane 提交于
      Using cstring as the input type was a poor decision, because that's not
      really a full-fledged type.  In particular, it lacks implicit coercions
      from text or varchar, meaning that usages like to_regproc('foo'||'bar')
      wouldn't work; basically the only case that did work without explicit
      casting was a simple literal constant argument.
      
      The lack of field complaints about this suggests that hardly anyone
      is using these functions, so hopefully fixing it won't cause much of
      a compatibility problem.  They've only been there since 9.4, anyway.
      
      Petr Korobeinikov
      ea0d494d
    • A
      Make pg_shseclabel available in early backend startup · efa318bc
      Alvaro Herrera 提交于
      While the in-core authentication mechanism doesn't need to access
      pg_shseclabel at all, it's reasonable to think that an authentication
      hook will want to look at the label for the role logging in, or for rows
      in other catalogs used during the authentication phase of startup.
      
      Catalog version bumped, because this changes the "is nailed" status for
      pg_shseclabel.
      
      Author: Adam Brightwell
      efa318bc
    • T
      Add to_regnamespace() and to_regrole() to the documentation. · 83be1844
      Tom Lane 提交于
      Commits cb9fa802 and 0c90f676 added these functions,
      but did not bother with documentation.
      83be1844
    • T
      Convert psql's tab completion for backslash commands to the new style. · 4f18010a
      Tom Lane 提交于
      This requires adding some more infrastructure to handle both case-sensitive
      and case-insensitive matching, as well as the ability to match a prefix of
      a previous word.  So it ends up being about a wash line-count-wise, but
      it's just as big a readability win here as in the SQL tab completion rules.
      
      Michael Paquier, some adjustments by me
      4f18010a
  4. 05 1月, 2016 3 次提交
    • T
      In psql's tab completion, change most TailMatches patterns to Matches. · 9b181b03
      Tom Lane 提交于
      In the refactoring in commit d37b816d,
      we mostly kept to the original design whereby only the last few words
      on the line were matched to identify a completable pattern.  However,
      after commit d854118c, there's really
      no reason to do it like that: where it's sensible, we can use patterns
      that expect to match the entire input line.  And mostly, it's sensible.
      Matching the entire line greatly reduces the odds of a false match that
      leads to offering irrelevant completions.  Moreover (though I've not
      tried to measure this), it should make tab completion faster since
      many of the patterns will be discarded after a single integer comparison
      that finds that the wrong number of words appear on the line.
      
      There are certain identifiable places where we still need to use
      TailMatches because the statement in question is allowed to appear
      embedded in a larger statement.  These are just a small minority of
      the existing patterns, though, so the benefit of switching where
      possible is large.
      
      It's possible that this patch has removed some within-line matching
      behaviors that are in fact desirable, but we can put those back when
      we get complaints.  Most of the removed behaviors are certainly silly.
      
      Michael Paquier, with some further adjustments by me
      9b181b03
    • T
      Docs: provide a concrete discussion and example for RLS race conditions. · 7debf360
      Tom Lane 提交于
      Commit 43cd468c added some wording to create_policy.sgml purporting
      to warn users against a race condition of the sort that had been noted some
      time ago by Peter Geoghegan.  However, that warning was far too vague to be
      useful (or at least, I completely failed to grasp what it was on about).
      Since the problem case occurs with a security design pattern that lots of
      people are likely to try to use, we need to be as clear as possible about
      it.  Provide a concrete example in the main-line docs in place of the
      original warning.
      7debf360
    • T
      Adjust behavior of row_security GUC to match the docs. · 5d354382
      Tom Lane 提交于
      Some time back we agreed that row_security=off should not be a way to
      bypass RLS entirely, but only a way to get an error if it was being
      applied.  However, the code failed to act that way for table owners.
      Per discussion, this is a must-fix bug for 9.5.0.
      
      Adjust the logic in rls.c to behave as expected; also, modify the
      error message to be more consistent with the new interpretation.
      The regression tests need minor corrections as well.  Also update
      the comments about row_security in ddl.sgml to be correct.  (The
      official description of the GUC in config.sgml is already correct.)
      
      I failed to resist the temptation to do some other very minor
      cleanup as well, such as getting rid of a duplicate extern declaration.
      5d354382
  5. 04 1月, 2016 9 次提交
    • R
      Fix typo in comment. · 8978eb03
      Robert Haas 提交于
      Masahiko Sawada
      8978eb03
    • T
      Fix regrole and regnamespace output functions to do quoting, too. · b0cadc08
      Tom Lane 提交于
      We discussed this but somehow failed to implement it...
      b0cadc08
    • T
      Fix regrole and regnamespace types to honor quoting like other reg* types. · fb1227af
      Tom Lane 提交于
      Aside from any consistency arguments, this is logically necessary because
      the I/O functions for these types also handle numeric OID values.  Without
      a quoting rule it is impossible to distinguish numeric OIDs from role or
      namespace names that happen to contain only digits.
      
      Also change the to_regrole and to_regnamespace functions to dequote their
      arguments.  While not logically essential, this seems like a good idea
      since the other to_reg* functions do it.  Anyone who really wants raw
      lookup of an uninterpreted name can fall back on the time-honored solution
      of (SELECT oid FROM pg_namespace WHERE nspname = whatever).
      
      Report and patch by Jim Nasby, reviewed by Michael Paquier
      fb1227af
    • T
      Fix bogus lock release in RemovePolicyById and RemoveRoleFromObjectPolicy. · f47b602d
      Tom Lane 提交于
      Can't release the AccessExclusiveLock on the target table until commit.
      Otherwise there is a race condition whereby other backends might service
      our cache invalidation signals before they can actually see the updated
      catalog rows.
      
      Just to add insult to injury, RemovePolicyById was closing the rel (with
      incorrect lock drop) and then passing the now-dangling rel pointer to
      CacheInvalidateRelcache.  Probably the reason this doesn't fall over on
      CLOBBER_CACHE buildfarm members is that some outer level of the DROP logic
      is still holding the rel open ... but it'd have bit us on the arse
      eventually, no doubt.
      f47b602d
    • T
      Do some copy-editing on the docs for row-level security. · c1611db0
      Tom Lane 提交于
      Clarifications, markup improvements, corrections of misleading or
      outright wrong statements.
      c1611db0
    • T
      Guard against null arguments in binary_upgrade_create_empty_extension(). · 939d10cd
      Tom Lane 提交于
      The CHECK_IS_BINARY_UPGRADE macro is not sufficient security protection
      if we're going to dereference pass-by-reference arguments before it.
      
      But in any case we really need to explicitly check PG_ARGISNULL for all
      the arguments of a non-strict function, not only the ones we expect null
      values for.
      
      Oversight in commits 30982be4 and
      f92fc4c9.  Found by Andreas Seltenreich.
      (The other usages in pg_upgrade_support.c seem safe.)
      939d10cd
    • T
      Do some copy-editing on the docs for replication origins. · c6aeba35
      Tom Lane 提交于
      Minor grammar and markup improvements.
      c6aeba35
    • T
      02798919
    • T
      Fix treatment of *lpNumberOfBytesRecvd == 0: that's a completion condition. · 90e61df8
      Tom Lane 提交于
      pgwin32_recv() has treated a non-error return of zero bytes from WSARecv()
      as being a reason to block ever since the current implementation was
      introduced in commit a4c40f14.  However, so far as one can tell
      from Microsoft's documentation, that is just wrong: what it means is
      graceful connection closure (in stream protocols) or receipt of a
      zero-length message (in message protocols), and neither case should result
      in blocking here.  The only reason the code worked at all was that control
      then fell into the retry loop, which did *not* treat zero bytes specially,
      so we'd get out after only wasting some cycles.  But as of 9.5 we do not
      normally reach the retry loop and so the bug is exposed, as reported by
      Shay Rojansky and diagnosed by Andres Freund.
      
      Remove the unnecessary test on the byte count, and rearrange the code
      in the retry loop so that it looks identical to the initial sequence.
      
      Back-patch to 9.5.  The code is wrong all the way back, AFAICS, but
      since it's relatively harmless in earlier branches we'll leave it alone.
      90e61df8
  6. 03 1月, 2016 6 次提交
    • T
      Teach pg_dump to quote reloption values safely. · b416c0bb
      Tom Lane 提交于
      Commit c7e27bec fixed this on the backend side, but we neglected
      the fact that several code paths in pg_dump were printing reloptions
      values that had not gotten massaged by ruleutils.  Apply essentially the
      same quoting logic in those places, too.
      b416c0bb
    • 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