Re: A simple question about text fields

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Gavan Schneider <list(dot)pg(dot)gavan(at)pendari(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Martin Mueller <martinmueller(at)northwestern(dot)edu>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: A simple question about text fields
Date: 2021-06-17 23:34:43
Message-ID: CAKFQuwZj=Vpoqeq0agPh0cct+qMijhGu1hv0hH05BZV-Kng1_A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thursday, June 17, 2021, Gavan Schneider <list(dot)pg(dot)gavan(at)pendari(dot)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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gavan Schneider 2021-06-18 00:28:08 Re: A simple question about text fields
Previous Message Gavan Schneider 2021-06-17 23:19:52 Re: A simple question about text fields