Inet type how to?

Started by Olivier PRENANTalmost 26 years ago10 messageshackers
Jump to latest
#1Olivier PRENANT
ohp@pyrenet.fr

Hi all,

I've had a table for years to keep radius connections to our NAS.

Not havin inet type, I typed ip_adress as text. Now, I'em trying to change
this column type to no avail.

select inet(ip_addr)... : cannot cast type to inet

How can I change this column??

TIA

--
Olivier PRENANT Tel: +33-5-61-50-97-00 (Work)
Quartier d'Harraud Turrou +33-5-61-50-97-01 (Fax)
31190 AUTERIVE +33-6-07-63-80-64 (GSM)
FRANCE Email: ohp@pyrenet.fr
------------------------------------------------------------------------------
Make your life a dream, make your dream a reality. (St Exupery)

#2Alex Pilosov
alex@pilosoft.com
In reply to: Olivier PRENANT (#1)
Re: Inet type how to?

You cannot change column type without dropping/recreating the table.

On Fri, 2 Jun 2000, Olivier PRENANT wrote:

Show quoted text

Hi all,

I've had a table for years to keep radius connections to our NAS.

Not havin inet type, I typed ip_adress as text. Now, I'em trying to change
this column type to no avail.

select inet(ip_addr)... : cannot cast type to inet

How can I change this column??

TIA

#3Olivier PRENANT
ohp@pyrenet.fr
In reply to: Alex Pilosov (#2)
Re: Inet type how to?

Yes, I know that; but even when I reload it, copy complains it can't
convert 194.250.190.185 ( for example) to inet!

Regards
On Fri, 2 Jun 2000, Alex Pilosov wrote:

You cannot change column type without dropping/recreating the table.

On Fri, 2 Jun 2000, Olivier PRENANT wrote:

Hi all,

I've had a table for years to keep radius connections to our NAS.

Not havin inet type, I typed ip_adress as text. Now, I'em trying to change
this column type to no avail.

select inet(ip_addr)... : cannot cast type to inet

How can I change this column??

TIA

--
Olivier PRENANT Tel: +33-5-61-50-97-00 (Work)
Quartier d'Harraud Turrou +33-5-61-50-97-01 (Fax)
31190 AUTERIVE +33-6-07-63-80-64 (GSM)
FRANCE Email: ohp@pyrenet.fr
------------------------------------------------------------------------------
Make your life a dream, make your dream a reality. (St Exupery)

#4Alex Pilosov
alex@pilosoft.com
In reply to: Olivier PRENANT (#3)
Re: Inet type how to?

It works for me for \copy (which uses inserts)

But yes, there is no way to convert text to inet, which is a pain. When it
annoys me sufficiently, I think I'll write text_inet wrapping inet_in...Or
just wait for someone else to do it (TODO, bruce? ;)

On Fri, 2 Jun 2000, Olivier PRENANT wrote:

Show quoted text

Yes, I know that; but even when I reload it, copy complains it can't
convert 194.250.190.185 ( for example) to inet!

Regards
On Fri, 2 Jun 2000, Alex Pilosov wrote:

You cannot change column type without dropping/recreating the table.

On Fri, 2 Jun 2000, Olivier PRENANT wrote:

Hi all,

I've had a table for years to keep radius connections to our NAS.

Not havin inet type, I typed ip_adress as text. Now, I'em trying to change
this column type to no avail.

select inet(ip_addr)... : cannot cast type to inet

How can I change this column??

TIA

#5Bruce Momjian
bruce@momjian.us
In reply to: Alex Pilosov (#4)
Re: Inet type how to?

It works for me for \copy (which uses inserts)

But yes, there is no way to convert text to inet, which is a pain. When it
annoys me sufficiently, I think I'll write text_inet wrapping inet_in...Or
just wait for someone else to do it (TODO, bruce? ;)

We don't? What about some double-casting option?

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#6Alex Pilosov
alex@pilosoft.com
In reply to: Bruce Momjian (#5)
Re: Inet type how to?

None works. I tried. There is no type that can be cast to inet. And
inet_in has a different calling sequence, and you can't really use that.

-alex

On Fri, 2 Jun 2000, Bruce Momjian wrote:

Show quoted text

It works for me for \copy (which uses inserts)

But yes, there is no way to convert text to inet, which is a pain. When it
annoys me sufficiently, I think I'll write text_inet wrapping inet_in...Or
just wait for someone else to do it (TODO, bruce? ;)

We don't? What about some double-casting option?

#7Bruce Momjian
bruce@momjian.us
In reply to: Alex Pilosov (#6)
Re: Inet type how to?

None works. I tried. There is no type that can be cast to inet. And
inet_in has a different calling sequence, and you can't really use that.

Added to TODO.

-alex

On Fri, 2 Jun 2000, Bruce Momjian wrote:

It works for me for \copy (which uses inserts)

But yes, there is no way to convert text to inet, which is a pain. When it
annoys me sufficiently, I think I'll write text_inet wrapping inet_in...Or
just wait for someone else to do it (TODO, bruce? ;)

We don't? What about some double-casting option?

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#8Olivier PRENANT
ohp@pyrenet.fr
In reply to: Alex Pilosov (#6)
Re: Inet type how to?

You're right... No way; However despite what I said befor it works.. until
text is ''; maybe this could be casted as NULL??

Regards,
On Fri, 2 Jun 2000, Alex Pilosov wrote:

None works. I tried. There is no type that can be cast to inet. And
inet_in has a different calling sequence, and you can't really use that.

-alex

On Fri, 2 Jun 2000, Bruce Momjian wrote:

It works for me for \copy (which uses inserts)

But yes, there is no way to convert text to inet, which is a pain. When it
annoys me sufficiently, I think I'll write text_inet wrapping inet_in...Or
just wait for someone else to do it (TODO, bruce? ;)

We don't? What about some double-casting option?

--
Olivier PRENANT Tel: +33-5-61-50-97-00 (Work)
Quartier d'Harraud Turrou +33-5-61-50-97-01 (Fax)
31190 AUTERIVE +33-6-07-63-80-64 (GSM)
FRANCE Email: ohp@pyrenet.fr
------------------------------------------------------------------------------
Make your life a dream, make your dream a reality. (St Exupery)

#9Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#7)
Re: Inet type how to?

None works. I tried. There is no type that can be cast to inet. And
inet_in has a different calling sequence, and you can't really use that.

Added to TODO.

If we had "C string" (or something like that) as a genuine type in the
type system, then it would be possible/reasonable for the parser to
understand
textvariable::cstring::inet
as a request to invoke text_out followed by inet_in.

I think it'd be a real bad idea to invoke such conversions silently,
since then we'd essentially have no type system at all (you could get
from anything to anything else via cstring, so how can the thing check
for errors?). But it'd be awful darn handy to be able to invoke the
type i/o routines explicitly...

regards, tom lane

#10Alex Pilosov
alex@pilosoft.com
In reply to: Tom Lane (#9)
Re: Inet type how to?

On Fri, 2 Jun 2000, Tom Lane wrote:

None works. I tried. There is no type that can be cast to inet. And
inet_in has a different calling sequence, and you can't really use that.

Added to TODO.

If we had "C string" (or something like that) as a genuine type in the
type system, then it would be possible/reasonable for the parser to
understand
textvariable::cstring::inet
as a request to invoke text_out followed by inet_in.

I think it'd be a real bad idea to invoke such conversions silently,
since then we'd essentially have no type system at all (you could get
from anything to anything else via cstring, so how can the thing check
for errors?). But it'd be awful darn handy to be able to invoke the
type i/o routines explicitly...

I think its a great idea. Is it just a matter of altering the catalog? Or
apparently we'd need postgres engine to know that cstring is a special
type and instead of looking for conversion routines it should use xxx_in
and yyy_out

I like it in any case. Last ditch do-not-use-unless-you-sure-its-what you
want thingy...

-alex