Library Version 18.1.40

DB_ENV->rep_set_view()
Prev | Chapter 10. Replication Methods | Next

## DB_ENV->rep_set_view()

    #include <db.h>

    int
    DB_ENV->rep_set_view(DB_ENV *env,
        int (*partial_func)(DB_ENV *dbenv,
        const char *name, int *result, u_int32_t flags));

The `DB_ENV->rep_set_view()` method specifies that this environment is a replication view. A replication view is a special type of client that can contain a full or partial copy of the replicated data. A partial view uses a callback to determine the subset of database files to replicate. A replication view does not vote in elections, cannot become master, and cannot contribute to transactional durability.

The `DB_ENV->rep_set_view()` method configures operations performed using the specified DB_ENV handle, not all operations performed on the underlying database environment.

The `DB_ENV->rep_set_view()` method must be called prior to opening the environment. Also the method must be called every time the environment is used after that point. Once an environment is configured as a view, it stays that way for the lifetime of the environment.

The `DB_ENV->rep_set_view()` method returns a non-zero error value on failure and 0 on success.

### Note

Berkeley DB is not re-entrant. The callback function for this method should not attempt to make library calls (for example, to release locks or close open handles). Re-entering Berkeley DB is not guaranteed to work correctly, and the results are undefined.

### Parameters

#### partial_func

The partial_func callback function determines whether a particular database file should be replicated to the local site. If a NULL callback is specified, all database files will be replicated. The parameters to partial_func are as follows:

- `dbenv`

  The dbenv parameter is the enclosing database environment handle.

- `name`

  The name parameter is the physical on-disk file name of the database. In-memory databases are always replicated and do not invoke this callback.

- `result`

  The result parameter is an output parameter indicating whether the file should be replicated. Set it to 0 to reject this file or to a non-zero value to accept this file.

- `flags`

  The flags parameter is currently unused.

The partial function must return 0 on success and non-zero on failure. If the partial function fails, the environment will panic.

### Errors

The `DB_ENV->rep_set_view()` method may fail and return one of the following non-zero errors:

#### EINVAL

The method was called after the environment was opened.

### Class

DB_ENV

### See Also

Replication and Related Methods

Prev | Up | Next
DB_ENV->rep_set_transport() | Home | DB_ENV->rep_start()