~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/item_func.cc

  • Committer: mark
  • Date: 2008-07-13 01:49:20 UTC
  • mto: This revision was merged to the branch mainline in revision 142.
  • Revision ID: mark@piggy.tangent.org-20080713014920-0m6zrvbzaext73ij
remove UUID_SHORT()

Show diffs side-by-side

added added

removed removed

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