48#include "utils/fmgroids.h"
140 datafield = &(tuple->data);
144 datafield = (
bytea *)
152 errmsg(
"pg_largeobject entry for OID %u, page %d has invalid data field size %d",
153 tuple->loid, tuple->pageno,
len)));
154 *pdatafield = datafield;
233 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
234 errmsg(
"invalid flags for opening a large object: %d",
246 (
errcode(ERRCODE_UNDEFINED_OBJECT),
247 errmsg(
"large object %u does not exist", lobjId)));
258 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
259 errmsg(
"permission denied for large object %u",
270 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
271 errmsg(
"permission denied for large object %u",
280 retval->
flags = descflags;
318 object.
classId = LargeObjectRelationId;
319 object.objectId = lobjId;
320 object.objectSubId = 0;
352 Anum_pg_largeobject_loid,
374 elog(
ERROR,
"null field found in pg_largeobject");
409 newoffset = obj_desc->
offset + offset;
416 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
417 errmsg(
"invalid whence setting: %d", whence)));
428 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
432 obj_desc->
offset = newoffset;
467 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
468 errmsg(
"permission denied for large object %u",
477 Anum_pg_largeobject_loid,
482 Anum_pg_largeobject_pageno,
496 elog(
ERROR,
"null field found in pg_largeobject");
505 if (pageoff > obj_desc->
offset)
507 n = pageoff - obj_desc->
offset;
508 n = (n <= (nbytes - nread)) ? n : (nbytes - nread);
517 off = (int) (obj_desc->
offset - pageoff);
524 n = (n <= (nbytes - nread)) ? n : (nbytes - nread);
525 memcpy(
buf + nread,
VARDATA(datafield) + off, n);
565 char *workb =
VARDATA(&workbuf.hdr);
568 bool nulls[Natts_pg_largeobject];
569 bool replace[Natts_pg_largeobject];
578 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
579 errmsg(
"permission denied for large object %u",
588 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
589 errmsg(
"invalid large object write request size: %d",
597 Anum_pg_largeobject_loid,
602 Anum_pg_largeobject_pageno,
613 while (nwritten < nbytes)
624 elog(
ERROR,
"null field found in pg_largeobject");
626 Assert(olddata->pageno >= pageno);
628 neednextpage =
false;
635 if (olddata != NULL && olddata->pageno == pageno)
658 n = (n <= (nbytes - nwritten)) ? n : (nbytes - nwritten);
659 memcpy(workb + off,
buf + nwritten, n);
671 memset(nulls,
false,
sizeof(nulls));
672 memset(replace,
false,
sizeof(replace));
674 replace[Anum_pg_largeobject_data - 1] =
true;
703 n = (n <= (nbytes - nwritten)) ? n : (nbytes - nwritten);
704 memcpy(workb + off,
buf + nwritten, n);
715 memset(nulls,
false,
sizeof(nulls));
756 char *workb =
VARDATA(&workbuf.hdr);
759 bool nulls[Natts_pg_largeobject];
760 bool replace[Natts_pg_largeobject];
768 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
769 errmsg(
"permission denied for large object %u",
778 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
790 Anum_pg_largeobject_loid,
795 Anum_pg_largeobject_pageno,
810 elog(
ERROR,
"null field found in pg_largeobject");
812 Assert(olddata->pageno >= pageno);
820 if (olddata != NULL && olddata->pageno == pageno)
828 memcpy(workb,
VARDATA(datafield), pagelen);
837 MemSet(workb + pagelen, 0, off - pagelen);
846 memset(nulls,
false,
sizeof(nulls));
847 memset(replace,
false,
sizeof(replace));
849 replace[Anum_pg_largeobject_data - 1] =
true;
865 Assert(olddata->pageno > pageno);
885 memset(nulls,
false,
sizeof(nulls));
AclResult pg_largeobject_aclcheck_snapshot(Oid lobj_oid, Oid roleid, AclMode mode, Snapshot snapshot)
static Datum values[MAXATTR]
#define InvalidSubTransactionId
#define Assert(condition)
#define PointerIsValid(pointer)
#define MemSet(start, val, len)
void performDeletion(const ObjectAddress *object, DropBehavior behavior, int flags)
struct varlena * detoast_attr(struct varlena *attr)
int errmsg_internal(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
SysScanDesc systable_beginscan_ordered(Relation heapRelation, Relation indexRelation, Snapshot snapshot, int nkeys, ScanKey key)
void systable_endscan_ordered(SysScanDesc sysscan)
HeapTuple systable_getnext_ordered(SysScanDesc sysscan, ScanDirection direction)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
#define HeapTupleHasNulls(tuple)
void index_close(Relation relation, LOCKMODE lockmode)
Relation index_open(Oid relationId, LOCKMODE lockmode)
void CatalogTupleInsertWithInfo(Relation heapRel, HeapTuple tup, CatalogIndexState indstate)
void CatalogCloseIndexes(CatalogIndexState indstate)
CatalogIndexState CatalogOpenIndexes(Relation heapRel)
void CatalogTupleDelete(Relation heapRel, ItemPointer tid)
void CatalogTupleUpdateWithInfo(Relation heapRel, ItemPointer otid, HeapTuple tup, CatalogIndexState indstate)
LargeObjectDesc * inv_open(Oid lobjId, int flags, MemoryContext mcxt)
static Relation lo_index_r
void inv_truncate(LargeObjectDesc *obj_desc, int64 len)
int inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
static void getdatafield(Form_pg_largeobject tuple, bytea **pdatafield, int *plen, bool *pfreeit)
Oid inv_create(Oid lobjId)
static Relation lo_heap_r
static void open_lo_relation(void)
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)
static uint64 inv_getsize(LargeObjectDesc *obj_desc)
if(TABLE==NULL||TABLE_index==NULL)
#define MAX_LARGE_OBJECT_SIZE
void * MemoryContextAlloc(MemoryContext context, Size size)
void pfree(void *pointer)
#define InvokeObjectPostCreateHook(classId, objectId, subId)
#define ERRCODE_DATA_CORRUPTED
bool LargeObjectExistsWithSnapshot(Oid loid, Snapshot snapshot)
Oid LargeObjectCreate(Oid loid)
FormData_pg_largeobject * Form_pg_largeobject
void recordDependencyOnOwner(Oid classId, Oid objectId, Oid owner)
static Datum PointerGetDatum(const void *X)
static Datum ObjectIdGetDatum(Oid X)
static Datum Int32GetDatum(int32 X)
#define RelationGetDescr(relation)
ResourceOwner TopTransactionResourceOwner
ResourceOwner CurrentResourceOwner
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Snapshot GetActiveSnapshot(void)
#define BTEqualStrategyNumber
#define BTGreaterEqualStrategyNumber
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
#define VARATT_IS_EXTENDED(PTR)
#define SET_VARSIZE(PTR, len)
void CommandCounterIncrement(void)