Re: Dry run through input function for a given built-in data type

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: fabio(at)vuole(dot)me
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Dry run through input function for a given built-in data type
Date: 2015-05-13 06:46:42
Message-ID: CAKFQuwZU52Hqy9F5df=n+MVAwsV3qCvFH6iHz2BTw4z-GXjaMg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, May 12, 2015 at 11:23 PM, Fabio Ugo Venchiarutti <fabio(at)vuole(dot)me>
wrote:

> Is there any cleaner way to, say, only run the validation part of a type
> input function
> ​ [...]​
>

​This pre-supposes that said type input function has a distinct validation
phase as opposed to simply performing its parse and failing when it
encounters something it cannot handle.

​I would suggest you attempt to separate the non-context-aware stuff and
the context-aware stuff into two separate phases; and only data that passes
the non-context-aware tests would then be bundled up into the full CTE
where you then check constraints and the like.​ The how is beyond me but
this is an open source project so you have access to all of the relevant
functions. How you would go about using them without having to invoke the
engine I do not know but that seems like the only performant option since
the PostgreSQL executor isn't designed to handle your usage pattern.

Without considerably more understanding of the how suggestions are
difficult to make - even were I to know the innards of PostgreSQL and using
C. Others more knowledgeable will likely chime in but I suspect that I'm
pretty close to the mark on this one.

Yes, you could make a regexp-base validation library...but that screams
"maintenance nightmare" to me. I'm doubtful such a thing already exists.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ravi Krishna 2015-05-13 08:13:48 How to clear buffer
Previous Message Fabio Ugo Venchiarutti 2015-05-13 06:23:47 Dry run through input function for a given built-in data type