private int compareRowForInsertOrDelete ( Session session , Row newRow , Row existingRow ) { Object [ ] a = newRow . getData ( ) ; Object [ ] b = existingRow . getData ( ) ; int j = 0 ; boolean hasNull = false ; for ( ; j < colIndex . length ; j ++ ) { Object currentvalue = a [ colIndex [ j ] ] ; Object othervalue = b [ colIndex [ j ] ] ; int i = colTypes [ j ] . compare ( currentvalue , othervalue ) ; boolean nulls = currentvalue == null || othervalue == null ; if ( i != 0 ) { if ( colDesc [ j ] && ! nulls ) { i = - i ; } if ( nullsLast [ j ] && nulls ) { i = - i ; } return i ; } if ( currentvalue == null ) { hasNull = true ; } } if ( isUnique && ! useRowId && ! hasNull ) { if ( session == null || session . database . txManager . canRead ( session , existingRow ) ) { //* debug 190 // session.database.txManager.canRead(session, existingRow); return 0 ; } else { int difference = newRow . getPos ( ) - existingRow . getPos ( ) ; return difference ; } } for ( j = 0 ; j < pkCols . length ; j ++ ) { Object currentvalue = a [ pkCols [ j ] ] ; int i = pkTypes [ j ] . compare ( currentvalue , b [ pkCols [ j ] ] ) ; if ( i != 0 ) { return i ; } } if ( useRowId ) { int difference = newRow . getPos ( ) - existingRow . getPos ( ) ; if ( difference < 0 ) { difference = - 1 ; } else if ( difference > 0 ) { difference = 1 ; } return difference ; } if ( session == null || session . database . txManager . canRead ( session , existingRow ) ) { return 0 ; } else { int difference = newRow . getPos ( ) - existingRow . getPos ( ) ; if ( difference < 0 ) { difference = - 1 ; } else if ( difference > 0 ) { difference = 1 ; } return difference ; } }
Compare two rows of the table for inserting rows into unique indexes Supports descending columns .