1. 07 Nov, 2016 2 commits
  2. 06 Nov, 2016 6 commits
    • Tom Lane's avatar
      Support PL/Tcl functions that return composite types and/or sets. · 26abb50c
      Tom Lane authored
      Jim Nasby, rather heavily editorialized by me
      
      Patch: <f2134651-14b3-efeb-f274-c69f3c084031@BlueTreble.com>
      26abb50c
    • Tom Lane's avatar
      Modernize result-tuple construction in pltcl_trigger_handler(). · 2178cbf4
      Tom Lane authored
      Use Tcl_ListObjGetElements instead of Tcl_SplitList.  Aside from being
      possibly more efficient in its own right, this means we are no longer
      responsible for freeing a malloc'd result array, so we can get rid of
      a PG_TRY/PG_CATCH block.
      
      Use heap_form_tuple instead of SPI_modifytuple.  We don't need the
      extra generality of the latter, since we're always replacing all
      columns.  Nor do we need its memory-context-munging, since at this
      point we're already out of the SPI environment.
      
      Per comparison of this code to tuple-building code submitted by Jim Nasby.
      I've abandoned the thought of merging the two cases into a single routine,
      but we may as well make the older code simpler and faster where we can.
      2178cbf4
    • Tom Lane's avatar
      Rationalize and document pltcl's handling of magic ".tupno" array element. · fd2664dc
      Tom Lane authored
      For a very long time, pltcl's spi_exec and spi_execp commands have had
      a behavior of storing the current row number as an element of output
      arrays, but this was never documented.  Fix that.
      
      For an equally long time, pltcl_trigger_handler had a behavior of silently
      ignoring ".tupno" as an output column name, evidently so that the result
      of spi_exec could be used directly as a trigger result tuple.  Not sure
      how useful that really is, but in any case it's bad that it would break
      attempts to use ".tupno" as an actual column name.  We can fix it by not
      checking for ".tupno" until after we check for a column name match.  This
      comports with the effective behavior of spi_exec[p] that ".tupno" is only
      magic when you don't have an actual column named that.
      
      In passing, wordsmith the description of returning modified tuples from
      a pltcl trigger.
      
      Noted while working on Jim Nasby's patch to support composite results
      from pltcl.  The inability to return trigger tuples using ".tupno" as
      a column name is a bug, so back-patch to all supported branches.
      fd2664dc
    • Tom Lane's avatar
      Need to do SPI_push/SPI_pop around expression evaluation in plpgsql. · fc8b81a2
      Tom Lane authored
      We must do this in case the expression evaluation results in calling
      another plpgsql function (or, really, anything using SPI).  I missed
      the need for this when I converted exec_cast_value() from doing a
      simple InputFunctionCall() to doing ExecEvalExpr() in commit 1345cc67.
      There is a SPI_push_conditional in InputFunctionCall(), so that there
      was no bug before that.
      
      Per bug #14414 from Marcos Castedo.  Add a regression test based on his
      example, which was that a plpgsql function in a domain check constraint
      didn't work when assigning to a domain-type variable within plpgsql.
      
      Report: <20161106010947.1387.66380@wrigleys.postgresql.org>
      fc8b81a2
    • Tom Lane's avatar
      Fix silly nil-pointer-dereference bug introduced in commit d5f6f13f. · 5485c99e
      Tom Lane authored
      Don't fetch record->xl_info before we've verified that record isn't
      NULL.  Per Coverity.
      
      Michael Paquier
      5485c99e
    • Tom Lane's avatar
      More zic cleanup. · 32416b0f
      Tom Lane authored
      The workaround the IANA guys chose to get rid of the clang warning
      we'd silenced in commit 23ed2ba8 turns out not to satisfy Coverity.
      Go back to the previous solution, ie, remove the useless comparison
      to SIZE_MAX.  (In principle, there could be machines out there where
      it's not useless because ptrdiff_t is wider than size_t.  But the whole
      thing is pretty academic anyway, as we could never approach this limit
      for any sane estimate of the amount of data that zic will ever be asked
      to work with.)
      
      Also, s/lineno/lineno_t/g, because if we accept their decision to start
      using "lineno" as a typedef, it is going to have very unpleasant
      consequences in our next pgindent run.  Noted that while fooling with
      pltcl yesterday.
      32416b0f
  3. 05 Nov, 2016 6 commits
    • Tom Lane's avatar
      Improve minor error-handling details in pltcl. · 1b00dd0e
      Tom Lane authored
      Don't ask Tcl_GetIndexFromObj to store an error message in the interpreter
      in cases where the next argument isn't necessarily one of the options
      we're asking it to check for.  At best that is a waste of time, and at
      worst it might cause an inappropriate error result to get left behind.
      
      Be sure to check for valid syntax (ie, no command arguments) in
      pltcl_SPI_lastoid.
      
      Extracted from a larger and otherwise-unrelated patch.
      
      Jim Nasby
      
      Patch: <f2134651-14b3-efeb-f274-c69f3c084031@BlueTreble.com>
      1b00dd0e
    • Tom Lane's avatar
      Adjust cost_merge_append() to reflect use of binaryheap_replace_first(). · 34ca0905
      Tom Lane authored
      Commit 7a2fe9bd improved merge append so that replacement of a tuple
      takes log(N) operations, not twice log(N).  Since cost_merge_append knew
      about that explicitly, we should adjust it.  This probably makes little
      difference in practice, but the obsolete comment is confusing.
      
      Ideally this would have been put in in 9.3 with the underlying behavior
      change; but I'm not going to back-patch it, since there's some small chance
      of changing a plan choice that somebody's optimized for.
      
      Thomas Munro
      
      Discussion: <CAEepm=0WQBSvuYcMOUj4Ga4NXpu2J=ejZcE=e=eiTjTX-6_gDw@mail.gmail.com>
      34ca0905
    • Tom Lane's avatar
      Remove duplicate macro definition. · 86d19d27
      Tom Lane authored
      Seems to be a copy-and-pasteo.  Odd that we heard no reports of
      compiler warnings about it.
      
      Thomas Munro
      86d19d27
    • Tom Lane's avatar
      pgwin32_is_junction's argument should be "const char *" not "char *". · 06f5fd2f
      Tom Lane authored
      We're passing const strings to it in places, and that's not an
      unreasonable thing to do.  Per buildfarm (noted on frogmouth
      in particular).
      06f5fd2f
    • Peter Eisentraut's avatar
      doc: Don't reformat .fo files before processing by fop · d49cc588
      Peter Eisentraut authored
      This messes up the whitespace in the output PDF document in some places.
      d49cc588
    • Peter Eisentraut's avatar
      6feb69f6
  4. 04 Nov, 2016 15 commits
    • Tom Lane's avatar
      Provide DLLEXPORT markers for C functions via PG_FUNCTION_INFO_V1 macro. · c8ead2a3
      Tom Lane authored
      Second try at the change originally made in commit 8518583c;
      this time with contrib updates so that manual extern declarations
      are also marked with PGDLLEXPORT.  The release notes should point
      this out as a significant source-code change for extension authors,
      since they'll have to make similar additions to avoid trouble on Windows.
      
      Laurenz Albe, doc change by me
      
      Patch: <A737B7A37273E048B164557ADEF4A58B53962ED8@ntex2010a.host.magwien.gv.at>
      c8ead2a3
    • Tom Lane's avatar
      Delete contrib/xml2's legacy implementation of xml_is_well_formed(). · 20540710
      Tom Lane authored
      This function is unreferenced in modern usage; it was superseded in 9.1
      by a core function of the same name.  It has been left in place in the C
      code only so that pre-9.1 SQL definitions of the contrib/xml2 functions
      would continue to work.  Six years seems like enough time for people to
      have updated to the extension-style version of the xml2 module, so let's
      drop this.
      
      The key reason for not keeping it any longer is that we want to stick
      an explicit PGDLLEXPORT into PG_FUNCTION_INFO_V1(), and the similarity
      of name to the core function creates a conflict that compilers will
      complain about.
      
      Extracted from a larger patch for that purpose.  I'm committing this
      change separately to give it more visibility in the commit logs.
      
      While at it, remove the documentation entry that claimed that
      xml_is_well_formed() is a function provided by contrib/xml2, and
      instead mention the even more ancient alias xml_valid().
      
      Laurenz Albe, doc change by me
      
      Patch: <A737B7A37273E048B164557ADEF4A58B53962ED8@ntex2010a.host.magwien.gv.at>
      20540710
    • Tom Lane's avatar
      Be more consistent about masking xl_info with ~XLR_INFO_MASK. · d5f6f13f
      Tom Lane authored
      Generally, WAL resource managers are only supposed to examine the
      top 4 bits of a WAL record's xl_info; the rest are reserved for
      the WAL mechanism itself.  A few places were not consistent about
      doing this with respect to XLOG_CHECKPOINT and XLOG_SWITCH records.
      There's no bug currently, since no additional bits ever get set in
      these specific record types, but that might not be true forever.
      Let's follow the generic coding rule here too.
      
      Michael Paquier
      d5f6f13f
    • Tom Lane's avatar
      Fix gin_leafpage_items(). · 367b99bb
      Tom Lane authored
      On closer inspection, commit 84ad68d6 broke gin_leafpage_items(),
      because the aligned copy of the page got palloc'd in a short-lived
      context whereas it needs to be in the SRF's multi_call_memory_ctx.
      This was not exposed by the regression test, because the regression
      test doesn't actually exercise the function in a meaningful way.
      Fix the code bug, and extend the test in what I hope is a portable
      fashion.
      367b99bb
    • Kevin Grittner's avatar
      Improve tab completion for CREATE TRIGGER. · 927d7bb6
      Kevin Grittner authored
      This includes support for the new REFERENCING clause.
      927d7bb6
    • Kevin Grittner's avatar
      Implement syntax for transition tables in AFTER triggers. · 8c48375e
      Kevin Grittner authored
      This is infrastructure for the complete SQL standard feature.  No
      support is included at this point for execution nodes or PLs.  The
      intent is to add that soon.
      
      As this patch leaves things, standard syntax can create tuplestores
      to contain old and/or new versions of rows affected by a statement.
      References to these tuplestores are in the TriggerData structure.
      C triggers can access the tuplestores directly, so they are usable,
      but they cannot yet be referenced within a SQL statement.
      8c48375e
    • Peter Eisentraut's avatar
      pg_xlogdump: Add NLS · 69d590ff
      Peter Eisentraut authored
      Reviewed-by: default avatarMichael Paquier <michael.paquier@gmail.com>
      69d590ff
    • Peter Eisentraut's avatar
      pg_test_timing: Add NLS · 59fa9d2d
      Peter Eisentraut authored
      Also straighten out use of time unit abbreviations a bit.
      Reviewed-by: default avatarMichael Paquier <michael.paquier@gmail.com>
      59fa9d2d
    • Peter Eisentraut's avatar
      pg_test_fsync: Add NLS · a39255d7
      Peter Eisentraut authored
      Reviewed-by: default avatarMichael Paquier <michael.paquier@gmail.com>
      a39255d7
    • Peter Eisentraut's avatar
      632fbe77
    • Peter Eisentraut's avatar
      pageinspect: Fix unaligned struct access in GIN functions · 84ad68d6
      Peter Eisentraut authored
      The raw page data that is passed into the functions will not be aligned
      at 8-byte boundaries.  Casting that to a struct and accessing int64
      fields will result in unaligned access.  On most platforms, you get away
      with it, but it will result on a crash on pickier platforms such as ia64
      and sparc64.
      84ad68d6
    • Robert Haas's avatar
      Add API to check if an existing exclusive lock allows cleanup. · f2e6a2cc
      Robert Haas authored
      LockBufferForCleanup() acquires a cleanup lock unconditionally, and
      ConditionalLockBufferForCleanup() acquires a cleanup lock if it is
      possible to do so without waiting; this patch adds a new API,
      IsBufferCleanupOK(), which tests whether an exclusive lock already
      held happens to be a cleanup lock.  This is possible because a cleanup
      lock simply means an exclusive lock plus the assurance any other pins
      on the buffer are newer than our own pin.  Therefore, just as the
      existing functions decide that the exclusive lock that they've just
      taken is a cleanup lock if they observe the pin count to be 1, this
      new function allows us to observe that the pin count is 1 on a buffer
      we've already locked.
      
      This is useful in situations where a backend definitely wishes to
      modify the buffer and also wishes to perform cleanup operations if
      possible.  The patch to eliminate heavyweight locking by hash indexes
      uses this, and it may have other applications as well.
      
      Amit Kapila, per a suggestion from me.  Some comment adjustments by me
      as well.
      f2e6a2cc
    • Robert Haas's avatar
      postgres_fdw: Fix typo in comment. · 7016e4c4
      Robert Haas authored
      Etsuro Fujita
      7016e4c4
    • Peter Eisentraut's avatar
      doc: Add index letter links to XSLT HTML build · 97f16b87
      Peter Eisentraut authored
      This matches what was already implemented in the DSSSL HTML build.
      97f16b87
    • Tom Lane's avatar
      Sync our copy of the timezone library with IANA tzcode master. · 1f87181e
      Tom Lane authored
      This patch absorbs some unreleased fixes for symlink manipulation bugs
      introduced in tzcode 2016g.  Ordinarily I'd wait around for a released
      version, but in this case it seems like we could do with extra testing,
      in particular checking whether it works in EDB's VMware build environment.
      This corresponds to commit aec59156abbf8472ba201b6c7ca2592f9c10e077 in
      https://github.com/eggert/tz.
      
      Per a report from Sandeep Thakkar, building in an environment where hard
      links are not supported in the timezone data installation directory failed,
      because upstream code refactoring had broken the case of symlinking from an
      existing symlink.  Further experimentation also showed that the symlinks
      were sometimes made incorrectly, with too many or too few "../"'s in the
      symlink contents.
      
      This should get back-patched, but first let's see what the buildfarm
      makes of it.  I'm not too sure about the new dependency on linkat(2).
      
      Report: <CANFyU94_p6mqRQc2i26PFp5QAOQGB++AjGX=FO8LDpXw0GSTjw@mail.gmail.com>
      Discussion: http://mm.icann.org/pipermail/tz/2016-November/024431.html
      1f87181e
  5. 03 Nov, 2016 4 commits
  6. 02 Nov, 2016 5 commits
    • Tom Lane's avatar
      Don't make FK-based selectivity estimates in inheritance situations. · 77067106
      Tom Lane authored
      The foreign-key-aware logic for estimation of join sizes (added in commit
      100340e2) blindly tried to apply the concept to rels that are actually
      parents of inheritance trees.  This is just plain wrong so far as the
      referenced relation is concerned, since the inheritance scan may well
      produce lots of rows that are not participating in the constraint.  It's
      wrong for the referencing relation too, for the same reason; although on
      that end we could conceivably detect whether all members of the inheritance
      tree have equivalent FK constraints pointing to the same referenced rel,
      and then proceed more or less as we do now.  But pending somebody writing
      code to do that, we must disable this, because it's producing completely
      silly estimates when there's an FK linking the heads of inheritance trees.
      
      Per bug #14404 from Clinton Adams.  Back-patch to 9.6 where the new
      estimation logic came in.
      
      Report: <20161028200412.15987.96482@wrigleys.postgresql.org>
      77067106
    • Tom Lane's avatar
      Don't convert Consts into Vars during setrefs.c processing. · da8f3ebf
      Tom Lane authored
      While converting expressions in an upper-level plan node so that they
      reference Vars and expressions provided by the input plan node(s),
      don't convert plain Const items, even if there happens to be a matching
      Const in the input.  It's silly to do so because a Var is more expensive to
      execute than a Const.  Moreover, converting can fool ExecCheckPlanOutput's
      check that an insert or update query inserts nulls into dropped columns,
      leading to "query provides a value for a dropped column" errors during
      INSERT or UPDATE on a table with a dropped column.  We could solve this
      by making that check more complicated, but I don't see the point; this fix
      should save a marginal number of cycles, and it also makes for less messy
      EXPLAIN output, as shown by the ensuing regression test result changes.
      
      Per report from Pavel Hanák.  I have not incorporated a test case based
      on that example, as there doesn't seem to be a simple way of checking
      this in isolation without making a bunch of assumptions about other
      planner and SQL-function behavior.
      
      Back-patch to 9.6.  This setrefs.c behavior exists much further back,
      but there is not currently reason to think that it causes problems
      before 9.6.
      
      Discussion: <83shraampf.fsf@is-it.eu>
      da8f3ebf
    • Peter Eisentraut's avatar
      pageinspect: Make page test more portable · 00a86856
      Peter Eisentraut authored
      Choose test data that makes the output independent of endianness.
      00a86856
    • Tom Lane's avatar
      Fix portability bug in gin_page_opaque_info(). · 14ee3579
      Tom Lane authored
      Somebody apparently thought that "if Int32GetDatum is good,
      Int64GetDatum must be better".  Per buildfarm failures now
      that Peter has added some regression tests here.
      14ee3579
    • Peter Eisentraut's avatar
      pageinspect: Make btree test more portable · f7c9a6e0
      Peter Eisentraut authored
      Choose test data that makes the output independent of endianness and
      alignment.
      f7c9a6e0
  7. 01 Nov, 2016 2 commits