On Thursday, June 17, 2021, Gavan Schneider <list.pg.ga...@pendari.org>
wrote:

>
> My approach is to define such fields as ‘text’ and set a constraint using
> char_length(). This allows PG to do the business with the text in native
> form, and only imposes the cost of any length check when the field is
> updated… best of both worlds.
>

Those are basically the same world…your alternative probably is strictly
worse than varchar(n) because of its novel way of implementing the same
functionality.

For most text fields any good constraint is going be done in the form of a
regular expression, one that at minimum prevents non-printable characters
(linefeed and carriage return being obvious examples).

David J.

Reply via email to