Thread: incompatible return type for netmask(inet) function between 7.0.3 and 7.1
incompatible return type for netmask(inet) function between 7.0.3 and 7.1
From
pgsql-bugs@postgresql.org
Date:
Vadim Passynkov (pvi@axxent.ca) reports a bug with a severity of 4 The lower the number the more severe it is. Short Description incompatible return type for netmask(inet) function between 7.0.3 and 7.1 Long Description Function netmask(inet) change return type from 7.0.3 to 7.1 In 7.0.3 return type was text, in 7.1 return type inet Realy in 7.1 added text(inet) and of course need that host and netmask have return type inet, but host in 7.1 still return text. Other problem this changes that dump code from 7.0.3 incompatible with 7.1. Sample Code Version 7.0.3 template1=# \df netmask List of functions Result | Function | Arguments --------+----------+----------- text | netmask | inet (1 row) template1=# \df host List of functions Result | Function | Arguments --------+----------+----------- text | host | inet (1 row) Version 7.1 template1=# \df netmask List of functions Result | Function | Arguments --------+----------+----------- inet | netmask | inet (1 row) template1=# \df host List of functions Result | Function | Arguments --------+----------+----------- text | host | inet (1 row) No file was uploaded with this report
Re: incompatible return type for netmask(inet) function between 7.0.3 and 7.1
From
Justin Clift
Date:
Hi Vadim, I don't know if this is of any help, but it might be... With PostgreSQL 7.0.x, there was a bug with the way inet type data was being returned. It was being given out as text, but with spaces used for padding stuck on the end of the string. i.e. '192.168.1.1 ' This was fixed in 7.1. i.e. '192.168.1.1' Depending on how you're doing things, you *might* be able to wrap stuff in a btrim() function for 7.0.x. i.e. btrim(<inet_field>) should return '192.168.1.1' Well, you get the idea. Might be a start of a workaround for you anyway. Regards and best wishes, Justin Clift pgsql-bugs@postgresql.org wrote: > > Vadim Passynkov (pvi@axxent.ca) reports a bug with a severity of 4 > The lower the number the more severe it is. > > Short Description > incompatible return type for netmask(inet) function between 7.0.3 and 7.1 > > Long Description > Function netmask(inet) change return type from 7.0.3 to 7.1 > In 7.0.3 return type was text, in 7.1 return type inet > Realy in 7.1 added text(inet) and of course need that > host and netmask have return type inet, but host in 7.1 still return > text. > > Other problem this changes that dump code from 7.0.3 incompatible > with 7.1. > > Sample Code > Version 7.0.3 > template1=# \df netmask > List of functions > Result | Function | Arguments > --------+----------+----------- > text | netmask | inet > (1 row) > > template1=# \df host > List of functions > Result | Function | Arguments > --------+----------+----------- > text | host | inet > (1 row) > > Version 7.1 > template1=# \df netmask > List of functions > Result | Function | Arguments > --------+----------+----------- > inet | netmask | inet > (1 row) > > template1=# \df host > List of functions > Result | Function | Arguments > --------+----------+----------- > text | host | inet > (1 row) > > No file was uploaded with this report > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) -- "My grandfather once told me that there are two kinds of people: those who work and those who take the credit. He told me to try to be in the first group; there was less competition there." - Indira Gandhi
Re: incompatible return type for netmask(inet) function between 7.0.3 and 7.1
From
"Vadim I. Passynkov"
Date:
Justin Clift wrote: > For 7.0.3 I already found solution for this problem, thanks. I ask now about why logical same functions host(inet) and netmask(inet) return different types ? > Hi Vadim, > > I don't know if this is of any help, but it might be... > > With PostgreSQL 7.0.x, there was a bug with the way inet type data was > being returned. It was being given out as text, but with spaces used > for padding stuck on the end of the string. > > i.e. '192.168.1.1 ' > > This was fixed in 7.1. > > i.e. '192.168.1.1' > > Depending on how you're doing things, you *might* be able to wrap stuff > in a btrim() function for 7.0.x. > > i.e. btrim(<inet_field>) should return '192.168.1.1' > > Well, you get the idea. Might be a start of a workaround for you > anyway. > > Regards and best wishes, > > Justin Clift > > pgsql-bugs@postgresql.org wrote: > > > > Vadim Passynkov (pvi@axxent.ca) reports a bug with a severity of 4 > > The lower the number the more severe it is. > > > > Short Description > > incompatible return type for netmask(inet) function between 7.0.3 and 7.1 > > > > Long Description > > Function netmask(inet) change return type from 7.0.3 to 7.1 > > In 7.0.3 return type was text, in 7.1 return type inet > > Realy in 7.1 added text(inet) and of course need that > > host and netmask have return type inet, but host in 7.1 still return > > text. > > > > Other problem this changes that dump code from 7.0.3 incompatible > > with 7.1. > > > > Sample Code > > Version 7.0.3 > > template1=# \df netmask > > List of functions > > Result | Function | Arguments > > --------+----------+----------- > > text | netmask | inet > > (1 row) > > > > template1=# \df host > > List of functions > > Result | Function | Arguments > > --------+----------+----------- > > text | host | inet > > (1 row) > > > > Version 7.1 > > template1=# \df netmask > > List of functions > > Result | Function | Arguments > > --------+----------+----------- > > inet | netmask | inet > > (1 row) > > > > template1=# \df host > > List of functions > > Result | Function | Arguments > > --------+----------+----------- > > text | host | inet > > (1 row) > > > > No file was uploaded with this report > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 2: you can get off all lists at once with the unregister command > > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > > -- > "My grandfather once told me that there are two kinds of people: those > who work and those who take the credit. He told me to try to be in the > first group; there was less competition there." > - Indira Gandhi -- Vadim I. Passynkov, Axxent Corp. mailto:pvi@axxent.ca
"Vadim I. Passynkov" <pvi@axxent.ca> writes: > I ask now about why logical same functions host(inet) and netmask(inet) > return different types ? There was a *long* discussion about this last year, and we concluded that was the right thing to do. See the mail archives if you want the details --- but the key point is that host() text() and abbrev() are primarily useful to allow non-default display formatting of inet/cidr values, so they should produce text. If they produced another inet value then they'd be unable to control how that value got formatted for display. regards, tom lane