Re: How to covert 'char' to 'inet'

From: Andrew Sullivan <andrew(at)libertyrms(dot)info>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to covert 'char' to 'inet'
Date: 2002-07-25 14:18:26
Message-ID: 20020725101826.A29680@mail.libertyrms.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jul 24, 2002 at 01:40:01AM -0700, Michal O wrote:
> Thank you. What I did was:
>
> inet(trim(both ' ' from server_ip::text))
>
> and worked fine. Convertion to 'text' was needed.
> Do you know how time consuming it is ? Is there more efficient way ?

No, as I say, char() is padded, and spaces (or whatever) are not
legal in IP addresses. So, if you have a char field with data
10.0.0.1, its actual representation is something more like
'10.0.0.1_______', where '_' is the padding. This is the same
problem you would have if you inserted the char() field into a
newly-created varchar() field: you'd get the padded text instead.
That's a reason to avoid using char() for most cases, unless you know
that the field will _always_ be the same length.

A

--
----
Andrew Sullivan 87 Mowat Avenue
Liberty RMS Toronto, Ontario Canada
<andrew(at)libertyrms(dot)info> M6K 3E3
+1 416 646 3304 x110

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Darren Ferguson 2002-07-25 14:18:37 Re: How to covert 'char' to 'inet'
Previous Message Ewald Geschwinde 2002-07-25 14:11:46 Re: UML