Skip to content
Snippets Groups Projects
  1. Oct 15, 2015
    • Robert Haas's avatar
      Allow FDWs to push down quals without breaking EvalPlanQual rechecks. · 5fc4c26d
      Robert Haas authored
      This fixes a long-standing bug which was discovered while investigating
      the interaction between the new join pushdown code and the EvalPlanQual
      machinery: if a ForeignScan appears on the inner side of a paramaterized
      nestloop, an EPQ recheck would re-return the original tuple even if
      it no longer satisfied the pushed-down quals due to changed parameter
      values.
      
      This fix adds a new member to ForeignScan and ForeignScanState and a
      new argument to make_foreignscan, and requires changes to FDWs which
      push down quals to populate that new argument with a list of quals they
      have chosen to push down.  Therefore, I'm only back-patching to 9.5,
      even though the bug is not new in 9.5.
      
      Etsuro Fujita, reviewed by me and by Kyotaro Horiguchi.
      5fc4c26d
  2. May 15, 2015
    • Simon Riggs's avatar
      TABLESAMPLE, SQL Standard and extensible · f6d208d6
      Simon Riggs authored
      Add a TABLESAMPLE clause to SELECT statements that allows
      user to specify random BERNOULLI sampling or block level
      SYSTEM sampling. Implementation allows for extensible
      sampling functions to be written, using a standard API.
      Basic version follows SQLStandard exactly. Usable
      concrete use cases for the sampling API follow in later
      commits.
      
      Petr Jelinek
      
      Reviewed by Michael Paquier and Simon Riggs
      f6d208d6
    • Simon Riggs's avatar
      Separate block sampling functions · 83e176ec
      Simon Riggs authored
      Refactoring ahead of tablesample patch
      
      Requested and reviewed by Michael Paquier
      
      Petr Jelinek
      83e176ec
  3. May 10, 2015
    • Tom Lane's avatar
      Code review for foreign/custom join pushdown patch. · 1a8a4e5c
      Tom Lane authored
      Commit e7cb7ee1 included some design
      decisions that seem pretty questionable to me, and there was quite a lot
      of stuff not to like about the documentation and comments.  Clean up
      as follows:
      
      * Consider foreign joins only between foreign tables on the same server,
      rather than between any two foreign tables with the same underlying FDW
      handler function.  In most if not all cases, the FDW would simply have had
      to apply the same-server restriction itself (far more expensively, both for
      lack of caching and because it would be repeated for each combination of
      input sub-joins), or else risk nasty bugs.  Anyone who's really intent on
      doing something outside this restriction can always use the
      set_join_pathlist_hook.
      
      * Rename fdw_ps_tlist/custom_ps_tlist to fdw_scan_tlist/custom_scan_tlist
      to better reflect what they're for, and allow these custom scan tlists
      to be used even for base relations.
      
      * Change make_foreignscan() API to include passing the fdw_scan_tlist
      value, since the FDW is required to set that.  Backwards compatibility
      doesn't seem like an adequate reason to expect FDWs to set it in some
      ad-hoc extra step, and anyway existing FDWs can just pass NIL.
      
      * Change the API of path-generating subroutines of add_paths_to_joinrel,
      and in particular that of GetForeignJoinPaths and set_join_pathlist_hook,
      so that various less-used parameters are passed in a struct rather than
      as separate parameter-list entries.  The objective here is to reduce the
      probability that future additions to those parameter lists will result in
      source-level API breaks for users of these hooks.  It's possible that this
      is even a small win for the core code, since most CPU architectures can't
      pass more than half a dozen parameters efficiently anyway.  I kept root,
      joinrel, outerrel, innerrel, and jointype as separate parameters to reduce
      code churn in joinpath.c --- in particular, putting jointype into the
      struct would have been problematic because of the subroutines' habit of
      changing their local copies of that variable.
      
      * Avoid ad-hocery in ExecAssignScanProjectionInfo.  It was probably all
      right for it to know about IndexOnlyScan, but if the list is to grow
      we should refactor the knowledge out to the callers.
      
      * Restore nodeForeignscan.c's previous use of the relcache to avoid
      extra GetFdwRoutine lookups for base-relation scans.
      
      * Lots of cleanup of documentation and missed comments.  Re-order some
      code additions into more logical places.
      1a8a4e5c
  4. Feb 21, 2015
  5. Jan 06, 2015
  6. May 06, 2014
    • Bruce Momjian's avatar
      pgindent run for 9.4 · 0a783200
      Bruce Momjian authored
      This includes removing tabs after periods in C comments, which was
      applied to back branches, so this change should not effect backpatching.
      0a783200
  7. Apr 22, 2014
  8. Apr 18, 2014
    • Peter Eisentraut's avatar
      Create function prototype as part of PG_FUNCTION_INFO_V1 macro · e7128e8d
      Peter Eisentraut authored
      Because of gcc -Wmissing-prototypes, all functions in dynamically
      loadable modules must have a separate prototype declaration.  This is
      meant to detect global functions that are not declared in header files,
      but in cases where the function is called via dfmgr, this is redundant.
      Besides filling up space with boilerplate, this is a frequent source of
      compiler warnings in extension modules.
      
      We can fix that by creating the function prototype as part of the
      PG_FUNCTION_INFO_V1 macro, which such modules have to use anyway.  That
      makes the code of modules cleaner, because there is one less place where
      the entry points have to be listed, and creates an additional check that
      functions have the right prototype.
      
      Remove now redundant prototypes from contrib and other modules.
      e7128e8d
  9. Mar 04, 2014
    • Andrew Dunstan's avatar
      Provide a FORCE NULL option to COPY in CSV mode. · 3b5e03dc
      Andrew Dunstan authored
      This forces an input field containing the quoted null string to be
      returned as a NULL. Without this option, only unquoted null strings
      behave this way. This helps where some CSV producers insist on quoting
      every field, whether or not it is needed. The option takes a list of
      fields, and only applies to those columns. There is an equivalent
      column-level option added to file_fdw.
      
      Ian Barwick, with some tweaking by Andrew Dunstan, reviewed by Payal
      Singh.
      3b5e03dc
  10. Jan 07, 2014
  11. May 29, 2013
  12. Feb 27, 2013
    • Heikki Linnakangas's avatar
      Add support for piping COPY to/from an external program. · 3d009e45
      Heikki Linnakangas authored
      This includes backend "COPY TO/FROM PROGRAM '...'" syntax, and corresponding
      psql \copy syntax. Like with reading/writing files, the backend version is
      superuser-only, and in the psql version, the program is run in the client.
      
      In the passing, the psql \copy STDIN/STDOUT syntax is subtly changed: if you
      the stdin/stdout is quoted, it's now interpreted as a filename. For example,
      "\copy foo from 'stdin'" now reads from a file called 'stdin', not from
      standard input. Before this, there was no way to specify a filename called
      stdin, stdout, pstdin or pstdout.
      
      This creates a new function in pgport, wait_result_to_str(), which can
      be used to convert the exit status of a process, as returned by wait(3),
      to a human-readable string.
      
      Etsuro Fujita, reviewed by Amit Kapila.
      3d009e45
  13. Jan 01, 2013
  14. Nov 12, 2012
  15. Aug 30, 2012
    • Alvaro Herrera's avatar
      Split tuple struct defs from htup.h to htup_details.h · c219d9b0
      Alvaro Herrera authored
      This reduces unnecessary exposure of other headers through htup.h, which
      is very widely included by many files.
      
      I have chosen to move the function prototypes to the new file as well,
      because that means htup.h no longer needs to include tupdesc.h.  In
      itself this doesn't have much effect in indirect inclusion of tupdesc.h
      throughout the tree, because it's also required by execnodes.h; but it's
      something to explore in the future, and it seemed best to do the htup.h
      change now while I'm busy with it.
      c219d9b0
  16. Jul 12, 2012
    • Tom Lane's avatar
      Skip text->binary conversion of unnecessary columns in contrib/file_fdw. · a36088bc
      Tom Lane authored
      When reading from a text- or CSV-format file in file_fdw, the datatype
      input routines can consume a significant fraction of the runtime.
      Often, the query does not need all the columns, so we can get a useful
      speed boost by skipping I/O conversion for unnecessary columns.
      
      To support this, add a "convert_selectively" option to the core COPY code.
      This is undocumented and not accessible from SQL (for now, anyway).
      
      Etsuro Fujita, reviewed by KaiGai Kohei
      a36088bc
  17. Jun 10, 2012
  18. May 17, 2012
  19. Apr 19, 2012
    • Tom Lane's avatar
      Revise parameterized-path mechanism to fix assorted issues. · 5b7b5518
      Tom Lane authored
      This patch adjusts the treatment of parameterized paths so that all paths
      with the same parameterization (same set of required outer rels) for the
      same relation will have the same rowcount estimate.  We cache the rowcount
      estimates to ensure that property, and hopefully save a few cycles too.
      Doing this makes it practical for add_path_precheck to operate without
      a rowcount estimate: it need only assume that paths with different
      parameterizations never dominate each other, which is close enough to
      true anyway for coarse filtering, because normally a more-parameterized
      path should yield fewer rows thanks to having more join clauses to apply.
      
      In add_path, we do the full nine yards of comparing rowcount estimates
      along with everything else, so that we can discard parameterized paths that
      don't actually have an advantage.  This fixes some issues I'd found with
      add_path rejecting parameterized paths on the grounds that they were more
      expensive than not-parameterized ones, even though they yielded many fewer
      rows and hence would be cheaper once subsequent joining was considered.
      
      To make the same-rowcounts assumption valid, we have to require that any
      parameterized path enforce *all* join clauses that could be obtained from
      the particular set of outer rels, even if not all of them are useful for
      indexing.  This is required at both base scans and joins.  It's a good
      thing anyway since the net impact is that join quals are checked at the
      lowest practical level in the join tree.  Hence, discard the original
      rather ad-hoc mechanism for choosing parameterization joinquals, and build
      a better one that has a more principled rule for when clauses can be moved.
      The original rule was actually buggy anyway for lack of knowledge about
      which relations are part of an outer join's outer side; getting this right
      requires adding an outer_relids field to RestrictInfo.
      5b7b5518
  20. Apr 06, 2012
    • Tom Lane's avatar
      Dept of second thoughts: improve the API for AnalyzeForeignTable. · cea49fe8
      Tom Lane authored
      If we make the initially-called function return the table physical-size
      estimate, acquire_inherited_sample_rows will be able to use that to
      allocate numbers of samples among child tables, when the day comes that
      we want to support foreign tables in inheritance trees.
      cea49fe8
    • Tom Lane's avatar
      Allow statistics to be collected for foreign tables. · 263d9de6
      Tom Lane authored
      ANALYZE now accepts foreign tables and allows the table's FDW to control
      how the sample rows are collected.  (But only manual ANALYZEs will touch
      foreign tables, for the moment, since among other things it's not very
      clear how to handle remote permissions checks in an auto-analyze.)
      
      contrib/file_fdw is extended to support this.
      
      Etsuro Fujita, reviewed by Shigeru Hanada, some further tweaking by me.
      263d9de6
  21. Mar 09, 2012
    • Tom Lane's avatar
      Revise FDW planning API, again. · b1495393
      Tom Lane authored
      Further reflection shows that a single callback isn't very workable if we
      desire to let FDWs generate multiple Paths, because that forces the FDW to
      do all work necessary to generate a valid Plan node for each Path.  Instead
      split the former PlanForeignScan API into three steps: GetForeignRelSize,
      GetForeignPaths, GetForeignPlan.  We had already bit the bullet of breaking
      the 9.1 FDW API for 9.2, so this shouldn't cause very much additional pain,
      and it's substantially more flexible for complex FDWs.
      
      Add an fdw_private field to RelOptInfo so that the new functions can save
      state there rather than possibly having to recalculate information two or
      three times.
      
      In addition, we'd not thought through what would be needed to allow an FDW
      to set up subexpressions of its choice for runtime execution.  We could
      treat ForeignScan.fdw_private as an executable expression but that seems
      likely to break existing FDWs unnecessarily (in particular, it would
      restrict the set of node types allowable in fdw_private to those supported
      by expression_tree_walker).  Instead, invent a separate field fdw_exprs
      which will receive the postprocessing appropriate for expression trees.
      (One field is enough since it can be a list of expressions; also, we assume
      the corresponding expression state tree(s) will be held within fdw_state,
      so we don't need to add anything to ForeignScanState.)
      
      Per review of Hanada Shigeru's pgsql_fdw patch.  We may need to tweak this
      further as we continue to work on that patch, but to me it feels a lot
      closer to being right now.
      b1495393
  22. Mar 08, 2012
    • Tom Lane's avatar
      Add GetForeignColumnOptions() to foreign.c, and add some documentation. · 9088d1b9
      Tom Lane authored
      GetForeignColumnOptions provides some abstraction for accessing
      column-specific FDW options, on a par with the access functions that were
      already provided here for other FDW-related information.
      
      Adjust file_fdw.c to use GetForeignColumnOptions instead of equivalent
      hand-rolled code.
      
      In addition, add some SGML documentation for the functions exported by
      foreign.c that are meant for use by FDW authors.
      
      (This is the fdw_helper portion of the proposed pgsql_fdw patch.)
      
      Hanada Shigeru, reviewed by KaiGai Kohei
      9088d1b9
  23. Mar 05, 2012
    • Tom Lane's avatar
      Redesign PlanForeignScan API to allow multiple paths for a foreign table. · 6b289942
      Tom Lane authored
      The original API specification only allowed an FDW to create a single
      access path, which doesn't seem like a terribly good idea in hindsight.
      Instead, move the responsibility for building the Path node and calling
      add_path() into the FDW's PlanForeignScan function.  Now, it can do that
      more than once if appropriate.  There is no longer any need for the
      transient FdwPlan struct, so get rid of that.
      
      Etsuro Fujita, Shigeru Hanada, Tom Lane
      6b289942
  24. Jan 02, 2012
  25. Sep 16, 2011
  26. Jul 06, 2011
  27. Jul 04, 2011
  28. Apr 10, 2011
  29. Feb 21, 2011
    • Itagaki Takahiro's avatar
      Add ENCODING option to COPY TO/FROM and file_fdw. · 3cba8240
      Itagaki Takahiro authored
      File encodings can be specified separately from client encoding.
      If not specified, client encoding is used for backward compatibility.
      
      Cases when the encoding doesn't match client encoding are slower
      than matched cases because we don't have conversion procs for other
      encodings. Performance improvement would be be a future work.
      
      Original patch by Hitoshi Harada, and modified by me.
      3cba8240
  30. Feb 20, 2011
    • Tom Lane's avatar
      Add contrib/file_fdw foreign-data wrapper for reading files via COPY. · 7c5d0ae7
      Tom Lane authored
      This is both very useful in its own right, and an important test case
      for the core FDW support.
      
      This commit includes a small refactoring of copy.c to expose its option
      checking code as a separately callable function.  The original patch
      submission duplicated hundreds of lines of that code, which seemed pretty
      unmaintainable.
      
      Shigeru Hanada, reviewed by Itagaki Takahiro and Tom Lane
      7c5d0ae7
Loading