/
githubmirror
/
postgres
Обзор
Документация
Войти
/
githubmirror
/
postgres
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/test/modules/test_copy_callbacks/test_copy_callbacks.c
51 строка
1 KB
Bruce Momjian
Update copyright for 2026
01 янв 2026, 21:24
01 янв 2026, 21:24
451c439
Код
Авторство
О чём код?
/*-------------------------------------------------------------------------- * * test_copy_callbacks.c * Code for testing COPY callbacks. * * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION * src/test/modules/test_copy_callbacks/test_copy_callbacks.c * * ------------------------------------------------------------------------- */ #include "postgres.h" #include "access/table.h" #include "commands/copy.h" #include "fmgr.h" #include "utils/rel.h" PG_MODULE_MAGIC; static void to_cb(void *data, int len) { ereport(NOTICE, (errmsg("COPY TO callback called with data \"%s\" and length %d", (char *) data, len))); } PG_FUNCTION_INFO_V1(test_copy_to_callback); Datum test_copy_to_callback(PG_FUNCTION_ARGS) { Relation rel = table_open(PG_GETARG_OID(0), AccessShareLock); CopyToState cstate; int64 processed; cstate = BeginCopyTo(NULL, rel, NULL, RelationGetRelid(rel), NULL, false, to_cb, NIL, NIL); processed = DoCopyTo(cstate); EndCopyTo(cstate); ereport(NOTICE, (errmsg("COPY TO callback has processed %" PRId64 " rows", processed))); table_close(rel, NoLock); PG_RETURN_VOID(); }