Eli Mesika has posted comments on this change.

Change subject: core: Don't use PostgreSQL UUID extension
......................................................................


Patch Set 2: (1 inline comment)

....................................................
File backend/manager/dbscripts/create_functions.sql
Line 647: --
Line 648: create or replace function uuid_generate_v1() returns uuid
Line 649: as $procedure$
Line 650: begin
Line 651:   return 'a851fa6f-d5a4-08d2-0598-' || 
lpad(to_hex(nextval('uuid_sequence')), 12, '0');
Thinking of that again, The fact that all UUIDs generated by DB has this 
constant prefix may cause some difficulties in reading logs and debug.
Therefore , I am suggesting the following code for this function
It was tested and is working 

create or replace function uuid_generate_v1() returns uuid
as $procedure$
declare
    v_val bigint;
    v_4_part char(4);
    v_8_part char(8);
    v_12_part char(12);
    v_4_part_max int;
begin
  -- The only part we should use modulo is the 4 digit part, all the rest
  -- are really big numbers (i.e 16^8 - 1 and 16^12 - 1)
  v_4_part_max = 65535; -- this is 16^4 -1
  v_val:=nextval('uuid_sequence');
  v_4_part:=lpad(to_hex(v_val%v_4_part_max), 4, '0');
  v_8_part:=lpad(to_hex(v_val), 8, '0');
  v_12_part:=lpad(to_hex(v_val), 12, '0');
  return v_8_part || '-' || v_4_part || '-' || v_4_part || '-'||
         v_4_part || '-' || v_12_part;
end; $procedure$
Line 652: end; $procedure$
Line 653: language plpgsql;


--
To view, visit http://gerrit.ovirt.org/8955
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I819e37224288b202d2126cec475ee1d97f83a925
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com>
Gerrit-Reviewer: Alex Lourie <alou...@redhat.com>
Gerrit-Reviewer: Eli Mesika <emes...@redhat.com>
Gerrit-Reviewer: Juan Hernandez <juan.hernan...@redhat.com>
Gerrit-Reviewer: Ohad Basan <oba...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to