RE: RE: VARCHAR to CIDR type cast

From: Nicolas Huillard <nhuillard(at)ghs(dot)fr>
To: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: RE: RE: VARCHAR to CIDR type cast
Date: 2001-06-11 17:03:38
Message-ID: 01C0F2A9.39CCECE0.nhuillard@ghs.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> -----Message d'origine-----
> De: Alex Pilosov [SMTP:alex(at)pilosoft(dot)com]
> Date: vendredi 8 juin 2001 19:59
> À: Nicolas Huillard
> Cc: 'pgsql-general(at)postgresql(dot)org'
> Objet: Re: [GENERAL] RE: VARCHAR to CIDR type cast
>
...
>
> However, you say that you have a varchar in database already. As strange
> as it may be, there isn't a cast function from any char type to any
> network type. I'm sure its an oversight, its not hard to write such a
> function based on inet_in....

That's what I'm planning...
But I have not such function code to start with. Is there somewhere
something like that :
* a simple C function with all the PostgreSQL stuff
* that simply call a PG's internal function (that will be cidr_in and
inet_in, for me)

>
> Unfortunately, you cannot use inet_in function to cast a varchar, since
it
> expects as input slightly different data (a null-terminated string),
> while varchar is different (it has length info in beginning). I remember
> there was a discussion about creation of a 'cstring' datatype to support
> such conversions (ie convert xxx to yyy via xxx_out and yyy_in), but I
> don't see any result...Anyone?

OK : the external cast function will only convert the
"length-info-at-the-beginning" string into a "null-terminated" string, then
call cidr_in...
Really simple, in fact, but with a lot of stuff all around, isn't it ?

NH

Responses

Browse pgsql-general by date

  From Date Subject
Next Message The Hermit Hacker 2001-06-11 17:42:13 sysauth-pgsql / pam-pgsql port(s) ...
Previous Message Lamar Owen 2001-06-11 16:31:44 Re: PGDG?