Re: [SQL] (possible) bug with constraint exclusion

2008-01-11 Thread Tom Lane
"Rajesh Kumar Mallah" <[EMAIL PROTECTED]> writes: > Am I correct in understanding that the current behavior is inappropriate > and shall be corrected at some point of time in future versions ? It's a bug, it's patched: http://archives.postgresql.org/pgsql-committers/2008-01/msg00184.php

Re: [SQL] (possible) bug with constraint exclusion

2008-01-11 Thread Rajesh Kumar Mallah
On Jan 12, 2008 1:26 AM, Tom Lane <[EMAIL PROTECTED]> wrote: > "Rajesh Kumar Mallah" <[EMAIL PROTECTED]> writes: > > looks like constraint exclusion is being too aggressive in excluding null > > values > > Hmm, you're right. Looks like I broke it here: > http://archives.postgresql.org/pgsql-commi

Re: [SQL] SQL question: Highest column value of unique column pairs

2008-01-11 Thread Kevin Jenkins
Thanks! How would I find the highest score in the union of the two tables? I tried this but it can't find unionTable: SELECT * FROM (select fnam1 as fname,lname1 as lname, score1 as score from myscorestable union select fnam2 as fname,lname2 as lname, score2 as score from myscorestable) as union

Re: [SQL] SQL question: Highest column value of unique column pairs

2008-01-11 Thread Shane Ambler
Kevin Jenkins wrote: Hi, I have the following table which holds the result of 1 on 1 matches: FName1, LName1, Score1, FName2, LName2, Score2, Date John, Doe,85 Bill, Gates, 20 Jan 1. John, Archer, 90 John, Doe,120 Jan 5 Bob,Barker, 70 Calvin, Klien

[SQL] SQL question: Highest column value of unique column pairs

2008-01-11 Thread Kevin Jenkins
Hi, I have the following table which holds the result of 1 on 1 matches: FName1, LName1, Score1, FName2, LName2, Score2, Date John, Doe,85 Bill, Gates, 20 Jan 1. John, Archer, 90 John, Doe,120 Jan 5 Bob,Barker, 70 Calvin, Klien 8 Jan 8 John,

Re: [SQL] (possible) bug with constraint exclusion

2008-01-11 Thread Tom Lane
"Rajesh Kumar Mallah" <[EMAIL PROTECTED]> writes: > looks like constraint exclusion is being too aggressive in excluding null > values Hmm, you're right. Looks like I broke it here: http://archives.postgresql.org/pgsql-committers/2007-05/msg00187.php > although its well known that check constra

Re: [SQL] trigger for TRUNCATE?

2008-01-11 Thread Bruce Momjian
Added to TODO: > * Add ability to trigger on TRUNCATE > > http://archives.postgresql.org/pgsql-sql/2008-01/msg00050.php --- Simon Riggs wrote: > On Fri, 2008-01-11 at 08:24 +, Richard Huxton wrote: > > > I've always

Re: [SQL] trigger for TRUNCATE?

2008-01-11 Thread Simon Riggs
On Fri, 2008-01-11 at 08:24 +, Richard Huxton wrote: > I've always considered TRUNCATE to be DDL rather than DML. I mentally > group it with DROP TABLE rather than DELETE> DDL/DML probably isn't the right split, since its then arguable as to which group of commands it belongs in. I see we

Re: [SQL] trigger for TRUNCATE?

2008-01-11 Thread Erik Jones
On Jan 11, 2008, at 2:24 AM, Richard Huxton wrote: Tom Lane wrote: Alvaro Herrera <[EMAIL PROTECTED]> writes: My thinking is that a TRUNCATE trigger is a per-statement trigger which doesn't have access to the set of deleted rows (Replicator uses it that way -- we replicate the truncate act

Re: [SQL] SQL stored function inserting and returning data in a row.

2008-01-11 Thread Pavel Stehule
Hello > By the way, is there any performance difference between pure SQL and > PL/pgSQL stored functions? If I remember correctly there was such a > distinction between pure SQL statement and PL/PLSQL stored procedures > (Oracle), in the sense that PL/PLSQL stored procedures are executed > within

Re: [SQL] SQL stored function inserting and returning data in a row.

2008-01-11 Thread Daniel Caune
> What about > $$ > INSERT INTO ; > select currval('seq_matchmaking_session_id'); > $$ language sql; > > ? Indeed... :-( For some reason, I thought that it was not possible to have to SQL statement in an SQL stored function. By the way, is there any performance difference between pure SQL a

Re: [SQL] SQL stored function inserting and returning data in a row.

2008-01-11 Thread Marcin Stępnicki
On Jan 11, 2008 4:23 AM, Daniel Caune <[EMAIL PROTECTED]> wrote: Please ignore my post. I havent' read your message carefully enough. ---(end of broadcast)--- TIP 7: You can help support the PostgreSQL project by donating at http://

Re: [SQL] SQL stored function inserting and returning data in a row.

2008-01-11 Thread Marcin Stępnicki
On Jan 11, 2008 4:23 AM, Daniel Caune <[EMAIL PROTECTED]> wrote: > Hi, > > Is there any way to define a SQL stored function that inserts a row in a > table and returns the serial generated? Maybe you just need INSERT ... RETURNING? http://www.postgresql.org/docs/8.2/interactive/sql-insert.html "

Re: [SQL] SQL stored function inserting and returning data in a row.

2008-01-11 Thread Gerardo Herzig
Daniel Caune wrote: Hi, Is there any way to define a SQL stored function that inserts a row in a table and returns the serial generated? CREATE TABLE matchmaking_session ( session_id bigint NOT NULL DEFAULT nextval('seq_matchmaking_session_id'), ... ); CREATE FUNCTION create_matchmaking_ses

Re: [SQL] trigger for TRUNCATE?

2008-01-11 Thread Richard Huxton
Tom Lane wrote: Alvaro Herrera <[EMAIL PROTECTED]> writes: My thinking is that a TRUNCATE trigger is a per-statement trigger which doesn't have access to the set of deleted rows (Replicator uses it that way -- we replicate the truncate action, and replay it on the replica). In that way it would