Re: [phpOpenTracker-User] Duplicate key insertion (bug?) with postgreSQL

Jean-Christian Imbeault <[email protected]>
Newsgroups gmane.comp.web.phpopentracker.general
Message-ID <[email protected]>
Here's a revised version of the function. I did a little bench marking
and the new version is slightly faster (0.2s faster over 12010 inserts)
and it is a few less lines of code and easier to read I think.

create or replace function pot_doc_dup_check() returns trigger as '
BEGIN
  PERFORM 1 FROM pot_documents WHERE data_id=NEW.data_id LIMIT 1;
  IF FOUND THEN
      RETURN null;
  END IF;
  RETURN NEW;
END;
' LANGUAGE 'plpgsql' with (iscachable);

Jean-Christian Imbeault



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.