COM Conflict Resolver Header File

Replication Programming

Replication Programming

COM Conflict Resolver Header File

A file named sqlres.h is located in C:\Program Files\Microsoft SQL Server\80\ Dev Tools\include, if the replication sample programs were installed to the default folder. The file, sqlres.h, contains several important definitions with which you should be familiar. Do no modify this file.

The custom resolver must implement the interface ICustomResolver, which is defined in this file.

#undef  INTERFACE
#define  INTERFACE ICustomResolver
DECLARE_INTERFACE_(ICustomResolver, Iunknown)
{
  //**   IUnknown methods
   STDMETHOD(QueryInterface)  (THIS_ REFIID riid, LPVOID *ppvObj)  PURE;
   STDMETHOD_(ULONG,AddRef)  (THIS)     PURE;
   STDMETHOD_(ULONG,Release)  (THIS)    PURE;

  //**   ICustomResolver methods
   STDMETHOD(Reconcile) (THIS_
                        IReplRowChange *pRowChange,
                        DWORD dwFlags,
                        PVOID pvReserved)  PURE;
   STDMETHOD(GetHandledStates) (THIS_
                        DWORD *pResolverBm)  PURE;
};

ICustomResolver inherits from IUnknown, similar to all COM classes. The IUnknown methods usually do not need to be modified from the supplied resolver, but the ICustomResolver methods Reconcile and GetHandledStates must be implemented. Reconcile is the method called for each table row that contains a conflict. GetHandledStates defines the conflict conditions that the resolver will handle.

The important parameter for Reconcile is a reference to an IReplRowChange object; IReplRowChange is defined in this include file. Through the method of IReplRowChange, the resolver determines the columns in conflict, examines the conflicting data, and then copies the appropriate data to the result row.

Other definitions in the file include IConnectionInfo, which is used when a resolver needs to access a stored procedure, and ITranDataChange, which is used in a transactional resolver. Only the Get<xxx> methods in IConnectionInfo are accessible to user-implemented resolvers.

Several enumerations are defined in sqlres.h. Symbols from these enumerations should be used wherever possible instead of using hard-coded constants.

Enumeration Name Description
REPOLE_CHANGE_TYPE Codes for the database operation (insert, update, delete), whether there is a conflict, and whether column tracking is active. Many symbolic definitions of aggregates of these change types are also available.
REPOLE_CONFLICT_TYPE Codes for the database operation and whether the failure occurred at upload or download.
REPOLE_COLSTATUS_TYPE Codes for the conflict status of an individual column.
REPOLE_PRIORITY_TYPE Codes for what have higher priority (source, destination, neither source nor destination).