@@ -101,6 +101,12 @@ class StorageNodeImpl final : public spectrum::StorageNode::Service {
101101      thd->lex ->sql_command  = (enum_sql_command)spectrum_thread.sql_command ();
102102      thd->tx_isolation  = (enum_tx_isolation)spectrum_thread.tx_isolation ();
103103      thd->variables .option_bits  = spectrum_thread.system_variables ().option_bits ();
104+       
105+       //  This is needed because register_uncommitted_object() and register_dropped_object() require a non-default
106+       //  auto releaser, even though it's not actually required because uncommitted/dropped objects will be
107+       //  released in remove_uncommitted_objects() when transaction commits.
108+       new  dd::cache::Dictionary_client::Auto_releaser (thd->dd_client ());
109+       
104110      return  (thd);
105111    }
106112
@@ -190,21 +196,13 @@ class StorageNodeImpl final : public spectrum::StorageNode::Service {
190196      const  char * table_name = request->table ().c_str ();
191197      uint64 handler_id = request->handler ();
192198
193-       sql_print_information (" CreateTable[%s:%d]" 
199+       sql_print_information (" CreateTable[%s:%s:% d]" , db_name , table_name, handler_id);
194200
195201      thd = handler_create_thd (request->thread ());
196202
197-       //  Invalidate shared dd cache for db
198-       dd::cache::Dictionary_client::Auto_releaser releaser (thd->dd_client ());
199-       thd->dd_client ()->acquire (db_name, &schema_def);
200-       if  (schema_def == nullptr ) {
201-         sql_print_error (" CreateTable[%s:%s:%d]: can not find schema definition" 
202-         goto  end;
203-       }
204-       thd->dd_client ()->invalidate (schema_def);
205- 
206203      //  Retrive table definition
207-       thd->dd_client ()->reload_uncommitted (db_name, table_name, (const  dd::Abstract_table **)&table_def);
204+       dd::cache::Dictionary_client::Auto_releaser releaser (thd->dd_client ());
205+       thd->dd_client ()->acquire (db_name, table_name, (const  dd::Abstract_table **)&table_def);
208206      if  (table_def == nullptr ) {
209207        sql_print_error (" CreateTable[%s:%s:%d]: can not find table definition" 
210208        goto  end;
@@ -219,9 +217,6 @@ class StorageNodeImpl final : public spectrum::StorageNode::Service {
219217      }
220218
221219    end:
222-       thd->lex ->sql_command  = SQLCOM_CREATE_TABLE;
223-       handlerton *db_type = get_viable_handlerton_for_create (thd, table_name, create_info);
224-       thd->m_transactional_ddl .init (db_name, table_name, db_type);
225220      return  grpc::Status::OK; 
226221    }
227222
@@ -283,7 +278,7 @@ class StorageNodeImpl final : public spectrum::StorageNode::Service {
283278      thr_lock_type lock_type = (thr_lock_type)request->lock_type ();
284279      thr_locked_row_action lock_action = (thr_locked_row_action)request->lock_action ();
285280
286-       sql_print_information (" LockTable[%s:%d]: lock_type=%d" 
281+       sql_print_information (" LockTable[%s:%s:% d]: lock_type=%d" , db_name , table_name, handler_id, lock_type);
287282
288283      thd = handler_create_thd (request->thread ());
289284      table = handler_find_or_open_table (thd, db_name, table_name, handler_id, lock_type, lock_action);
@@ -304,7 +299,7 @@ class StorageNodeImpl final : public spectrum::StorageNode::Service {
304299      thr_lock_type lock_type = (thr_lock_type)request->lock_type ();
305300      thr_locked_row_action lock_action = (thr_locked_row_action)request->lock_action ();
306301
307-       sql_print_information (" UnLockTable[%s:%d]" 
302+       sql_print_information (" UnLockTable[%s:%s:% d]" , db_name , table_name, handler_id);
308303
309304      thd = handler_create_thd (request->thread ());
310305      table = handler_find_or_open_table (thd, db_name, table_name, handler_id, lock_type, lock_action);
@@ -321,7 +316,7 @@ class StorageNodeImpl final : public spectrum::StorageNode::Service {
321316      const  char * table_name = request->table ().c_str ();
322317      uint64 handler_id = request->handler ();
323318
324-       sql_print_information (" CloseTable[%s:%d]" 
319+       sql_print_information (" CloseTable[%s:%s:% d]" , db_name , table_name, handler_id);
325320
326321      thd = handler_create_thd (request->thread ());
327322      handler_find_and_close_table (thd, db_name, table_name, handler_id);
@@ -335,7 +330,7 @@ class StorageNodeImpl final : public spectrum::StorageNode::Service {
335330      thr_lock_type lock_type = (thr_lock_type)request->lock_type ();
336331      thr_locked_row_action lock_action = (thr_locked_row_action)request->lock_action ();
337332
338-       sql_print_information (" InitIndex[%s:%d]: index=%d" table ().c_str (), request->handler (), request->index ());
333+       sql_print_information (" InitIndex[%s:%s:% d]: index=%d" , request-> database (). c_str () , request->table ().c_str (), request->handler (), request->index ());
339334
340335      thd = handler_create_thd (request->thread ());
341336      table = handler_find_or_open_table (thd, request->database ().c_str (), request->table ().c_str (), request->handler (), lock_type, lock_action);
@@ -351,7 +346,7 @@ class StorageNodeImpl final : public spectrum::StorageNode::Service {
351346      thr_lock_type lock_type = (thr_lock_type)request->lock_type ();
352347      thr_locked_row_action lock_action = (thr_locked_row_action)request->lock_action ();
353348
354-       sql_print_information (" InitRnd[%s:%d]: scan=%d" table ().c_str (), request->handler (), request->scan ());
349+       sql_print_information (" InitRnd[%s:%s:% d]: scan=%d" , request-> database (). c_str () , request->table ().c_str (), request->handler (), request->scan ());
355350
356351      thd = handler_create_thd (request->thread ());
357352      table = handler_find_or_open_table (thd, request->database ().c_str (), request->table ().c_str (), request->handler (), lock_type, lock_action);
@@ -367,7 +362,7 @@ class StorageNodeImpl final : public spectrum::StorageNode::Service {
367362      thr_lock_type lock_type = (thr_lock_type)request->lock_type ();
368363      thr_locked_row_action lock_action = (thr_locked_row_action)request->lock_action ();
369364
370-       sql_print_information (" EndIndex[%s:%d]" table ().c_str (), request->handler ());
365+       sql_print_information (" EndIndex[%s:%s:% d]" , request-> database (). c_str () , request->table ().c_str (), request->handler ());
371366
372367      thd = handler_create_thd (request->thread ());
373368      table = handler_find_or_open_table (thd, request->database ().c_str (), request->table ().c_str (), request->handler (), lock_type, lock_action);
@@ -394,7 +389,7 @@ class StorageNodeImpl final : public spectrum::StorageNode::Service {
394389        key = (const  uchar *)request->key ().data ();
395390      }
396391
397-       sql_print_information (" ReadRow[%s:%d]" table ().c_str (), request->handler ());
392+       sql_print_information (" ReadRow[%s:%s:% d]" , request-> database (). c_str () , request->table ().c_str (), request->handler ());
398393
399394      thd = handler_create_thd (request->thread ());
400395      table = handler_find_or_open_table (thd, request->database ().c_str (), request->table ().c_str (), request->handler (), lock_type, lock_action);
@@ -415,7 +410,7 @@ class StorageNodeImpl final : public spectrum::StorageNode::Service {
415410      thr_locked_row_action lock_action = (thr_locked_row_action)request->lock_action ();
416411      int  error;
417412
418-       sql_print_information (" ReadNextRow[%s:%d]" table ().c_str (), request->handler ());
413+       sql_print_information (" ReadNextRow[%s:%s:% d]" , request-> database (). c_str () , request->table ().c_str (), request->handler ());
419414
420415      thd = handler_create_thd (request->thread ());
421416      table = handler_find_or_open_table (thd, request->database ().c_str (), request->table ().c_str (), request->handler (), lock_type, lock_action);
@@ -444,7 +439,7 @@ class StorageNodeImpl final : public spectrum::StorageNode::Service {
444439      thr_locked_row_action lock_action = (thr_locked_row_action)request->lock_action ();
445440      int  error;
446441
447-       sql_print_information (" ReadPrevRow[%s:%d]" table ().c_str (), request->handler ());
442+       sql_print_information (" ReadPrevRow[%s:%s:% d]" , request-> database (). c_str () , request->table ().c_str (), request->handler ());
448443
449444      thd = handler_create_thd (request->thread ());
450445      table = handler_find_or_open_table (thd, request->database ().c_str (), request->table ().c_str (), request->handler (), lock_type, lock_action);
@@ -584,6 +579,27 @@ class StorageNodeImpl final : public spectrum::StorageNode::Service {
584579      return  grpc::Status::OK; 
585580    }
586581
582+     ::grpc::Status UpdateMetadata (::grpc::ServerContext* context, const  ::spectrum::UpdateMetadataRequest* request, ::spectrum::UpdateMetadataResponse* response) {
583+       THD *thd;
584+       const  std::string& table = request->table ();
585+       const  dd::Object_id object_id = request->object_id ();
586+       const  std::string& object_name = request->object_name ();
587+ 
588+       sql_print_information (" UpdateMetadata: table=%s, object_id=%d, object_name=%s" 
589+             table.c_str (), object_id, object_name.c_str ()); 
590+ 
591+       thd = handler_create_thd (request->thread ());
592+ 
593+       if  (!strcmp (table.c_str (), " schemata" 
594+         const  dd::Schema *object;
595+         thd->dd_client ()->reload_uncommitted (object_id, &object);
596+       } else  if  (!strcmp (table.c_str (), " tables" 
597+         const  dd::Abstract_table *object;
598+         thd->dd_client ()->reload_uncommitted (object_id, &object);
599+       }
600+       return  grpc::Status::OK; 
601+     }
602+ 
587603    ::grpc::Status AcquireMetadataLock (::grpc::ServerContext* context, const  ::spectrum::AcquireMetadataLockRequest* request, ::spectrum::AcquireMetadataLockResponse* response) {
588604      THD *thd;
589605      MDL_key::enum_mdl_namespace namespace_ = static_cast <MDL_key::enum_mdl_namespace>(request->namespace_ ());
@@ -706,7 +722,7 @@ class StorageNodeImpl final : public spectrum::StorageNode::Service {
706722      mysql_unlock_some_tables (thd, &table, 1 );
707723
708724      if  (err) {
709-         sql_print_error (" ReplicateRow[%s:%d]: error=%d" table ().c_str (), request->handler (), err);
725+         sql_print_error (" ReplicateRow[%s:%s:% d]: error=%d" , request-> database (). c_str () , request->table ().c_str (), request->handler (), err);
710726      }
711727      return  grpc::Status::OK; 
712728    }
0 commit comments