LCOV - code coverage report
Current view: top level - src/test/modules/test_copy_callbacks - test_copy_callbacks.c (source / functions) Coverage Total Hit
Test: Code coverage Lines: 0.0 % 16 0
Test Date: 2026-01-26 10:56:24 Functions: 0.0 % 4 0
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /*--------------------------------------------------------------------------
       2              :  *
       3              :  * test_copy_callbacks.c
       4              :  *              Code for testing COPY callbacks.
       5              :  *
       6              :  * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
       7              :  * Portions Copyright (c) 1994, Regents of the University of California
       8              :  *
       9              :  * IDENTIFICATION
      10              :  *              src/test/modules/test_copy_callbacks/test_copy_callbacks.c
      11              :  *
      12              :  * -------------------------------------------------------------------------
      13              :  */
      14              : 
      15              : #include "postgres.h"
      16              : 
      17              : #include "access/table.h"
      18              : #include "commands/copy.h"
      19              : #include "fmgr.h"
      20              : #include "utils/rel.h"
      21              : 
      22            0 : PG_MODULE_MAGIC;
      23              : 
      24              : static void
      25            0 : to_cb(void *data, int len)
      26              : {
      27            0 :         ereport(NOTICE,
      28              :                         (errmsg("COPY TO callback called with data \"%s\" and length %d",
      29              :                                         (char *) data, len)));
      30            0 : }
      31              : 
      32            0 : PG_FUNCTION_INFO_V1(test_copy_to_callback);
      33              : Datum
      34            0 : test_copy_to_callback(PG_FUNCTION_ARGS)
      35              : {
      36            0 :         Relation        rel = table_open(PG_GETARG_OID(0), AccessShareLock);
      37            0 :         CopyToState cstate;
      38            0 :         int64           processed;
      39              : 
      40            0 :         cstate = BeginCopyTo(NULL, rel, NULL, RelationGetRelid(rel), NULL, false,
      41              :                                                  to_cb, NIL, NIL);
      42            0 :         processed = DoCopyTo(cstate);
      43            0 :         EndCopyTo(cstate);
      44              : 
      45            0 :         ereport(NOTICE, (errmsg("COPY TO callback has processed %" PRId64 " rows",
      46              :                                                         processed)));
      47              : 
      48            0 :         table_close(rel, NoLock);
      49              : 
      50            0 :         PG_RETURN_VOID();
      51            0 : }
        

Generated by: LCOV version 2.3.2-1