Re: [BUGS] INET operators and NOT

Поиск
Список
Период
Сортировка
Искать

Re: [BUGS] INET operators and NOT

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Tomas Cerha  writes:
> Aplying the NOT operator with << INET operator results always in false.

> accounting=> SELECT * FROM a;
>       ip
> --------
> 10.1.1.1
> 10.1.1.2
> 10.2.1.2
> 10.2.1.1
> (4 rows)

> accounting=> SELECT * FROM a WHERE ip<<'10.1/16';
>       ip
> --------
> 10.1.1.1
> 10.1.1.2
> (2 rows)

> accounting=> SELECT * FROM a WHERE NOT ip<<'10.1/16';
> ip
> --
> (0 rows)

What's going on here is that the optimizer is simplifying "NOT x<>=y" (network_supeq), because the pg_operator
entry for << claims that >>= is its negator.  This example demonstrates
that that ain't so.

Can anyone comment on whether any of the inet operators are actually the
correct negator of << ?  For that matter, are inet's other commutator
and negator declarations just as broken?

			regards, tom lane

Re: Re: [BUGS] INET operators and NOT

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Here is Tom Lane's comment.

> Tomas Cerha  writes:
> > Aplying the NOT operator with << INET operator results always in false.
> 
> > accounting=> SELECT * FROM a;
> >       ip
> > --------
> > 10.1.1.1
> > 10.1.1.2
> > 10.2.1.2
> > 10.2.1.1
> > (4 rows)
> 
> > accounting=> SELECT * FROM a WHERE ip<<'10.1/16';
> >       ip
> > --------
> > 10.1.1.1
> > 10.1.1.2
> > (2 rows)
> 
> > accounting=> SELECT * FROM a WHERE NOT ip<<'10.1/16';
> > ip
> > --
> > (0 rows)
> 
> What's going on here is that the optimizer is simplifying "NOT x< (network_sub) into "x>>=y" (network_supeq), because the pg_operator
> entry for << claims that >>= is its negator.  This example demonstrates
> that that ain't so.
> 
> Can anyone comment on whether any of the inet operators are actually the
> correct negator of << ?  For that matter, are inet's other commutator
> and negator declarations just as broken?
> 
> 			regards, tom lane
> 
> ************
> 


--  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

Re: Re: [BUGS] INET operators and NOT

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian  writes:
>> What's going on here is that the optimizer is simplifying "NOT x<> (network_sub) into "x>>=y" (network_supeq), because the pg_operator
>> entry for << claims that >>= is its negator.  This example demonstrates
>> that that ain't so.
>> 
>> Can anyone comment on whether any of the inet operators are actually the
>> correct negator of << ?  For that matter, are inet's other commutator
>> and negator declarations just as broken?

I did take out the demonstrably incorrect negator links for 7.0.
We still have those other issues about CIDR/INET types though...
		regards, tom lane

FAQ