Skip to content

Instantly share code, notes, and snippets.

@sholden
Last active August 29, 2015 14:07
Show Gist options
  • Save sholden/325df262310e33f1877c to your computer and use it in GitHub Desktop.
Save sholden/325df262310e33f1877c to your computer and use it in GitHub Desktop.
drop table if exists shard_seq_tbl;
create table shard_seq_tbl ( nextval bigint not null primary key auto_increment ) engine = MyISAM;
alter table shard_seq_tbl AUTO_INCREMENT = 10000;
drop function if exists shard_nextval;
DELIMITER //
create function shard_nextval()
RETURNS bigint NOT DETERMINISTIC
begin
insert into shard_seq_tbl values (NULL) ;
set @R_ObjectId_val=LAST_INSERT_ID() ;
delete from shard_seq_tbl ;
return @R_ObjectId_val ;
end //
DELIMITER ;
drop function if exists now_msec;
CREATE FUNCTION now_msec RETURNS STRING SONAME "now_msec.so" ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment