Skip to content
Snippets Groups Projects
  1. Jul 11, 2012
  2. 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
  3. 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
  4. Jul 06, 2012
  5. 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
  6. Jul 04, 2012
  7. 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
  8. Jul 02, 2012
  9. 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
  10. Jun 30, 2012
    • Tom Lane's avatar
      Remove inappropriate semicolons after function definitions. · 4f1e0e40
      Tom Lane authored
      Solaris Studio warns about this, and some compilers might think it's an
      outright syntax error.
      4f1e0e40
    • Tom Lane's avatar
      Prevent CREATE TABLE LIKE/INHERITS from (mis) copying whole-row Vars. · 52336a47
      Tom Lane authored
      If a CHECK constraint or index definition contained a whole-row Var (that
      is, "table.*"), an attempt to copy that definition via CREATE TABLE LIKE or
      table inheritance produced incorrect results: the copied Var still claimed
      to have the rowtype of the source table, rather than the created table.
      
      For the LIKE case, it seems reasonable to just throw error for this
      situation, since the point of LIKE is that the new table is not permanently
      coupled to the old, so there's no reason to assume its rowtype will stay
      compatible.  In the inheritance case, we should ideally allow such
      constraints, but doing so will require nontrivial refactoring of CREATE
      TABLE processing (because we'd need to know the OID of the new table's
      rowtype before we adjust inherited CHECK constraints).  In view of the lack
      of previous complaints, that doesn't seem worth the risk in a back-patched
      bug fix, so just make it throw error for the inheritance case as well.
      
      Along the way, replace change_varattnos_of_a_node() with a more robust
      function map_variable_attnos(), which is capable of being extended to
      handle insertion of ConvertRowtypeExpr whenever we get around to fixing
      the inheritance case nicely, and in the meantime it returns a failure
      indication to the caller so that a helpful message with some context can be
      thrown.  Also, this code will do the right thing with subselects (if we
      ever allow them in CHECK or indexes), and it range-checks varattnos before
      using them to index into the map array.
      
      Per report from Sergey Konoplev.  Back-patch to all supported branches.
      52336a47
    • Peter Eisentraut's avatar
      initdb: Update check_need_password for new options · 31fff64e
      Peter Eisentraut authored
      Change things so that something like initdb --auth-local=peer
      --auth-host=md5 does not cause a "must specify a password" error,
      like initdb -A md5 does.
      31fff64e
  11. Jun 29, 2012
  12. Jun 28, 2012
    • Tom Lane's avatar
      Make UtilityContainsQuery recurse until it finds a non-utility Query. · c8967e38
      Tom Lane authored
      The callers of UtilityContainsQuery want it to return a non-utility Query
      if it returns anything at all.  However, since we made CREATE TABLE
      AS/SELECT INTO into a utility command instead of a variant of SELECT,
      a command like "EXPLAIN SELECT INTO" results in two nested utility
      statements.  So what we need UtilityContainsQuery to do is drill down
      to the bottom non-utility Query.
      
      I had thought of this possibility in setrefs.c, and fixed it there by
      looping around the UtilityContainsQuery call; but overlooked that the call
      sites in plancache.c have a similar issue.  In those cases it's
      notationally inconvenient to provide an external loop, so let's redefine
      UtilityContainsQuery as recursing down to a non-utility Query instead.
      
      Noted by Rushabh Lathia.  This is a somewhat cleaned-up version of his
      proposed patch.
      c8967e38
Loading