Reserve prepared statement key before it is passed to Postgres

  The fix is for prepare_statement method:

    def prepare_statement(sql)
      sql_key = sql_key(sql)
      unless @statements.key? sql_key
        nextkey = @statements.next_key
        begin
          @connection.prepare nextkey, sql
        rescue => e
          raise translate_exception_class(e, sql)
        end
        # Clear the queue
        @connection.get_last_result
        @statements[sql_key] = nextkey
      end
      @statements[sql_key]
    end

  If error happens anywhere after "@connection.prepare nextkey, sql"
  and before "@statements[sql_key] = nextkey" then connection is
  left in the inconsistent state and every query that was not
  prepared will fail (it will be prepared in PostgreSQL but cache
  won't know that key is reserved). This fix changes next_key
  to always return different value on every call, so if error is
  raised before statement is cached then next statemnt will not fail.