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

Function pickout

src/test/examples/testlo.c:77–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77static void
78pickout(PGconn *conn, Oid lobjId, int 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 lo_lseek(conn, lobj_fd, start, SEEK_SET);
90 buf = malloc(len + 1);
91
92 nread = 0;
93 while (len - nread > 0)
94 {
95 nbytes = lo_read(conn, lobj_fd, buf, len - nread);
96 buf[nbytes] = '\0';
97 fprintf(stderr, ">>> %s", buf);
98 nread += nbytes;
99 if (nbytes <= 0)
100 break; /* no more data? */
101 }
102 free(buf);
103 fprintf(stderr, "\n");
104 lo_close(conn, lobj_fd);
105}
106
107static void
108overwrite(PGconn *conn, Oid lobjId, int start, int len)

Callers 1

mainFunction · 0.70

Calls 4

lo_openFunction · 0.85
lo_lseekFunction · 0.85
lo_closeFunction · 0.85
lo_readFunction · 0.50

Tested by

no test coverage detected