1. 21 Jul, 2009 4 commits
    • Tom Lane's avatar
      Speed up AllocSetFreeIndex, which is a significant cost in palloc and pfree, · ab5b4e2f
      Tom Lane authored
      by using a lookup table instead of a naive shift-and-count loop.  Based on
      code originally posted by Sean Eron Anderson at
      http://graphics.stanford.edu/%7eseander/bithacks.html.
      Greg Stark did the research and benchmarking to show that this is what
      we should use.  Jeremy Kerr first noticed that this is a hotspot that
      could be optimized, though we ended up not using his suggestion of
      platform-specific bit-searching code.
      ab5b4e2f
    • Peter Eisentraut's avatar
      Remove translated FAQs · f3f45c87
      Peter Eisentraut authored
      The English FAQ has been moved to the wiki, so the translated versions should
      have been removed at that point as well.
      
      The FAQ_MINGW.html should have been removed when the platform FAQs were
      integrated into the documentation (or earlier).
      
      applied to both 8.4 and 8.5
      f3f45c87
    • Peter Eisentraut's avatar
      Add a further customization to the SGML Emacs mode to prevent the use of · f7ad9cab
      Peter Eisentraut authored
      tabs in the documentation source.
      f7ad9cab
    • Tom Lane's avatar
      Fix another semijoin-ordering bug. We already knew that we couldn't · b2c51e6e
      Tom Lane authored
      reorder a semijoin into or out of the righthand side of another semijoin,
      but actually it doesn't work to reorder it into or out of the righthand
      side of a left or antijoin, either.  Per bug #4906 from Mathieu Fenniak.
      
      This was sloppy thinking on my part.  This identity does work:
      
      	( A left join B on (Pab) ) semijoin C on (Pac)
      ==
      	( A semijoin C on (Pac) ) left join B on (Pab)
      
      but I failed to see that that doesn't mean this does:
      
      	( A left join B on (Pab) ) semijoin C on (Pbc)
      !=
      	A left join ( B semijoin C on (Pbc) ) on (Pab)
      b2c51e6e
  2. 20 Jul, 2009 7 commits
  3. 19 Jul, 2009 2 commits
    • Tom Lane's avatar
      Rewrite GEQO's gimme_tree function so that it always finds a legal join · 400e2c93
      Tom Lane authored
      sequence, even when the input "tour" doesn't lead directly to such a sequence.
      The stack logic that was added in 2004 only supported cases where relations
      that had to be joined to each other (due to join order restrictions) were
      adjacent in the tour.  However, relying on a random search to figure that out
      is tremendously inefficient in large join problems, and could even fail
      completely (leading to "failed to make a valid plan" errors) if
      random_init_pool ran out of patience.  It seems better to make the
      tour-to-plan transformation a little bit fuzzier so that every tour can form
      a legal plan, even though this means that apparently different tours will
      sometimes yield the same plan.
      
      In the same vein, get rid of the logic that knew that tours (a,b,c,d,...)
      are the same as tours (b,a,c,d,...), and therefore insisted the latter
      are invalid.  The chance of generating two tours that differ only in
      this way isn't that high, and throwing out 50% of possible tours to
      avoid such duplication seems more likely to waste valuable genetic-
      refinement generations than to do anything useful.
      
      This leaves us with no cases in which geqo_eval will deem a tour invalid,
      so get rid of assorted kluges that tried to deal with such cases, in
      particular the undocumented assumption that DBL_MAX is an impossible
      plan cost.
      
      This is all per testing of Robert Haas' lets-remove-the-collapse-limits
      patch.  That idea has crashed and burned, at least for now, but we still
      got something useful out of it.
      
      It's possible we should back-patch this change, since the "failed to make a
      valid plan" error can happen in existing releases; but I'd rather not until
      it has gotten more testing.
      400e2c93
    • Tom Lane's avatar
      Fix a thinko in join_is_legal: when we decide we can implement a semijoin · a43b190e
      Tom Lane authored
      by unique-ifying the RHS and then inner-joining to some other relation,
      that is not grounds for violating the RHS of some other outer join.
      Noticed while regression-testing new GEQO code, which will blindly follow
      any path that join_is_legal says is legal, and then complain later if that
      leads to a dead end.
      
      I'm not certain that this can result in any visible failure in 8.4: the
      mistake may always be masked by the fact that subsequent attempts to join
      the rest of the RHS of the other join will fail.  But I'm not certain it
      can't, either, and it's definitely not operating as intended.  So back-patch.
      
      The added regression test depends on the new no-failures-allowed logic
      that I'm about to commit in GEQO, so no point back-patching that.
      a43b190e
  4. 18 Jul, 2009 1 commit
    • Tom Lane's avatar
      Fix error cleanup failure caused by 8.4 changes in plpgsql to try to avoid · 011eae60
      Tom Lane authored
      memory leakage in error recovery.  We were calling FreeExprContext, and
      therefore invoking ExprContextCallback callbacks, in both normal and error
      exits from subtransactions.  However this isn't very safe, as shown in
      recent trouble report from Frank van Vugt, in which releasing a tupledesc
      refcount failed.  It's also unnecessary, since the resources that callbacks
      might wish to release should be cleaned up by other error recovery mechanisms
      (ie the resource owners).  We only really want FreeExprContext to release
      memory attached to the exprcontext in the error-exit case.  So, add a bool
      parameter to FreeExprContext to tell it not to call the callbacks.
      
      A more general solution would be to pass the isCommit bool parameter on to
      the callbacks, so they could do only safe things during error exit.  But
      that would make the patch significantly more invasive and possibly break
      third-party code that registers ExprContextCallback callbacks.  We might want
      to do that later in HEAD, but for now I'll just do what seems reasonable to
      back-patch.
      011eae60
  5. 17 Jul, 2009 1 commit
    • Tom Lane's avatar
      Repair bug #4926 "too few pathkeys for mergeclauses". This example shows · fb180559
      Tom Lane authored
      that the sanity checking I added to create_mergejoin_plan() in 8.3 was a
      few bricks shy of a load: the mergeclauses could reference pathkeys in a
      noncanonical order such as x,y,x, not only cases like x,x,y which is all
      that the code had allowed for.  The odd cases only turn up when using
      redundant clauses in an outer join condition, which is why no one had
      noticed before.
      fb180559
  6. 16 Jul, 2009 4 commits
    • Tom Lane's avatar
      Make GEQO's planning deterministic by having it start from a predictable · f5bc7419
      Tom Lane authored
      random number seed each time.  This is how it used to work years ago, but
      we got rid of the seed reset because it was resetting the main random()
      sequence and thus having undesirable effects on the rest of the system.
      To fix, establish a private random number state for each execution of
      geqo(), and initialize the state using the new GUC variable geqo_seed.
      People who want to experiment with different random searches can do so
      by changing geqo_seed, but you'll always get the same plan for the same
      value of geqo_seed (if holding all other planner inputs constant, of course).
      
      The new state is kept in PlannerInfo by adding a "void *" field reserved
      for use by join_search hooks.  Most of the rather bulky code changes in
      this commit are just arranging to pass PlannerInfo around to all the GEQO
      functions (many of which formerly didn't receive it).
      
      Andres Freund, with some editorialization by Tom
      f5bc7419
    • Tom Lane's avatar
      Add erand48() to the set of functions supported by our src/port/ library, · c43feefa
      Tom Lane authored
      and extend configure to test for it properly instead of hard-wiring
      an assumption that everybody but Windows has the rand48 functions.
      (We do cheat to the extent of assuming that probing for erand48 will do
      for the entire rand48 family.)
      
      erand48() is unused as of this commit, but a followon patch will cause
      GEQO to depend on it.
      
      Andres Freund, additional hacking by Tom
      c43feefa
    • Heikki Linnakangas's avatar
    • Peter Eisentraut's avatar
      Make backend header files C++ safe · de160e2c
      Peter Eisentraut authored
      This alters various incidental uses of C++ key words to use other similar
      identifiers, so that a C++ compiler won't choke outright.  You still
      (probably) need extern "C" { }; around the inclusion of backend headers.
      
      based on a patch by Kurt Harriman <harriman@acm.org>
      
      Also add a script cpluspluscheck to check for C++ compatibility in the
      future.  As of right now, this passes without error for me.
      de160e2c
  7. 14 Jul, 2009 4 commits
    • Peter Eisentraut's avatar
      Rearrangement of the HTML docs build rules · 4ef8dc7a
      Peter Eisentraut authored
      Set up proper makefile dependencies in the documentation build rules,
      especially around the HTML/index build.  The problem we've had with all
      previous solutions is that we have used the same file name, such as HTML.index
      or bookindex.sgml, to mean different things at different stages of the build,
      and make can't distinguish that.  The solution here is that the first jade run
      produces HTML.index, but does not require bookindex.sgml at all, and produces
      no other html output (the latter an idea from Alvaro).  The second jade run
      includes bookindex.sgml, but does not recreate HTML.index.  That way, when you
      change an sgml file, jade is run twice and at the end all dependencies are
      satisfied.  Omitting the html output in the first stage also makes the full
      build a lot faster.
      
      When you run one of the print format targets, only the first jade run is run,
      then the print target-specific commands.  If an HTML build has completed
      previously, the first jade run is skipped because the dependencies have
      already been satisfied.
      
      The draft and check targets for quick builds and syntax verification are still
      there.
      4ef8dc7a
    • Tom Lane's avatar
      Remove duplicate definition of TYPECAST token. · 4baaaf7a
      Tom Lane authored
      (Apparently, some but not all versions of Bison will warn about this.)
      4baaaf7a
    • Tom Lane's avatar
      Tweak the core scanner so that it can be used by plpgsql too. · 1aa58d3a
      Tom Lane authored
      Changes:
      
      Pass in the keyword lookup array instead of having it be hardwired.
      (This incidentally allows elimination of some duplicate coding in ecpg.)
      
      Re-order the token declarations in gram.y so that non-keyword tokens have
      numbers that won't change when keywords are added or removed.
      
      Add ".." and ":=" to the set of tokens recognized by scan.l.  (Since these
      combinations are nowhere legal in core SQL, this does not change anything
      except the precise wording of the error you get when you write this.)
      1aa58d3a
    • Tom Lane's avatar
      Do a conditional SPI_push/SPI_pop when replanning a query in · 0d4899e4
      Tom Lane authored
      RevalidateCachedPlan.  This is to avoid a "SPI_ERROR_CONNECT" failure when
      the planner calls a SPI-using function and we are already inside one.
      The alternative fix is to expect callers of RevalidateCachedPlan to do this,
      which seems likely to result in additional hard-to-detect bugs of omission.
      Per reports from Frank van Vugt and Marek Lewczuk.
      
      Back-patch to 8.3. It's much harder to trigger the bug in 8.3, due to a
      smaller set of cases in which plans can be invalidated, but it could happen.
      (I think perhaps only a SI reset event could make 8.3 fail here, but that's
      certainly within the realm of possibility.)
      0d4899e4
  8. 13 Jul, 2009 8 commits
  9. 12 Jul, 2009 1 commit
    • Tom Lane's avatar
      Move some declarations in the raw-parser header files to create a clearer · 6566e37e
      Tom Lane authored
      distinction between the external API (parser.h) and declarations that only
      need to be visible within the raw parser code (gramparse.h, which now is only
      included by parser.c, gram.y, scan.l, and keywords.c).  This is in preparation
      for the upcoming change to a reentrant lexer, which will require referencing
      YYSTYPE in the declarations of base_yylex and filtered_base_yylex, hence
      gram.h will have to be included by gramparse.h.  We don't want any more files
      than absolutely necessary to depend on gram.h, so some cleanup is called for.
      6566e37e
  10. 11 Jul, 2009 3 commits
    • Peter Eisentraut's avatar
      Alter some gratuitous uses of "ANSI" when "SQL standard" might have been · 23d830bd
      Peter Eisentraut authored
      meant or the reference to a standard was unnecessary.
      23d830bd
    • Peter Eisentraut's avatar
      Correct what ISO stands for · c95db342
      Peter Eisentraut authored
      c95db342
    • Tom Lane's avatar
      Fix set_rel_width() to do something reasonable with non-Var items in a · 014be150
      Tom Lane authored
      RelOptInfo targetlist.  It used to be that the only possibility other than
      a Var was a RowExpr representing a whole-row child Var, but as of 8.4's
      expanded ability to flatten appendrel members, we can get arbitrary expressions
      in there.  Use the expression's type info and get_typavgwidth() to produce
      an at-least-marginally-sane result.  Note that get_typavgwidth()'s fallback
      estimate (32 bytes) is the same as what was here before, so there will be
      no behavioral change for RowExprs.  Noted while looking at recent gripe
      about constant quals pushed down to FunctionScan appendrel members ...
      not only were we failing to recognize the constant qual, we were getting
      the width estimate wrong :-(
      014be150
  11. 10 Jul, 2009 1 commit
    • Tom Lane's avatar
      Fix xslt_process() to ensure that it inserts a NULL terminator after the · e7370bab
      Tom Lane authored
      last pair of parameter name/value strings, even when there are MAXPARAMS
      of them.  Aboriginal bug in contrib/xml2, noted while studying bug #4912
      (though I'm not sure whether there's something else involved in that
      report).
      
      This might be thought a security issue, since it's a potential backend
      crash; but considering that untrustworthy users shouldn't be allowed
      to get their hands on xslt_process() anyway, it's probably not worth
      getting excited about.
      e7370bab
  12. 08 Jul, 2009 4 commits