50
51
has more fields than the other. */
53
/*****************************************************************
54
/*************************************************************//**
54
55
Used in debug checking of cmp_dtuple_... .
55
56
This function is used to compare a data tuple to a physical record. If
56
57
dtuple has n fields then rec must have either m >= n fields, or it must
57
differ from dtuple in some of the m fields rec has. */
58
differ from dtuple in some of the m fields rec has.
59
@return 1, 0, -1, if dtuple is greater, equal, less than rec,
60
respectively, when only the common first fields are compared */
60
63
cmp_debug_dtuple_rec_with_match(
61
64
/*============================*/
62
/* out: 1, 0, -1, if dtuple is greater, equal,
63
less than rec, respectively, when only the
64
common first fields are compared */
65
const dtuple_t* dtuple, /* in: data tuple */
66
const rec_t* rec, /* in: physical record which differs from
65
const dtuple_t* dtuple, /*!< in: data tuple */
66
const rec_t* rec, /*!< in: physical record which differs from
67
67
dtuple in some of the common fields, or which
68
68
has an equal number or more fields than
70
const ulint* offsets,/* in: array returned by rec_get_offsets() */
71
ulint* matched_fields);/* in/out: number of already
70
const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
71
ulint* matched_fields);/*!< in/out: number of already
72
72
completely matched fields; when function
73
73
returns, contains the value for current
75
75
#endif /* UNIV_DEBUG */
76
#ifndef UNIV_HOTBACKUP
77
/*****************************************************************
76
/*************************************************************//**
78
77
This function is used to compare two data fields for which the data type
79
78
is such that we must use MySQL code to compare them. The prototype here
80
must be a copy of the the one in ha_innobase.cc! */
79
must be a copy of the the one in ha_innobase.cc!
80
@return 1, 0, -1, if a is greater, equal, less than b, respectively */
83
83
innobase_mysql_cmp(
84
84
/*===============*/
85
/* out: 1, 0, -1, if a is greater,
86
equal, less than b, respectively */
87
int mysql_type, /* in: MySQL type */
88
uint charset_number, /* in: number of the charset */
89
const unsigned char* a, /* in: data field */
90
unsigned int a_length, /* in: data field length,
92
const unsigned char* b, /* in: data field */
93
unsigned int b_length); /* in: data field length,
95
#endif /* !UNIV_HOTBACKUP */
96
/*************************************************************************
85
int mysql_type, /*!< in: MySQL type */
86
uint charset_number, /*!< in: number of the charset */
87
const unsigned char* a, /*!< in: data field */
88
unsigned int a_length, /*!< in: data field length,
90
const unsigned char* b, /*!< in: data field */
91
unsigned int b_length); /*!< in: data field length,
93
/*********************************************************************//**
97
94
Transforms the character code so that it is ordered appropriately for the
98
95
language. This is only used for the latin1 char set. MySQL does the
99
comparisons for other char sets. */
96
comparisons for other char sets.
97
@return collation order position */
104
/* out: collation order position */
105
ulint code) /* in: code of a character stored in database record */
102
ulint code) /*!< in: code of a character stored in database record */
107
104
return((ulint) srv_latin1_ordering[code]);
110
/*****************************************************************
111
Returns TRUE if two columns are equal for comparison purposes. */
107
/*************************************************************//**
108
Returns TRUE if two columns are equal for comparison purposes.
109
@return TRUE if the columns are considered equal in comparisons */
114
112
cmp_cols_are_equal(
115
113
/*===============*/
116
/* out: TRUE if the columns are
117
considered equal in comparisons */
118
const dict_col_t* col1, /* in: column 1 */
119
const dict_col_t* col2, /* in: column 2 */
114
const dict_col_t* col1, /*!< in: column 1 */
115
const dict_col_t* col2, /*!< in: column 2 */
120
116
ibool check_charsets)
121
/* in: whether to check charsets */
117
/*!< in: whether to check charsets */
123
119
if (dtype_is_non_binary_string_type(col1->mtype, col1->prtype)
124
120
&& dtype_is_non_binary_string_type(col2->mtype, col2->prtype)) {
161
157
return(col1->mtype != DATA_INT || col1->len == col2->len);
164
#ifndef UNIV_HOTBACKUP
165
/*****************************************************************
160
/*************************************************************//**
166
161
Innobase uses this function to compare two data fields for which the data type
167
is such that we must compare whole fields or call MySQL to do the comparison */
162
is such that we must compare whole fields or call MySQL to do the comparison
163
@return 1, 0, -1, if a is greater, equal, less than b, respectively */
172
/* out: 1, 0, -1, if a is greater,
173
equal, less than b, respectively */
174
ulint mtype, /* in: main type */
175
ulint prtype, /* in: precise type */
176
const byte* a, /* in: data field */
177
unsigned int a_length, /* in: data field length,
168
ulint mtype, /*!< in: main type */
169
ulint prtype, /*!< in: precise type */
170
const byte* a, /*!< in: data field */
171
unsigned int a_length, /*!< in: data field length,
178
172
not UNIV_SQL_NULL */
179
const byte* b, /* in: data field */
180
unsigned int b_length) /* in: data field length,
173
const byte* b, /*!< in: data field */
174
unsigned int b_length) /*!< in: data field length,
181
175
not UNIV_SQL_NULL */
291
#endif /* !UNIV_HOTBACKUP */
293
/*****************************************************************
286
/*************************************************************//**
294
287
This function is used to compare two data fields for which we know the
289
@return 1, 0, -1, if data1 is greater, equal, less than data2, respectively */
298
292
cmp_data_data_slow(
299
293
/*===============*/
300
/* out: 1, 0, -1, if data1 is greater, equal,
301
less than data2, respectively */
302
ulint mtype, /* in: main type */
303
ulint prtype, /* in: precise type */
304
const byte* data1, /* in: data field (== a pointer to a memory
306
ulint len1, /* in: data field length or UNIV_SQL_NULL */
307
const byte* data2, /* in: data field (== a pointer to a memory
309
ulint len2) /* in: data field length or UNIV_SQL_NULL */
294
ulint mtype, /*!< in: main type */
295
ulint prtype, /*!< in: precise type */
296
const byte* data1, /*!< in: data field (== a pointer to a memory
298
ulint len1, /*!< in: data field length or UNIV_SQL_NULL */
299
const byte* data2, /*!< in: data field (== a pointer to a memory
301
ulint len2) /*!< in: data field length or UNIV_SQL_NULL */
311
#ifndef UNIV_HOTBACKUP
312
303
ulint data1_byte;
313
304
ulint data2_byte;
404
#else /* !UNIV_HOTBACKUP */
405
/* This function depends on MySQL code that is not included in
406
InnoDB Hot Backup builds. Besides, this function should never
407
be called in InnoDB Hot Backup. */
409
#endif /* !UNIV_HOTBACKUP */
413
/*****************************************************************
398
/*************************************************************//**
414
399
This function is used to compare a data tuple to a physical record.
415
400
Only dtuple->n_fields_cmp first fields are taken into account for
416
401
the the data tuple! If we denote by n = n_fields_cmp, then rec must
417
402
have either m >= n fields, or it must differ from dtuple in some of
418
403
the m fields rec has. If rec has an externally stored field we do not
419
404
compare it but return with value 0 if such a comparison should be
406
@return 1, 0, -1, if dtuple is greater, equal, less than rec,
407
respectively, when only the common first fields are compared, or until
408
the first externally stored field in rec */
423
411
cmp_dtuple_rec_with_match(
424
412
/*======================*/
425
/* out: 1, 0, -1, if dtuple is greater, equal,
426
less than rec, respectively, when only the
427
common first fields are compared, or
428
until the first externally stored field in
430
const dtuple_t* dtuple, /* in: data tuple */
431
const rec_t* rec, /* in: physical record which differs from
413
const dtuple_t* dtuple, /*!< in: data tuple */
414
const rec_t* rec, /*!< in: physical record which differs from
432
415
dtuple in some of the common fields, or which
433
416
has an equal number or more fields than
435
const ulint* offsets,/* in: array returned by rec_get_offsets() */
436
ulint* matched_fields, /* in/out: number of already completely
418
const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
419
ulint* matched_fields, /*!< in/out: number of already completely
437
420
matched fields; when function returns,
438
421
contains the value for current comparison */
439
ulint* matched_bytes) /* in/out: number of already matched
422
ulint* matched_bytes) /*!< in/out: number of already matched
440
423
bytes within the first field not completely
441
424
matched; when function returns, contains the
442
425
value for current comparison */
444
#ifndef UNIV_HOTBACKUP
445
427
const dfield_t* dtuple_field; /* current field in logical record */
446
428
ulint dtuple_f_len; /* the length of the current field
447
429
in the logical record */
649
631
*matched_bytes = cur_bytes;
652
#else /* !UNIV_HOTBACKUP */
653
/* This function depends on MySQL code that is not included in
654
InnoDB Hot Backup builds. Besides, this function should never
655
be called in InnoDB Hot Backup. */
658
#endif /* !UNIV_HOTBACKUP */
661
/******************************************************************
662
Compares a data tuple to a physical record. */
636
/**************************************************************//**
637
Compares a data tuple to a physical record.
638
@see cmp_dtuple_rec_with_match
639
@return 1, 0, -1, if dtuple is greater, equal, less than rec, respectively */
667
/* out: 1, 0, -1, if dtuple is greater, equal,
668
less than rec, respectively; see the comments
669
for cmp_dtuple_rec_with_match */
670
const dtuple_t* dtuple, /* in: data tuple */
671
const rec_t* rec, /* in: physical record */
672
const ulint* offsets)/* in: array returned by rec_get_offsets() */
644
const dtuple_t* dtuple, /*!< in: data tuple */
645
const rec_t* rec, /*!< in: physical record */
646
const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
674
648
ulint matched_fields = 0;
675
649
ulint matched_bytes = 0;
679
653
&matched_fields, &matched_bytes));
682
/******************************************************************
656
/**************************************************************//**
683
657
Checks if a dtuple is a prefix of a record. The last field in dtuple
684
is allowed to be a prefix of the corresponding field in the record. */
658
is allowed to be a prefix of the corresponding field in the record.
659
@return TRUE if prefix */
687
662
cmp_dtuple_is_prefix_of_rec(
688
663
/*========================*/
689
/* out: TRUE if prefix */
690
const dtuple_t* dtuple, /* in: data tuple */
691
const rec_t* rec, /* in: physical record */
692
const ulint* offsets)/* in: array returned by rec_get_offsets() */
664
const dtuple_t* dtuple, /*!< in: data tuple */
665
const rec_t* rec, /*!< in: physical record */
666
const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
695
669
ulint matched_fields = 0;
722
#ifndef UNIV_HOTBACKUP
723
/*****************************************************************
696
/*************************************************************//**
724
697
Compare two physical records that contain the same number of columns,
725
none of which are stored externally. */
698
none of which are stored externally.
699
@return 1, 0, -1 if rec1 is greater, equal, less, respectively, than rec2 */
728
702
cmp_rec_rec_simple(
729
703
/*===============*/
730
/* out: 1, 0 , -1 if rec1 is greater,
731
equal, less, respectively, than rec2 */
732
const rec_t* rec1, /* in: physical record */
733
const rec_t* rec2, /* in: physical record */
734
const ulint* offsets1,/* in: rec_get_offsets(rec1, index) */
735
const ulint* offsets2,/* in: rec_get_offsets(rec2, index) */
736
const dict_index_t* index) /* in: data dictionary index */
704
const rec_t* rec1, /*!< in: physical record */
705
const rec_t* rec2, /*!< in: physical record */
706
const ulint* offsets1,/*!< in: rec_get_offsets(rec1, ...) */
707
const ulint* offsets2,/*!< in: rec_get_offsets(rec2, ...) */
708
const dict_index_t* index) /*!< in: data dictionary index */
738
ulint rec1_f_len; /* length of current field in rec1 */
739
const byte* rec1_b_ptr; /* pointer to the current byte
710
ulint rec1_f_len; /*!< length of current field in rec1 */
711
const byte* rec1_b_ptr; /*!< pointer to the current byte
741
ulint rec1_byte; /* value of current byte to be
713
ulint rec1_byte; /*!< value of current byte to be
742
714
compared in rec1 */
743
ulint rec2_f_len; /* length of current field in rec2 */
744
const byte* rec2_b_ptr; /* pointer to the current byte
715
ulint rec2_f_len; /*!< length of current field in rec2 */
716
const byte* rec2_b_ptr; /*!< pointer to the current byte
746
ulint rec2_byte; /* value of current byte to be
718
ulint rec2_byte; /*!< value of current byte to be
747
719
compared in rec2 */
748
ulint cur_field; /* current field number */
720
ulint cur_field; /*!< current field number */
751
723
n_uniq = dict_index_get_n_unique(index);
869
841
/* If we ran out of fields, rec1 was equal to rec2. */
872
#endif /* !UNIV_HOTBACKUP */
874
/*****************************************************************
845
/*************************************************************//**
875
846
This function is used to compare two physical records. Only the common
876
847
first fields are compared, and if an externally stored field is
877
encountered, then 0 is returned. */
848
encountered, then 0 is returned.
849
@return 1, 0, -1 if rec1 is greater, equal, less, respectively */
880
852
cmp_rec_rec_with_match(
881
853
/*===================*/
882
/* out: 1, 0 , -1 if rec1 is greater, equal,
883
less, respectively, than rec2; only the common
884
first fields are compared */
885
const rec_t* rec1, /* in: physical record */
886
const rec_t* rec2, /* in: physical record */
887
const ulint* offsets1,/* in: rec_get_offsets(rec1, index) */
888
const ulint* offsets2,/* in: rec_get_offsets(rec2, index) */
889
dict_index_t* index, /* in: data dictionary index */
890
ulint* matched_fields, /* in/out: number of already completely
854
const rec_t* rec1, /*!< in: physical record */
855
const rec_t* rec2, /*!< in: physical record */
856
const ulint* offsets1,/*!< in: rec_get_offsets(rec1, index) */
857
const ulint* offsets2,/*!< in: rec_get_offsets(rec2, index) */
858
dict_index_t* index, /*!< in: data dictionary index */
859
ulint* matched_fields, /*!< in/out: number of already completely
891
860
matched fields; when the function returns,
892
861
contains the value the for current
894
ulint* matched_bytes) /* in/out: number of already matched
863
ulint* matched_bytes) /*!< in/out: number of already matched
895
864
bytes within the first field not completely
896
865
matched; when the function returns, contains
897
866
the value for the current comparison */
899
#ifndef UNIV_HOTBACKUP
900
868
ulint rec1_n_fields; /* the number of fields in rec */
901
869
ulint rec1_f_len; /* length of current field in rec */
902
870
const byte* rec1_b_ptr; /* pointer to the current byte
1110
1078
*matched_bytes = cur_bytes;
1113
#else /* !UNIV_HOTBACKUP */
1114
/* This function depends on MySQL code that is not included in
1115
InnoDB Hot Backup builds. Besides, this function should never
1116
be called in InnoDB Hot Backup. */
1119
#endif /* !UNIV_HOTBACKUP */
1122
1083
#ifdef UNIV_DEBUG
1123
/*****************************************************************
1084
/*************************************************************//**
1124
1085
Used in debug checking of cmp_dtuple_... .
1125
1086
This function is used to compare a data tuple to a physical record. If
1126
1087
dtuple has n fields then rec must have either m >= n fields, or it must
1127
1088
differ from dtuple in some of the m fields rec has. If encounters an
1128
externally stored field, returns 0. */
1089
externally stored field, returns 0.
1090
@return 1, 0, -1, if dtuple is greater, equal, less than rec,
1091
respectively, when only the common first fields are compared */
1131
1094
cmp_debug_dtuple_rec_with_match(
1132
1095
/*============================*/
1133
/* out: 1, 0, -1, if dtuple is greater, equal,
1134
less than rec, respectively, when only the
1135
common first fields are compared */
1136
const dtuple_t* dtuple, /* in: data tuple */
1137
const rec_t* rec, /* in: physical record which differs from
1096
const dtuple_t* dtuple, /*!< in: data tuple */
1097
const rec_t* rec, /*!< in: physical record which differs from
1138
1098
dtuple in some of the common fields, or which
1139
1099
has an equal number or more fields than
1141
const ulint* offsets,/* in: array returned by rec_get_offsets() */
1142
ulint* matched_fields) /* in/out: number of already
1101
const ulint* offsets,/*!< in: array returned by rec_get_offsets() */
1102
ulint* matched_fields) /*!< in/out: number of already
1143
1103
completely matched fields; when function
1144
1104
returns, contains the value for current