Skip to content
Snippets Groups Projects
  1. Feb 06, 2017
  2. Nov 29, 2016
    • Tom Lane's avatar
      Test all contrib-created operator classes with amvalidate. · ade49c60
      Tom Lane authored
      I'd supposed that people would do this manually when creating new operator
      classes, but the folly of that was exposed today.  The tests seem fast
      enough that we can just apply them during the normal regression tests.
      
      contrib/isn fails the checks for lack of complete sets of cross-type
      operators.  That's a nice-to-have policy rather than a functional
      requirement, so leave it as-is, but insert ORDER BY in the query to
      ensure consistent cross-platform output.
      
      Discussion: https://postgr.es/m/7076.1480446837@sss.pgh.pa.us
      ade49c60
  3. Nov 07, 2016
  4. Nov 05, 2016
    • 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
  5. Jun 14, 2016
    • Robert Haas's avatar
      Update extensions with GIN/GIST support for parallel query. · 2910fc82
      Robert Haas authored
      Commit 749a787c bumped the extension
      version on all of these extensions already, and we haven't had a
      release since then, so we can make further changes without bumping the
      extension version again.  Take this opportunity to mark all of the
      functions exported by these modules PARALLEL SAFE -- except for
      pg_trgm's set_limit().  Mark that one PARALLEL RESTRICTED, because it
      makes a persistent change to a GUC value.
      
      Note that some of the markings added by this commit don't have any
      effect; for example, gseg_picksplit() isn't likely to be mentioned
      explicitly in a query and therefore it's parallel-safety marking will
      never be consulted.  But this commit just marks everything for
      consistency: if it were somehow used in a query, that would be fine as
      far as parallel query is concerned, since it does not consult any
      backend-private state, attempt to write data, etc.
      
      Andreas Karlsson, with a few revisions by me.
      2910fc82
  6. 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
  7. Mar 08, 2016
  8. 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
  9. Oct 05, 2015
    • Noah Misch's avatar
      Prevent stack overflow in query-type functions. · 5976097c
      Noah Misch authored
      The tsquery, ltxtquery and query_int data types have a common ancestor.
      Having acquired check_stack_depth() calls independently, each was
      missing at least one call.  Back-patch to 9.0 (all supported versions).
      5976097c
  10. May 24, 2015
  11. May 15, 2015
    • Alvaro Herrera's avatar
      Move strategy numbers to include/access/stratnum.h · 26df7066
      Alvaro Herrera authored
      For upcoming BRIN opclasses, it's convenient to have strategy numbers
      defined in a single place.  Since there's nothing appropriate, create
      it.  The StrategyNumber typedef now lives there, as well as existing
      strategy numbers for B-trees (from skey.h) and R-tree-and-friends (from
      gist.h).  skey.h is forced to include stratnum.h because of the
      StrategyNumber typedef, but gist.h is not; extensions that currently
      rely on gist.h for rtree strategy numbers might need to add a new
      
      A few .c files can stop including skey.h and/or gist.h, which is a nice
      side benefit.
      
      Per discussion:
      https://www.postgresql.org/message-id/20150514232132.GZ2523@alvh.no-ip.org
      
      Authored by Emre Hasegeli and Álvaro.
      
      (It's not clear to me why bootscanner.l has any #include lines at all.)
      26df7066
  12. Apr 14, 2015
    • Heikki Linnakangas's avatar
      Reorganize our CRC source files again. · 4f700bcd
      Heikki Linnakangas authored
      Now that we use CRC-32C in WAL and the control file, the "traditional" and
      "legacy" CRC-32 variants are not used in any frontend programs anymore.
      Move the code for those back from src/common to src/backend/utils/hash.
      
      Also move the slicing-by-8 implementation (back) to src/port. This is in
      preparation for next patch that will add another implementation that uses
      Intel SSE 4.2 instructions to calculate CRC-32C, where available.
      4f700bcd
  13. Feb 20, 2015
    • Tom Lane's avatar
      Use FLEXIBLE_ARRAY_MEMBER in a bunch more places. · 09d8d110
      Tom Lane authored
      Replace some bogus "x[1]" declarations with "x[FLEXIBLE_ARRAY_MEMBER]".
      Aside from being more self-documenting, this should help prevent bogus
      warnings from static code analyzers and perhaps compiler misoptimizations.
      
      This patch is just a down payment on eliminating the whole problem, but
      it gets rid of a lot of easy-to-fix cases.
      
      Note that the main problem with doing this is that one must no longer rely
      on computing sizeof(the containing struct), since the result would be
      compiler-dependent.  Instead use offsetof(struct, lastfield).  Autoconf
      also warns against spelling that offsetof(struct, lastfield[0]).
      
      Michael Paquier, review and additional fixes by me.
      09d8d110
  14. Feb 09, 2015
    • Heikki Linnakangas's avatar
      Move pg_crc.c to src/common, and remove pg_crc_tables.h · c619c235
      Heikki Linnakangas authored
      To get CRC functionality in a client program, you now need to link with
      libpgcommon instead of libpgport. The CRC code has nothing to do with
      portability, so libpgcommon is a better home. (libpgcommon didn't exist
      when pg_crc.c was originally moved to src/port.)
      
      Remove the possibility to get CRC functionality by just #including
      pg_crc_tables.h. I'm not aware of any extensions that actually did that and
      couldn't simply link with libpgcommon.
      
      This also moves the pg_crc.h header file from src/include/utils to
      src/include/common, which will require changes to any external programs
      that currently does #include "utils/pg_crc.h". That seems acceptable, as
      include/common is clearly the right home for it now, and the change needed
      to any such programs is trivial.
      c619c235
  15. Nov 05, 2014
    • Tom Lane's avatar
      Fix volatility markings of some contrib I/O functions. · 66c029c8
      Tom Lane authored
      In general, datatype I/O functions are supposed to be immutable or at
      worst stable.  Some contrib I/O functions were, through oversight, not
      marked with any volatility property at all, which made them VOLATILE.
      Since (most of) these functions actually behave immutably, the erroneous
      marking isn't terribly harmful; but it can be user-visible in certain
      circumstances, as per a recent bug report from Joe Van Dyk in which a
      cast to text was disallowed in an expression index definition.
      
      To fix, just adjust the declarations in the extension SQL scripts.  If we
      were being very fussy about this, we'd bump the extension version numbers,
      but that seems like more trouble (for both developers and users) than the
      problem is worth.
      
      A fly in the ointment is that chkpass_in actually is volatile, because
      of its use of random() to generate a fresh salt when presented with a
      not-yet-encrypted password.  This is bad because of the general assumption
      that I/O functions aren't volatile: the consequence is that records or
      arrays containing chkpass elements may have input behavior a bit different
      from a bare chkpass column.  But there seems no way to fix this without
      breaking existing usage patterns for chkpass, and the consequences of the
      inconsistency don't seem bad enough to justify that.  So for the moment,
      just document it in a comment.
      
      Since we're not bumping version numbers, there seems no harm in
      back-patching these fixes; at least future installations will get the
      functions marked correctly.
      66c029c8
  16. Nov 04, 2014
    • Heikki Linnakangas's avatar
      Switch to CRC-32C in WAL and other places. · 5028f22f
      Heikki Linnakangas authored
      The old algorithm was found to not be the usual CRC-32 algorithm, used by
      Ethernet et al. We were using a non-reflected lookup table with code meant
      for a reflected lookup table. That's a strange combination that AFAICS does
      not correspond to any bit-wise CRC calculation, which makes it difficult to
      reason about its properties. Although it has worked well in practice, seems
      safer to use a well-known algorithm.
      
      Since we're changing the algorithm anyway, we might as well choose a
      different polynomial. The Castagnoli polynomial has better error-correcting
      properties than the traditional CRC-32 polynomial, even if we had
      implemented it correctly. Another reason for picking that is that some new
      CPUs have hardware support for calculating CRC-32C, but not CRC-32, let
      alone our strange variant of it. This patch doesn't add any support for such
      hardware, but a future patch could now do that.
      
      The old algorithm is kept around for tsquery and pg_trgm, which use the
      values in indexes that need to remain compatible so that pg_upgrade works.
      While we're at it, share the old lookup table for CRC-32 calculation
      between hstore, ltree and core. They all use the same table, so might as
      well.
      5028f22f
  17. Aug 25, 2014
  18. Jul 14, 2014
  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. Feb 17, 2014
    • Noah Misch's avatar
      Predict integer overflow to avoid buffer overruns. · 31400a67
      Noah Misch authored
      Several functions, mostly type input functions, calculated an allocation
      size such that the calculation wrapped to a small positive value when
      arguments implied a sufficiently-large requirement.  Writes past the end
      of the inadvertent small allocation followed shortly thereafter.
      Coverity identified the path_in() vulnerability; code inspection led to
      the rest.  In passing, add check_stack_depth() to prevent stack overflow
      in related functions.
      
      Back-patch to 8.4 (all supported versions).  The non-comment hstore
      changes touch code that did not exist in 8.4, so that part stops at 9.0.
      
      Noah Misch and Heikki Linnakangas, reviewed by Tom Lane.
      
      Security: CVE-2014-0064
      31400a67
  22. 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
  23. Jul 16, 2012
    • Peter Eisentraut's avatar
      Remove unreachable code · dd16f948
      Peter Eisentraut authored
      The Solaris Studio compiler warns about these instances, unlike more
      mainstream compilers such as gcc.  But manual inspection showed that
      the code is clearly not reachable, and we hope no worthy compiler will
      complain about removing this code.
      dd16f948
  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. Feb 28, 2012
  26. 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
  27. 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
  28. Sep 01, 2011
  29. Aug 27, 2011
  30. 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
  31. Feb 14, 2011
    • Tom Lane's avatar
      Avoid use of CREATE OR REPLACE FUNCTION in extension installation files. · 029fac22
      Tom Lane authored
      It was never terribly consistent to use OR REPLACE (because of the lack of
      comparable functionality for data types, operators, etc), and
      experimentation shows that it's now positively pernicious in the extension
      world.  We really want a failure to occur if there are any conflicts, else
      it's unclear what the extension-ownership state of the conflicted object
      ought to be.  Most of the time, CREATE EXTENSION will fail anyway because
      of conflicts on other object types, but an extension defining only
      functions can succeed, with bad results.
      029fac22
    • Tom Lane's avatar
      Convert contrib modules to use the extension facility. · 629b3af2
      Tom Lane authored
      This isn't fully tested as yet, in particular I'm not sure that the
      "foo--unpackaged--1.0.sql" scripts are OK.  But it's time to get some
      buildfarm cycles on it.
      
      sepgsql is not converted to an extension, mainly because it seems to
      require a very nonstandard installation process.
      
      Dimitri Fontaine and Tom Lane
      629b3af2
  32. Feb 08, 2011
    • Peter Eisentraut's avatar
      Per-column collation support · 414c5a2e
      Peter Eisentraut authored
      This adds collation support for columns and domains, a COLLATE clause
      to override it per expression, and B-tree index support.
      
      Peter Eisentraut
      reviewed by Pavel Stehule, Itagaki Takahiro, Robert Haas, Noah Misch
      414c5a2e
  33. Jan 09, 2011
    • Tom Lane's avatar
      Use array_contains_nulls instead of ARR_HASNULL on user-supplied arrays. · 30484507
      Tom Lane authored
      This applies the fix for bug #5784 to remaining places where we wish
      to reject nulls in user-supplied arrays.  In all these places, there's
      no reason not to allow a null bitmap to be present, so long as none of
      the current elements are actually null.
      
      I did not change some other places where we are looking at system catalog
      entries or aggregate transition values, as the presence of a null bitmap
      in such an array would be suspicious.
      30484507
  34. Dec 22, 2010
  35. Dec 19, 2010
    • Tom Lane's avatar
      Fix erroneous parsing of tsquery input "... & !(subexpression) | ..." · abc10262
      Tom Lane authored
      After parsing a parenthesized subexpression, we must pop all pending
      ANDs and NOTs off the stack, just like the case for a simple operand.
      Per bug #5793.
      
      Also fix clones of this routine in contrib/intarray and contrib/ltree,
      where input of types query_int and ltxtquery had the same problem.
      
      Back-patch to all supported versions.
      abc10262
  36. Nov 23, 2010
  37. Sep 22, 2010
  38. Sep 20, 2010
Loading