def get_export_filename(region, subregion, layerset, pgosm_date, input_file):
    """Returns the .sql filename to use for pg_dump.

    Parameters
    ----------------------
    region : str
    subregion : str
    layerset : str
    pgosm_date : str
    input_file : str

    Returns
    ----------------------
    filename : str
    """
    # region is always set internally, even with --input-file and no --region
    region = region.replace('/', '-')
    if subregion:
        subregion = subregion.replace('/', '-')

    if input_file:
        # Assumes .osm.pbf
        base_name = input_file[:-8]
        filename = f'{base_name}-{layerset}-{pgosm_date}.sql'
    elif subregion is None:
        filename = f'{region}-{layerset}-{pgosm_date}.sql'
    else:
        filename = f'{region}-{subregion}-{layerset}-{pgosm_date}.sql'

    return filename