Skip to content
Snippets Groups Projects
Select Git revision
  • benchmark-tools
  • postgres-lambda
  • master default
  • REL9_4_25
  • REL9_5_20
  • REL9_6_16
  • REL_10_11
  • REL_11_6
  • REL_12_1
  • REL_12_0
  • REL_12_RC1
  • REL_12_BETA4
  • REL9_4_24
  • REL9_5_19
  • REL9_6_15
  • REL_10_10
  • REL_11_5
  • REL_12_BETA3
  • REL9_4_23
  • REL9_5_18
  • REL9_6_14
  • REL_10_9
  • REL_11_4
23 results

deparse.c

Blame
    • Tom Lane's avatar
      76f965ff
      Improve handling of collations in contrib/postgres_fdw. · 76f965ff
      Tom Lane authored
      If we have a local Var of say varchar type with default collation, and
      we apply a RelabelType to convert that to text with default collation, we
      don't want to consider that as creating an FDW_COLLATE_UNSAFE situation.
      It should be okay to compare that to a remote Var, so long as the remote
      Var determines the comparison collation.  (When we actually ship such an
      expression to the remote side, the local Var would become a Param with
      default collation, meaning the remote Var would in fact control the
      comparison collation, because non-default implicit collation overrides
      default implicit collation in parse_collate.c.)  To fix, be more precise
      about what FDW_COLLATE_NONE means: it applies either to a noncollatable
      data type or to a collatable type with default collation, if that collation
      can't be traced to a remote Var.  (When it can, FDW_COLLATE_SAFE is
      appropriate.)  We were essentially using that interpretation already at
      the Var/Const/Param level, but we weren't bubbling it up properly.
      
      An alternative fix would be to introduce a separate FDW_COLLATE_DEFAULT
      value to describe the second situation, but that would add more code
      without changing the actual behavior, so it didn't seem worthwhile.
      
      Also, since we're clarifying the rule to be that we care about whether
      operator/function input collations match, there seems no need to fail
      immediately upon seeing a Const/Param/non-foreign-Var with nondefault
      collation.  We only have to reject if it appears in a collation-sensitive
      context (for example, "var IS NOT NULL" is perfectly safe from a collation
      standpoint, whatever collation the var has).  So just set the state to
      UNSAFE rather than failing immediately.
      
      Per report from Jeevan Chalke.  This essentially corrects some sloppy
      thinking in commit ed3ddf91, so back-patch
      to 9.3 where that logic appeared.
      76f965ff
      History
      Improve handling of collations in contrib/postgres_fdw.
      Tom Lane authored
      If we have a local Var of say varchar type with default collation, and
      we apply a RelabelType to convert that to text with default collation, we
      don't want to consider that as creating an FDW_COLLATE_UNSAFE situation.
      It should be okay to compare that to a remote Var, so long as the remote
      Var determines the comparison collation.  (When we actually ship such an
      expression to the remote side, the local Var would become a Param with
      default collation, meaning the remote Var would in fact control the
      comparison collation, because non-default implicit collation overrides
      default implicit collation in parse_collate.c.)  To fix, be more precise
      about what FDW_COLLATE_NONE means: it applies either to a noncollatable
      data type or to a collatable type with default collation, if that collation
      can't be traced to a remote Var.  (When it can, FDW_COLLATE_SAFE is
      appropriate.)  We were essentially using that interpretation already at
      the Var/Const/Param level, but we weren't bubbling it up properly.
      
      An alternative fix would be to introduce a separate FDW_COLLATE_DEFAULT
      value to describe the second situation, but that would add more code
      without changing the actual behavior, so it didn't seem worthwhile.
      
      Also, since we're clarifying the rule to be that we care about whether
      operator/function input collations match, there seems no need to fail
      immediately upon seeing a Const/Param/non-foreign-Var with nondefault
      collation.  We only have to reject if it appears in a collation-sensitive
      context (for example, "var IS NOT NULL" is perfectly safe from a collation
      standpoint, whatever collation the var has).  So just set the state to
      UNSAFE rather than failing immediately.
      
      Per report from Jeevan Chalke.  This essentially corrects some sloppy
      thinking in commit ed3ddf91, so back-patch
      to 9.3 where that logic appeared.