Search Postgresql Archives

Re: Problem with records that disappear.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/14/2013 1:34 AM, Condor wrote:
It's a standalone statements without BEGIN TRANSACTION. An update is easy to explain with another but insert with missing row and there is no DELETE command in whole code and no one other have access to server. No any error logs, only access log system insert that user make the changes (no info what changes).


as I see it, that INSERT can't ever happen. if AID is NULL, then the first IF AID > 0 will be FALSE, so the 2nd IF AID IS NULL will never get evaluated. the two UPDATE's up front will not happen either if AID is null.

and, what is SET X=X about?!?   thats a big noop anyways.

is this 'redacted' code that's been sanitized? the more I look at it, the more I'm cringing. WHERE x=x on that SELECT INTO ids will return the whole table, since X = X is always true unless X is NULL.


BEGIN
  UPDATE table SET X = X where id = aid;
  UPDATE table_2 SET Y=Y where id = aid;
  IF aid > 0 THEN
    SELECT INTO ids id FROM table_3 WHERE x = x;
    IF aid IS NULL THEN
      INSERT INTO table_3 (id) VALUES (x);
    ELSE
      UPDATE table_3 SET id = id + 1 WHERE x = X;
    END IF;
  END IF;
  RETURN 200;
END;






--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux