diff --git a/lib/modules/Sql.pmod/postgres.pike b/lib/modules/Sql.pmod/postgres.pike
index aa853735af6b3580edf965808066e9fbce8fdbad..25f935945c6ca638c58d31f923caf5a941d10b8a 100644
--- a/lib/modules/Sql.pmod/postgres.pike
+++ b/lib/modules/Sql.pmod/postgres.pike
@@ -461,7 +461,7 @@ int|object streaming_query(object|string q,
   return big_query(q, bindings);
 }
 
-#else
+#elif constant(Sql.pgsql)
 /*
  * If libpq wasn't available at compile time, the pgsql-module can provide
  * near the same functionality as the postgres module.
@@ -479,4 +479,6 @@ int|object streaming_query(object|string q,
 //! @seealso
 //!   @[Sql.pgsql], @[Sql.Sql]
 inherit Sql.pgsql;
-#endif /* constant(Postgres.postgres) */
+#else /* constant(Sql.pgsql) */
+constant this_program_does_not_exist = 1;
+#endif