Skip to content
Snippets Groups Projects
  1. Jun 21, 2017
    • Tom Lane's avatar
      Phase 2 of pgindent updates. · c7b8998e
      Tom Lane authored
      Change pg_bsd_indent to follow upstream rules for placement of comments
      to the right of code, and remove pgindent hack that caused comments
      following #endif to not obey the general rule.
      
      Commit e3860ffa wasn't actually using
      the published version of pg_bsd_indent, but a hacked-up version that
      tried to minimize the amount of movement of comments to the right of
      code.  The situation of interest is where such a comment has to be
      moved to the right of its default placement at column 33 because there's
      code there.  BSD indent has always moved right in units of tab stops
      in such cases --- but in the previous incarnation, indent was working
      in 8-space tab stops, while now it knows we use 4-space tabs.  So the
      net result is that in about half the cases, such comments are placed
      one tab stop left of before.  This is better all around: it leaves
      more room on the line for comment text, and it means that in such
      cases the comment uniformly starts at the next 4-space tab stop after
      the code, rather than sometimes one and sometimes two tabs after.
      
      Also, ensure that comments following #endif are indented the same
      as comments following other preprocessor commands such as #else.
      That inconsistency turns out to have been self-inflicted damage
      from a poorly-thought-through post-indent "fixup" in pgindent.
      
      This patch is much less interesting than the first round of indent
      changes, but also bulkier, so I thought it best to separate the effects.
      
      Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
      Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
      c7b8998e
    • Tom Lane's avatar
      Initial pgindent run with pg_bsd_indent version 2.0. · e3860ffa
      Tom Lane authored
      The new indent version includes numerous fixes thanks to Piotr Stefaniak.
      The main changes visible in this commit are:
      
      * Nicer formatting of function-pointer declarations.
      * No longer unexpectedly removes spaces in expressions using casts,
        sizeof, or offsetof.
      * No longer wants to add a space in "struct structname *varname", as
        well as some similar cases for const- or volatile-qualified pointers.
      * Declarations using PG_USED_FOR_ASSERTS_ONLY are formatted more nicely.
      * Fixes bug where comments following declarations were sometimes placed
        with no space separating them from the code.
      * Fixes some odd decisions for comments following case labels.
      * Fixes some cases where comments following code were indented to less
        than the expected column 33.
      
      On the less good side, it now tends to put more whitespace around typedef
      names that are not listed in typedefs.list.  This might encourage us to
      put more effort into typedef name collection; it's not really a bug in
      indent itself.
      
      There are more changes coming after this round, having to do with comment
      indentation and alignment of lines appearing within parentheses.  I wanted
      to limit the size of the diffs to something that could be reviewed without
      one's eyes completely glazing over, so it seemed better to split up the
      changes as much as practical.
      
      Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
      Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
      e3860ffa
  2. Mar 13, 2017
    • Noah Misch's avatar
      Use wrappers of PG_DETOAST_DATUM_PACKED() more. · 3a0d4731
      Noah Misch authored
      This makes almost all core code follow the policy introduced in the
      previous commit.  Specific decisions:
      
      - Text search support functions with char* and length arguments, such as
        prsstart and lexize, may receive unaligned strings.  I doubt
        maintainers of non-core text search code will notice.
      
      - Use plain VARDATA() on values detoasted or synthesized earlier in the
        same function.  Use VARDATA_ANY() on varlenas sourced outside the
        function, even if they happen to always have four-byte headers.  As an
        exception, retain the universal practice of using VARDATA() on return
        values of SendFunctionCall().
      
      - Retain PG_GETARG_BYTEA_P() in pageinspect.  (Page images are too large
        for a one-byte header, so this misses no optimization.)  Sites that do
        not call get_page_from_raw() typically need the four-byte alignment.
      
      - For now, do not change btree_gist.  Its use of four-byte headers in
        memory is partly entangled with storage of 4-byte headers inside
        GBT_VARKEY, on disk.
      
      - For now, do not change gtrgm_consistent() or gtrgm_distance().  They
        incorporate the varlena header into a cache, and there are multiple
        credible implementation strategies to consider.
      3a0d4731
  3. Jan 03, 2017
  4. Dec 22, 2016
  5. Dec 18, 2016
    • Tom Lane's avatar
      In contrib/uuid-ossp, #include headers needed for ntohl() and ntohs(). · 4a0a34b5
      Tom Lane authored
      Oversight in commit b8cc8f94.  I just noticed this causes compiler
      warnings on FreeBSD, and it really ought to cause warnings elsewhere too:
      all references I can find say that <arpa/inet.h> is required for these.
      We have a lot of code elsewhere that thinks that both <netinet/in.h>
      and <arpa/inet.h> should be included for these functions, so do it that
      way here too, even though <arpa/inet.h> ought to be sufficient according
      to the references I consulted.
      
      Back-patch to 9.4 where the previous commit landed.
      4a0a34b5
  6. Jun 14, 2016
  7. Jan 02, 2016
  8. Jan 06, 2015
  9. Aug 25, 2014
  10. Jul 14, 2014
  11. Jul 10, 2014
  12. May 29, 2014
    • Tom Lane's avatar
      When using the OSSP UUID library, cache its uuid_t state object. · c941aed9
      Tom Lane authored
      The original coding in contrib/uuid-ossp created and destroyed a uuid_t
      object (or, in some cases, even two of them) each time it was called.
      This is not the intended usage: you're supposed to keep the uuid_t object
      around so that the library can cache its state across uses.  (Other UUID
      libraries seem to keep equivalent state behind-the-scenes in static
      variables, but OSSP chose differently.)  Aside from being quite inefficient,
      creating a new uuid_t loses knowledge of the previously generated UUID,
      which in theory could result in duplicate V1-style UUIDs being created
      on sufficiently fast machines.
      
      On at least some platforms, creating a new uuid_t also draws some entropy
      from /dev/urandom, leaving less for the rest of the system.  This seems
      sufficiently unpleasant to justify back-patching this change.
      c941aed9
    • Tom Lane's avatar
      Fix uuid-ossp regression tests based on buildfarm feedback. · 25dd07e0
      Tom Lane authored
      The previous version of these tests expected uuid_generate_v1() to always
      emit MAC addresses with the local-admin and multicast address bits zero.
      However, several of the buildfarm critters are reporting values with the
      local-admin bit set.  (Perhaps they're running inside VMs or jails.)
      And a couple are reporting values with the multicast bit set, probably
      meaning that the UUID library couldn't read the system MAC address.
      
      Also, it emerges that if OSSP UUID can't read the system MAC address, it
      falls back to V1MC behavior wherein the whole node field gets randomized
      each time, breaking the test that expected the node field to remain stable
      in V1 output.  (It looks like e2fs doesn't behave that way, though.)
      
      It's not entirely clear why we can't get a system MAC address, since the
      buildfarm scripts would not work without internet access.  Nonetheless,
      the regression tests had better cope with the case, so adjust the tests
      to expect these behaviors.
      25dd07e0
  13. May 28, 2014
    • Tom Lane's avatar
      Improve regression tests for uuid-ossp. · c0f27628
      Tom Lane authored
      On reflection, the timestamp-advances test might fail if we're unlucky
      enough for the time_mid field to change between two calls, since uuid_cmp
      is just bytewise comparison and the field ordering has more significant
      fields later.  Build some field extraction functions so we can do a more
      honest test of that.  Also check that the version and reserved fields
      contain what they should.
      c0f27628
    • Tom Lane's avatar
      Fix stack clobber in new uuid-ossp code. · 2103218d
      Tom Lane authored
      The V5 (SHA1 hashing) code wrote 20 bytes into a 16-byte local variable.
      This had accidentally failed to fail in my testing and Matteo's, but
      buildfarm results exposed the problem.
      2103218d
    • Tom Lane's avatar
      Support BSD and e2fsprogs UUID libraries alongside OSSP UUID library. · b8cc8f94
      Tom Lane authored
      Allow the contrib/uuid-ossp extension to be built atop any one of these
      three popular UUID libraries.  (The extension's name is now arguably a
      misnomer, but we'll keep it the same so as not to cause unnecessary
      compatibility issues for users.)
      
      We would not normally consider a change like this post-beta1, but the issue
      has been forced by our upgrade to autoconf 2.69, whose more rigorous header
      checks are causing OSSP's header files to be rejected on some platforms.
      It's been foreseen for some time that we'd have to move away from depending
      on OSSP UUID due to lack of upstream maintenance, so this is a down payment
      on that problem.
      
      While at it, add some simple regression tests, in hopes of catching any
      major incompatibilities between the three implementations.
      
      Matteo Beccati, with some further hacking by me
      b8cc8f94
  14. 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
  15. Jan 07, 2014
  16. Nov 22, 2013
  17. Jan 01, 2013
  18. Jan 02, 2012
  19. 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
  20. 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
  21. Jan 01, 2011
  22. Oct 26, 2010
  23. Sep 20, 2010
  24. Jan 02, 2010
  25. Jun 11, 2009
  26. Jan 01, 2009
  27. Mar 25, 2008
    • Tom Lane's avatar
      Simplify and standardize conversions between TEXT datums and ordinary C · 220db7cc
      Tom Lane authored
      strings.  This patch introduces four support functions cstring_to_text,
      cstring_to_text_with_len, text_to_cstring, and text_to_cstring_buffer, and
      two macros CStringGetTextDatum and TextDatumGetCString.  A number of
      existing macros that provided variants on these themes were removed.
      
      Most of the places that need to make such conversions now require just one
      function or macro call, in place of the multiple notational layers that used
      to be needed.  There are no longer any direct calls of textout or textin,
      and we got most of the places that were using handmade conversions via
      memcpy (there may be a few still lurking, though).
      
      This commit doesn't make any serious effort to eliminate transient memory
      leaks caused by detoasting toasted text objects before they reach
      text_to_cstring.  We changed PG_GETARG_TEXT_P to PG_GETARG_TEXT_PP in a few
      places where it was easy, but much more could be done.
      
      Brendan Jurd and Tom Lane
      220db7cc
  28. Jan 01, 2008
  29. Dec 31, 2007
  30. Nov 15, 2007
  31. Nov 13, 2007
Loading