1. 14 Jun, 2017 4 commits
    • Tom Lane's avatar
      Fix violations of CatalogTupleInsert/Update/Delete abstraction. · a571c7f6
      Tom Lane authored
      In commits 2f5c9d9c and ab028965 we invented an abstraction layer
      to insulate catalog manipulations from direct heap update calls.
      But evidently some patches that hadn't landed in-tree at that point
      didn't get the memo completely.  Fix a couple of direct calls to
      simple_heap_delete to use CatalogTupleDelete instead; these appear
      to have been added in commits 7c4f5240 and 7b504eb2.  This change is
      purely cosmetic ATM, but there's no point in having an abstraction layer
      if we allow random code to break it.
      
      Masahiko Sawada and Tom Lane
      
      Discussion: https://postgr.es/m/CAD21AoDOPRSVcwbnCN3Y1n_68ATyTspsU6=ygtHz_uY0VcdZ8A@mail.gmail.com
      a571c7f6
    • Dean Rasheed's avatar
      Teach PL/pgSQL about partitioned tables. · d3c3f2b1
      Dean Rasheed authored
      Table partitioning, introduced in commit f0e44751, added a new
      relkind - RELKIND_PARTITIONED_TABLE. Update a couple of places in
      PL/pgSQL to handle it. Specifically plpgsql_parse_cwordtype() and
      build_row_from_class() needed updating in order to make table%ROWTYPE
      and table.col%TYPE work for partitioned tables.
      
      Dean Rasheed, reviewed by Amit Langote.
      
      Discussion: https://postgr.es/m/CAEZATCUnNOKN8sLML9jUzxecALWpEXK3a3W7y0PgFR4%2Buhgc%3Dg%40mail.gmail.com
      d3c3f2b1
    • Dean Rasheed's avatar
      Teach RemoveRoleFromObjectPolicy() about partitioned tables. · f356ec57
      Dean Rasheed authored
      Table partitioning, introduced in commit f0e44751, added a new
      relkind - RELKIND_PARTITIONED_TABLE. Update
      RemoveRoleFromObjectPolicy() to handle it, otherwise DROP OWNED BY
      will fail if the role has any RLS policies referring to partitioned
      tables.
      
      Dean Rasheed, reviewed by Amit Langote.
      
      Discussion: https://postgr.es/m/CAEZATCUnNOKN8sLML9jUzxecALWpEXK3a3W7y0PgFR4%2Buhgc%3Dg%40mail.gmail.com
      f356ec57
    • Tom Lane's avatar
      Disallow set-returning functions inside CASE or COALESCE. · 0436f6bd
      Tom Lane authored
      When we reimplemented SRFs in commit 69f4b9c8, our initial choice was
      to allow the behavior to vary from historical practice in cases where a
      SRF call appeared within a conditional-execution construct (currently,
      only CASE or COALESCE).  But that was controversial to begin with, and
      subsequent discussion has resulted in a consensus that it's better to
      throw an error instead of executing the query differently from before,
      so long as we can provide a reasonably clear error message and a way to
      rewrite the query.
      
      Hence, add a parser mechanism to allow detection of such cases during
      parse analysis.  The mechanism just requires storing, in the ParseState,
      a pointer to the set-returning FuncExpr or OpExpr most recently emitted
      by parse analysis.  Then the parsing functions for CASE and COALESCE can
      detect the presence of a SRF in their arguments by noting whether this
      pointer changes while analyzing their arguments.  Furthermore, if it does,
      it provides a suitable error cursor location for the complaint.  (This
      means that if there's more than one SRF in the arguments, the error will
      point at the last one to be analyzed not the first.  While connoisseurs of
      parsing behavior might find that odd, it's unlikely the average user would
      ever notice.)
      
      While at it, we can also provide more specific error messages than before
      about some pre-existing restrictions, such as no-SRFs-within-aggregates.
      Also, reject at parse time cases where a NULLIF or IS DISTINCT FROM
      construct would need to return a set.  We've never supported that, but the
      restriction is depended on in more subtle ways now, so it seems wise to
      detect it at the start.
      
      Also, provide some documentation about how to rewrite a SRF-within-CASE
      query using a custom wrapper SRF.
      
      It turns out that the information_schema.user_mapping_options view
      contained an instance of exactly the behavior we're now forbidding; but
      rewriting it makes it more clear and safer too.
      
      initdb forced because of user_mapping_options change.
      
      Patch by me, with error message suggestions from Alvaro Herrera and
      Andres Freund, pursuant to a complaint from Regina Obe.
      
      Discussion: https://postgr.es/m/000001d2d5de$d8d66170$8a832450$@pcorp.us
      0436f6bd
  2. 13 Jun, 2017 19 commits
  3. 12 Jun, 2017 9 commits
  4. 11 Jun, 2017 2 commits
    • Tom Lane's avatar
      Handle unqualified SEQUENCE NAME options properly in parse_utilcmd.c. · 51893985
      Tom Lane authored
      generateSerialExtraStmts() was sloppy about handling the case where
      SEQUENCE NAME is given with a not-schema-qualified name.  It was generating
      a CreateSeqStmt with an unqualified sequence name, and an AlterSeqStmt
      whose "owned_by" DefElem contained a T_String Value with a null string
      pointer in the schema-name position.  The generated nextval() argument was
      also underqualified.  This accidentally failed to fail at runtime, but only
      so long as the current default creation namespace at runtime is the right
      namespace.  That's bogus; the parse-time transformation is supposed to be
      inserting the right schema name in all cases, so as to avoid any possible
      skew in that selection.  I'm not sure this could fail in pg_dump's usage,
      but it's still wrong; we have had real bugs in this area before adopting
      the policy that parse_utilcmd.c should generate only fully-qualified
      auxiliary commands.  A slightly lesser problem, which is what led me to
      notice this in the first place, is that pprint() dumped core on the
      AlterSeqStmt because of the bogus T_String.
      
      Noted while poking into the open problem with ALTER SEQUENCE breaking
      pg_upgrade.
      51893985
    • Joe Conway's avatar
      Apply RLS policies to partitioned tables. · 4f7a95be
      Joe Conway authored
      The new partitioned table capability added a new relkind, namely
      RELKIND_PARTITIONED_TABLE. Update fireRIRrules() to apply RLS
      policies on RELKIND_PARTITIONED_TABLE as it does RELKIND_RELATION.
      
      In addition, add RLS regression test coverage for partitioned tables.
      
      Issue raised by Fakhroutdinov Evgenievich and patch by Mike Palmiotto.
      Regression test editorializing by me.
      
      Discussion: https://postgr.es/m/flat/20170601065959.1486.69906@wrigleys.postgresql.org
      4f7a95be
  5. 10 Jun, 2017 2 commits
  6. 09 Jun, 2017 4 commits