Fix postgres error when displaying network graph.

fix #4149

I have tested by MySQL and PostgreSQL.