'bdr_sequence_options'
);
-CREATE TYPE bdr.bdr_handler_types AS ENUM(
- 'UPDATE_VS_UPDATE', 'UPDATE_VS_DELETE',
- 'INSERT_VS_INSERT', 'INSERT_VS_UPDATE'
+CREATE TYPE bdr_conflict_type AS ENUM
+(
+ 'insert_insert',
+ 'insert_update',
+ 'update_update',
+ 'update_delete',
+ 'unhandled_tx_abort'
);
+COMMENT ON TYPE bdr_conflict_type IS 'The nature of a BDR apply conflict - concurrent updates (update_update), conflicting inserts, etc.';
+
CREATE TYPE bdr.bdr_conflict_handler_action
AS ENUM('IGNORE', 'ROW', 'SKIP');
CREATE TABLE bdr.bdr_conflict_handlers (
ch_name NAME NOT NULL,
- ch_type bdr.bdr_handler_types NOT NULL,
+ ch_type bdr.bdr_conflict_type NOT NULL,
ch_reloid Oid NOT NULL,
ch_fun regprocedure NOT NULL,
ch_timeframe INTERVAL,
ch_rel REGCLASS,
ch_name NAME,
ch_proc REGPROCEDURE,
- ch_type bdr.bdr_handler_types,
+ ch_type bdr.bdr_conflict_type,
ch_timeframe INTERVAL
)
RETURNS VOID
ch_rel REGCLASS,
ch_name NAME,
ch_proc REGPROCEDURE,
- ch_type bdr.bdr_handler_types
+ ch_type bdr.bdr_conflict_type
)
RETURNS VOID
LANGUAGE C
;
-CREATE TYPE bdr_conflict_type AS ENUM
-(
- 'insert_insert',
- 'update_update',
- 'update_delete',
- 'unhandled_tx_abort'
-);
-
-COMMENT ON TYPE bdr_conflict_type IS 'The nature of a BDR apply conflict - concurrent updates (update_update), conflicting inserts, etc.';
-
CREATE TYPE bdr_conflict_resolution AS ENUM
(
'conflict_trigger_skip_change',
BDR_OUTPUT_COMMIT_HAS_ORIGIN = 1
} BdrOutputCommitFlags;
-typedef enum BDRConflictHandlerType
-{
- BDRUpdateUpdateConflictHandler,
- BDRUpdateDeleteConflictHandler,
- BDRInsertInsertConflictHandler,
- BDRInsertUpdateConflictHandler
-} BDRConflictHandlerType;
-
/*
* BDR conflict detection: type of conflict that was identified.
*
typedef enum BdrConflictType
{
BdrConflictType_InsertInsert,
+ BdrConflictType_InsertUpdate,
BdrConflictType_UpdateUpdate,
BdrConflictType_UpdateDelete,
BdrConflictType_UnhandledTxAbort
typedef struct BDRConflictHandler
{
Oid handler_oid;
- BDRConflictHandlerType handler_type;
+ BdrConflictType handler_type;
uint64 timeframe;
} BDRConflictHandler;
extern HeapTuple bdr_conflict_handlers_resolve(BDRRelation * rel, const HeapTuple local,
const HeapTuple remote, const char *command_tag,
- BDRConflictHandlerType event_type,
+ BdrConflictType event_type,
uint64 timeframe, bool *skip);
#endif /* BDR_H */
static void bdr_conflict_handlers_check_handler_fun(Relation rel, Oid proc_oid);
static void bdr_conflict_handlers_check_access(Oid reloid);
-static const char *bdr_conflict_handlers_event_type_name(BDRConflictHandlerType event_type);
+static const char *bdr_conflict_handlers_event_type_name(BdrConflictType event_type);
static Oid bdr_conflict_handler_table_oid = InvalidOid;
static Oid bdr_conflict_handler_type_oid = InvalidOid;
elog(ERROR, "cache lookup failed for relation bdr.bdr_conflict_handlers");
bdr_conflict_handler_type_oid =
- GetSysCacheOidError2(TYPENAMENSP, PointerGetDatum("bdr_handler_types"),
+ GetSysCacheOidError2(TYPENAMENSP, PointerGetDatum("bdr_conflict_type"),
ObjectIdGetDatum(schema_oid));
bdr_conflict_handler_action_oid =
if (failed)
ereport(ERROR,
(errmsg("handler function is expected to accept " \
- "tablerow IN, tablerow IN, text IN, text IN, bdr_handler_types IN," \
+ "tablerow IN, tablerow IN, text IN, text IN, bdr_conflict_type IN," \
"tablerow OUT, bdr_conflict_handler_action OUT")));
}
htype = TextDatumGetCString(dat);
- if (strcmp(htype, "UPDATE_VS_UPDATE") == 0)
- rel->conflict_handlers[i].handler_type = BDRUpdateUpdateConflictHandler;
- else if (strcmp(htype, "UPDATE_VS_DELETE") == 0)
- rel->conflict_handlers[i].handler_type = BDRUpdateDeleteConflictHandler;
- else if (strcmp(htype, "INSERT_VS_INSERT") == 0)
- rel->conflict_handlers[i].handler_type = BDRInsertInsertConflictHandler;
- else if (strcmp(htype, "INSERT_VS_UPDATE") == 0)
- rel->conflict_handlers[i].handler_type = BDRInsertUpdateConflictHandler;
+ if (strcmp(htype, "update_update") == 0)
+ rel->conflict_handlers[i].handler_type = BdrConflictType_UpdateUpdate;
+ else if (strcmp(htype, "update_delete") == 0)
+ rel->conflict_handlers[i].handler_type = BdrConflictType_UpdateDelete;
+ else if (strcmp(htype, "insert_insert") == 0)
+ rel->conflict_handlers[i].handler_type = BdrConflictType_InsertInsert;
+ else if (strcmp(htype, "insert_update") == 0)
+ rel->conflict_handlers[i].handler_type = BdrConflictType_InsertUpdate;
else
elog(ERROR, "unknown handler type: %s", htype);
}
static const char *
-bdr_conflict_handlers_event_type_name(BDRConflictHandlerType event_type)
+bdr_conflict_handlers_event_type_name(BdrConflictType event_type)
{
switch (event_type)
{
- case BDRUpdateUpdateConflictHandler:
- return "UPDATE_VS_UPDATE";
- case BDRUpdateDeleteConflictHandler:
- return "UPDATE_VS_DELETE";
- case BDRInsertInsertConflictHandler:
- return "INSERT_VS_INSERT";
- case BDRInsertUpdateConflictHandler:
- return "INSERT_VS_UPDATE";
+ case BdrConflictType_InsertInsert:
+ return "insert_insert";
+ case BdrConflictType_InsertUpdate:
+ return "insert_update";
+ case BdrConflictType_UpdateUpdate:
+ return "update_update";
+ case BdrConflictType_UpdateDelete:
+ return "update_delete";
+ case BdrConflictType_UnhandledTxAbort:
+ return "unhandled_tx_abort";
+
+ default:
+ elog(ERROR,
+ "wrong value for event type, possibly corrupted memory: %d",
+ event_type);
}
return "(unknown)";
HeapTuple
bdr_conflict_handlers_resolve(BDRRelation * rel, const HeapTuple local,
const HeapTuple remote, const char *command_tag,
- BDRConflictHandlerType event_type,
+ BdrConflictType event_type,
uint64 timeframe, bool *skip)
{
size_t i;