Fixed segments SQL queries for PostgreSQL compatibility

PostgreSQL doesn't cast int to boolean.
Without that, many tasks are not possible (tried with index and kill but may be more tasks affected).