@@ -211,7 +211,7 @@ impl ModuleValidatorV9<'_> {
211211 . into_iter ( )
212212 . map ( |index| {
213213 table_in_progress
214- . validate_index_def ( index)
214+ . validate_index_def ( index, RawModuleDefVersion :: V9OrEarlier )
215215 . map ( |index| ( index. name . clone ( ) , index) )
216216 } )
217217 . collect_all_errors :: < StrMap < _ > > ( ) ;
@@ -1047,16 +1047,20 @@ impl<'a, 'b> TableValidator<'a, 'b> {
10471047 }
10481048
10491049 /// Validate an index definition.
1050- pub ( crate ) fn validate_index_def ( & mut self , index : RawIndexDefV9 ) -> Result < IndexDef > {
1050+ pub ( crate ) fn validate_index_def (
1051+ & mut self ,
1052+ index : RawIndexDefV9 ,
1053+ raw_def_version : RawModuleDefVersion ,
1054+ ) -> Result < IndexDef > {
10511055 let RawIndexDefV9 {
10521056 name,
1053- algorithm,
1057+ algorithm : algorithm_raw ,
10541058 accessor_name,
10551059 } = index;
10561060
1057- let name = name. unwrap_or_else ( || generate_index_name ( & self . raw_name , self . product_type , & algorithm ) ) ;
1061+ let name = name. unwrap_or_else ( || generate_index_name ( & self . raw_name , self . product_type , & algorithm_raw ) ) ;
10581062
1059- let algorithm: Result < IndexAlgorithm > = match algorithm {
1063+ let algorithm: Result < IndexAlgorithm > = match algorithm_raw . clone ( ) {
10601064 RawIndexAlgorithm :: BTree { columns } => self
10611065 . validate_col_ids ( & name, columns)
10621066 . map ( |columns| BTreeAlgorithm { columns } . into ( ) ) ,
@@ -1089,8 +1093,16 @@ impl<'a, 'b> TableValidator<'a, 'b> {
10891093 } ) ,
10901094 algo => unreachable ! ( "unknown algorithm {algo:?}" ) ,
10911095 } ;
1096+
1097+ let accessor_name = match raw_def_version {
1098+ // In V9, `name`field is used for database internals but `accessor_name` supplied by module is used for client codegen.
1099+ RawModuleDefVersion :: V9OrEarlier => accessor_name. map ( identifier) . transpose ( ) ,
1100+
1101+ // In V10, `name` is used both for internal purpose and client codefen.
1102+ RawModuleDefVersion :: V10 => identifier ( name. clone ( ) ) . map ( Some ) ,
1103+ } ;
1104+
10921105 let name = self . add_to_global_namespace ( name) ;
1093- let accessor_name = accessor_name. map ( identifier) . transpose ( ) ;
10941106
10951107 let ( name, accessor_name, algorithm) = ( name, accessor_name, algorithm) . combine_errors ( ) ?;
10961108
0 commit comments