<commit_before>CREATE OR REPLACE FUNCTION get_new_transaction_id ()  RETURNS character varying
  VOLATILE
AS $valtech$
DECLARE
    id VARCHAR;
    allowed VARCHAR := '23456789ABCDEFGHJKLMNPQRSTUVWXYZ';
    pos INTEGER;
BEGIN
    -- Try to generate an unique transaction id up to 5 times
    -- If it cannot generate an unique transaction id after 5 attemps then throws exception
    <<ATTEMPS>> 
    FOR attemps IN 1..5 LOOP
        <<GENERATION>> FOR i IN 1..7
        LOOP
            pos := FLOOR(32 * random()) + 1 ;
            id := concat(id, SUBSTR(allowed, pos, 1)) ;
        END LOOP GENERATION;
        BEGIN
            INSERT INTO transactionids (transaction_id) VALUES (id);
            RETURN id;
        EXCEPTION
            WHEN unique_violation THEN
              -- Do nothing, and loop to try the INSERT again.
            END;
    END LOOP ATTEMPS;
    RAISE EXCEPTION 'Did not manage to generate unique transaction id';
END;
$valtech$ LANGUAGE plpgsql

<commit_msg>Fixed stored procedure bug.<commit_after>CREATE OR REPLACE FUNCTION get_new_transaction_id ()  RETURNS character varying
  VOLATILE
AS $valtech$
DECLARE
    id VARCHAR;
    allowed VARCHAR := '23456789ABCDEFGHJKLMNPQRSTUVWXYZ';
    pos INTEGER;
BEGIN
    -- Try to generate an unique transaction id up to 5 times
    -- If it cannot generate an unique transaction id after 5 attemps then throws exception
    <<ATTEMPS>> 
    FOR attemps IN 1..5 LOOP
        <<GENERATION>> FOR i IN 1..7
        LOOP
            pos := FLOOR(32 * random()) + 1 ;
            id := concat(id, SUBSTR(allowed, pos, 1)) ;
        END LOOP GENERATION;
        BEGIN
            INSERT INTO transactionids (transaction_id) VALUES (id);
            RETURN id;
        EXCEPTION
            WHEN unique_violation THEN 
            -- Need to reset id so try to build a new one
            id := '';
            END;
    END LOOP ATTEMPS;
    RAISE EXCEPTION 'Did not manage to generate unique transaction id';
END;
$valtech$ LANGUAGE plpgsql


{'fraction_non_alphanumeric': 0.0697211155378486, 'fraction_numerical': 0.017928286852589643, 'mean_word_length': 2.2613636363636362, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4804691', 'n_tokens_mistral': 646, 'n_tokens_neox': 575, 'n_words': 226}