<commit_before>/**
 * Tests for the undeletable root trigger.
 */

--#SET TERMINATOR @
SET CURRENT SCHEMA LOGGER @

BEGIN
-- Reserved names for errors.
DECLARE SQLCODE INTEGER DEFAULT 0;
DECLARE SQLSTATE CHAR(5) DEFAULT '0000';

DECLARE GENERATED_ID SMALLINT; -- Generated id for the logger.
DECLARE RAISED BOOLEAN; -- For an controlled error.

-- Controlled SQL State.
DECLARE CONTINUE HANDLER FOR SQLSTATE 'LG004' SET RAISED = TRUE;
-- For any other SQL State.
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
  INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SESSION_USER, 'SQLCode ' || SQLCODE || '-SQLState ' || SQLSTATE);

-- Prepares the environment.
SET RAISED = FALSE;
INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SESSION_USER, 'Preparing environment');

-- Test1: Deletes a normal level.
INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SESSION_USER, 'Test1: Deletes a normal level');
SELECT LOGGER_ID INTO GENERATED_ID FROM FINAL TABLE (
  INSERT INTO CONF_LOGGERS_EFFECTIVE (NAME, PARENT_ID, LEVEL_ID) VALUES
  ('TEST1', 0, 0));
DELETE FROM CONF_LOGGERS_EFFECTIVE
  WHERE LOGGER_ID = GENERATED_ID;

-- Test2: Tries to delete root logger.
INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SESSION_USER, 'Test2: Tries to delete root logger');
DELETE FROM CONF_LOGGERS_EFFECTIVE
  WHERE LOGGER_ID = 0;
IF (RAISED = FALSE) THEN
 INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SESSION_USER, 'Exception not raised');
END IF;
SET RAISED = FALSE;

-- Test3: Delete all loggers except root.
INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SESSION_USER, 'Test3: Delete all loggers except root');
DELETE FROM CONF_LOGGERS_EFFECTIVE
  WHERE LOGGER_ID <> 0;

-- Test4: Tries to delete all loggers.
INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SESSION_USER, 'Test4: Tries to delete all loggers');
DELETE FROM CONF_LOGGERS_EFFECTIVE;
IF (RAISED = FALSE) THEN
 INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SESSION_USER, 'Exception not raised');
END IF;
SET RAISED = FALSE;

-- Cleans the environment.
INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SESSION_USER, 'Finished succesfully');

END<commit_msg>More info for env, format<commit_after>/**
 * Tests for the undeletable root trigger.
 */

--#SET TERMINATOR @
SET CURRENT SCHEMA LOGGER @

BEGIN
-- Reserved names for errors.
DECLARE SQLCODE INTEGER DEFAULT 0;
DECLARE SQLSTATE CHAR(5) DEFAULT '0000';

DECLARE GENERATED_ID SMALLINT; -- Generated id for the logger.
DECLARE RAISED BOOLEAN; -- For a controlled error.

-- Controlled SQL State.
DECLARE CONTINUE HANDLER FOR SQLSTATE 'LG004' SET RAISED = TRUE;
-- For any other SQL State.
DECLARE CONTINUE HANDLER FOR SQLWARNING, SQLEXCEPTION, NOT FOUND
  INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SYSPROC.MON_GET_APPLICATION_ID() || '-' || SESSION_USER, 'SQLCode ' || SQLCODE || '-SQLState ' || SQLSTATE);

-- Prepares the environment.
SET RAISED = FALSE;
INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SYSPROC.MON_GET_APPLICATION_ID() || '-' || SESSION_USER, 'TestUndeletable: Preparing environment');

-- Test1: Deletes a normal level.
INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SYSPROC.MON_GET_APPLICATION_ID() || '-' || SESSION_USER, 'Test1: Deletes a normal level');
SELECT LOGGER_ID INTO GENERATED_ID FROM FINAL TABLE (
  INSERT INTO CONF_LOGGERS_EFFECTIVE (NAME, PARENT_ID, LEVEL_ID) VALUES
  ('TEST1', 0, 0));
DELETE FROM CONF_LOGGERS_EFFECTIVE
  WHERE LOGGER_ID = GENERATED_ID;

-- Test2: Tries to delete root logger.
INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SYSPROC.MON_GET_APPLICATION_ID() || '-' || SESSION_USER, 'Test2: Tries to delete root logger');
DELETE FROM CONF_LOGGERS_EFFECTIVE
  WHERE LOGGER_ID = 0;
IF (RAISED = FALSE) THEN
 INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SYSPROC.MON_GET_APPLICATION_ID() || '-' || SESSION_USER, 'Exception not raised');
END IF;
SET RAISED = FALSE;

-- Test3: Delete all loggers except root.
INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SYSPROC.MON_GET_APPLICATION_ID() || '-' || SESSION_USER, 'Test3: Delete all loggers except root');
INSERT INTO CONF_LOGGERS_EFFECTIVE (NAME, PARENT_ID, LEVEL_ID) VALUES
  ('TEST3', 0, 0);
DELETE FROM CONF_LOGGERS_EFFECTIVE
  WHERE LOGGER_ID <> 0;

-- Test4: Tries to delete all loggers.
INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SYSPROC.MON_GET_APPLICATION_ID() || '-' || SESSION_USER, 'Test4: Tries to delete all loggers');
DELETE FROM CONF_LOGGERS_EFFECTIVE;
IF (RAISED = FALSE) THEN
 INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SYSPROC.MON_GET_APPLICATION_ID() || '-' || SESSION_USER, 'Exception not raised');
END IF;
SET RAISED = FALSE;

-- Cleans the environment.
INSERT INTO LOGS VALUES (CURRENT TIMESTAMP, 0, 0, SYSPROC.MON_GET_APPLICATION_ID() || '-' || SESSION_USER, 'TestUndeletable: Finished succesfully');

END
{'fraction_non_alphanumeric': 0.10292887029288703, 'fraction_numerical': 0.017364016736401675, 'mean_word_length': 4.902469135802469, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2183305', 'n_tokens_mistral': 1801, 'n_tokens_neox': 1614, 'n_words': 571}