Re: String concatenation operator which keeps trailing spaces in CHAR(n) columns - Mailing list pgsql-general

From Andrus
Subject Re: String concatenation operator which keeps trailing spaces in CHAR(n) columns
Date
Msg-id 989A8C97FBD34193801F2E1B7F2AB744@dell2
Whole thread Raw
In response to Re: String concatenation operator which keeps trailing spaces in CHAR(n) columns  (Albe Laurenz <laurenz.albe@wien.gv.at>)
Responses Re: String concatenation operator which keeps trailing spaces in CHAR(n) columns
List pgsql-general
Hi!

>Use "bpchar" instead of "text" in the definition of function and operator.
>Otherwise col1 gets cast to "text" and loses its trailing spaces.

Thank you very much.
It worked.
Which notation to use for this ?

Is it reasonable use "+" as such operator for strings or should some other
notation used ?

I tried:

CREATE OR REPLACE FUNCTION public.concatkeepspaces(left bpchar, right
bpchar)
RETURNS bpchar
LANGUAGE sql IMMUTABLE
AS $BODY$
SELECT concat($1,$2);
$BODY$;

CREATE OPERATOR public.+ (
    leftarg = bpchar,
    rightarg = bpchar,
    procedure = public.concatkeepspaces
);

Andrus.



pgsql-general by date:

Previous
From: Albe Laurenz
Date:
Subject: Re: String concatenation operator which keeps trailing spaces in CHAR(n) columns
Next
From: Albe Laurenz
Date:
Subject: Re: String concatenation operator which keeps trailing spaces in CHAR(n) columns