Re: String concatenation operator which keeps trailing spaces in CHAR(n) columns

From: "Andrus" <kobruleht2(at)hot(dot)ee>
To: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: String concatenation operator which keeps trailing spaces in CHAR(n) columns
Date: 2014-07-30 11:46:19
Message-ID: 989A8C97FBD34193801F2E1B7F2AB744@dell2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2014-07-30 11:59:18 Re: String concatenation operator which keeps trailing spaces in CHAR(n) columns
Previous Message Albe Laurenz 2014-07-30 11:07:08 Re: String concatenation operator which keeps trailing spaces in CHAR(n) columns