Re: minimal update

Поиск
Список
Период
Сортировка
От Gurjeet Singh
Тема Re: minimal update
Дата
Msg-id 65937bea0803180746s5ec87000gc755adfefece1441@mail.gmail.com
обсуждение исходный текст
Ответ на Re: minimal update  (Andrew Dunstan <andrew@dunslane.net>)
Ответы Re: minimal update  (Bruce Momjian <bruce@momjian.us>)
Список pgsql-hackers
On Tue, Mar 18, 2008 at 7:46 PM, Andrew Dunstan <<a href="mailto:andrew@dunslane.net">andrew@dunslane.net</a>>
wrote:<br/><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204);
margin:0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br /><br /><br /><br /><br /> Gurjeet Singh
wrote:<br/> > On Fri, Mar 7, 2008 at 9:40 PM, Bruce Momjian <<a
href="mailto:bruce@momjian.us">bruce@momjian.us</a><br/></div><div class="Ih2E3d">> <mailto:<a
href="mailto:bruce@momjian.us">bruce@momjian.us</a>>>wrote:<br /> ><br /> ><br /> >     I assume don't
wanta TODO for this?  (Suppress UPDATE no changed<br /> >     columns)<br /> ><br /> ><br /> > I am
startingto implement this. Do we want to have this trigger<br /> > function in the server, or in an external
module?<br/> ><br /> ><br /><br /></div>I have the trigger part of this done, in fact. What remains to be done<br
/>is to add it to the catalog and document it. The intention is to make it<br /> a builtin as it will be generally
useful.If you want to work on the<br /> remaining parts then I will happily ship you the C code for the trigger.<br
/><br/></blockquote></div><br />In fact, I just finished writing the C code and including it in the catalog (Just
testedthat it's visible in the catalog). I will test it to see if it does actually do what we want it to.<br /><br />I
haveincorporated all the suggestions above. Would love to see your code in the meantime.<br /><br />Here's the C
code:<br/><br /><span style="font-family: courier new,monospace;">Datum<br />trig_ignore_duplicate_updates(
PG_FUNCTION_ARGS)<br /> {<br />    TriggerData *trigData;<br />    HeapTuple oldTuple;<br />    HeapTuple newTuple;<br
/><br/>    if (!CALLED_AS_TRIGGER(fcinfo))<br />        elog(ERROR, "trig_ignore_duplicate_updates: not called by
triggermanager.");<br /><br />    if( !TRIGGER_FIRED_BY_UPDATE(trigData->tg_event)<br />        &&
!TRIGGER_FIRED_BEFORE(trigData->tg_event)<br/>        && !TRIGGER_FIRED_FOR_ROW(trigData->tg_event) )<br
/>   {<br />        elog(ERROR, "trig_ignore_duplicate_updates: Can only be executed for UPDATE, BEFORE and FOR EACH
ROW.");<br/>     }<br /><br />    trigData =  (TriggerData *) fcinfo->context;<br />    oldTuple =
trigData->tg_trigtuple;<br/>    newTuple = trigData->tg_newtuple;<br /><br />    if (newTuple->t_len ==
oldTuple->t_len<br/>        && newTuple->t_data->t_hoff == oldTuple->t_data->t_hoff<br />    
   && HeapTupleHeaderGetNatts(newTuple->t_data) == HeapTupleHeaderGetNatts(oldTuple->t_data)<br />       
&&(newTuple->t_data->t_infomask & ~HEAP_XACT_MASK)<br />            ==
(oldTuple->t_data->t_infomask& ~HEAP_XACT_MASK)<br />         && memcmp( (char*)(newTuple->t_data)
+offsetof(HeapTupleHeaderData, t_bits),<br />                (char*)(oldTuple->t_data) +
offsetof(HeapTupleHeaderData,t_bits),<br />                    newTuple->t_len - offsetof(HeapTupleHeaderData,
t_bits)) == 0 )<br />     {<br />        /* return without crating a new tuple */<br />        return PointerGetDatum(
NULL);<br />    }<br />    <br />    return PointerGetDatum( trigData->tg_newtuple );<br />}<br /></span><span
style="font-family:courier new,monospace;"></span><br style="font-family: courier new,monospace;" /><br clear="all"
/><br/>-- <br />gurjeet[.singh]@EnterpriseDB.com<br />singh.gurjeet@{ gmail | hotmail | indiatimes | yahoo }.com<br
/><br/>EnterpriseDB <a href="http://www.enterprisedb.com">http://www.enterprisedb.com</a><br /><br />17° 29' 34.37"N,
78°30' 59.76"E - Hyderabad *<br /> 18° 32' 57.25"N, 73° 56' 25.42"E - Pune<br />37° 47' 19.72"N, 122° 24' 1.69" W - San
Francisco<br/><br /><a href="http://gurjeet.frihost.net">http://gurjeet.frihost.net</a><br /><br />Mail sent from my
BlackLaptopdevice  

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [COMMITTERS] pgsql: Enable probes to work with Mac OS X Leopard and other OSes that
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: [COMMITTERS] pgsql: Enable probes to work with Mac OS X Leopard and other OSes that