Skip to content
Snippets Groups Projects
  1. Feb 03, 2017
    • Tom Lane's avatar
      In pageinspect/hashfuncs.c, avoid crashes on alignment-picky machines. · 14e9b18f
      Tom Lane authored
      On machines with MAXALIGN = 8, the payload of a bytea is not maxaligned,
      since it will start 4 bytes into a palloc'd value.  On alignment-picky
      hardware, this will cause failures in accesses to 8-byte-wide values
      within the page.  We already encountered this problem when we introduced
      GIN index inspection functions, and fixed it in commit 84ad68d6.  Make
      use of the same function for hash indexes.
      
      A small difficulty is that up to now contrib/pageinspect has not shared
      any functions at all across files.  To support that, introduce a common
      header file "pageinspect.h" for the module.
      
      Also, move get_page_from_raw() out of ginfuncs.c, where it didn't
      especially belong, and put it in rawpage.c which seems a more natural home.
      
      Per buildfarm.
      
      Discussion: https://postgr.es/m/17311.1486134714@sss.pgh.pa.us
      14e9b18f
    • Robert Haas's avatar
      pageinspect: Remove platform-dependent values from hash tests. · 29e312bc
      Robert Haas authored
      Per a report from Tom Lane, the ffactor reported by hash_metapage_info
      and the free_size reported by hash_page_stats vary by platform.
      
      Ashutosh Sharma and Robert Haas
      29e312bc
    • Tom Lane's avatar
      Fix a bunch more portability bugs in commit 08bf6e52. · c6eeb67d
      Tom Lane authored
      It seems like somebody used a dartboard while choosing integer widths
      for the various values taken and returned by these functions ... and
      then threw a fresh set of darts while writing the SQL declarations.
      
      This patch brings the C code into line with what the SQL declarations
      say, which is enough to make it not dump core on the particular 32-bit
      machine I'm testing on.  But I think we could do with another round
      of looking at what the datum widths *should* be.  For instance, it's
      not all that sensible that hash_bitmap_info decided to use int64 to
      represent a BlockNumber input when get_raw_page doesn't do it that way.
      
      There's also a remaining problem that the expected outputs from the
      test script are platform-dependent, but I'll leave that issue for
      somebody else.
      
      Per buildfarm.
      c6eeb67d
    • Robert Haas's avatar
      pageinspect: Try to fix some bugs in previous commit. · ed807fda
      Robert Haas authored
      Commit 08bf6e52 seems not to have
      used the correct *GetDatum and PG_GETARG_* macros for the SQL types
      in some cases, and some of the SQL types seem to have been poorly
      chosen, too.  Try to fix it.  I'm not sure if this is the reason
      why the buildfarm is currently unhappy with this code, but it
      seems like a good place to start.
      
      Buildfarm unhappiness reported by Tom Lane.
      ed807fda
  2. Feb 02, 2017
  3. Feb 01, 2017
    • Heikki Linnakangas's avatar
      Replace isMD5() with a more future-proof way to check if pw is encrypted. · dbd69118
      Heikki Linnakangas authored
      The rule is that if pg_authid.rolpassword begins with "md5" and has the
      right length, it's an MD5 hash, otherwise it's a plaintext password. The
      idiom has been to use isMD5() to check for that, but that gets awkward,
      when we add new kinds of verifiers, like the verifiers for SCRAM
      authentication in the pending SCRAM patch set. Replace isMD5() with a new
      get_password_type() function, so that when new verifier types are added, we
      don't need to remember to modify every place that currently calls isMD5(),
      to also recognize the new kinds of verifiers.
      
      Also, use the new plain_crypt_verify function in passwordcheck, so that it
      doesn't need to know about MD5, or in the future, about other kinds of
      hashes or password verifiers.
      
      Reviewed by Michael Paquier and Peter Eisentraut.
      
      Discussion: https://www.postgresql.org/message-id/2d07165c-1793-e243-a2a9-e45b624c7580@iki.fi
      dbd69118
  4. Jan 27, 2017
  5. Jan 25, 2017
  6. Jan 24, 2017
  7. Jan 21, 2017
  8. Jan 19, 2017
  9. Jan 18, 2017
  10. Jan 17, 2017
  11. Jan 14, 2017
    • Tom Lane's avatar
      Teach contrib/pg_stat_statements to handle multi-statement commands better. · 83f2061d
      Tom Lane authored
      Make use of the statement boundary info added by commit ab1f0c82
      to let pg_stat_statements behave more sanely when multiple SQL queries
      are jammed into one query string.  It now records just the relevant
      part of the source string, not the whole thing, for each individual
      query.
      
      Even when no multi-statement strings are involved, users may notice small
      changes in the output: leading and trailing whitespace and semicolons will
      be stripped from statements, which did not happen before.
      
      Also, significantly expand pg_stat_statements' regression test script.
      
      Fabien Coelho, reviewed by Craig Ringer and Kyotaro Horiguchi,
      some mods by me
      
      Discussion: https://postgr.es/m/alpine.DEB.2.20.1612200926310.29821@lancre
      83f2061d
    • Tom Lane's avatar
      Change representation of statement lists, and add statement location info. · ab1f0c82
      Tom Lane authored
      This patch makes several changes that improve the consistency of
      representation of lists of statements.  It's always been the case
      that the output of parse analysis is a list of Query nodes, whatever
      the types of the individual statements in the list.  This patch brings
      similar consistency to the outputs of raw parsing and planning steps:
      
      * The output of raw parsing is now always a list of RawStmt nodes;
      the statement-type-dependent nodes are one level down from that.
      
      * The output of pg_plan_queries() is now always a list of PlannedStmt
      nodes, even for utility statements.  In the case of a utility statement,
      "planning" just consists of wrapping a CMD_UTILITY PlannedStmt around
      the utility node.  This list representation is now used in Portal and
      CachedPlan plan lists, replacing the former convention of intermixing
      PlannedStmts with bare utility-statement nodes.
      
      Now, every list of statements has a consistent head-node type depending
      on how far along it is in processing.  This allows changing many places
      that formerly used generic "Node *" pointers to use a more specific
      pointer type, thus reducing the number of IsA() tests and casts needed,
      as well as improving code clarity.
      
      Also, the post-parse-analysis representation of DECLARE CURSOR is changed
      so that it looks more like EXPLAIN, PREPARE, etc.  That is, the contained
      SELECT remains a child of the DeclareCursorStmt rather than getting flipped
      around to be the other way.  It's now true for both Query and PlannedStmt
      that utilityStmt is non-null if and only if commandType is CMD_UTILITY.
      That allows simplifying a lot of places that were testing both fields.
      (I think some of those were just defensive programming, but in many places,
      it was actually necessary to avoid confusing DECLARE CURSOR with SELECT.)
      
      Because PlannedStmt carries a canSetTag field, we're also able to get rid
      of some ad-hoc rules about how to reconstruct canSetTag for a bare utility
      statement; specifically, the assumption that a utility is canSetTag if and
      only if it's the only one in its list.  While I see no near-term need for
      relaxing that restriction, it's nice to get rid of the ad-hocery.
      
      The API of ProcessUtility() is changed so that what it's passed is the
      wrapper PlannedStmt not just the bare utility statement.  This will affect
      all users of ProcessUtility_hook, but the changes are pretty trivial; see
      the affected contrib modules for examples of the minimum change needed.
      (Most compilers should give pointer-type-mismatch warnings for uncorrected
      code.)
      
      There's also a change in the API of ExplainOneQuery_hook, to pass through
      cursorOptions instead of expecting hook functions to know what to pick.
      This is needed because of the DECLARE CURSOR changes, but really should
      have been done in 9.6; it's unlikely that any extant hook functions
      know about using CURSOR_OPT_PARALLEL_OK.
      
      Finally, teach gram.y to save statement boundary locations in RawStmt
      nodes, and pass those through to Query and PlannedStmt nodes.  This allows
      more intelligent handling of cases where a source query string contains
      multiple statements.  This patch doesn't actually do anything with the
      information, but a follow-on patch will.  (Passing this information through
      cleanly is the true motivation for these changes; while I think this is all
      good cleanup, it's unlikely we'd have bothered without this end goal.)
      
      catversion bump because addition of location fields to struct Query
      affects stored rules.
      
      This patch is by me, but it owes a good deal to Fabien Coelho who did
      a lot of preliminary work on the problem, and also reviewed the patch.
      
      Discussion: https://postgr.es/m/alpine.DEB.2.20.1612200926310.29821@lancre
      ab1f0c82
    • Peter Eisentraut's avatar
      pg_ctl: Change default to wait for all actions · 05cd12ed
      Peter Eisentraut authored
      
      The different actions in pg_ctl had different defaults for -w and -W,
      mostly for historical reasons.  Most users will want the -w behavior, so
      make that the default.
      
      Remove the -w option in most example and test code, so avoid confusion
      and reduce verbosity.  pg_upgrade is not touched, so it can continue to
      work with older installations.
      
      Reviewed-by: default avatarBeena Emerson <memissemerson@gmail.com>
      Reviewed-by: default avatarRyan Murphy <ryanfmurphy@gmail.com>
      05cd12ed
    • Peter Eisentraut's avatar
      Updates to reflect that pg_ctl stop -m fast is the default · e574f15d
      Peter Eisentraut authored
      Various example and test code used -m fast explicitly, but since it's
      the default, this can be omitted now or should be replaced by a better
      example.
      
      pg_upgrade is not touched, so it can continue to operate with older
      installations.
      e574f15d
  12. Jan 12, 2017
  13. Jan 06, 2017
    • Tom Lane's avatar
      Invalidate cached plans on FDW option changes. · c52d37c8
      Tom Lane authored
      This fixes problems where a plan must change but fails to do so,
      as seen in a bug report from Rajkumar Raghuwanshi.
      
      For ALTER FOREIGN TABLE OPTIONS, do this through the standard method of
      forcing a relcache flush on the table.  For ALTER FOREIGN DATA WRAPPER
      and ALTER SERVER, just flush the whole plan cache on any change in
      pg_foreign_data_wrapper or pg_foreign_server.  That matches the way
      we handle some other low-probability cases such as opclass changes, and
      it's unclear that the case arises often enough to be worth working harder.
      Besides, that gives a patch that is simple enough to back-patch with
      confidence.
      
      Back-patch to 9.3.  In principle we could apply the code change to 9.2 as
      well, but (a) we lack postgres_fdw to test it with, (b) it's doubtful that
      anyone is doing anything exciting enough with FDWs that far back to need
      this desperately, and (c) the patch doesn't apply cleanly.
      
      Patch originally by Amit Langote, reviewed by Etsuro Fujita and Ashutosh
      Bapat, who each contributed substantial changes as well.
      
      Discussion: https://postgr.es/m/CAKcux6m5cA6rRPTKkqVdJ-R=KKDfe35Q_ZuUqxDSV_4hwga=og@mail.gmail.com
      c52d37c8
  14. Jan 05, 2017
  15. Jan 03, 2017
  16. Dec 22, 2016
  17. 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
  18. Dec 15, 2016
    • Peter Eisentraut's avatar
      Various temporary slots test improvements · fdf71389
      Peter Eisentraut authored
      Fix the tests on slow machines (per buildfarm).
      
      Add test for dropping on error.  And also try to consume real changes
      from temporary slots.
      
      From: Petr Jelinek <petr.jelinek@2ndquadrant.com>
      fdf71389
  19. Dec 12, 2016
  20. Dec 08, 2016
    • Robert Haas's avatar
      Log the creation of an init fork unconditionally. · fa0f466d
      Robert Haas authored
      Previously, it was thought that this only needed to be done for the
      benefit of possible standbys, so wal_level = minimal skipped it.
      But that's not safe, because during crash recovery we might replay
      XLOG_DBASE_CREATE or XLOG_TBLSPC_CREATE record which recursively
      removes the directory that contains the new init fork.  So log it
      always.
      
      The user-visible effect of this bug is that if you create a database
      or tablespace, then create an unlogged table, then crash without
      checkpointing, then restart, accessing the table will fail, because
      the it won't have been properly reset.  This commit fixes that.
      
      Michael Paquier, per a report from Konstantin Knizhnik.  Wording of
      the comments per a suggestion from me.
      fa0f466d
  21. Dec 05, 2016
    • Heikki Linnakangas's avatar
      Replace PostmasterRandom() with a stronger source, second attempt. · fe0a0b59
      Heikki Linnakangas authored
      This adds a new routine, pg_strong_random() for generating random bytes,
      for use in both frontend and backend. At the moment, it's only used in
      the backend, but the upcoming SCRAM authentication patches need strong
      random numbers in libpq as well.
      
      pg_strong_random() is based on, and replaces, the existing implementation
      in pgcrypto. It can acquire strong random numbers from a number of sources,
      depending on what's available:
      
      - OpenSSL RAND_bytes(), if built with OpenSSL
      - On Windows, the native cryptographic functions are used
      - /dev/urandom
      
      Unlike the current pgcrypto function, the source is chosen by configure.
      That makes it easier to test different implementations, and ensures that
      we don't accidentally fall back to a less secure implementation, if the
      primary source fails. All of those methods are quite reliable, it would be
      pretty surprising for them to fail, so we'd rather find out by failing
      hard.
      
      If no strong random source is available, we fall back to using erand48(),
      seeded from current timestamp, like PostmasterRandom() was. That isn't
      cryptographically secure, but allows us to still work on platforms that
      don't have any of the above stronger sources. Because it's not very secure,
      the built-in implementation is only used if explicitly requested with
      --disable-strong-random.
      
      This replaces the more complicated Fortuna algorithm we used to have in
      pgcrypto, which is unfortunate, but all modern platforms have /dev/urandom,
      so it doesn't seem worth the maintenance effort to keep that. pgcrypto
      functions that require strong random numbers will be disabled with
      --disable-strong-random.
      
      Original patch by Magnus Hagander, tons of further work by Michael Paquier
      and me.
      
      Discussion: https://www.postgresql.org/message-id/CAB7nPqRy3krN8quR9XujMVVHYtXJ0_60nqgVc6oUk8ygyVkZsA@mail.gmail.com
      Discussion: https://www.postgresql.org/message-id/CAB7nPqRWkNYRRPJA7-cF+LfroYV10pvjdz6GNvxk-Eee9FypKA@mail.gmail.com
      fe0a0b59
  22. Nov 30, 2016
    • Heikki Linnakangas's avatar
      Remove dead stuff from pgcrypto. · b2cc748b
      Heikki Linnakangas authored
      pgp-pubkey-DISABLED test has been unused since 2006, when support for
      built-in bignum math was added (commit 1abf76e8). pgp-encrypt-DISABLED has
      been unused forever, AFAICS.
      
      Also remove a couple of unused error codes.
      b2cc748b
  23. Nov 29, 2016
Loading