5757
5858
5959/* From src/backend/replication/logical/conflict.c */
60- static const char * const ConflictTypeNames [] = {
61- [CT_INSERT_EXISTS ] = "insert_exists" ,
62- [CT_UPDATE_ORIGIN_DIFFERS ] = "update_origin_differs" ,
63- [CT_UPDATE_EXISTS ] = "update_exists" ,
64- [CT_UPDATE_MISSING ] = "update_missing" ,
65- [CT_DELETE_ORIGIN_DIFFERS ] = "delete_origin_differs" ,
66- [CT_DELETE_MISSING ] = "delete_missing"
60+ static const char * const SpockConflictTypeNames [] = {
61+ [SPOCK_CT_INSERT_EXISTS ] = "insert_exists" ,
62+ [SPOCK_CT_UPDATE_ORIGIN_DIFFERS ] = "update_origin_differs" ,
63+ [SPOCK_CT_UPDATE_EXISTS ] = "update_exists" ,
64+ [SPOCK_CT_UPDATE_MISSING ] = "update_missing" ,
65+ [SPOCK_CT_DELETE_ORIGIN_DIFFERS ] = "delete_origin_differs" ,
66+ [SPOCK_CT_DELETE_MISSING ] = "delete_missing" ,
67+ [SPOCK_CT_DELETE_LATE ] = "delete_late"
6768};
6869
6970
@@ -328,7 +329,7 @@ conflict_resolution_to_string(SpockConflictResolution resolution)
328329 * we still try to free the big chunks as we go.
329330 */
330331void
331- spock_report_conflict (ConflictType conflict_type ,
332+ spock_report_conflict (SpockConflictType conflict_type ,
332333 SpockRelation * rel ,
333334 HeapTuple localtuple ,
334335 SpockTupleData * oldkey ,
@@ -350,7 +351,7 @@ spock_report_conflict(ConflictType conflict_type,
350351
351352
352353 /* Ignore update-update conflict for same origin */
353- if (conflict_type == CT_UPDATE_EXISTS )
354+ if (conflict_type == SPOCK_CT_UPDATE_EXISTS )
354355 {
355356 /*
356357 * If updating a row that came from the same origin, do not report it
@@ -365,7 +366,7 @@ spock_report_conflict(ConflictType conflict_type,
365366 return ;
366367
367368 /* Differing origin */
368- conflict_type = CT_UPDATE_ORIGIN_DIFFERS ;
369+ conflict_type = SPOCK_CT_UPDATE_ORIGIN_DIFFERS ;
369370 }
370371
371372 /* Count statistics */
@@ -415,17 +416,17 @@ spock_report_conflict(ConflictType conflict_type,
415416 * log_error_verbosity=verbose because we don't necessarily have all that
416417 * info enabled.
417418 *
418- * Handling for CT_DELETE_ORIGIN_DIFFERS will be added separately.
419+ * Handling for SPOCK_CT_DELETE_ORIGIN_DIFFERS will be added separately.
419420 */
420421 switch (conflict_type )
421422 {
422- case CT_INSERT_EXISTS :
423- case CT_UPDATE_EXISTS :
424- case CT_UPDATE_ORIGIN_DIFFERS :
423+ case SPOCK_CT_INSERT_EXISTS :
424+ case SPOCK_CT_UPDATE_EXISTS :
425+ case SPOCK_CT_UPDATE_ORIGIN_DIFFERS :
425426 ereport (spock_conflict_log_level ,
426427 (errcode (ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION ),
427428 errmsg ("CONFLICT: remote %s on relation %s (local index %s). Resolution: %s." ,
428- ConflictTypeNames [conflict_type ],
429+ SpockConflictTypeNames [conflict_type ],
429430 qualrelname , idxname ,
430431 conflict_resolution_to_string (resolution )),
431432 errdetail ("existing local tuple {%s} xid=%u,origin=%d,timestamp=%s; remote tuple {%s} in xact origin=%u,timestamp=%s,commit_lsn=%X/%X" ,
@@ -438,12 +439,11 @@ spock_report_conflict(ConflictType conflict_type,
438439 (uint32 ) (replorigin_session_origin_lsn << 32 ),
439440 (uint32 ) replorigin_session_origin_lsn )));
440441 break ;
441- case CT_UPDATE_MISSING :
442- case CT_DELETE_MISSING :
442+ case SPOCK_CT_UPDATE_MISSING :
443443 ereport (spock_conflict_log_level ,
444444 (errcode (ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION ),
445445 errmsg ("CONFLICT: remote %s on relation %s replica identity index %s (tuple not found). Resolution: %s." ,
446- ConflictTypeNames [conflict_type ],
446+ SpockConflictTypeNames [conflict_type ],
447447 qualrelname , idxname ,
448448 conflict_resolution_to_string (resolution )),
449449 errdetail ("remote tuple {%s} in xact origin=%u,timestamp=%s,commit_lsn=%X/%X" ,
@@ -453,7 +453,33 @@ spock_report_conflict(ConflictType conflict_type,
453453 (uint32 ) (replorigin_session_origin_lsn << 32 ),
454454 (uint32 ) replorigin_session_origin_lsn )));
455455 break ;
456- case CT_DELETE_ORIGIN_DIFFERS :
456+ case SPOCK_CT_DELETE_MISSING :
457+ ereport (spock_conflict_log_level ,
458+ (errcode (ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION ),
459+ errmsg ("CONFLICT: remote %s on relation %s replica identity index %s (tuple not found). Resolution: %s." ,
460+ SpockConflictTypeNames [conflict_type ],
461+ qualrelname , idxname ,
462+ conflict_resolution_to_string (resolution )),
463+ errdetail ("tuple for remote delete in xact origin=%u,timestamp=%s,commit_lsn=%X/%X" ,
464+ replorigin_session_origin ,
465+ timestamptz_to_str (replorigin_session_origin_timestamp ),
466+ (uint32 ) (replorigin_session_origin_lsn << 32 ),
467+ (uint32 ) replorigin_session_origin_lsn )));
468+ break ;
469+ case SPOCK_CT_DELETE_LATE :
470+ ereport (spock_conflict_log_level ,
471+ (errcode (ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION ),
472+ errmsg ("CONFLICT: remote %s on relation %s replica identity index %s (newer tuple found). Resolution: %s." ,
473+ SpockConflictTypeNames [conflict_type ],
474+ qualrelname , idxname ,
475+ conflict_resolution_to_string (resolution )),
476+ errdetail ("remote delete in xact origin=%u,timestamp=%s,commit_lsn=%X/%X" ,
477+ replorigin_session_origin ,
478+ timestamptz_to_str (replorigin_session_origin_timestamp ),
479+ (uint32 ) (replorigin_session_origin_lsn << 32 ),
480+ (uint32 ) replorigin_session_origin_lsn )));
481+ break ;
482+ case SPOCK_CT_DELETE_ORIGIN_DIFFERS :
457483 /* keep compiler happy; handling will be added separately */
458484 break ;
459485 }
@@ -482,7 +508,7 @@ spock_report_conflict(ConflictType conflict_type,
482508 * we still try to free the big chunks as we go.
483509 */
484510void
485- spock_conflict_log_table (ConflictType conflict_type ,
511+ spock_conflict_log_table (SpockConflictType conflict_type ,
486512 SpockRelation * rel ,
487513 HeapTuple localtuple ,
488514 SpockTupleData * oldkey ,
@@ -543,7 +569,7 @@ spock_conflict_log_table(ConflictType conflict_type,
543569 nulls [4 ] = true;
544570
545571 /* conflict type */
546- values [5 ] = CStringGetTextDatum (ConflictTypeNames [conflict_type ]);
572+ values [5 ] = CStringGetTextDatum (SpockConflictTypeNames [conflict_type ]);
547573 /* conflict_resolution */
548574 values [6 ] = CStringGetTextDatum (conflict_resolution_to_string (resolution ));
549575 /* local_origin */
0 commit comments