Re: A simple question about text fields - Mailing list pgsql-general

From David G. Johnston
Subject Re: A simple question about text fields
Date
Msg-id CAKFQuwZj=Vpoqeq0agPh0cct+qMijhGu1hv0hH05BZV-Kng1_A@mail.gmail.com
Whole thread Raw
In response to Re: A simple question about text fields  (Gavan Schneider <list.pg.gavan@pendari.org>)
Responses Re: A simple question about text fields  (Gavan Schneider <list.pg.gavan@pendari.org>)
List pgsql-general
On Thursday, June 17, 2021, Gavan Schneider <list.pg.gavan@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.

pgsql-general by date:

Previous
From: Gavan Schneider
Date:
Subject: Re: A simple question about text fields
Next
From: Gavan Schneider
Date:
Subject: Re: A simple question about text fields