1. 19 Jan, 2019 4 commits
  2. 18 Jan, 2019 12 commits
    • Tom Lane's avatar
      Fix under-quoted filename pattern in pgbench TAP test. · 458a1244
      Tom Lane authored
      Avoids issues if build directory's pathname contains regex
      metacharacters.
      
      Raúl Marín Rodríguez
      
      Discussion: https://postgr.es/m/CAM6_UM6dGdU39PKAC24T+HD9ouy0jLN9vH6163K8QEEzr__iZw@mail.gmail.com
      458a1244
    • Tom Lane's avatar
      Use our own getopt() on OpenBSD. · 69bcd718
      Tom Lane authored
      Recent OpenBSD (at least 5.9 and up) has a version of getopt(3)
      that will not cope with the "-:" spec we use to accept double-dash
      options in postgres.c and postmaster.c.  Admittedly, that's a hack
      because POSIX only requires getopt() to allow alphanumeric option
      characters.  I have no desire to find another way, however, so
      let's just do what we were already doing on Solaris: force use
      of our own src/port/getopt.c implementation.
      
      In passing, improve some of the comments around said implementation.
      
      Per buildfarm and local testing.  Back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/30197.1547835700@sss.pgh.pa.us
      69bcd718
    • Alvaro Herrera's avatar
      Fix creation of duplicate foreign keys on partitions · 0325d7a5
      Alvaro Herrera authored
      When creating a foreign key in a partitioned table, if some partitions
      already have equivalent constraints, we wastefully create duplicates of
      the constraints instead of attaching to the existing ones.  That's
      inconsistent with the de-duplication that is applied when a table is
      attached as a partition.  To fix, reuse the FK-cloning code instead of
      having a separate code path.
      
      Backpatch to Postgres 11.  This is a subtle behavior change, but surely
      a welcome one since there's no use in having duplicate foreign keys.
      
      Discovered by Álvaro Herrera while thinking about a different problem
      reported by Jesper Pedersen (bug #15587).
      
      Author: Álvaro Herrera
      Discussion: https://postgr.es/m/201901151935.zfadrzvyof4k@alvherre.pgsql
      0325d7a5
    • Alvaro Herrera's avatar
      Move CloneForeignKeyConstraints to tablecmds.c · 03afae20
      Alvaro Herrera authored
      My commit 3de241db introduced some code to create a clone of a
      foreign key to a partition, but I put it in pg_constraint.c because it
      was too close to the contents of the pg_constraint row.  With the
      previous commit that split out the constraint tuple deconstruction into
      its own routine, it makes more sense to have the FK-cloning function in
      tablecmds.c, mostly because its static subroutine can then be used by a
      future bugfix.
      
      My initial posting of this patch had this routine as static in
      tablecmds.c, but sadly this function is already part of the Postgres 11
      ABI as exported from pg_constraint.c, so keep it as exported also just
      to avoid breaking any possible users of it.
      03afae20
    • Alvaro Herrera's avatar
      Refactor duplicate code into DeconstructFkConstraintRow · 0080396d
      Alvaro Herrera authored
      My commit 3de241db introduced some code (in tablecmds.c) to obtain
      data from a pg_constraint row for a foreign key, that already existed in
      ri_triggers.c.  Split it out into its own routine in pg_constraint.c,
      where it naturally belongs.
      
      No functional code changes, only code movement.
      
      Backpatch to pg11, because a future bugfix is simpler after this.
      0080396d
    • Tom Lane's avatar
      Avoid sometimes printing both tables and their columns in DROP CASCADE. · 9194c427
      Tom Lane authored
      A cascaded drop might find independent reasons to drop both a table
      and some column of the table (for instance, a schema drop might include
      dropping a data type used in some table in the schema).  Depending on
      the order of visitation of pg_depend entries, we might report the
      table column and the whole table as separate objects-to-be-dropped,
      or we might only report the table.  This is confusing and leads to
      unstable regression test output, so fix it to report only the table
      regardless of visitation order.
      
      Per gripe from Peter Geoghegan.  This is just cosmetic from a user's
      standpoint, and we haven't actually seen regression test problems in
      practice (yet), so I'll refrain from back-patching.
      
      Discussion: https://postgr.es/m/15908.1547762076@sss.pgh.pa.us
      9194c427
    • Peter Eisentraut's avatar
      Remove obsolete comment · f04ad77a
      Peter Eisentraut authored
      f04ad77a
    • Peter Eisentraut's avatar
      configure: More use of AC_ARG_VAR · 29b3ac75
      Peter Eisentraut authored
      AC_ARG_VAR is necessary if an environment variable influences a
      configure result that is then used by other tests that are cached.
      With AC_ARG_VAR, a change in the variable is detected on subsequent
      configure runs and the user is then advised to remove the cache.
      
      This adds AC_ARG_VAR calls for: MSGFMT, PERL, PYTHON, TCLSH, XML2_CONFIG
      Reviewed-by: default avatarTom Lane <tgl@sss.pgh.pa.us>
      Discussion: https://www.postgresql.org/message-id/30672.1546816567@sss.pgh.pa.us
      29b3ac75
    • Michael Paquier's avatar
    • Michael Paquier's avatar
      Enforce non-parallel plan when calling current_schema() in newly-added test · 396676b0
      Michael Paquier authored
      current_schema() gets called in the recently-added regression test from
      c5660e0a, and can be used in a parallel context, causing its call to fail
      when creating a temporary schema.
      
      Per buildfarm members crake and lapwing.
      
      Discussion: https://postgr.es/m/20190118005949.GD1883@paquier.xyz
      396676b0
    • Tom Lane's avatar
      Avoid assuming that we know the spelling of getopt_long's error messages. · 251f5746
      Tom Lane authored
      I've had enough of "fixing" this test case.  Whatever value it has
      is limited to verifying that pgbench fails for an unrecognized switch,
      and we don't need to assume anything about what getopt_long prints in
      order to do that.
      
      Discussion: https://postgr.es/m/9427.1547701450@sss.pgh.pa.us
      251f5746
    • Michael Paquier's avatar
      Restrict the use of temporary namespace in two-phase transactions · c5660e0a
      Michael Paquier authored
      Attempting to use a temporary table within a two-phase transaction is
      forbidden for ages.  However, there have been uncovered grounds for
      a couple of other object types and commands which work on temporary
      objects with two-phase commit.  In short, trying to create, lock or drop
      an object on a temporary schema should not be authorized within a
      two-phase transaction, as it would cause its state to create
      dependencies with other sessions, causing all sorts of side effects with
      the existing session or other sessions spawned later on trying to use
      the same temporary schema name.
      
      Regression tests are added to cover all the grounds found, the original
      report mentioned function creation, but monitoring closer there are many
      other patterns with LOCK, DROP or CREATE EXTENSION which are involved.
      One of the symptoms resulting in combining both is that the session
      which used the temporary schema is not able to shut down completely,
      waiting for being able to drop the temporary schema, something that it
      cannot complete because of the two-phase transaction involved with
      temporary objects.  In this case the client is able to disconnect but
      the session remains alive on the backend-side, potentially blocking
      connection backend slots from being used.  Other problems reported could
      also involve server crashes.
      
      This is back-patched down to v10, which is where 9b013dc2 has introduced
      MyXactFlags, something that this patch relies on.
      
      Reported-by: Alexey Bashtanov
      Author: Michael Paquier
      Reviewed-by: Masahiko Sawada
      Discussion: https://postgr.es/m/5d910e2e-0db8-ec06-dd5f-baec420513c3@imap.cc
      Backpatch-through: 10
      c5660e0a
  3. 17 Jan, 2019 5 commits
  4. 16 Jan, 2019 5 commits
  5. 15 Jan, 2019 8 commits
    • Andres Freund's avatar
      Don't duplicate parallel seqscan shmem sizing logic in nbtree. · 90525d7b
      Andres Freund authored
      This is architecturally mildly problematic, which becomes more
      pronounced with the upcoming introduction of pluggable storage.
      
      To fix, teach heap_parallelscan_estimate() to deal with SnapshotAny
      snapshots, and then use it from _bt_parallel_estimate_shared().
      
      Author: Andres Freund
      Discussion: https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de
      90525d7b
    • Andres Freund's avatar
      Move vacuumlazy.c into access/heap. · 285d8e12
      Andres Freund authored
      It's heap table storage specific code that can't realistically be
      generalized into table AM agnostic code.
      
      Author: Andres Freund
      Discussion: https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de
      285d8e12
    • Andres Freund's avatar
      Fix parent of WCO qual. · 148e632c
      Andres Freund authored
      The parent of some WCO expressions was, apparently by accident, set to
      the the source of DML queries, rather than the target table.  This
      causes problems for the upcoming pluggable storage work, because the
      target and source table might be of different storage types.
      
      It's possible that this is already problematic, but neither
      experimenting nor inquiries on -hackers have found them. So don't
      backpatch for now.
      
      Author: Andres Freund
      Discussion: https://postgr.es/m/20181205225213.hiwa3kgoxeybqcqv@alap3.anarazel.de
      148e632c
    • Tom Lane's avatar
      Finish reverting "recheck_on_update" patch. · 1c53c4de
      Tom Lane authored
      This reverts commit c203d6cf and some follow-on fixes, completing the
      task begun in commit 5d28c9bd.  If that feature is ever resurrected,
      the code will look quite a bit different from this, so it seems best
      to start from a clean slate.
      
      The v11 branch is not touched; in that branch, the recheck_on_update
      storage option remains present, but nonfunctional and undocumented.
      
      Discussion: https://postgr.es/m/20190114223409.3tcvejfhlvbucrv5@alap3.anarazel.de
      1c53c4de
    • Andres Freund's avatar
      Don't include genam.h from execnodes.h and relscan.h anymore. · 0944ec54
      Andres Freund authored
      This is the genam.h equivalent of 4c850ece (which removed
      heapam.h from a lot of other headers).  There's still a few header
      includes of genam.h, but not from central headers anymore.
      
      As a few headers are not indirectly included anymore, execnodes.h and
      relscan.h need a few additional includes. Some of the depended on
      types were replacable by using the underlying structs, but e.g. for
      Snapshot in execnodes.h that'd have gotten more invasive than
      reasonable in this commit.
      
      Like the aforementioned commit 4c850ece, this requires adding new
      genam.h includes to a number of backend files, which likely is also
      required in a few external projects.
      
      Author: Andres Freund
      Discussion: https://postgr.es/m/20190114000701.y4ttcb74jpskkcfb@alap3.anarazel.de
      0944ec54
    • Andres Freund's avatar
      Make naming of tupdesc related structs more consistent with the rest of PG. · 774a975c
      Andres Freund authored
      We usually don't change the name of structs between the struct name
      itself and the name of the typedef. Additionally, structs that are
      usually used via a typedef that hides being a pointer, are commonly
      suffixed Data.  Change tupdesc code to follow those convention.
      
      This is triggered by a future patch that intends to forward declare
      TupleDescData in another header - keeping with the naming scheme makes
      that easier to understand.
      
      Author: Andres Freund
      Discussion: https://postgr.es/m/20190114000701.y4ttcb74jpskkcfb@alap3.anarazel.de
      774a975c
    • Andres Freund's avatar
      Remove too generically named MissingPtr typedef. · e451dd55
      Andres Freund authored
      As there's only a single user of the typedef in the entire codebase,
      just use the underlying struct directly.
      
      Per complaint from Alvaro Herrera
      
      Author: Andres Freund
      Discussion: https://postgr.es/m/201901141836.oxtm4uzc63j3@alvherre.pgsql
      e451dd55
    • Andres Freund's avatar
      Don't include heapam.h from others headers. · 4c850ece
      Andres Freund authored
      heapam.h previously was included in a number of widely used
      headers (e.g. execnodes.h, indirectly in executor.h, ...). That's
      problematic on its own, as heapam.h contains a lot of low-level
      details that don't need to be exposed that widely, but becomes more
      problematic with the upcoming introduction of pluggable table storage
      - it seems inappropriate for heapam.h to be included that widely
      afterwards.
      
      heapam.h was largely only included in other headers to get the
      HeapScanDesc typedef (which was defined in heapam.h, even though
      HeapScanDescData is defined in relscan.h). The better solution here
      seems to be to just use the underlying struct (forward declared where
      necessary). Similar for BulkInsertState.
      
      Another problem was that LockTupleMode was used in executor.h - parts
      of the file tried to cope without heapam.h, but due to the fact that
      it indirectly included it, several subsequent violations of that goal
      were not not noticed. We could just reuse the approach of declaring
      parameters as int, but it seems nicer to move LockTupleMode to
      lockoptions.h - that's not a perfect location, but also doesn't seem
      bad.
      
      As a number of files relied on implicitly included heapam.h, a
      significant number of files grew an explicit include. It's quite
      probably that a few external projects will need to do the same.
      
      Author: Andres Freund
      Reviewed-By: Alvaro Herrera
      Discussion: https://postgr.es/m/20190114000701.y4ttcb74jpskkcfb@alap3.anarazel.de
      4c850ece
  6. 14 Jan, 2019 4 commits
    • Michael Paquier's avatar
      Fix typos in documentation and for one wait event · 42e2a580
      Michael Paquier authored
      These have been found while cross-checking for the use of unique words
      in the documentation, and a wait event was not getting generated in a way
      consistent to what the documentation provided.
      
      Author: Alexander Lakhin
      Discussion: https://postgr.es/m/9b5a3a85-899a-ae62-dbab-1e7943aa5ab1@gmail.com
      42e2a580
    • Andres Freund's avatar
      Re-add default_with_oids GUC to avoid breaking old dump files. · de66987a
      Andres Freund authored
      After 578b2297 / the removal of WITH OIDS support, older dump files
      containing
          SET default_with_oids = false;
      either report unnecessary errors (as the subsequent tables have no
      oids) or even fail to restore entirely (when using transaction mode).
      To avoid that, re-add the GUC, but don't allow setting it to true.
      
      Per complaint from Tom Lane.
      
      Author: Amit Khandekar, editorialized by me
      Discussion: https://postgr.es/m/CAJ3gD9dZyxrtL0rJfoNoOj6v7fJSDaXBngi9wy5XU8m-ioXhAA@mail.gmail.com
      de66987a
    • Alvaro Herrera's avatar
      Fix unique INCLUDE indexes on partitioned tables · 0ad41cf5
      Alvaro Herrera authored
      We were considering the INCLUDE columns as part of the key, allowing
      unicity-violating rows to be inserted in different partitions.
      
      Concurrent development conflict in eb7ed3f3 and 8224de4f.
      
      Reported-by: Justin Pryzby
      Discussion: https://postgr.es/m/20190109065109.GA4285@telsasoft.com
      0ad41cf5
    • Heikki Linnakangas's avatar
      Detach postmaster process from pg_ctl's session at server startup. · bb24439c
      Heikki Linnakangas authored
      pg_ctl is supposed to daemonize the postmaster process, so that it's not
      affected by signals to the launching process group.  Before this patch, if
      you had a shell script that used "pg_ctl start", and you interrupted the
      shell script after postmaster had been launched, postmaster was also
      killed.  To fix, call setsid() after forking the postmaster process.
      
      Long time ago, we had a 'silent_mode' option, which daemonized the
      postmaster process by calling setsid(), but that was removed back in 2011
      (commit f7ea6bea).  We discussed bringing that back in some form, but
      pg_ctl is the documented way of launching postmaster to the background, so
      putting the setsid() call in pg_ctl itself seems appropriate.
      
      Just putting postmaster in a separate session would change the behavior
      when you interrupt "pg_ctl -w start", e.g. with CTRL-C, while it's waiting
      for postmaster to start.  The historical behavior has been that
      interrupting pg_ctl aborts the server launch, which is handy if the server
      is stuck in recovery, for example, and won't fully start up.  To keep that
      behavior, install a signal handler in pg_ctl, to explicitly kill
      postmaster, if pg_ctl is interrupted while it's waiting for the server to
      start up.  This isn't 100% watertight, there is a small window after
      forking the postmaster process, where the signal handler doesn't know the
      postmaster's PID yet, but seems good enough.
      
      Arguably this is a long-standing bug, but I refrained from back-batching,
      out of fear of breaking someone's scripts that depended on the old
      behavior.
      
      Reviewed by Tom Lane.  Report and original patch by Paul Guo, with
      feedback from Michael Paquier.
      
      Discussion: https://www.postgresql.org/message-id/CAEET0ZH5Bf7dhZB3mYy8zZQttJrdZg_0Wwaj0o1PuuBny1JkEw%40mail.gmail.com
      bb24439c
  7. 13 Jan, 2019 2 commits