1. 24 Jun, 2019 8 commits
    • Tom Lane's avatar
      Purely-cosmetic adjustments in tablecmds.c. · ccfcc8fd
      Tom Lane authored
      Move ATExecAlterColumnGenericOptions away from where it was unthinkingly
      dropped, in the middle of a lot of ALTER COLUMN TYPE code.  I don't have
      any high principles about where to put it instead, so let's just put it
      after ALTER COLUMN TYPE and before ALTER OWNER, matching existing
      decisions about how to order related code stanzas.
      
      Also add the minimal function header comment that the original author
      was too cool to bother with.
      
      Along the way, upgrade header comments for nearby ALTER COLUMN TYPE
      functions.
      
      Discussion: https://postgr.es/m/14787.1561403130@sss.pgh.pa.us
      ccfcc8fd
    • Peter Eisentraut's avatar
      82be666e
    • Peter Eisentraut's avatar
      2cadefbb
    • Peter Eisentraut's avatar
      Correct script name in README file · eb8d05bf
      Peter Eisentraut authored
      eb8d05bf
    • Tom Lane's avatar
      Further fix ALTER COLUMN TYPE's handling of indexes and index constraints. · f946a409
      Tom Lane authored
      This patch reverts all the code changes of commit e76de886, which turns
      out to have been seriously misguided.  We can't wait till later to compute
      the definition string for an index; we must capture that before applying
      the data type change for any column it depends on, else ruleutils.c will
      deliverr wrong/misleading results.  (This fine point was documented
      nowhere, of course.)
      
      I'd also managed to forget that ATExecAlterColumnType executes once per
      ALTER COLUMN TYPE clause, not once per statement; which resulted in the
      code being basically completely broken for any case in which multiple ALTER
      COLUMN TYPE clauses are applied to a table having non-constraint indexes
      that must be rebuilt.  Through very bad luck, none of the existing test
      cases nor the ones added by e76de886 caught that, but of course it was
      soon found in the field.
      
      The previous patch also had an implicit assumption that if a constraint's
      index had a dependency on a table column, so would the constraint --- but
      that isn't actually true, so it didn't fix such cases.
      
      Instead of trying to delete unneeded index dependencies later, do the
      is-there-a-constraint lookup immediately on seeing an index dependency,
      and switch to remembering the constraint if so.  In the unusual case of
      multiple column dependencies for a constraint index, this will result in
      duplicate constraint lookups, but that's not that horrible compared to all
      the other work that happens here.  Besides, such cases did not work at all
      before, so it's hard to argue that they're performance-critical for anyone.
      
      Per bug #15865 from Keith Fiske.  As before, back-patch to all supported
      branches.
      
      Discussion: https://postgr.es/m/15865-17940eacc8f8b081@postgresql.org
      f946a409
    • Peter Geoghegan's avatar
      Correct obsolete amcheck comments. · b00326df
      Peter Geoghegan authored
      Oversight in commit dd299df8.
      b00326df
    • Tom Lane's avatar
      Drop test user when done with it. · f31111bb
      Tom Lane authored
      Commit d7f8d26d added a test case that created a user, but forgot
      to drop it again.  This is no good; for one thing, it causes repeated
      "make installcheck" runs to fail.
      f31111bb
    • Peter Eisentraut's avatar
      Upgrade internal error message to external · 12e037e2
      Peter Eisentraut authored
      As part of REINDEX CONCURRENTLY, this formerly internal-only error
      message becomes potentially user-visible (see regression tests), so
      change from errmsg_internal() to errmsg(), and update comment.
      12e037e2
  2. 23 Jun, 2019 4 commits
    • Noah Misch's avatar
      Don't call PG_RETURN_BOOL() in a function not returning Datum. · 9a81c9fa
      Noah Misch authored
      This code is new in v12, and the defect probably was not user-visible.
      9a81c9fa
    • Dean Rasheed's avatar
      Add security checks to the multivariate MCV estimation code. · d7f8d26d
      Dean Rasheed authored
      The multivariate MCV estimation code may run user-defined operators on
      the values in the MCV list, which means that those operators may
      potentially leak the values from the MCV list. Guard against leaking
      data to unprivileged users by checking that the user has SELECT
      privileges on the table or all of the columns referred to by the
      statistics.
      
      Additionally, if there are any securityQuals on the RTE (either due to
      RLS policies on the table, or accessing the table via a security
      barrier view), not all rows may be visible to the current user, even
      if they have table or column privileges. Thus we further insist that
      the operator be leakproof in this case.
      
      Dean Rasheed, reviewed by Tomas Vondra.
      
      Discussion: https://postgr.es/m/CAEZATCUhT9rt7Ui=Vdx4N==VV5XOK5dsXfnGgVOz_JhAicB=ZA@mail.gmail.com
      d7f8d26d
    • Thomas Munro's avatar
      89ff7c08
    • Tom Lane's avatar
      Fix spinlock assembly code for MIPS so it works on MIPS r6. · 1323bfce
      Tom Lane authored
      Original MIPS-I processors didn't have the LL/SC instructions (nor any
      other userland synchronization primitive).  If the build toolchain
      targets that ISA variant by default, as an astonishingly large fraction
      of MIPS platforms still do, the assembler won't take LL/SC without
      coercion in the form of a ".set mips2" instruction.  But we issued that
      unconditionally, making it an ISA downgrade for chips later than MIPS2.
      That breaks things for the latest MIPS r6 ISA, which encodes these
      instructions differently.  Adjust the code so we don't change ISA level
      if it's >= 2.
      
      Note that this patch doesn't change what happens on an actual MIPS-I
      processor: either the kernel will emulate these instructions
      transparently, or you'll get a SIGILL failure.  That tradeoff seemed
      fine in 2002 when this code was added (cf 3cbe6b24), and it's even
      more so today when MIPS-I is basically extinct.  But let's add a
      comment about that.
      
      YunQiang Su (with cosmetic adjustments by me).  Back-patch to all
      supported branches.
      
      Discussion: https://postgr.es/m/15844-8f62fe7e163939b3@postgresql.org
      1323bfce
  3. 22 Jun, 2019 1 commit
  4. 20 Jun, 2019 3 commits
  5. 19 Jun, 2019 11 commits
  6. 18 Jun, 2019 3 commits
    • Andres Freund's avatar
      Fix memory corruption/crash in ANALYZE. · 23224563
      Andres Freund authored
      This fixes an embarrassing oversight I (Andres) made in 737a292b,
      namely missing two place where liverows/deadrows were used when
      converting those variables to pointers, leading to incrementing the
      pointer, rather than the value.
      
      It's not that actually that easy to trigger a crash: One needs tuples
      deleted by the current transaction, followed by a tuple deleted in
      another session, all in one page. Which is presumably why this hasn't
      been noticed before.
      
      Reported-By: Steve Singer
      Author: Steve Singer
      Discussion: https://postgr.es/m/c7988239-d42c-ddc4-41db-171b23b35e4f@ssinger.info
      23224563
    • Alvaro Herrera's avatar
      Avoid spurious deadlocks when upgrading a tuple lock · 8b21b416
      Alvaro Herrera authored
      This puts back reverted commit de87a084, with some bug fixes.
      
      When two (or more) transactions are waiting for transaction T1 to release a
      tuple-level lock, and transaction T1 upgrades its lock to a higher level, a
      spurious deadlock can be reported among the waiting transactions when T1
      finishes.  The simplest example case seems to be:
      
      T1: select id from job where name = 'a' for key share;
      Y: select id from job where name = 'a' for update; -- starts waiting for T1
      Z: select id from job where name = 'a' for key share;
      T1: update job set name = 'b' where id = 1;
      Z: update job set name = 'c' where id = 1; -- starts waiting for T1
      T1: rollback;
      
      At this point, transaction Y is rolled back on account of a deadlock: Y
      holds the heavyweight tuple lock and is waiting for the Xmax to be released,
      while Z holds part of the multixact and tries to acquire the heavyweight
      lock (per protocol) and goes to sleep; once T1 releases its part of the
      multixact, Z is awakened only to be put back to sleep on the heavyweight
      lock that Y is holding while sleeping.  Kaboom.
      
      This can be avoided by having Z skip the heavyweight lock acquisition.  As
      far as I can see, the biggest downside is that if there are multiple Z
      transactions, the order in which they resume after T1 finishes is not
      guaranteed.
      
      Backpatch to 9.6.  The patch applies cleanly on 9.5, but the new tests don't
      work there (because isolationtester is not smart enough), so I'm not going
      to risk it.
      
      Author: Oleksii Kliukin
      Discussion: https://postgr.es/m/B9C9D7CD-EB94-4635-91B6-E558ACEC0EC3@hintbits.com
      Discussion: https://postgr.es/m/2815.1560521451@sss.pgh.pa.us
      8b21b416
    • Thomas Munro's avatar
      Prevent Parallel Hash Join for JOIN_UNIQUE_INNER. · aca127c1
      Thomas Munro authored
      WHERE EXISTS (...) queries cannot be executed by Parallel Hash Join
      with jointype JOIN_UNIQUE_INNER, because there is no way to make a
      partial plan totally unique.  The consequence of allowing such plans
      was duplicate results from some EXISTS queries.
      
      Back-patch to 11.  Bug #15857.
      
      Author: Thomas Munro
      Reviewed-by: Tom Lane
      Reported-by: Vladimir Kriukov
      Discussion: https://postgr.es/m/15857-d1ba2a64bce0795e%40postgresql.org
      aca127c1
  7. 17 Jun, 2019 6 commits
  8. 16 Jun, 2019 3 commits
  9. 15 Jun, 2019 1 commit