AW: [HACKERS] rules bug? - Mailing list pgsql-hackers

From Zeugswetter Andreas IZ5
Subject AW: [HACKERS] rules bug?
Date
Msg-id 219F68D65015D011A8E000006F8590C60267B353@sdexcsrv1.f000.d0188.sd.spardat.at
Whole thread Raw
Responses Re: AW: [HACKERS] rules bug?
List pgsql-hackers
> create rule surveys_ins as on insert to surveys
> do instead
> insert into survey_data (survey_date, name)
>     select new.survey_date, new.name where not exists
>     (select * from survey_data d where d.survey_date = new.survey_date
> and d.name = new.name);
> 
Since this is a rewrite rule, the whole statement gets rewritten, thus 
leading to different results, when one statement inserts many rows (insert
into ... select)
or one statement only inserts one row (insert ...).

The "problem" is visibility of data. The rows that have already been
inserted by this 
same statement (insert ...select) are not visible to the restricting select.

Andreas 



pgsql-hackers by date:

Previous
From: Dmitry Samersoff
Date:
Subject: Re: [HACKERS] EGCS becomes GCC
Next
From: Oleg Bartunov
Date:
Subject: Re: [HACKERS] EGCS becomes GCC