LCOV - differential code coverage report
Current view: top level - src/test/modules/test_copy_callbacks - test_copy_callbacks.c (source / functions) Coverage Total Hit GNC
Current: Differential Code Coverage HEAD vs 15 Lines: 100.0 % 13 13 13
Current Date: 2023-04-08 15:15:32 Functions: 100.0 % 4 4 4
Baseline: 15
Baseline Date: 2023-04-08 15:09:40
Legend: Lines: hit not hit

           TLA  Line data    Source code
       1                 : /*--------------------------------------------------------------------------
       2                 :  *
       3                 :  * test_copy_callbacks.c
       4                 :  *      Code for testing COPY callbacks.
       5                 :  *
       6                 :  * Portions Copyright (c) 1996-2023, 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 GNC           1 : PG_MODULE_MAGIC;
      23                 : 
      24                 : static void
      25               3 : to_cb(void *data, int len)
      26                 : {
      27               3 :     ereport(NOTICE,
      28                 :             (errmsg("COPY TO callback called with data \"%s\" and length %d",
      29                 :                     (char *) data, len)));
      30               3 : }
      31                 : 
      32               2 : PG_FUNCTION_INFO_V1(test_copy_to_callback);
      33                 : Datum
      34               1 : test_copy_to_callback(PG_FUNCTION_ARGS)
      35                 : {
      36               1 :     Relation    rel = table_open(PG_GETARG_OID(0), AccessShareLock);
      37                 :     CopyToState cstate;
      38                 :     int64       processed;
      39                 : 
      40               1 :     cstate = BeginCopyTo(NULL, rel, NULL, RelationGetRelid(rel), NULL, false,
      41                 :                          to_cb, NIL, NIL);
      42               1 :     processed = DoCopyTo(cstate);
      43               1 :     EndCopyTo(cstate);
      44                 : 
      45               1 :     ereport(NOTICE, (errmsg("COPY TO callback has processed %lld rows",
      46                 :                             (long long) processed)));
      47                 : 
      48               1 :     table_close(rel, NoLock);
      49                 : 
      50               1 :     PG_RETURN_VOID();
      51                 : }
        

Generated by: LCOV version v1.16-55-g56c0a2a