<commit_before>-- The Postgres trigger function

CREATE OR REPLACE FUNCTION pubsubpull_change_recorder() RETURNS TRIGGER AS $body$
BEGIN
  IF (TG_OP = 'DELETE') THEN
    INSERT INTO pubsubpull_updatelog ("table", "when", old, new)
    SELECT TG_TABLE_NAME, now(), row_to_json(OLD)::jsonb, NULL;
  ELSEIF (TG_OP = 'UPDATE') THEN
    INSERT INTO pubsubpull_updatelog ("table", "when", old, new)
    SELECT TG_TABLE_NAME, now(), row_to_json(OLD)::jsonb, row_to_json(NEW)::jsonb;
  ELSEIF (TG_OP = 'INSERT') THEN
    INSERT INTO pubsubpull_updatelog ("table", "when", old, new)
    SELECT TG_TABLE_NAME, now(), NULL, row_to_json(NEW)::jsonb;
  END IF;
  RETURN NULL;
END;
$body$ LANGUAGE plpgsql;
<commit_msg>Fix the trigger function to record the instruction type.<commit_after>-- The Postgres trigger function

CREATE OR REPLACE FUNCTION pubsubpull_change_recorder() RETURNS TRIGGER AS $body$
BEGIN
  IF (TG_OP = 'DELETE') THEN
    INSERT INTO pubsubpull_updatelog ("table", type, "when", old, new)
    SELECT TG_TABLE_NAME, 'D', now(), row_to_json(OLD)::jsonb, NULL;
  ELSEIF (TG_OP = 'UPDATE') THEN
    INSERT INTO pubsubpull_updatelog ("table", type, "when", old, new)
    SELECT TG_TABLE_NAME, 'U', now(), row_to_json(OLD)::jsonb, row_to_json(NEW)::jsonb;
  ELSEIF (TG_OP = 'INSERT') THEN
    INSERT INTO pubsubpull_updatelog ("table", type, "when", old, new)
    SELECT TG_TABLE_NAME, 'I', now(), NULL, row_to_json(NEW)::jsonb;
  END IF;
  RETURN NULL;
END;
$body$ LANGUAGE plpgsql;

{'fraction_non_alphanumeric': 0.13122476446837147, 'fraction_numerical': 0.0, 'mean_word_length': 5.2478991596638656, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6622935', 'n_tokens_mistral': 594, 'n_tokens_neox': 547, 'n_words': 156}