127 (
errcode(ERRCODE_UNDEFINED_OBJECT),
128 errmsg(
"invalid large-object descriptor: %d",
fd)));
156 (
errcode(ERRCODE_UNDEFINED_OBJECT),
157 errmsg(
"invalid large-object descriptor: %d",
fd)));
167 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
168 errmsg(
"large object descriptor %d was not opened for reading",
184 (
errcode(ERRCODE_UNDEFINED_OBJECT),
185 errmsg(
"invalid large-object descriptor: %d",
fd)));
191 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
192 errmsg(
"large object descriptor %d was not opened for writing",
210 (
errcode(ERRCODE_UNDEFINED_OBJECT),
211 errmsg(
"invalid large-object descriptor: %d",
fd)));
218 (
errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
219 errmsg(
"lo_lseek result out of range for large-object descriptor %d",
235 (
errcode(ERRCODE_UNDEFINED_OBJECT),
236 errmsg(
"invalid large-object descriptor: %d",
fd)));
273 (
errcode(ERRCODE_UNDEFINED_OBJECT),
274 errmsg(
"invalid large-object descriptor: %d",
fd)));
279 if (offset != (
int32) offset)
281 (
errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
282 errmsg(
"lo_tell result out of range for large-object descriptor %d",
296 (
errcode(ERRCODE_UNDEFINED_OBJECT),
297 errmsg(
"invalid large-object descriptor: %d",
fd)));
317 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
318 errmsg(
"must be owner of large object %u", lobjId)));
424 errmsg(
"could not open server file \"%s\": %m",
447 errmsg(
"could not read server file \"%s\": %m",
455 errmsg(
"could not close file \"%s\": %m",
506 errmsg(
"could not create server file \"%s\": %m",
518 errmsg(
"could not write server file \"%s\": %m",
525 errmsg(
"could not close file \"%s\": %m",
544 (
errcode(ERRCODE_UNDEFINED_OBJECT),
545 errmsg(
"invalid large-object descriptor: %d",
fd)));
551 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
552 errmsg(
"large object descriptor %d was not opened for writing",
641 if (lo != NULL && lo->
subid == mySubid)
644 lo->
subid = parentSubid;
731 bytea *result = NULL;
740 loSize =
inv_seek(loDesc, 0, SEEK_END);
743 if (nbytes >= 0 && nbytes <= loSize - offset)
744 result_length = nbytes;
746 result_length = loSize - offset;
757 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
758 errmsg(
"large object read request is too large")));
764 Assert(total_read == result_length);
799 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
800 errmsg(
"requested length cannot be negative")));
850 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
851 errmsg(
"permission denied for large object %u",
AclResult pg_largeobject_aclcheck_snapshot(Oid lobj_oid, Oid roleid, AclMode mode, Snapshot snapshot)
bool pg_largeobject_ownercheck(Oid lobj_oid, Oid roleid)
Datum be_lo_lseek(PG_FUNCTION_ARGS)
Datum be_loread(PG_FUNCTION_ARGS)
static MemoryContext fscxt
Datum be_lo_get(PG_FUNCTION_ARGS)
static void closeLOfd(int fd)
Datum be_lo_export(PG_FUNCTION_ARGS)
void AtEOXact_LargeObject(bool isCommit)
Datum be_lo_unlink(PG_FUNCTION_ARGS)
Datum be_lo_import_with_oid(PG_FUNCTION_ARGS)
Datum be_lo_truncate64(PG_FUNCTION_ARGS)
Datum be_lo_lseek64(PG_FUNCTION_ARGS)
Datum be_lo_tell64(PG_FUNCTION_ARGS)
int lo_write(int fd, const char *buf, int len)
Datum be_lo_from_bytea(PG_FUNCTION_ARGS)
int lo_read(int fd, char *buf, int len)
static Oid lo_import_internal(text *filename, Oid lobjOid)
Datum be_lowrite(PG_FUNCTION_ARGS)
Datum be_lo_creat(PG_FUNCTION_ARGS)
Datum be_lo_put(PG_FUNCTION_ARGS)
Datum be_lo_truncate(PG_FUNCTION_ARGS)
Datum be_lo_create(PG_FUNCTION_ARGS)
static bool lo_cleanup_needed
static bytea * lo_get_fragment_internal(Oid loOid, int64 offset, int32 nbytes)
Datum be_lo_tell(PG_FUNCTION_ARGS)
Datum be_lo_import(PG_FUNCTION_ARGS)
Datum be_lo_get_fragment(PG_FUNCTION_ARGS)
static LargeObjectDesc ** cookies
Datum be_lo_close(PG_FUNCTION_ARGS)
static void lo_truncate_internal(int32 fd, int64 len)
void AtEOSubXact_LargeObject(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Datum be_lo_open(PG_FUNCTION_ARGS)
#define MemSet(start, val, len)
#define PG_USED_FOR_ASSERTS_ONLY
int errcode_for_file_access(void)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
int CloseTransientFile(int fd)
int OpenTransientFile(const char *fileName, int fileFlags)
int OpenTransientFilePerm(const char *fileName, int fileFlags, mode_t fileMode)
#define PG_GETARG_BYTEA_PP(n)
#define PG_GETARG_TEXT_PP(n)
#define PG_RETURN_BYTEA_P(x)
#define PG_RETURN_INT64(x)
#define PG_GETARG_INT64(n)
#define PG_RETURN_INT32(x)
#define PG_GETARG_INT32(n)
void inv_truncate(LargeObjectDesc *obj_desc, int64 len)
LargeObjectDesc * inv_open(Oid lobjId, int flags, MemoryContext mcxt)
int inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
Oid inv_create(Oid lobjId)
int64 inv_seek(LargeObjectDesc *obj_desc, int64 offset, int whence)
void close_lo_relation(bool isCommit)
int inv_write(LargeObjectDesc *obj_desc, const char *buf, int nbytes)
int64 inv_tell(LargeObjectDesc *obj_desc)
bool lo_compat_privileges
void inv_close(LargeObjectDesc *obj_desc)
Assert(fmt[strlen(fmt) - 1] !='\n')
MemoryContext TopMemoryContext
void * MemoryContextAllocZero(MemoryContext context, Size size)
MemoryContext CurrentMemoryContext
void * repalloc(void *pointer, Size size)
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
static PgChecksumMode mode
static void static void status(const char *fmt,...) pg_attribute_printf(1
#define SET_VARSIZE(PTR, len)
#define VARSIZE_ANY_EXHDR(PTR)
static int fd(const char *x, int i)
ResourceOwner TopTransactionResourceOwner
void UnregisterSnapshotFromOwner(Snapshot snapshot, ResourceOwner owner)
Snapshot RegisterSnapshotOnOwner(Snapshot snapshot, ResourceOwner owner)
void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len)
SubTransactionId GetCurrentSubTransactionId(void)