5656#include "spock_worker.h"
5757
5858
59- /* From src/backend/replication/logical/conflict.c */
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"
68- };
59+ const char *
60+ SpockConflictTypeName (SpockConflictType t )
61+ {
62+ switch (t )
63+ {
64+ case SPOCK_CT_INSERT_EXISTS :
65+ return "insert_exists" ;
66+ case SPOCK_CT_UPDATE_ORIGIN_DIFFERS :
67+ return "update_origin_differs" ;
68+ case SPOCK_CT_UPDATE_EXISTS :
69+ return "update_exists" ;
70+ case SPOCK_CT_UPDATE_MISSING :
71+ return "update_missing" ;
72+ case SPOCK_CT_DELETE_ORIGIN_DIFFERS :
73+ return "delete_origin_differs" ;
74+ case SPOCK_CT_DELETE_MISSING :
75+ return "delete_missing" ;
76+ case SPOCK_CT_DELETE_EXISTS :
77+ return "delete_exists" ;
78+ default :
79+ return "unknown" ;
80+ }
81+ }
6982
7083
7184int spock_conflict_resolver = SPOCK_RESOLVE_LAST_UPDATE_WINS ;
@@ -478,7 +491,7 @@ spock_report_conflict(SpockConflictType conflict_type,
478491 ereport (spock_conflict_log_level ,
479492 (errcode (ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION ),
480493 errmsg ("CONFLICT: remote %s on relation %s (local index %s). Resolution: %s." ,
481- SpockConflictTypeNames [ conflict_type ] ,
494+ SpockConflictTypeName ( conflict_type ) ,
482495 qualrelname , idxname ,
483496 conflict_resolution_to_string (resolution )),
484497 errdetail ("existing local tuple {%s} xid=%u,origin=%s,timestamp=%s; remote tuple {%s} in xact origin=%u,timestamp=%s,commit_lsn=%X/%X" ,
@@ -495,7 +508,7 @@ spock_report_conflict(SpockConflictType conflict_type,
495508 ereport (spock_conflict_log_level ,
496509 (errcode (ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION ),
497510 errmsg ("CONFLICT: remote %s on relation %s replica identity index %s (tuple not found). Resolution: %s." ,
498- SpockConflictTypeNames [ conflict_type ] ,
511+ SpockConflictTypeName ( conflict_type ) ,
499512 qualrelname , idxname ,
500513 conflict_resolution_to_string (resolution )),
501514 errdetail ("remote tuple {%s} in xact origin=%u,timestamp=%s,commit_lsn=%X/%X" ,
@@ -509,7 +522,7 @@ spock_report_conflict(SpockConflictType conflict_type,
509522 ereport (spock_conflict_log_level ,
510523 (errcode (ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION ),
511524 errmsg ("CONFLICT: remote %s on relation %s replica identity index %s (tuple not found). Resolution: %s." ,
512- SpockConflictTypeNames [ conflict_type ] ,
525+ SpockConflictTypeName ( conflict_type ) ,
513526 qualrelname , idxname ,
514527 conflict_resolution_to_string (resolution )),
515528 errdetail ("tuple for remote delete in xact origin=%u,timestamp=%s,commit_lsn=%X/%X" ,
@@ -518,11 +531,11 @@ spock_report_conflict(SpockConflictType conflict_type,
518531 (uint32 ) (replorigin_session_origin_lsn << 32 ),
519532 (uint32 ) replorigin_session_origin_lsn )));
520533 break ;
521- case SPOCK_CT_DELETE_LATE :
534+ case SPOCK_CT_DELETE_EXISTS :
522535 ereport (spock_conflict_log_level ,
523536 (errcode (ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION ),
524537 errmsg ("CONFLICT: remote %s on relation %s replica identity index %s (newer tuple found). Resolution: %s." ,
525- SpockConflictTypeNames [ conflict_type ] ,
538+ SpockConflictTypeName ( conflict_type ) ,
526539 qualrelname , idxname ,
527540 conflict_resolution_to_string (resolution )),
528541 errdetail ("remote delete in xact origin=%u,timestamp=%s,commit_lsn=%X/%X" ,
@@ -621,7 +634,7 @@ spock_conflict_log_table(SpockConflictType conflict_type,
621634 nulls [4 ] = true;
622635
623636 /* conflict type */
624- values [5 ] = CStringGetTextDatum (SpockConflictTypeNames [ conflict_type ] );
637+ values [5 ] = CStringGetTextDatum (SpockConflictTypeName ( conflict_type ) );
625638 /* conflict_resolution */
626639 values [6 ] = CStringGetTextDatum (conflict_resolution_to_string (resolution ));
627640 /* local_origin */
0 commit comments