I would like to test the behaviour of a program which executes queries to a PostgreSQL server in case of a query timeout.
How could I simulate that?
If you are just trying to simulate a timeout on your application side you could just use a dummy query like:
seconds is some integer value that would simulate a query just not coming back in a reasonable timeframe.
If you want to never come back from a query just run the above and kill the database.
pgrep posgres | xargs kill -15 $1
This would also simulate a query timeout I believe.
How are you simulating the successful queries? You should be able to use the same mechanism, but return
PGRES_FATAL_ERROR (and appropriate message strings) in your
PGresult return value .