1. 24 Oct, 2014 1 commit
    • Alvaro Herrera's avatar
      psql: complain if pg_dump custom-format is detected · 3c2aa0c6
      Alvaro Herrera authored
      Apparently, this is a very common mistake for users to make; it is
      better to have it fail reasonably rather than throw potentially a large
      number of errors.  Since we have a magic string at the start of the
      file, we can detect the case easily and there's no other possible useful
      behavior anyway.
      
      Author: Craig Ringer
      3c2aa0c6
  2. 23 Oct, 2014 9 commits
    • Alvaro Herrera's avatar
      Update README.tuplock · b01a4f68
      Alvaro Herrera authored
      This file was documenting an older version of patch 0ac5ad51; update
      it to match what was really committed
      
      Author: Florian Pflug
      b01a4f68
    • Tom Lane's avatar
      In type_sanity, check I/O functions of built-in types are not volatile. · 43ac12c6
      Tom Lane authored
      We have a project policy that I/O functions must not be volatile, as per
      commit aab353a6, but we weren't doing
      anything to enforce that.  In most usage the marking of the function
      doesn't matter as long as its behavior is sane --- but I/O casts can
      expose the marking as user-visible behavior, as per today's complaint
      from Joe Van Dyk about contrib/ltree.
      
      This test as such will only protect us against future errors in built-in
      data types.  To catch the same error in contrib or third-party types,
      perhaps we should make CREATE TYPE complain?  But that's a separate
      issue from enforcing the policy for built-in types.
      43ac12c6
    • Tom Lane's avatar
      Improve ispell dictionary's defenses against bad affix files. · b34d6f03
      Tom Lane authored
      Don't crash if an ispell dictionary definition contains flags but not
      any compound affixes.  (This isn't a security issue since only superusers
      can install affix files, but still it's a bad thing.)
      
      Also, be more careful about detecting whether an affix-file FLAG command
      is old-format (ispell) or new-format (myspell/hunspell).  And change the
      error message about mixed old-format and new-format commands into something
      intelligible.
      
      Per bug #11770 from Emre Hasegeli.  Back-patch to all supported branches.
      b34d6f03
    • Robert Haas's avatar
      Perform less setup work for AFTER triggers at transaction start. · 2781b4be
      Robert Haas authored
      Testing reveals that the memory allocation we do at transaction start
      has small but measurable overhead on simple transactions.  To cut
      down on that overhead, defer some of that work to the point when
      AFTER triggers are first used, thus avoiding it altogether if they
      never are.
      
      Patch by me.  Review by Andres Freund.
      2781b4be
    • Fujii Masao's avatar
      Remove the unused argument of PSQLexec(). · efbbbbc8
      Fujii Masao authored
      This commit simply removes the second argument of PSQLexec that was
      set to the same value everywhere. Comments and code blocks related
      to this parameter are removed.
      
      Noticed by Heikki Linnakangas, reviewed by Michael Paquier
      efbbbbc8
    • Robert Haas's avatar
      Add a function to get the authenticated user ID. · 5ac372fc
      Robert Haas authored
      Previously, this was not exposed outside of miscinit.c.  It is needed
      for the pending pg_background patch, and will also be needed for
      parallelism.  Without it, there's no way for a background worker to
      re-create the exact authentication environment that was present in the
      process that started it, which could lead to security exposures.
      5ac372fc
    • Fujii Masao's avatar
      Prevent the already-archived WAL file from being archived again. · c7371c4a
      Fujii Masao authored
      Previously the archive recovery always created .ready file for
      the last WAL file of the old timeline at the end of recovery even when
      it's restored from the archive and has .done file. That is, there was
      the case where the WAL file had both .ready and .done files.
      This caused the already-archived WAL file to be archived again.
      
      This commit prevents the archive recovery from creating .ready file
      for the last WAL file if it has .done file, in order to prevent it from
      being archived again.
      
      This bug was added when cascading replication feature was introduced,
      i.e., the commit 52861058.
      So, back-patch to 9.2, where cascading replication was added.
      
      Reviewed by Michael Paquier
      c7371c4a
    • Peter Eisentraut's avatar
      Minimize calls of pg_class_aclcheck to minimum necessary · e64d3c56
      Peter Eisentraut authored
      In a couple of code paths, pg_class_aclcheck is called in succession
      with multiple different modes set.  This patch combines those modes to
      have a single call of this function and reduce a bit process overhead
      for permission checking.
      
      Author: Michael Paquier <michael@otacoo.com>
      Reviewed-by: default avatarFabrízio de Royes Mello <fabriziomello@gmail.com>
      e64d3c56
    • Peter Eisentraut's avatar
      Add tests for sequence privileges · a5f7d581
      Peter Eisentraut authored
      a5f7d581
  3. 22 Oct, 2014 5 commits
    • Tom Lane's avatar
      Ensure libpq reports a suitable error message on unexpected socket EOF. · 69fed5b2
      Tom Lane authored
      The EOF-detection logic in pqReadData was a bit confused about who should
      set up the error message in case the kernel gives us read-ready-but-no-data
      rather than ECONNRESET or some other explicit error condition.  Since the
      whole point of this situation is that the lower-level functions don't know
      there's anything wrong, pqReadData itself must set up the message.  But
      keep the assumption that if an errno was reported, a message was set up at
      lower levels.
      
      Per bug #11712 from Marko Tiikkaja.  It's been like this for a very long
      time, so back-patch to all supported branches.
      69fed5b2
    • Michael Meskes's avatar
      Small code cleanup. · 2ae7811d
      Michael Meskes authored
      Declare static variable as static and external as extern.
      2ae7811d
    • Heikki Linnakangas's avatar
      Update comment. · 98b37437
      Heikki Linnakangas authored
      The _bt_tuplecompare() function mentioned in comment hasn't existed for a
      long time.
      
      Peter Geoghegan
      98b37437
    • Noah Misch's avatar
      MinGW: Use -static-libgcc when linking a DLL. · 284590e4
      Noah Misch authored
      When commit 846e91e0 switched the linker
      driver from dlltool/dllwrap to gcc, it became possible for linking to
      choose shared libgcc.  Backends having loaded a module dynamically
      linked to libgcc can exit abnormally, which the postmaster treats like a
      crash.  Resume use of static libgcc exclusively, like 9.3 and earlier.
      Back-patch to 9.4.
      284590e4
    • Noah Misch's avatar
      MinGW: Link with shell32.dll instead of shfolder.dll. · 53566fc0
      Noah Misch authored
      This improves consistency with the MSVC build.  On buildfarm member
      narwhal, since commit 846e91e0,
      shfolder.dll:SHGetFolderPath() crashes when dblink calls it by way of
      pqGetHomeDirectory().  Back-patch to 9.4, where that commit first
      appeared.  How it caused this regression remains a mystery.  This is a
      partial revert of commit 889f0381, which
      adopted shfolder.dll for Windows NT 4.0 compatibility.  PostgreSQL 8.2
      dropped support for that operating system.
      53566fc0
  4. 21 Oct, 2014 5 commits
  5. 20 Oct, 2014 9 commits
    • Andres Freund's avatar
      Don't duplicate log_checkpoint messages for both of restart and checkpoints. · 5e5b65f3
      Andres Freund authored
      The duplication originated in cdd46c76, where restartpoints were
      introduced.
      
      In LogCheckpointStart's case the duplication actually lead to the
      compiler's format string checking not to be effective because the
      format string wasn't constant.
      
      Arguably these messages shouldn't be elog(), but ereport() style
      messages. That'd even allow to translate the messages... But as
      there's more mistakes of that kind in surrounding code, it seems
      better to change that separately.
      5e5b65f3
    • Andres Freund's avatar
      Renumber CHECKPOINT_* flags. · 11abd6c9
      Andres Freund authored
      Commit 7dbb6069 added a new CHECKPOINT_FLUSH_ALL flag. As that
      commit needed to be backpatched I didn't change the numeric values of
      the existing flags as that could lead to nastly problems if any
      external code issued checkpoints. That's not a concern on master, so
      renumber them there.
      
      Also add a comment about CHECKPOINT_FLUSH_ALL above
      CreateCheckPoint().
      11abd6c9
    • Andres Freund's avatar
      Flush unlogged table's buffers when copying or moving databases. · 7dbb6069
      Andres Freund authored
      CREATE DATABASE and ALTER DATABASE .. SET TABLESPACE copy the source
      database directory on the filesystem level. To ensure the on disk
      state is consistent they block out users of the affected database and
      force a checkpoint to flush out all data to disk. Unfortunately, up to
      now, that checkpoint didn't flush out dirty buffers from unlogged
      relations.
      
      That bug means there could be leftover dirty buffers in either the
      template database, or the database in its old location. Leading to
      problems when accessing relations in an inconsistent state; and to
      possible problems during shutdown in the SET TABLESPACE case because
      buffers belonging files that don't exist anymore are flushed.
      
      This was reported in bug #10675 by Maxim Boguk.
      
      Fix by Pavan Deolasee, modified somewhat by me. Reviewed by MauMau and
      Fujii Masao.
      
      Backpatch to 9.1 where unlogged tables were introduced.
      7dbb6069
    • Peter Eisentraut's avatar
      pg_test_fsync: Update output format · 83dc5908
      Peter Eisentraut authored
      Apparently, computers are now a bit faster than when this was first
      added, so we need to make room for a digit or two in the ops/sec format.
      
      While we're at it, adjust some of the other output for a more consistent
      line length.
      83dc5908
    • Andrew Dunstan's avatar
      Correct volatility markings of a few json functions. · af2b8fd0
      Andrew Dunstan authored
      json_agg and json_object_agg and their associated transition functions
      should have been marked as stable rather than immutable, as they call IO
      functions indirectly. Changing this probably isn't going to make much
      difference, as you can't use an aggregate function in an index
      expression, but we should be correct nevertheless.
      
      json_object, on the other hand, should be marked immutable rather than
      stable, as it does not call IO functions.
      
      As discussed on -hackers, this change is being made without bumping the
      catalog version, as we don't want to do that at this stage of the  cycle,
      and  the changes are very unlikely to affect anyone.
      af2b8fd0
    • Tom Lane's avatar
      Fix mishandling of FieldSelect-on-whole-row-Var in nested lateral queries. · f330a6d1
      Tom Lane authored
      If an inline-able SQL function taking a composite argument is used in a
      LATERAL subselect, and the composite argument is a lateral reference,
      the planner could fail with "variable not found in subplan target list",
      as seen in bug #11703 from Karl Bartel.  (The outer function call used in
      the bug report and in the committed regression test is not really necessary
      to provoke the bug --- you can get it if you manually expand the outer
      function into "LATERAL (SELECT inner_function(outer_relation))", too.)
      
      The cause of this is that we generate the reltargetlist for the referenced
      relation before doing eval_const_expressions() on the lateral sub-select's
      expressions (cf find_lateral_references()), so what's scheduled to be
      emitted by the referenced relation is a whole-row Var, not the simplified
      single-column Var produced by optimizing the function's FieldSelect on the
      whole-row Var.  Then setrefs.c fails to match up that lateral reference to
      what's available from the outer scan.
      
      Preserving the FieldSelect optimization in such cases would require either
      major planner restructuring (to recursively do expression simplification
      on sub-selects much earlier) or some amazingly ugly kluge to change the
      reltargetlist of a possibly-already-planned relation.  It seems better
      just to skip the optimization when the Var is from an upper query level;
      the case is not so common that it's likely anyone will notice a few
      wasted cycles.
      
      AFAICT this problem only occurs for uplevel LATERAL references, so
      back-patch to 9.3 where LATERAL was added.
      f330a6d1
    • Tom Lane's avatar
      Fix file-identification comment in contrib/pgcrypto/pgcrypto--1.2.sql. · 488a7c9c
      Tom Lane authored
      Cosmetic oversight in commit 32984d8f.
      
      Marko Tiikkaja
      488a7c9c
    • Robert Haas's avatar
      Fix typos. · bc279c92
      Robert Haas authored
      David Rowley
      bc279c92
    • Robert Haas's avatar
      Fix typos. · 0f565c07
      Robert Haas authored
      Etsuro Fujita
      0f565c07
  6. 19 Oct, 2014 3 commits
  7. 18 Oct, 2014 6 commits
    • Bruce Momjian's avatar
      Shorten warning about hash creation · b87671f1
      Bruce Momjian authored
      Also document that PITR is also affected.
      b87671f1
    • Bruce Momjian's avatar
      interval: tighten precision specification · 417f9248
      Bruce Momjian authored
      interval precision can only be specified after the "interval" keyword if
      no units are specified.
      
      Previously we incorrectly checked the units to see if the precision was
      legal, causing confusion.
      
      Report by Alvaro Herrera
      417f9248
    • Bruce Momjian's avatar
      doc: restrictions on alter database moving default tablespace · 97d55487
      Bruce Momjian authored
      Mention tablespace must be empty and no one connected to the database.
      
      Report by Josh Berkus
      97d55487
    • Peter Eisentraut's avatar
      doc: Clean up pg_recvlogical reference page · 52c1ae22
      Peter Eisentraut authored
      This needed a general cleanup of wording, typos, outdated terminology,
      formatting, and hard-to-understand and borderline incorrect information.
      
      Also tweak the pg_receivexlog page a bit to make the two more
      consistent.
      52c1ae22
    • Tom Lane's avatar
      Declare mkdtemp() only if we're providing it. · 60f8133d
      Tom Lane authored
      Follow our usual style of providing an "extern" for a standard library
      function only when we're also providing the implementation.  This avoids
      issues when the system headers declare the function slightly differently
      than we do, as noted by Caleb Welton.
      
      We might have to go to the extent of probing to see if the system headers
      declare the function, but let's not do that until it's demonstrated to be
      necessary.
      
      Oversight in commit 9e6b1bf2.  Back-patch
      to all supported branches, as that was.
      60f8133d
    • Tom Lane's avatar
      Avoid core dump in _outPathInfo() for Path without a parent RelOptInfo. · 5ba062ee
      Tom Lane authored
      Nearly all Paths have parents, but a ResultPath representing an empty FROM
      clause does not.  Avoid a core dump in such cases.  I believe this is only
      a hazard for debugging usage, not for production, else we'd have heard
      about it before.  Nonetheless, back-patch to 9.1 where the troublesome code
      was introduced.  Noted while poking at bug #11703.
      5ba062ee
  8. 17 Oct, 2014 2 commits
    • Fujii Masao's avatar
      Fix bug in handling of connections that pg_receivexlog creates. · 504c7175
      Fujii Masao authored
      Previously pg_receivexlog created new connection for WAL streaming
      even though another connection which had been established to create
      or delete the replication slot was being left. This caused the unused
      connection to be left uselessly until pg_receivexlog exited.
      This bug was introduced by the commit d9f38c7a.
      
      This patch changes pg_receivexlog so that the connection for
      the replication slot is reused for WAL streaming.
      
      Andres Freund, slightly modified by me, reviewed by Michael Paquier
      504c7175
    • Tom Lane's avatar
      Fix core dump in pg_dump --binary-upgrade on zero-column composite type. · 5c38a1d4
      Tom Lane authored
      This reverts nearly all of commit 28f6cab6
      in favor of just using the typrelid we already have in pg_dump's TypeInfo
      struct for the composite type.  As coded, it'd crash if the composite type
      had no attributes, since then the query would return no rows.
      
      Back-patch to all supported versions.  It seems to not really be a problem
      in 9.0 because that version rejects the syntax "create type t as ()", but
      we might as well keep the logic similar in all affected branches.
      
      Report and fix by Rushabh Lathia.
      5c38a1d4