fix random crashes

Hi everybody!

I fixed random crashes, that happened with PostgreSQL 9.2 using pgmemcache.

Regards, Ky