@@ -301,7 +301,7 @@ indexed_keydesc (cob_file *f, struct keydesc *kd, cob_file_key *key)
301
301
}
302
302
/* LCOV_EXCL_STOP */
303
303
keylen = 0 ;
304
- for (part = 0 ; part < key -> count_components ; part ++ ) {
304
+ for (part = 0 ; part < key -> count_components ; part ++ ) {
305
305
struct keypart * k_part = & kd -> k_part [part ];
306
306
k_part -> kp_start = key -> component [part ]-> data - f -> record -> data ;
307
307
k_part -> kp_leng = key -> component [part ]-> size ;
@@ -725,6 +725,18 @@ struct indexed_file {
725
725
DB_LOCK bdb_record_lock ;
726
726
};
727
727
728
+ /* collation aware key comparision,
729
+ currently only used for BDB, likely used in general later */
730
+ static int
731
+ indexed_key_compare (const unsigned char * k1 , const unsigned char * k2 ,
732
+ size_t sz , const unsigned char * col )
733
+ {
734
+ if (col ) {
735
+ return cob_cmps (k1 , k2 , sz , col );
736
+ }
737
+ return memcmp (k1 , k2 , sz );
738
+ }
739
+
728
740
/* Return total length of the key */
729
741
static int
730
742
bdb_keylen (cob_file * f , int idx )
@@ -899,6 +911,21 @@ bdb_close_index (cob_file *f, int index)
899
911
return 1 ;
900
912
}
901
913
914
+ static int
915
+ bdb_bt_compare (DB * db , const DBT * k1 , const DBT * k2 )
916
+ {
917
+ const unsigned char * col = (unsigned char * )DBT_GET_APP_DATA (k1 );
918
+ /* LCOV_EXCL_START */
919
+ if (col == NULL ) {
920
+ cob_runtime_error ("bdb_bt_compare was set but no collating sequence was stored in DBT" );
921
+ }
922
+ if (k1 -> size != k2 -> size ) {
923
+ cob_runtime_error ("bdb_bt_compare was given keys of different length" );
924
+ }
925
+ /* LCOV_EXCL_STOP */
926
+ return indexed_key_compare (k1 -> data , k2 -> data , k2 -> size , col );
927
+ }
928
+
902
929
#endif /* WITH_DB */
903
930
904
931
@@ -4162,31 +4189,6 @@ indexed_file_delete (cob_file *f, const char *filename)
4162
4189
#endif
4163
4190
}
4164
4191
4165
- static int
4166
- indexed_key_compare (const unsigned char * k1 , const unsigned char * k2 ,
4167
- size_t sz , const unsigned char * col )
4168
- {
4169
- if (col == NULL ) {
4170
- return memcmp (k1 , k2 , sz );
4171
- } else {
4172
- return cob_cmps (k1 , k2 , sz , col );
4173
- }
4174
- }
4175
-
4176
- static int
4177
- bdb_bt_compare (DB * db , const DBT * k1 , const DBT * k2 )
4178
- {
4179
- const unsigned char * col = (unsigned char * )DBT_GET_APP_DATA (k1 );
4180
- /* LCOV_EXCL_START */
4181
- if (col == NULL ) {
4182
- cob_runtime_error ("bdb_bt_compare was set but no collating sequence was stored in DBT" );
4183
- }
4184
- if (k1 -> size != k2 -> size ) {
4185
- cob_runtime_error ("bdb_bt_compare was given keys of different length" );
4186
- }
4187
- /* LCOV_EXCL_STOP */
4188
- return indexed_key_compare (k1 -> data , k2 -> data , k2 -> size , col );
4189
- }
4190
4192
4191
4193
/* OPEN INDEXED file */
4192
4194
0 commit comments