def check_string(sql_string, add_semicolon=False):
    """
    Check whether a string is valid PostgreSQL. Returns a boolean
    indicating validity and a message from ecpg, which will be an
    empty string if the input was valid, or a description of the
    problem otherwise.
    """
    prepped_sql = sqlprep.prepare_sql(sql_string, add_semicolon=add_semicolon)
    success, msg = ecpg.check_syntax(prepped_sql)
    return success, msg