Skip to main content
Common Reference

nocreatedbifnotexists.js Filter

The nocreatedbifnotexists filter removes statements that start with:

CREATE DATABASE IF NOT EXISTS
Pre-configured filter namenocreatedbifnotexists
JavaScript Filter Filetungsten-replicator/support/filters-javascript/nocreatedbifnotexists.js
Property prefixreplicator.filter.nocreatedbifnotexists
Stage compatibilityq-to-dbms
tpm Option compatibilitysvc-applier-filters
Data compatibilityAny event

This can be useful in heterogeneous replication where Tungsten Replicator specific databases need to be removed from the replication stream.

The filter works in two phases. The first phase creates a global variable within the prepare() function that defines the string to be examined:

function prepare()
{
beginning = "CREATE DATABASE IF NOT EXISTS";
}

Row based changes can be ignored, but for statement based events, the SQL is examined and the statement removed if the SQL starts with the text in the beginning variable:

sql = d.getQuery();
if(sql.startsWith(beginning))
{
data.remove(i);
i--;
}