[MonetDB-users] Check for inet equals
Hi, How to select from table by value in column with INET type? For example, I have table: $ msqldump -d billing -- msqldump dump database Mon Aug 1 11:03:13 2011 -- MonetDB v11.3.3, 'b0' START TRANSACTION; SET SCHEMA "sys"; CREATE TABLE "sys"."transfer_ip" ( "packetdate" TIMESTAMP, "proto" INTEGER, "src" INET, "sport" INTEGER, "sintf" VARCHAR(15), "dst" INET, "dport" INTEGER, "dintf" VARCHAR(15), "packets" BIGINT, "bytes" BIGINT, "prefix" VARCHAR(5), "processed" BOOLEAN ); COMMIT; COPY 10293965 RECORDS INTO "sys"."transfer_ip" FROM stdin USING DELIMITERS '\t','\n','"'; ^C I tried to select in such ways: # mclient -d billing Welcome to mclient, the MonetDB/SQL interactive terminal (Apr2011-SP1) Database: MonetDB v11.3.3, 'billing' Type \q to quit, \? for a list of available commands auto commit mode: on sql>select * from transfer_ip where src = '10.7.1.10' limit 10; SQLException:str_cast:value too long for type (var)char(9) sql>select * from transfer_ip where src = '10.7.1.10':inet limit 10; unexpected symbol (:) sql>select * from transfer_ip where src << '10.7.1.10' limit 10; types inet(0,0) and tinyint(8,0) are not equal for column 'src' What it the right way? -- Thanks, Eugene Prokopiev
On 2011-08-01 09:11, Eugene Prokopiev wrote:
Hi,
How to select from table by value in column with INET type? For example, I have table:
$ msqldump -d billing -- msqldump dump database Mon Aug 1 11:03:13 2011 -- MonetDB v11.3.3, 'b0' START TRANSACTION; SET SCHEMA "sys"; CREATE TABLE "sys"."transfer_ip" ( "packetdate" TIMESTAMP, "proto" INTEGER, "src" INET, "sport" INTEGER, "sintf" VARCHAR(15), "dst" INET, "dport" INTEGER, "dintf" VARCHAR(15), "packets" BIGINT, "bytes" BIGINT, "prefix" VARCHAR(5), "processed" BOOLEAN ); COMMIT; COPY 10293965 RECORDS INTO "sys"."transfer_ip" FROM stdin USING DELIMITERS '\t','\n','"'; ^C
I tried to select in such ways:
# mclient -d billing Welcome to mclient, the MonetDB/SQL interactive terminal (Apr2011-SP1) Database: MonetDB v11.3.3, 'billing' Type \q to quit, \? for a list of available commands auto commit mode: on sql>select * from transfer_ip where src = '10.7.1.10' limit 10; SQLException:str_cast:value too long for type (var)char(9) sql>select * from transfer_ip where src = '10.7.1.10':inet limit 10; unexpected symbol (:) sql>select * from transfer_ip where src << '10.7.1.10' limit 10; types inet(0,0) and tinyint(8,0) are not equal for column 'src'
What it the right way?
Try select * from transfer_ip where src = inet '10.7.1.10' limit 10; -- Sjoerd Mullender
How to check whether ip is contained within network? I tried: sql>select * from transfer_ip where dst << '10.7.1.0/24' limit 10; types inet(0,0) and tinyint(8,0) are not equal for column 'dst' sql>select * from transfer_ip where dst << inet '10.7.1.0/24' limit 10; types inet(0,0) and tinyint(8,0) are not equal for column 'dst' -- Thanks, Eugene Prokopiev
On 2011-08-02 08:21, Eugene Prokopiev wrote:
How to check whether ip is contained within network? I tried:
sql>select * from transfer_ip where dst << '10.7.1.0/24' limit 10; types inet(0,0) and tinyint(8,0) are not equal for column 'dst' sql>select * from transfer_ip where dst << inet '10.7.1.0/24' limit 10; types inet(0,0) and tinyint(8,0) are not equal for column 'dst'
<< is the left shift operator, so both sides are expected to be a integers. -- Sjoerd Mullender
2011/8/5 Sjoerd Mullender
On 2011-08-02 08:21, Eugene Prokopiev wrote:
How to check whether ip is contained within network? I tried:
sql>select * from transfer_ip where dst << '10.7.1.0/24' limit 10; types inet(0,0) and tinyint(8,0) are not equal for column 'dst' sql>select * from transfer_ip where dst << inet '10.7.1.0/24' limit 10; types inet(0,0) and tinyint(8,0) are not equal for column 'dst'
<< is the left shift operator, so both sides are expected to be a integers.
As I see, this operator is defined for INET type in /usr/lib64/monetdb5/inet.mal Is it impossible to do what I wish?
participants (2)
-
Eugene Prokopiev
-
Sjoerd Mullender