On Mon, Jun 29, 2026 at 9:38 PM Tom Lane <[email protected]> wrote:
>
> jian he <[email protected]> writes:
> > Only the topmost CollateExpr will be used, all others will be dropped.
> > We can apply this to coerce_type also.
> > See the attached minor patch.
>
> It's not apparent to me that this does anything (will there ever
> be a CollateExpr at this stage?), or that it's correct if it does.
> Please provide an example.  Not to mention a comment.
>

will there ever be a CollateExpr at this stage?)
Yes. We use coerce_to_target_type->coerce_type, but some places we
just use coerce_type directly.
For example ParseFuncOrColumn->make_fn_arguments->coerce_type

select to_char(1, 'x' collate "C" collate "POSIX");

Without  the patch: After make_fn_arguments->coerce_type the second fargs is:
   {COLLATEEXPR
   :arg
      {COLLATEEXPR
      :arg
         {CONST
         :consttype 25
         :consttypmod -1
         :constcollid 100
         :constlen -1
         :constbyval false
         :constisnull false
         :location 18
         :constvalue 5 [ 20 0 0 0 120 ]
         }
      :collOid 950
      :location 22
      }
   :collOid 951
   :location 34
   }

With the patch:

   {COLLATEEXPR
   :arg
      {CONST
      :consttype 25
      :consttypmod -1
      :constcollid 100
      :constlen -1
      :constbyval false
      :constisnull false
      :location 18
      :constvalue 5 [ 20 0 0 0 120 ]
      }
   :collOid 951
   :location 34
   }


Reply via email to