Actually, you can simplify the fix thusly: diff = (long long)(now.tv_sec - then.tv_sec) * 1000000 + (now.tv_usec - then.tv_usec);
pgsql-hackers by date:
Соглашаюсь с условиями обработки персональных данных