Fixes #1175 Added PgSQL part
Fixes #11475 Remove duplicated line
Fixes #1186
Merge pull request #1187 from JN-Jones/fix-1186

Fixes #1186
Merge pull request #1179 from JN-Jones/fix-1175

Fix 1175