PostgreSQL Source Code  git master
test_copy_callbacks.c File Reference
#include "postgres.h"
#include "access/table.h"
#include "commands/copy.h"
#include "fmgr.h"
#include "utils/rel.h"
Include dependency graph for test_copy_callbacks.c:

Go to the source code of this file.


static void to_cb (void *data, int len)
 PG_FUNCTION_INFO_V1 (test_copy_to_callback)
Datum test_copy_to_callback (PG_FUNCTION_ARGS)



Function Documentation


PG_FUNCTION_INFO_V1 ( test_copy_to_callback  )

◆ test_copy_to_callback()

Datum test_copy_to_callback ( PG_FUNCTION_ARGS  )

Definition at line 34 of file test_copy_callbacks.c.

35 {
37  CopyToState cstate;
38  int64 processed;
40  cstate = BeginCopyTo(NULL, rel, NULL, RelationGetRelid(rel), NULL, false,
41  to_cb, NIL, NIL);
42  processed = DoCopyTo(cstate);
43  EndCopyTo(cstate);
45  ereport(NOTICE, (errmsg("COPY TO callback has processed %lld rows",
46  (long long) processed)));
48  table_close(rel, NoLock);
51 }
uint64 DoCopyTo(CopyToState cstate)
Definition: copyto.c:742
CopyToState BeginCopyTo(ParseState *pstate, Relation rel, RawStmt *raw_query, Oid queryRelId, const char *filename, bool is_program, copy_data_dest_cb data_dest_cb, List *attnamelist, List *options)
Definition: copyto.c:350
void EndCopyTo(CopyToState cstate)
Definition: copyto.c:721
int errmsg(const char *fmt,...)
Definition: elog.c:1072
#define NOTICE
Definition: elog.h:35
#define ereport(elevel,...)
Definition: elog.h:149
#define PG_RETURN_VOID()
Definition: fmgr.h:349
#define PG_GETARG_OID(n)
Definition: fmgr.h:275
#define NoLock
Definition: lockdefs.h:34
#define AccessShareLock
Definition: lockdefs.h:36
#define NIL
Definition: pg_list.h:68
#define RelationGetRelid(relation)
Definition: rel.h:505
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:126
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:40
static void to_cb(void *data, int len)

References AccessShareLock, BeginCopyTo(), DoCopyTo(), EndCopyTo(), ereport, errmsg(), NIL, NoLock, NOTICE, PG_GETARG_OID, PG_RETURN_VOID, RelationGetRelid, table_close(), table_open(), and to_cb().

◆ to_cb()

static void to_cb ( void *  data,
int  len 

Definition at line 25 of file test_copy_callbacks.c.

26 {
28  (errmsg("COPY TO callback called with data \"%s\" and length %d",
29  (char *) data, len)));
30 }
const void size_t len
const void * data

References data, ereport, errmsg(), len, and NOTICE.

Referenced by test_copy_to_callback().

Variable Documentation



Definition at line 22 of file test_copy_callbacks.c.