dbTalk Databases Forums  

[BUGS] BUG #2739: INTERSECT ALL not working

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #2739: INTERSECT ALL not working in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mason Hale
 
Posts: n/a

Default [BUGS] BUG #2739: INTERSECT ALL not working - 11-06-2006 , 12:44 PM







The following bug has been logged online:

Bug reference: 2739
Logged by: Mason Hale
Email address: masonhale (AT) gmail (DOT) com
PostgreSQL version: 8.1.5
Operating system: GNU/Linux 2.6.9-42.0.3.ELsmp
Description: INTERSECT ALL not working
Details:

'INTERSECT ALL' does not return duplicate rows in a query.

The query below should return 10 rows, but it returns 5 rows on my system:

(
SELECT tablename
FROM pg_tables
LIMIT 5
)
INTERSECT ALL
(
(
SELECT tablename
FROM pg_tables
LIMIT 5
)
UNION ALL
(
SELECT tablename
FROM pg_tables
LIMIT 5
)
)

Note, the above is a simplied query meant to demonstrate the problem. This
same behavior occurs (and was discovered) in real-world situations with
user-defined tables.

This is nearly a deal-stopper for our application. Please reply to let me
know the status of this report.

Thanks,
Mason Hale

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] BUG #2739: INTERSECT ALL not working - 11-06-2006 , 01:11 PM






"Mason Hale" <masonhale (AT) gmail (DOT) com> writes:
Quote:
The query below should return 10 rows,
Not by my reading of the spec. SQL92 7.10 saith:

b) If a set operator is specified, then the result of applying
the set operator is a table containing the following rows:

i) Let R be a row that is a duplicate of some row in T1 or of
some row in T2 or both. Let m be the number of duplicates
of R in T1 and let n be the number of duplicates of R in
T2, where m >= 0 and n >= 0.

....

iii) If ALL is specified, then

....


3) If INTERSECT is specified, then the number of duplicates
of R that T contains is the minimum of m and n.

You have m = 1, n = 2 for each distinct row at the INTERSECT step,
ergo you get one copy out.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
  #3  
Old   
Mason Hale
 
Posts: n/a

Default Re: [BUGS] BUG #2739: INTERSECT ALL not working - 11-06-2006 , 02:49 PM



------=_Part_48723_20617781.1162843021877
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Tom -

Many thanks for the quick reply. I feel honored to receive email from you
after seeing your name so many times in my web searches on Postgres topics.

That's not how I understood INTERSECT ALL to work. But it's the clear the
spec is right and my understanding is wrong.
This is not a bug.

Unfortunately the INTERSECT ALL as spec'd and implemented doesn't quite give
me what I need. So back to the drawing board for me...

best regards,
Mason

On 11/6/06, Tom Lane <tgl (AT) sss (DOT) pgh.pa.us> wrote:
Quote:
"Mason Hale" <masonhale (AT) gmail (DOT) com> writes:
The query below should return 10 rows,

Not by my reading of the spec. SQL92 7.10 saith:

b) If a set operator is specified, then the result of applying
the set operator is a table containing the following rows:

i) Let R be a row that is a duplicate of some row in T1 or
of
some row in T2 or both. Let m be the number of duplicates
of R in T1 and let n be the number of duplicates of R in
T2, where m >= 0 and n >= 0.

...

iii) If ALL is specified, then

...


3) If INTERSECT is specified, then the number of
duplicates
of R that T contains is the minimum of m and n.

You have m = 1, n = 2 for each distinct row at the INTERSECT step,
ergo you get one copy out.

regards, tom lane

------=_Part_48723_20617781.1162843021877
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Tom -<br><br>Many thanks for the quick reply. I feel honored to receive email from you after seeing your name so many times in my web searches on Postgres topics.<br><br>That's not how I understood INTERSECT ALL to work. But it's the clear the spec is right and my understanding is wrong.
<br>This is not a bug.<br><br>Unfortunately the INTERSECT ALL as spec'd and implemented doesn't quite give me what I need. So back to the drawing board for me...<br><br>best regards,<br>Mason<br><br><div><span class="gmail_quote">
On 11/6/06, <b class="gmail_sendername">Tom Lane</b> &lt;<a href="mailto:tgl (AT) sss (DOT) pgh.pa.us">tgl (AT) sss (DOT) pgh.pa.us</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&quot;Mason Hale&quot; &lt;<a href="mailto:masonhale (AT) gmail (DOT) com">masonhale (AT) gmail (DOT) com</a>&gt; writes:<br>&gt; The query below should return 10 rows,<br><br>Not by my reading of the spec.&nbsp;&nbsp;SQL92 7.10 saith:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b) If a set operator is specified, then the result of applying
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the set operator is a table containing the following rows:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i) Let R be a row that is a duplicate of some row in T1 or of<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p; some row in T2 or both. Let m be the number of duplicates
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; of R in T1 and let n be the number of duplicates of R in<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p; T2, where m &gt;= 0 and n &gt;= 0.<br><br>...<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iii) If ALL is specified, then<br><br>...<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp; 3) If INTERSECT is specified, then the number of duplicates
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; of R that T contains is the minimum of m and n.<br><br>You have m = 1, n = 2 for each distinct row at the INTERSECT step,<br>ergo you get one copy out.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;regards, tom lane
<br></blockquote></div><br>

------=_Part_48723_20617781.1162843021877--


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.