Skip to content
Snippets Groups Projects
  1. Jun 09, 2016
    • Tom Lane's avatar
      Handle contrib's GIN/GIST support function signature changes honestly. · 749a787c
      Tom Lane authored
      In commits 9ff60273 and dbe23289 I (tgl) fixed the
      signatures of a bunch of contrib's GIN and GIST support functions so that
      they would pass validation by the recently-added amvalidate functions.
      The backend does not actually consult or check those signatures otherwise,
      so I figured this was basically cosmetic and did not require an extension
      version bump.  However, Alexander Korotkov pointed out that that would
      leave us in a pretty messy situation if we ever wanted to redefine those
      functions later, because there wouldn't be a unique way to name them.
      Since we're going to be bumping these extensions' versions anyway for
      parallel-query cleanups, let's take care of this now.
      
      Andreas Karlsson, adjusted for more search-path-safety by me
      749a787c
  2. Jun 05, 2016
    • Tom Lane's avatar
      Properly initialize SortSupport for ORDER BY rechecks in nodeIndexscan.c. · 8a859691
      Tom Lane authored
      Fix still another bug in commit 35fcb1b3: it failed to fully initialize
      the SortSupport states it introduced to allow the executor to re-check
      ORDER BY expressions containing distance operators.  That led to a null
      pointer dereference if the sortsupport code tried to use ssup_cxt.  The
      problem only manifests in narrow cases, explaining the lack of previous
      field reports.  It requires a GiST-indexable distance operator that lacks
      SortSupport and is on a pass-by-ref data type, which among core+contrib
      seems to be only btree_gist's interval opclass; and it requires the scan
      to be done as an IndexScan not an IndexOnlyScan, which explains how
      btree_gist's regression test didn't catch it.  Per bug #14134 from
      Jihyun Yu.
      
      Peter Geoghegan
      
      Report: <20160511154904.2603.43889@wrigleys.postgresql.org>
      8a859691
  3. May 13, 2016
    • Tom Lane's avatar
      Ensure plan stability in contrib/btree_gist regression test. · d94977ef
      Tom Lane authored
      Buildfarm member skink failed with symptoms suggesting that an
      auto-analyze had happened and changed the plan displayed for a
      test query.  Although this is evidently of low probability,
      regression tests that sometimes fail are no fun, so add commands
      to force a bitmap scan to be chosen.
      d94977ef
  4. Jan 19, 2016
    • Tom Lane's avatar
      Fix assorted inconsistencies in GiST opclass support function declarations. · 9ff60273
      Tom Lane authored
      The conventions specified by the GiST SGML documentation were widely
      ignored.  For example, the strategy-number argument for "consistent" and
      "distance" functions is specified to be a smallint, but most of the
      built-in support functions declared it as an integer, and for that matter
      the core code passed it using Int32GetDatum not Int16GetDatum.  None of
      that makes any real difference at runtime, but it's quite confusing for
      newcomers to the code, and it makes it very hard to write an amvalidate()
      function that checks support function signatures.  So let's try to instill
      some consistency here.
      
      Another similar issue is that the "query" argument is not of a single
      well-defined type, but could have different types depending on the strategy
      (corresponding to search operators with different righthand-side argument
      types).  Some of the functions threw up their hands and declared the query
      argument as being of "internal" type, which surely isn't right ("any" would
      have been more appropriate); but the majority position seemed to be to
      declare it as being of the indexed data type, corresponding to a search
      operator with both input types the same.  So I've specified a convention
      that that's what to do always.
      
      Also, the result of the "union" support function actually must be of the
      index's storage type, but the documentation suggested declaring it to
      return "internal", and some of the functions followed that.  Standardize
      on telling the truth, instead.
      
      Similarly, standardize on declaring the "same" function's inputs as
      being of the storage type, not "internal".
      
      Also, somebody had forgotten to add the "recheck" argument to both
      the documentation of the "distance" support function and all of their
      SQL declarations, even though the C code was happily using that argument.
      Clean that up too.
      
      Fix up some other omissions in the docs too, such as documenting that
      union's second input argument is vestigial.
      
      So far as the errors in core function declarations go, we can just fix
      pg_proc.h and bump catversion.  Adjusting the erroneous declarations in
      contrib modules is more debatable: in principle any change in those
      scripts should involve an extension version bump, which is a pain.
      However, since these changes are purely cosmetic and make no functional
      difference, I think we can get away without doing that.
      9ff60273
  5. Sep 05, 2015
  6. Aug 23, 2015
  7. May 24, 2015
  8. Apr 02, 2015
    • Andres Freund's avatar
      Define integer limits independently from the system definitions. · 62e2a8dc
      Andres Freund authored
      In 83ff1618 we defined integer limits iff they're not provided by the
      system. That turns out not to be the greatest idea because there's
      different ways some datatypes can be represented. E.g. on OSX PG's 64bit
      datatype will be a 'long int', but OSX unconditionally uses 'long
      long'. That disparity then can lead to warnings, e.g. around printf
      formats.
      
      One way to fix that would be to back int64 using stdint.h's
      int64_t. While a good idea it's not that easy to implement. We would
      e.g. need to include stdint.h in our external headers, which we don't
      today. Also computing the correct int64 printf formats in that case is
      nontrivial.
      
      Instead simply prefix the integer limits with PG_ and define them
      unconditionally. I've adjusted all the references to them in code, but
      not the ones in comments; the latter seems unnecessary to me.
      
      Discussion: 20150331141423.GK4878@alap3.anarazel.de
      62e2a8dc
  9. Mar 30, 2015
    • Tom Lane's avatar
      Be more careful about printing constants in ruleutils.c. · 542320c2
      Tom Lane authored
      The previous coding in get_const_expr() tried to avoid quoting integer,
      float, and numeric literals if at all possible.  While that looks nice,
      it means that dumped expressions might re-parse to something that's
      semantically equivalent but not the exact same parsetree; for example
      a FLOAT8 constant would re-parse as a NUMERIC constant with a cast to
      FLOAT8.  Though the result would be the same after constant-folding,
      this is problematic in certain contexts.  In particular, Jeff Davis
      pointed out that this could cause unexpected failures in ALTER INHERIT
      operations because of child tables having not-exactly-equivalent CHECK
      expressions.  Therefore, favor correctness over legibility and dump
      such constants in quotes except in the limited cases where they'll
      be interpreted as the same type even without any casting.
      
      This results in assorted small changes in the regression test outputs,
      and will affect display of user-defined views and rules similarly.
      The odds of that causing problems in the field seem non-negligible;
      given the lack of previous complaints, it seems best not to change
      this in the back branches.
      542320c2
  10. Mar 27, 2015
  11. Mar 26, 2015
    • Heikki Linnakangas's avatar
      Minor refactoring of btree_gist code. · 8816af65
      Heikki Linnakangas authored
      The gbt_var_key_copy function was doing two different things depending on
      the boolean argument. Seems cleaner to have two separate functions.
      
      Remove unused argument from gbt_num_compress.
      8816af65
  12. Mar 25, 2015
    • Andres Freund's avatar
      Centralize definition of integer limits. · 83ff1618
      Andres Freund authored
      Several submitted and even committed patches have run into the problem
      that C89, our baseline, does not provide minimum/maximum values for
      various integer datatypes. C99's stdint.h does, but we can't rely on
      it.
      
      Several parts of the code defined limits locally, so instead centralize
      the definitions to c.h.
      
      This patch also changes the more obvious usages of literal limit values;
      there's more places that could be changed, but it's less clear whether
      it's beneficial to change those.
      
      Author: Andrew Gierth
      Discussion: 87619tc5wc.fsf@news-spur.riddles.org.uk
      83ff1618
  13. Jan 28, 2015
    • Heikki Linnakangas's avatar
      Remove dead NULL-pointer checks in GiST code. · 670bf71f
      Heikki Linnakangas authored
      gist_poly_compress() and gist_circle_compress() checked for a NULL-pointer
      key argument, but that was dead code; the gist code never passes a
      NULL-pointer to the "compress" method.
      
      This commit also removes a documentation note added in commit a0a3883d,
      about doing NULL-pointer checks in the "compress" method. It was added
      based on the fact that some implementations were doing NULL-pointer
      checks, but those checks were unnecessary in the first place.
      
      The NULL-pointer check in gbt_var_same() function was also unnecessary.
      The arguments to the "same" method come from the "compress", "union", or
      "picksplit" methods, but none of them return a NULL pointer.
      
      None of this is to be confused with SQL NULL values. Those are dealt with
      by the gist machinery, and are never passed to the GiST opclass methods.
      
      Michael Paquier
      670bf71f
  14. Oct 16, 2014
    • Tom Lane's avatar
      Support timezone abbreviations that sometimes change. · b2cbced9
      Tom Lane authored
      Up to now, PG has assumed that any given timezone abbreviation (such as
      "EDT") represents a constant GMT offset in the usage of any particular
      region; we had a way to configure what that offset was, but not for it
      to be changeable over time.  But, as with most things horological, this
      view of the world is too simplistic: there are numerous regions that have
      at one time or another switched to a different GMT offset but kept using
      the same timezone abbreviation.  Almost the entire Russian Federation did
      that a few years ago, and later this month they're going to do it again.
      And there are similar examples all over the world.
      
      To cope with this, invent the notion of a "dynamic timezone abbreviation",
      which is one that is referenced to a particular underlying timezone
      (as defined in the IANA timezone database) and means whatever it currently
      means in that zone.  For zones that use or have used daylight-savings time,
      the standard and DST abbreviations continue to have the property that you
      can specify standard or DST time and get that time offset whether or not
      DST was theoretically in effect at the time.  However, the abbreviations
      mean what they meant at the time in question (or most recently before that
      time) rather than being absolutely fixed.
      
      The standard abbreviation-list files have been changed to use this behavior
      for abbreviations that have actually varied in meaning since 1970.  The
      old simple-numeric definitions are kept for abbreviations that have not
      changed, since they are a bit faster to resolve.
      
      While this is clearly a new feature, it seems necessary to back-patch it
      into all active branches, because otherwise use of Russian zone
      abbreviations is going to become even more problematic than it already was.
      This change supersedes the changes in commit 513d06de et al to modify the
      fixed meanings of the Russian abbreviations; since we've not shipped that
      yet, this will avoid an undesirably incompatible (not to mention incorrect)
      change in behavior for timestamps between 2011 and 2014.
      
      This patch makes some cosmetic changes in ecpglib to keep its usage of
      datetime lookup tables as similar as possible to the backend code, but
      doesn't do anything about the increasingly obsolete set of timezone
      abbreviation definitions that are hard-wired into ecpglib.  Whatever we
      do about that will likely not be appropriate material for back-patching.
      Also, a potential free() of a garbage pointer after an out-of-memory
      failure in ecpglib has been fixed.
      
      This patch also fixes pre-existing bugs in DetermineTimeZoneOffset() that
      caused it to produce unexpected results near a timezone transition, if
      both the "before" and "after" states are marked as standard time.  We'd
      only ever thought about or tested transitions between standard and DST
      time, but that's not what's happening when a zone simply redefines their
      base GMT offset.
      
      In passing, update the SGML documentation to refer to the Olson/zoneinfo/
      zic timezone database as the "IANA" database, since it's now being
      maintained under the auspices of IANA.
      b2cbced9
  15. Aug 25, 2014
  16. Jul 14, 2014
  17. May 16, 2014
    • Tom Lane's avatar
      Suppress some more valgrind whining about btree_gist. · af215d81
      Tom Lane authored
      A couple of functions didn't bother to zero out pad bytes in datums that
      would ultimately go to disk.  Harmless, but valgrind doesn't know that.
      af215d81
    • Tom Lane's avatar
      Fix a second cause of undersized pallocs for btree_gist indexes on macaddr. · 39586bc1
      Tom Lane authored
      gbt_macad_union also allocated 12-byte structs where we really need 16.
      
      Per report from Andres Freund.  No back-patch since there's no current
      risk of a real problem.
      39586bc1
    • Tom Lane's avatar
      Fix valgrind warning for btree_gist indexes on macaddr. · 82bbb60c
      Tom Lane authored
      The macaddr opclass stores two macaddr structs (each of size 6) in an
      index column that's declared as being of type gbtreekey16, ie 16 bytes.
      In the original coding this led to passing a palloc'd value of size 12
      to the index insertion code, so that data would be fetched past the
      end of the allocated value during index tuple construction.  This makes
      valgrind unhappy.  In principle it could result in a SIGSEGV, though
      with the current implementation of palloc there's no risk since
      the 12-byte request size would be rounded up to 16 bytes anyway.
      
      To fix, add a field to struct gbtree_ninfo showing the declared size of
      the index datums, and use that in the palloc requests; and use palloc0
      to be sure that any wasted bytes are cleanly initialized.
      
      Per report from Andres Freund.  No back-patch since there's no current
      risk of a real problem.
      82bbb60c
  18. May 13, 2014
    • Heikki Linnakangas's avatar
      Initialize padding bytes in btree_gist varbit support. · 540ac7ce
      Heikki Linnakangas authored
      The code expands a varbit gist leaf key to a node key by copying the bit
      data twice in a varlen datum, as both the lower and upper key. The lower key
      was expanded to INTALIGN size, but the padding bytes were not initialized.
      That's a problem because when the lower/upper keys are compared, the padding
      bytes are used compared too, when the values are otherwise equal. That could
      lead to incorrect query results.
      
      REINDEX is advised for any btree_gist indexes on bit or bit varying data
      type, to fix any garbage padding bytes on disk.
      
      Per Valgrind, reported by Andres Freund. Backpatch to all supported
      versions.
      540ac7ce
  19. 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
  20. 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
  21. May 29, 2013
  22. Feb 08, 2013
    • Tom Lane's avatar
      Make contrib/btree_gist's GiST penalty function a bit saner. · 9221f9d4
      Tom Lane authored
      The previous coding supposed that the first differing bytes in two varlena
      datums must have the same sign difference as their overall comparison
      result.  This is obviously bogus for text strings in non-C locales, and
      probably wrong for numeric, and even for bytea I think it was wrong on
      machines where char is signed.  When the assumption failed, the function
      could deliver a zero or negative penalty in situations where such a result
      is quite ridiculous, leading the core GiST code to make very bad page-split
      decisions.
      
      To fix, take the absolute values of the byte-level differences.  Also,
      switch the code to using unsigned char not just char, so that the behavior
      will be consistent whether char is signed or not.
      
      Per investigation of a trouble report from Tomas Vondra.  Back-patch to all
      supported branches.
      9221f9d4
    • Tom Lane's avatar
      Fix erroneous range-union logic for varlena types in contrib/btree_gist. · 94f565dc
      Tom Lane authored
      gbt_var_bin_union() failed to do the right thing when the existing range
      needed to be widened at both ends rather than just one end.  This could
      result in an invalid index in which keys that are present would not be
      found by searches, because the searches would not think they need to
      descend to the relevant leaf pages.  This error affected all the varlena
      datatypes supported by btree_gist (text, bytea, bit, numeric).
      
      Per investigation of a trouble report from Tomas Vondra.  (There is also
      an issue in gbt_var_penalty(), but that should only result in inefficiency
      not wrong answers.  I'm committing this separately so that we have a git
      state in which it can be tested that bad penalty results don't produce
      invalid indexes.)  Back-patch to all supported branches.
      94f565dc
  23. Jul 05, 2012
  24. Jun 25, 2012
    • Peter Eisentraut's avatar
      Replace int2/int4 in C code with int16/int32 · b8b2e3b2
      Peter Eisentraut authored
      The latter was already the dominant use, and it's preferable because
      in C the convention is that intXX means XX bits.  Therefore, allowing
      mixed use of int2, int4, int8, int16, int32 is obviously confusing.
      
      Remove the typedefs for int2 and int4 for now.  They don't seem to be
      widely used outside of the PostgreSQL source tree, and the few uses
      can probably be cleaned up by the time this ships.
      b8b2e3b2
  25. Oct 12, 2011
    • Tom Lane's avatar
      Throw a useful error message if an extension script file is fed to psql. · 458857cc
      Tom Lane authored
      We have seen one too many reports of people trying to use 9.1 extension
      files in the old-fashioned way of sourcing them in psql.  Not only does
      that usually not work (due to failure to substitute for MODULE_PATHNAME
      and/or @extschema@), but if it did work they'd get a collection of loose
      objects not an extension.  To prevent this, insert an \echo ... \quit
      line that prints a suitable error message into each extension script file,
      and teach commands/extension.c to ignore lines starting with \echo.
      That should not only prevent any adverse consequences of loading a script
      file the wrong way, but make it crystal clear to users that they need to
      do it differently now.
      
      Tom Lane, following an idea of Andrew Dunstan's.  Back-patch into 9.1
      ... there is not going to be much value in this if we wait till 9.2.
      458857cc
  26. Sep 11, 2011
    • Peter Eisentraut's avatar
      Remove many -Wcast-qual warnings · 1b81c2fe
      Peter Eisentraut authored
      This addresses only those cases that are easy to fix by adding or
      moving a const qualifier or removing an unnecessary cast.  There are
      many more complicated cases remaining.
      1b81c2fe
  27. Sep 09, 2011
    • Tom Lane's avatar
      Move Timestamp/Interval typedefs and basic macros into datatype/timestamp.h. · a7801b62
      Tom Lane authored
      As per my recent proposal, this refactors things so that these typedefs and
      macros are available in a header that can be included in frontend-ish code.
      I also changed various headers that were undesirably including
      utils/timestamp.h to include datatype/timestamp.h instead.  Unsurprisingly,
      this showed that half the system was getting utils/timestamp.h by way of
      xlog.h.
      
      No actual code changes here, just header refactoring.
      a7801b62
  28. Sep 01, 2011
  29. Aug 27, 2011
  30. Jun 09, 2011
  31. Apr 25, 2011
    • Peter Eisentraut's avatar
      Support "make check" in contrib · f8ebe3bc
      Peter Eisentraut authored
      Added a new option --extra-install to pg_regress to arrange installing
      the respective contrib directory into the temporary installation.
      This is currently not yet supported for Windows MSVC builds.
      
      Updated the .gitignore files for contrib modules to ignore the
      leftovers of a temp-install check run.
      
      Changed the exit status of "make check" in a pgxs build (which still
      does nothing) to 0 from 1.
      
      Added "make check" in contrib to top-level "make check-world".
      f8ebe3bc
  32. Apr 23, 2011
    • Tom Lane's avatar
      Fix contrib/btree_gist to handle collations properly. · bb850306
      Tom Lane authored
      Make use of the collation attached to the index column, instead of
      hard-wiring DEFAULT_COLLATION_OID.  (Note: in theory this could require
      reindexing btree_gist indexes on textual columns, but I rather doubt anyone
      has one with a non-default declared collation as yet.)
      bb850306
  33. Apr 13, 2011
    • Tom Lane's avatar
      Pass collations to functions in FunctionCallInfoData, not FmgrInfo. · d64713df
      Tom Lane authored
      Since collation is effectively an argument, not a property of the function,
      FmgrInfo is really the wrong place for it; and this becomes critical in
      cases where a cached FmgrInfo is used for varying purposes that might need
      different collation settings.  Fix by passing it in FunctionCallInfoData
      instead.  In particular this allows a clean fix for bug #5970 (record_cmp
      not working).  This requires touching a bit more code than the original
      method, but nobody ever thought that collations would not be an invasive
      patch...
      d64713df
  34. Apr 10, 2011
  35. Mar 03, 2011
  36. Mar 02, 2011
  37. Feb 17, 2011
    • Tom Lane's avatar
      Fix upgrade of contrib/btree_gist from 9.0. · ec65a79d
      Tom Lane authored
      The initial version of the update-from-unpackaged script neglected to
      include the <> operators that were added to the opclasses during 9.1.
      To make this script produce the same final state as the regular install
      script, use the same ALTER OPERATOR FAMILY trick as in pg_trgm.
      ec65a79d
Loading