Lists: | pgsql-general |
---|
From: | Vasiliy G Tolstov <v(dot)tolstov(at)selfip(dot)ru> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | cidr data type question |
Date: | 2009-11-02 08:07:16 |
Message-ID: | 1257149236.3426.9.camel@localhost |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
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(dot)tolstov(at)selfip(dot)ru>
Selfip.Ru
From: | John R Pierce <pierce(at)hogranch(dot)com> |
---|---|
To: | v(dot)tolstov(at)selfip(dot)ru |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: cidr data type question |
Date: | 2009-11-02 08:34:22 |
Message-ID: | 4AEE998E.1080502@hogranch.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
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
From: | Vasiliy G Tolstov <v(dot)tolstov(at)selfip(dot)ru> |
---|---|
To: | John R Pierce <pierce(at)hogranch(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: cidr data type question |
Date: | 2009-11-02 08:49:25 |
Message-ID: | 1257151765.3426.22.camel@localhost |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
В Пнд, 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(dot)tolstov(at)selfip(dot)ru>
Selfip.Ru
From: | Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: cidr data type question |
Date: | 2009-11-02 12:29:49 |
Message-ID: | pumy35xg76.fsf@srv.protecting.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
In article <1257149236(dot)3426(dot)9(dot)camel(at)localhost>,
Vasiliy G Tolstov <v(dot)tolstov(at)selfip(dot)ru> 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.
From: | Vasiliy G Tolstov <v(dot)tolstov(at)selfip(dot)ru> |
---|---|
To: | Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: cidr data type question |
Date: | 2009-11-02 12:34:46 |
Message-ID: | 1257165286.3426.120.camel@localhost |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
В Пнд, 02/11/2009 в 13:29 +0100, Harald Fuchs пишет:
> In article <1257149236(dot)3426(dot)9(dot)camel(at)localhost>,
> Vasiliy G Tolstov <v(dot)tolstov(at)selfip(dot)ru> 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(dot)tolstov(at)selfip(dot)ru>
Selfip.Ru