LCOV - code coverage report
Current view: top level - src/interfaces/ecpg/test/sql - func.pgc (source / functions) Hit Total Coverage
Test: PostgreSQL 18devel Lines: 23 23 100.0 %
Date: 2024-11-21 08:14:44 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #include <stdio.h>
       2             : #include <stdlib.h>
       3             : #include <string.h>
       4             : 
       5             : EXEC SQL INCLUDE ../regression;
       6             : 
       7           4 : int main() {
       8             :   EXEC SQL char text[25];
       9             : 
      10           4 :   ECPGdebug(1, stderr);
      11           4 :   EXEC SQL CONNECT TO REGRESSDB1;
      12             : 
      13           4 :   EXEC SQL SET AUTOCOMMIT TO ON;
      14             :   EXEC SQL WHENEVER SQLWARNING SQLPRINT;
      15             :   EXEC SQL WHENEVER SQLERROR SQLPRINT;
      16             : 
      17           4 :   EXEC SQL CREATE TABLE My_Table ( Item1 int, Item2 text );
      18           4 :   EXEC SQL CREATE TABLE Log (name text, w text);
      19           4 : 
      20           4 :   EXEC SQL CREATE FUNCTION My_Table_Check() RETURNS trigger
      21             :     AS $test$
      22             :     BEGIN
      23             :     INSERT INTO Log VALUES(TG_NAME, TG_WHEN);
      24             :     RETURN NEW;
      25             :     END; $test$
      26             :     LANGUAGE plpgsql;
      27           4 : 
      28           4 :   EXEC SQL CREATE TRIGGER My_Table_Check_Trigger
      29             :     BEFORE INSERT
      30             :     ON My_Table
      31             :     FOR EACH ROW
      32             :     EXECUTE PROCEDURE My_Table_Check();
      33           4 : 
      34           4 :   EXEC SQL INSERT INTO My_Table VALUES (1234, 'Some random text');
      35           4 :   EXEC SQL INSERT INTO My_Table VALUES (5678, 'The Quick Brown');
      36           4 :   EXEC SQL SELECT name INTO :text FROM Log LIMIT 1;
      37           4 :   printf("Trigger %s fired.\n", text);
      38             : 
      39           4 :   EXEC SQL DROP TRIGGER My_Table_Check_Trigger ON My_Table;
      40           4 :   EXEC SQL DROP FUNCTION My_Table_Check();
      41           4 :   EXEC SQL DROP TABLE Log;
      42           4 :   EXEC SQL DROP TABLE My_Table;
      43           4 : 
      44           4 :   EXEC SQL DISCONNECT ALL;
      45           4 : 
      46           4 :   return 0;
      47             : }

Generated by: LCOV version 1.14