MCPcopy Create free account
hub / github.com/apache/cloudberry / pickout

Function pickout

src/test/examples/testlo64.c:77–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77static void
78pickout(PGconn *conn, Oid lobjId, pg_int64 start, int len)
79{
80 int lobj_fd;
81 char *buf;
82 int nbytes;
83 int nread;
84
85 lobj_fd = lo_open(conn, lobjId, INV_READ);
86 if (lobj_fd < 0)
87 fprintf(stderr, "cannot open large object %u", lobjId);
88
89 if (lo_lseek64(conn, lobj_fd, start, SEEK_SET) < 0)
90 fprintf(stderr, "error in lo_lseek64: %s", PQerrorMessage(conn));
91
92 if (lo_tell64(conn, lobj_fd) != start)
93 fprintf(stderr, "error in lo_tell64: %s", PQerrorMessage(conn));
94
95 buf = malloc(len + 1);
96
97 nread = 0;
98 while (len - nread > 0)
99 {
100 nbytes = lo_read(conn, lobj_fd, buf, len - nread);
101 buf[nbytes] = '\0';
102 fprintf(stderr, ">>> %s", buf);
103 nread += nbytes;
104 if (nbytes <= 0)
105 break; /* no more data? */
106 }
107 free(buf);
108 fprintf(stderr, "\n");
109 lo_close(conn, lobj_fd);
110}
111
112static void
113overwrite(PGconn *conn, Oid lobjId, pg_int64 start, int len)

Callers 1

mainFunction · 0.70

Calls 6

lo_openFunction · 0.85
lo_lseek64Function · 0.85
PQerrorMessageFunction · 0.85
lo_tell64Function · 0.85
lo_closeFunction · 0.85
lo_readFunction · 0.50

Tested by

no test coverage detected