Home Page for the TeradataForum

Archives of the TeradataForum

Message Posted: Wed, 25 Nov 2009 @ 11:09:35 GMT

  <Prev Next>   <<First <Prev Next> Last>>  

Subj:   Re: GUID/UUID generation in UDF
From:   kaare.wehn

Thanks to Victor and Geoffrey for great answers!

The MD5 hashing function is the most promising one, but it requires the user to give it a unique input to get a (pseudo) unique GUID/UUID as output. I was hoping to create or find a UDF _without_ parameters.

The GUID generating algorithm could use the following data as input (not parameters to the UDF):

1. A memory address containing a counter. I think most processors have atomic functions like "increase and fetch".

2. The hardware clock in the machine. Unfortunately a hardware clock usually does not have enough resolution alone.

3. The network card MAC address. This is always unique to each physical machine.

Number one ensures that a physical node does not create two equal GUID's until it's restarted.

Number two in conjunction with number one ensures that one physical node never creates two equal GUID's. (Even after a restart) Number three ensures that two different physical nodes never generate the same GUID.

Combining these three input values directly or through MD5 gives me exactly what I need!

Unfortunately there are still a few questions to be answered:

1. Is it possible to allocate a memory address once and then let my UDF "increase and fetch" a value each time it's running?

2. Can I access some sort of clock from a UDF? (If this is a problem, CURRENT_TIME(6) can be an input parameter to the UDF. I can live with that :-)

3. Can I access the MAC address of the machine from a UDF? If not, are there any other node or amp identifiers that could be used. (It could maybe be passed in as a parameter, if necessary)

I have some experience with C++ and know that this is possible in a normal program context. But I also realize that a UDF runs in a special context that may not allow calls to the standard platform libraries.

Again, thanks for your answers. I hope to hear from you again!

Kaare Wehn

  <Prev Next>   <<First <Prev Next> Last>>  
  Top Home Privacy Feedback  
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 28 Jun 2020