Hiyou can define || operator for char(N) typepostgres=# select oprname, oprleft::regtype, oprright::regtype from pg_operator where oprname = '||' ; oprname | oprleft | oprright ---------+-------------+------------- || | bytea | bytea || | text | text || | text | anynonarray || | bit varying | bit varying || | anyarray | anyarray || | anyarray | anyelement || | anyelement | anyarray || | anynonarray | text || | tsvector | tsvector || | tsquery | tsquery(10 rows)it is defined only for text, and value char(n) is reduced when it is converted probablypostgres=# create or replace function concat_character(character, character) returns text as $$ select concat($1,$1)$$ language sql;CREATE FUNCTIONpostgres=# create operator || (procedure = concat_character, leftarg = character, rightarg = character); CREATE OPERATORpostgres=# select 'abc '::char(7) || 'dbe '::char(6); ?column? ---------------- abc abc (1 row)concat is variadic "any" function, so implicit casting character(n) -> text is not used therePavel
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных