MCPcopy Create free account
hub / github.com/MariaDB/server / compare_record

Function compare_record

sql/sql_update.cc:76–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74*/
75
76bool compare_record(const TABLE *table)
77{
78 DBUG_ASSERT(records_are_comparable(table));
79
80 if (table->file->ha_table_flags() & HA_PARTIAL_COLUMN_READ ||
81 table->s->has_update_default_function)
82 {
83 /*
84 Storage engine may not have read all columns of the record. Fields
85 (including NULL bits) not in the write_set may not have been read and
86 can therefore not be compared.
87 Or ON UPDATE DEFAULT NOW() could've changed field values, including
88 NULL bits.
89 */
90 for (Field **ptr= table->field ; *ptr != NULL; ptr++)
91 {
92 Field *field= *ptr;
93 if (field->has_explicit_value() && !field->vcol_info)
94 {
95 if (field->real_maybe_null())
96 {
97 uchar null_byte_index= (uchar)(field->null_ptr - table->record[0]);
98
99 if (((table->record[0][null_byte_index]) & field->null_bit) !=
100 ((table->record[1][null_byte_index]) & field->null_bit))
101 return TRUE;
102 }
103 if (field->cmp_binary_offset(table->s->rec_buff_length))
104 return TRUE;
105 }
106 }
107 return FALSE;
108 }
109
110 /*
111 The storage engine has read all columns, so it's safe to compare all bits
112 including those not in the write_set. This is cheaper than the
113 field-by-field comparison done above.
114 */
115 if (table->s->can_cmp_whole_record)
116 return cmp_record(table,record[1]);
117 /* Compare null bits */
118 if (memcmp(table->null_flags,
119 table->null_flags+table->s->rec_buff_length,
120 table->s->null_bytes_for_compare))
121 return TRUE; // Diff in NULL value
122 /* Compare updated fields */
123 for (Field **ptr= table->field ; *ptr ; ptr++)
124 {
125 Field *field= *ptr;
126 if (field->has_explicit_value() && !field->vcol_info &&
127 field->cmp_binary_offset(table->s->rec_buff_length))
128 return TRUE;
129 }
130 return FALSE;
131}
132
133

Callers 5

update_or_insertFunction · 0.70
update_single_tableMethod · 0.70
send_dataMethod · 0.70
do_updatesMethod · 0.70

Calls 5

records_are_comparableFunction · 0.85
ha_table_flagsMethod · 0.80
has_explicit_valueMethod · 0.80
real_maybe_nullMethod · 0.80
cmp_binary_offsetMethod · 0.45

Tested by

no test coverage detected