LCOV - differential code coverage report
Current view: top level - src/test/modules/test_copy_callbacks - test_copy_callbacks.c (source / functions) Coverage Total Hit UBC CBC
Current: Differential Code Coverage 16@8cea358b128 vs 17@8cea358b128 Lines: 100.0 % 13 13 13
Current Date: 2024-04-14 14:21:10 Functions: 100.0 % 4 4 4
Baseline: 16@8cea358b128 Branches: 50.0 % 4 2 2 2
Baseline Date: 2024-04-14 14:21:09 Line coverage date bins:
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed (240..) days: 100.0 % 13 13 13
Function coverage date bins:
(240..) days: 100.0 % 4 4 4
Branch coverage date bins:
(240..) days: 50.0 % 4 2 2 2

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*--------------------------------------------------------------------------
                                  2                 :                :  *
                                  3                 :                :  * test_copy_callbacks.c
                                  4                 :                :  *      Code for testing COPY callbacks.
                                  5                 :                :  *
                                  6                 :                :  * Portions Copyright (c) 1996-2024, 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                 :                : 
  551 michael@paquier.xyz        22                 :CBC           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                 :                : 
  550                            40                 :              1 :     cstate = BeginCopyTo(NULL, rel, NULL, RelationGetRelid(rel), NULL, false,
                                 41                 :                :                          to_cb, NIL, NIL);
  551                            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 2.1-beta2-3-g6141622