rihad <[EMAIL PROTECTED]> writes:
     LOOP
SELECT date+1 INTO day FROM days WHERE date=day OR EXTRACT(dow FROM day) IN (0,6);
       EXIT WHEN NOT FOUND;
       timeout := timeout + 86400;
     END LOOP;

If the EXTRACT condition is true, then the SELECT will always succeed.

Isn't the new "day" re-evaluated on every loop iteration? I'm totally confused.

It's morning again over at our place, so... of course it's not! I stupidly did a SELECT date+1 instead of SELECT day+1, resulting in an infinite loop. A hard to spot bug, especially when your eyes are half closed. Good thing is that the solution came to me while I was still in bed a minute ago :-)


But your idea later on of separating EXTRACT outside the disk-touching code might be a nice cpu-memory trade-off that I hadn't thought of (or wasn't aware). It turns out any SQL "thing" can be in an IF or WHILE etc. ? I'll go read the docs more attentively.

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply via email to