Skip to content
Snippets Groups Projects
  1. Jul 17, 2012
    • Tom Lane's avatar
      Improve coding around the fsync request queue. · 4abcce8c
      Tom Lane authored
      In all branches back to 8.3, this patch fixes a questionable assumption in
      CompactCheckpointerRequestQueue/CompactBgwriterRequestQueue that there are
      no uninitialized pad bytes in the request queue structs.  This would only
      cause trouble if (a) there were such pad bytes, which could happen in 8.4
      and up if the compiler makes enum ForkNumber narrower than 32 bits, but
      otherwise would require not-currently-planned changes in the widths of
      other typedefs; and (b) the kernel has not uniformly initialized the
      contents of shared memory to zeroes.  Still, it seems a tad risky, and we
      can easily remove any risk by pre-zeroing the request array for ourselves.
      In addition to that, we need to establish a coding rule that struct
      RelFileNode can't contain any padding bytes, since such structs are copied
      into the request array verbatim.  (There are other places that are assuming
      this anyway, it turns out.)
      
      In 9.1 and up, the risk was a bit larger because we were also effectively
      assuming that struct RelFileNodeBackend contained no pad bytes, and with
      fields of different types in there, that would be much easier to break.
      However, there is no good reason to ever transmit fsync or delete requests
      for temp files to the bgwriter/checkpointer, so we can revert the request
      structs to plain RelFileNode, getting rid of the padding risk and saving
      some marginal number of bytes and cycles in fsync queue manipulation while
      we are at it.  The savings might be more than marginal during deletion of
      a temp relation, because the old code transmitted an entirely useless but
      nonetheless expensive-to-process ForgetRelationFsync request to the
      background process, and also had the background process perform the file
      deletion even though that can safely be done immediately.
      
      In addition, make some cleanup of nearby comments and small improvements to
      the code in CompactCheckpointerRequestQueue/CompactBgwriterRequestQueue.
      4abcce8c
    • Peter Eisentraut's avatar
      Show step titles in the pg_upgrade man page · 3d03c97a
      Peter Eisentraut authored
      The upstream XSLT stylesheets missed that case.
      
      found by Álvaro Herrera
      3d03c97a
    • Alvaro Herrera's avatar
      Remove recently added PL/Perl encoding tests · 82b7faa3
      Alvaro Herrera authored
      These only pass cleanly on UTF8 and SQL_ASCII encodings, besides the
      Japanese encoding in which they were originally written, which is clearly
      not good enough.  Since the functionality they test has not ever been
      tested from PL/Perl, the best answer seems to be to remove the new tests
      completely.
      
      Per buildfarm results and ensuing discussion.
      82b7faa3
  2. Jul 16, 2012
    • Tom Lane's avatar
      Avoid pre-determining index names during CREATE TABLE LIKE parsing. · 3727240d
      Tom Lane authored
      Formerly, when trying to copy both indexes and comments, CREATE TABLE LIKE
      had to pre-assign names to indexes that had comments, because it made up an
      explicit CommentStmt command to apply the comment and so it had to know the
      name for the index.  This creates bad interactions with other indexes, as
      shown in bug #6734 from Daniele Varrazzo: the preassignment logic couldn't
      take any other indexes into account so it could choose a conflicting name.
      
      To fix, add a field to IndexStmt that allows it to carry a comment to be
      assigned to the new index.  (This isn't a user-exposed feature of CREATE
      INDEX, only an internal option.)  Now we don't need preassignment of index
      names in any situation.
      
      I also took the opportunity to refactor DefineIndex to accept the IndexStmt
      as such, rather than passing all its fields individually in a mile-long
      parameter list.
      
      Back-patch to 9.2, but no further, because it seems too dangerous to change
      IndexStmt or DefineIndex's API in released branches.  The bug exists back
      to 9.0 where CREATE TABLE LIKE grew the ability to copy comments, but given
      the lack of prior complaints we'll just let it go unfixed before 9.2.
      3727240d
  3. Jul 15, 2012
    • Tom Lane's avatar
      Prevent corner-case core dump in rfree(). · 1116c9d1
      Tom Lane authored
      rfree() failed to cope with the case that pg_regcomp() had initialized the
      regex_t struct but then failed to allocate any memory for re->re_guts (ie,
      the first malloc call in pg_regcomp() failed).  It would try to touch the
      guts struct anyway, and thus dump core.  This is a sufficiently narrow
      corner case that it's not surprising it's never been seen in the field;
      but still a bug is a bug, so patch all active branches.
      
      Noted while investigating whether we need to call pg_regfree after a
      failure return from pg_regcomp.  Other than this bug, it turns out we
      don't, so adjust comments appropriately.
      1116c9d1
  4. Jul 14, 2012
  5. Jul 12, 2012
    • Tom Lane's avatar
      Fix walsender processes to establish a SIGALRM handler. · 0bf8eb2a
      Tom Lane authored
      Walsenders must have working SIGALRM handling during InitPostgres,
      but they set the handler to SIG_IGN so that nothing would happen
      if a timeout was reached.  This could result in two failure modes:
      
      * If a walsender participated in a deadlock during its authentication
      transaction, and was the last to wait in the deadly embrace, the deadlock
      would not get cleared automatically.  This would require somebody to be
      trying to take out AccessExclusiveLock on multiple system catalogs, so
      it's not very probable.
      
      * If a client failed to respond to a walsender's authentication challenge,
      the intended disconnect after AuthenticationTimeout wouldn't happen, and
      the walsender would wait indefinitely for the client.
      
      For the moment, fix in back branches only, since this is fixed in a
      different way in the timeout-infrastructure patch that's awaiting
      application to HEAD.  If we choose not to apply that, then we'll need
      to do this in HEAD as well.
      0bf8eb2a
  6. Jul 11, 2012
  7. Jul 10, 2012
    • Tom Lane's avatar
      Back-patch addition of pg_wchar-to-multibyte conversion functionality. · f12960d8
      Tom Lane authored
      Back-patch of commits 72dd6291,
      f6a05fd9, and
      60e9c224.
      
      This is needed to support fixing the regex prefix extraction bug in
      back branches.
      f12960d8
    • Alvaro Herrera's avatar
      plperl: Skip setting UTF8 flag when in SQL_ASCII encoding · 7c460f0b
      Alvaro Herrera authored
      When in SQL_ASCII encoding, strings passed around are not necessarily
      UTF8-safe.  We had already fixed this in some places, but it looks like
      we missed some.
      
      I had to backpatch Peter Eisentraut's a8b92b60 to 9.1 in order for this
      patch to cherry-pick more cleanly.
      
      Patch from Alex Hunsaker, tweaked by Kyotaro HORIGUCHI and myself.
      
      Some desultory cleanup and comment addition by me, during patch review.
      
      Per bug report from Christoph Berg in
      20120209102116.GA14429@msgid.df7cb.de
      7c460f0b
    • Tom Lane's avatar
      Refactor pattern_fixed_prefix() to avoid dealing in incomplete patterns. · 8fc7b07b
      Tom Lane authored
      Previously, pattern_fixed_prefix() was defined to return whatever fixed
      prefix it could extract from the pattern, plus the "rest" of the pattern.
      That definition was sensible for LIKE patterns, but not so much for
      regexes, where reconstituting a valid pattern minus the prefix could be
      quite tricky (certainly the existing code wasn't doing that correctly).
      Since the only thing that callers ever did with the "rest" of the pattern
      was to pass it to like_selectivity() or regex_selectivity(), let's cut out
      the middle-man and just have pattern_fixed_prefix's subroutines do this
      directly.  Then pattern_fixed_prefix can return a simple selectivity
      number, and the question of how to cope with partial patterns is removed
      from its API specification.
      
      While at it, adjust the API spec so that callers who don't actually care
      about the pattern's selectivity (which is a lot of them) can pass NULL for
      the selectivity pointer to skip doing the work of computing a selectivity
      estimate.
      
      This patch is only an API refactoring that doesn't actually change any
      processing, other than allowing a little bit of useless work to be skipped.
      However, it's necessary infrastructure for my upcoming fix to regex prefix
      extraction, because after that change there won't be any simple way to
      identify the "rest" of the regex, not even to the low level of fidelity
      needed by regex_selectivity.  We can cope with that if regex_fixed_prefix
      and regex_selectivity communicate directly, but not if we have to work
      within the old API.  Hence, back-patch to all active branches.
      8fc7b07b
  8. Jul 09, 2012
    • Tom Lane's avatar
      Fix planner to pass correct collation to operator selectivity estimators. · eb1b4881
      Tom Lane authored
      We can do this without creating an API break for estimation functions
      by passing the collation using the existing fmgr functionality for
      passing an input collation as a hidden parameter.
      
      The need for this was foreseen at the outset, but we didn't get around to
      making it happen in 9.1 because of the decision to sort all pg_statistic
      histograms according to the database's default collation.  That meant that
      selectivity estimators generally need to use the default collation too,
      even if they're estimating for an operator that will do something
      different.  The reason it's suddenly become more interesting is that
      regexp interpretation also uses a collation (for its LC_TYPE not LC_COLLATE
      property), and we no longer want to use the wrong collation when examining
      regexps during planning.  It's not that the selectivity estimate is likely
      to change much from this; rather that we are thinking of caching compiled
      regexps during planner estimation, and we won't get the intended benefit
      if we cache them with a different collation than the executor will use.
      
      Back-patch to 9.1, both because the regexp change is likely to get
      back-patched and because we might as well get this right in all
      collation-supporting branches, in case any third-party code wants to
      rely on getting the collation.  The patch turns out to be minuscule
      now that I've done it ...
      eb1b4881
  9. Jul 06, 2012
  10. Jul 05, 2012
    • Tom Lane's avatar
      Don't try to trim "../" in join_path_components(). · f882084d
      Tom Lane authored
      join_path_components() tried to remove leading ".." components from its
      tail argument, but it was not nearly bright enough to do so correctly
      unless the head argument was (a) absolute and (b) canonicalized.
      Rather than try to fix that logic, let's just get rid of it: there is no
      correctness reason to remove "..", and cosmetic concerns can be taken
      care of by a subsequent canonicalize_path() call.  Per bug #6715 from
      Greg Davidson.
      
      Back-patch to all supported branches.  It appears that pre-9.2, this
      function is only used with absolute paths as head arguments, which is why
      we'd not noticed the breakage before.  However, third-party code might be
      expecting this function to work in more general cases, so it seems wise
      to back-patch.
      
      In HEAD and 9.2, also make some minor cosmetic improvements to callers.
      f882084d
    • Heikki Linnakangas's avatar
      Revert part of the previous patch that avoided using PLy_elog(). · 7c58a5f2
      Heikki Linnakangas authored
      That caused the plpython_unicode regression test to fail on SQL_ASCII
      encoding, as evidenced by the buildfarm. The reason is that with the patch,
      you don't get the detail in the error message that you got before. That
      detail is actually very informative, so rather than just adjust the expected
      output, let's revert that part of the patch for now to make the buildfarm
      green again, and figure out some other way to avoid the recursion of
      PLy_elog() that doesn't lose the detail.
      7c58a5f2
    • Heikki Linnakangas's avatar
      Fix mapping of PostgreSQL encodings to Python encodings. · 77328801
      Heikki Linnakangas authored
      Windows encodings, "win1252" and so forth, are named differently in Python,
      like "cp1252". Also, if the PyUnicode_AsEncodedString() function call fails
      for some reason, use a plain ereport(), not a PLy_elog(), to report that
      error. That avoids recursion and crash, if PLy_elog() tries to call
      PLyUnicode_Bytes() again.
      
      This fixes bug reported by Asif Naeem. Backpatch down to 9.0, before that
      plpython didn't even try these conversions.
      
      Jan Urbański, with minor comment improvements by me.
      77328801
    • Bruce Momjian's avatar
      Fix missing regex slash that caused perltidy to get confused on · 071589cb
      Bruce Momjian authored
      copyright.pl.
      
      Backpatch to 9.2.
      071589cb
    • Bruce Momjian's avatar
      Run newly-configured perltidy script on Perl files. · 2bc09ff4
      Bruce Momjian authored
      Run on HEAD and 9.2.
      2bc09ff4
  11. Jul 04, 2012
  12. Jul 03, 2012
    • Alvaro Herrera's avatar
      c602b429
    • Alvaro Herrera's avatar
      Have REASSIGN OWNED work on extensions, too · 6416895c
      Alvaro Herrera authored
      Per bug #6593, REASSIGN OWNED fails when the affected role has created
      an extension.  Even though the user related to the extension is not
      nominally the owner, its OID appears on pg_shdepend and thus causes
      problems when the user is to be dropped.
      
      This commit adds code to change the "ownership" of the extension itself,
      not of the contained objects.  This is fine because it's currently only
      called from REASSIGN OWNED, which would also modify the ownership of the
      contained objects.  However, this is not sufficient for a working ALTER
      OWNER implementation extension.
      
      Back-patch to 9.1, where extensions were introduced.
      
      Bug #6593 reported by Emiliano Leporati.
      6416895c
  13. Jul 02, 2012
  14. Jul 01, 2012
    • Tom Lane's avatar
      Fix race condition in enum value comparisons. · 972e0666
      Tom Lane authored
      When (re) loading the typcache comparison cache for an enum type's values,
      use an up-to-date MVCC snapshot, not the transaction's existing snapshot.
      This avoids problems if we encounter an enum OID that was created since our
      transaction started.  Per report from Andres Freund and diagnosis by Robert
      Haas.
      
      To ensure this is safe even if enum comparison manages to get invoked
      before we've set a transaction snapshot, tweak GetLatestSnapshot to
      redirect to GetTransactionSnapshot instead of throwing error when
      FirstSnapshotSet is false.  The existing uses of GetLatestSnapshot (in
      ri_triggers.c) don't care since they couldn't be invoked except in a
      transaction that's already done some work --- but it seems just conceivable
      that this might not be true of enums, especially if we ever choose to use
      enums in system catalogs.
      
      Note that the comparable coding in enum_endpoint and enum_range_internal
      remains GetTransactionSnapshot; this is perhaps debatable, but if we
      changed it those functions would have to be marked volatile, which doesn't
      seem attractive.
      
      Back-patch to 9.1 where ALTER TYPE ADD VALUE was added.
      972e0666
  15. Jun 30, 2012
Loading