~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/item_func.cc

  • Committer: Brian Aker
  • Date: 2008-07-13 02:23:24 UTC
  • mfrom: (138.1.1 remove-uuid-short)
  • Revision ID: brian@tangent.org-20080713022324-ejablzhzc8vhtw5x
Merge from Mark to remove short UUID

Show diffs side-by-side

added added

removed removed

Lines of Context:
4586
4586
 
4587
4587
  return thd->found_rows();
4588
4588
}
4589
 
 
4590
 
 
4591
 
 
4592
 
/*
4593
 
  uuid_short handling.
4594
 
 
4595
 
  The short uuid is defined as a longlong that contains the following bytes:
4596
 
 
4597
 
  Bytes  Comment
4598
 
  1      Server_id & 255
4599
 
  4      Startup time of server in seconds
4600
 
  3      Incrementor
4601
 
 
4602
 
  This means that an uuid is guaranteed to be unique
4603
 
  even in a replication environment if the following holds:
4604
 
 
4605
 
  - The last byte of the server id is unique
4606
 
  - If you between two shutdown of the server don't get more than
4607
 
    an average of 2^24 = 16M calls to uuid_short() per second.
4608
 
*/
4609
 
 
4610
 
ulonglong uuid_value;
4611
 
 
4612
 
void uuid_short_init()
4613
 
{
4614
 
  uuid_value= ((((ulonglong) server_id) << 56) + 
4615
 
               (((ulonglong) server_start_time) << 24));
4616
 
}
4617
 
 
4618
 
 
4619
 
longlong Item_func_uuid_short::val_int()
4620
 
{
4621
 
  ulonglong val;
4622
 
  pthread_mutex_lock(&LOCK_uuid_generator);
4623
 
  val= uuid_value++;
4624
 
  pthread_mutex_unlock(&LOCK_uuid_generator);
4625
 
  return (longlong) val;
4626
 
}