PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pg_largeobject.c File Reference
#include "postgres.h"
#include "access/genam.h"
#include "access/htup_details.h"
#include "access/table.h"
#include "catalog/catalog.h"
#include "catalog/indexing.h"
#include "catalog/pg_largeobject.h"
#include "catalog/pg_largeobject_metadata.h"
#include "miscadmin.h"
#include "utils/acl.h"
#include "utils/fmgroids.h"
#include "utils/rel.h"
Include dependency graph for pg_largeobject.c:

Go to the source code of this file.

Functions

Oid LargeObjectCreate (Oid loid)
 
void LargeObjectDrop (Oid loid)
 
bool LargeObjectExists (Oid loid)
 
bool LargeObjectExistsWithSnapshot (Oid loid, Snapshot snapshot)
 

Function Documentation

◆ LargeObjectCreate()

Oid LargeObjectCreate ( Oid  loid)

Definition at line 38 of file pg_largeobject.c.

39{
45 Oid ownerId;
46 Acl *lomacl;
47
50
51 /*
52 * Insert metadata of the largeobject
53 */
54 memset(values, 0, sizeof(values));
55 memset(nulls, false, sizeof(nulls));
56
57 if (OidIsValid(loid))
58 loid_new = loid;
59 else
63 ownerId = GetUserId();
65
68 = ObjectIdGetDatum(ownerId);
69
70 if (lomacl != NULL)
73 else
75
77 values, nulls);
78
80
82
84
85 /* dependencies on roles mentioned in default ACL */
87 ownerId, lomacl);
88
89 return loid_new;
90}
void recordDependencyOnNewAcl(Oid classId, Oid objectId, int32 objsubId, Oid ownerId, Acl *acl)
Definition aclchk.c:4327
Acl * get_user_default_acl(ObjectType objtype, Oid ownerId, Oid nsp_oid)
Definition aclchk.c:4247
static Datum values[MAXATTR]
Definition bootstrap.c:155
#define OidIsValid(objectId)
Definition c.h:788
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
Definition catalog.c:448
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
Definition heaptuple.c:1117
void heap_freetuple(HeapTuple htup)
Definition heaptuple.c:1435
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
Definition indexing.c:233
#define RowExclusiveLock
Definition lockdefs.h:38
Oid GetUserId(void)
Definition miscinit.c:469
@ OBJECT_LARGEOBJECT
static Datum PointerGetDatum(const void *X)
Definition postgres.h:352
static Datum ObjectIdGetDatum(Oid X)
Definition postgres.h:262
uint64_t Datum
Definition postgres.h:70
#define InvalidOid
unsigned int Oid
static int fb(int x)
#define RelationGetDescr(relation)
Definition rel.h:540
void table_close(Relation relation, LOCKMODE lockmode)
Definition table.c:126
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition table.c:40

References CatalogTupleInsert(), fb(), get_user_default_acl(), GetNewOidWithIndex(), GetUserId(), heap_form_tuple(), heap_freetuple(), InvalidOid, OBJECT_LARGEOBJECT, ObjectIdGetDatum(), OidIsValid, PointerGetDatum(), recordDependencyOnNewAcl(), RelationGetDescr, RowExclusiveLock, table_close(), table_open(), and values.

Referenced by inv_create().

◆ LargeObjectDrop()

void LargeObjectDrop ( Oid  loid)

Definition at line 97 of file pg_largeobject.c.

98{
101 ScanKeyData skey[1];
102 SysScanDesc scan;
103 HeapTuple tuple;
104
107
110
111 /*
112 * Delete an entry from pg_largeobject_metadata
113 */
114 ScanKeyInit(&skey[0],
118
121 NULL, 1, skey);
122
123 tuple = systable_getnext(scan);
124 if (!HeapTupleIsValid(tuple))
127 errmsg("large object %u does not exist", loid)));
128
130
131 systable_endscan(scan);
132
133 /*
134 * Delete all the associated entries from pg_largeobject
135 */
136 ScanKeyInit(&skey[0],
140
143 NULL, 1, skey);
144 while (HeapTupleIsValid(tuple = systable_getnext(scan)))
145 {
147 }
148
149 systable_endscan(scan);
150
152
154}
int errcode(int sqlerrcode)
Definition elog.c:863
int errmsg(const char *fmt,...)
Definition elog.c:1080
#define ERROR
Definition elog.h:39
#define ereport(elevel,...)
Definition elog.h:150
void systable_endscan(SysScanDesc sysscan)
Definition genam.c:603
HeapTuple systable_getnext(SysScanDesc sysscan)
Definition genam.c:514
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
Definition genam.c:388
#define HeapTupleIsValid(tuple)
Definition htup.h:78
void CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid)
Definition indexing.c:365
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Definition scankey.c:76
#define BTEqualStrategyNumber
Definition stratnum.h:31
ItemPointerData t_self
Definition htup.h:65

References BTEqualStrategyNumber, CatalogTupleDelete(), ereport, errcode(), errmsg(), ERROR, fb(), HeapTupleIsValid, ObjectIdGetDatum(), RowExclusiveLock, ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), HeapTupleData::t_self, table_close(), and table_open().

Referenced by doDeletion().

◆ LargeObjectExists()

bool LargeObjectExists ( Oid  loid)

Definition at line 169 of file pg_largeobject.c.

170{
172}
bool LargeObjectExistsWithSnapshot(Oid loid, Snapshot snapshot)

References fb(), and LargeObjectExistsWithSnapshot().

Referenced by be_lo_unlink(), get_object_address(), getObjectDescription(), and getObjectIdentityParts().

◆ LargeObjectExistsWithSnapshot()

bool LargeObjectExistsWithSnapshot ( Oid  loid,
Snapshot  snapshot 
)