[Community Puzzle] Remove insert statements

So I managed to complete the puzzle with the following test case :

Input:

25
--
-- Name: fp_insert(integer)
--
CREATE FUNCTION func.fp_insert(pid integer) RETURNS integer
    LANGUAGE plpgsql
    AS $$
declare
Begin
  return 1;
end;
$$;
-- TOC entry 49324
INSERT INTO func.ap VALUES ('PLAYER1', 'CODINGAME', 0);
INSERT into func.ap VALUES ('PLAYER2', 'CODINGAME', 1);
insert INTO func.ap VALUES ('PLAYER3', 'CODINGAME', 2);
--
CREATE TABLE winners (
    date_creation timestamp without time zone,
    game_name text,
    id character integer NOT NULL,
);
insert into winners(date_creation, game_name, id_ch) 
values('BOSS', 'CODINGAME', -1);
Insert INTO func.wr VALUES ('DON', '2024-04-28 21:00:00');
-- END Batch

Output:

--
-- Name: fp_insert(integer)
--
CREATE FUNCTION func.fp_insert(pid integer) RETURNS integer
    LANGUAGE plpgsql
    AS $$
declare
Begin
  return 1;
end;
$$;
-- TOC entry 49324
--
CREATE TABLE winners (
    date_creation timestamp without time zone,
    game_name text,
    id character integer NOT NULL,
);
-- END Batch

For me, the point was that I looked for begin followed by a space, and I forgot the line could end right after the keyword. Also, I looked for a closing parenthesis to detect when a multi-line insert would end, but it was the semicolon.

Many thanks to 5DN1L who shared this example

1 Like