cidr data type question

View: New views
5 Messages — Rating Filter:   Alert me  

cidr data type question

by Vasiliy G Tolstov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello.
I have table with cidr data type column (table is white/black list of
networks).

Does it possible to query - is the some address contains in any cidr
network in this table? (for all networks in the table do "contains or
equals"
http://www.postgresql.org/docs/8.4/interactive/functions-net.html
)


--
Vasiliy G Tolstov <v.tolstov@...>
Selfip.Ru


--
Sent via pgsql-general mailing list (pgsql-general@...)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: cidr data type question

by John R Pierce :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Vasiliy G Tolstov wrote:
> Hello.
> I have table with cidr data type column (table is white/black list of
> networks).
>
> Does it possible to query - is the some address contains in any cidr
> network in this table? (for all networks in the table do "contains or equals"
>  
> http://www.postgresql.org/docs/8.4/interactive/functions-net.html

    SELECT * FRMO mytable WHERE mytable.network >>= $1::INET;

that will return all rows of mytable which have a subnet that includes
the IP or subnet $1



--
Sent via pgsql-general mailing list (pgsql-general@...)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: cidr data type question

by Vasiliy G Tolstov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

В Пнд, 02/11/2009 в 00:34 -0800, John R Pierce пишет:

> Vasiliy G Tolstov wrote:
> > Hello.
> > I have table with cidr data type column (table is white/black list of
> > networks).
> >
> > Does it possible to query - is the some address contains in any cidr
> > network in this table? (for all networks in the table do "contains or equals"
> >  
> > http://www.postgresql.org/docs/8.4/interactive/functions-net.html
>
>     SELECT * FRMO mytable WHERE mytable.network >>= $1::INET;
>
> that will return all rows of mytable which have a subnet that includes
> the IP or subnet $1
>
>
>


Thank You! Does i need to replace ::INET with ::CIDR ша ш гыу cidr data
type or no?

--
Vasiliy G Tolstov <v.tolstov@...>
Selfip.Ru


--
Sent via pgsql-general mailing list (pgsql-general@...)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: cidr data type question

by Harald Fuchs-10 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In article <1257149236.3426.9.camel@localhost>,
Vasiliy G Tolstov <v.tolstov@...> writes:

> Hello.
> I have table with cidr data type column (table is white/black list of
> networks).

> Does it possible to query - is the some address contains in any cidr
> network in this table? (for all networks in the table do "contains or
> equals"
> http://www.postgresql.org/docs/8.4/interactive/functions-net.html
> )

If you mess with IP addresses, you should have a look at the ip4r
contrib module.  Since I discovered it, I've never looked back at
cidr/inet.


--
Sent via pgsql-general mailing list (pgsql-general@...)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: cidr data type question

by Vasiliy G Tolstov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

В Пнд, 02/11/2009 в 13:29 +0100, Harald Fuchs пишет:

> In article <1257149236.3426.9.camel@localhost>,
> Vasiliy G Tolstov <v.tolstov@...> writes:
>
> > Hello.
> > I have table with cidr data type column (table is white/black list of
> > networks).
>
> > Does it possible to query - is the some address contains in any cidr
> > network in this table? (for all networks in the table do "contains or
> > equals"
> > http://www.postgresql.org/docs/8.4/interactive/functions-net.html
> > )
>
> If you mess with IP addresses, you should have a look at the ip4r
> contrib module.  Since I discovered it, I've never looked back at
> cidr/inet.
>
>

Thank's but cidr solved fine my task

--
Vasiliy G Tolstov <v.tolstov@...>
Selfip.Ru


--
Sent via pgsql-general mailing list (pgsql-general@...)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general