PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include "access/xact.h"
#include "catalog/pg_largeobject.h"
#include "libpq/be-fsstubs.h"
#include "libpq/libpq-fs.h"
#include "miscadmin.h"
#include "storage/fd.h"
#include "storage/large_object.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/memutils.h"
#include "utils/snapmgr.h"
#include "varatt.h"
Go to the source code of this file.
Macros | |
#define | BUFSIZE 8192 |
Variables | |
static LargeObjectDesc ** | cookies = NULL |
static int | cookies_size = 0 |
static bool | lo_cleanup_needed = false |
static MemoryContext | fscxt = NULL |
#define BUFSIZE 8192 |
Definition at line 61 of file be-fsstubs.c.
void AtEOSubXact_LargeObject | ( | bool | isCommit, |
SubTransactionId | mySubid, | ||
SubTransactionId | parentSubid | ||
) |
Definition at line 648 of file be-fsstubs.c.
References closeLOfd(), cookies, cookies_size, fscxt, i, and LargeObjectDesc::subid.
Referenced by AbortSubTransaction(), and CommitSubTransaction().
void AtEOXact_LargeObject | ( | bool | isCommit | ) |
Definition at line 602 of file be-fsstubs.c.
References close_lo_relation(), closeLOfd(), cookies, cookies_size, fscxt, i, lo_cleanup_needed, and MemoryContextDelete().
Referenced by AbortTransaction(), CommitTransaction(), and PrepareTransaction().
Datum be_lo_close | ( | PG_FUNCTION_ARGS | ) |
Definition at line 126 of file be-fsstubs.c.
References closeLOfd(), cookies, cookies_size, DEBUG4, elog, ereport, errcode(), errmsg(), ERROR, fd(), PG_GETARG_INT32, and PG_RETURN_INT32.
Datum be_lo_creat | ( | PG_FUNCTION_ARGS | ) |
Definition at line 249 of file be-fsstubs.c.
References inv_create(), InvalidOid, lo_cleanup_needed, PG_RETURN_OID, and PreventCommandIfReadOnly().
Datum be_lo_create | ( | PG_FUNCTION_ARGS | ) |
Definition at line 262 of file be-fsstubs.c.
References inv_create(), lo_cleanup_needed, PG_GETARG_OID, PG_RETURN_OID, and PreventCommandIfReadOnly().
Datum be_lo_export | ( | PG_FUNCTION_ARGS | ) |
Definition at line 481 of file be-fsstubs.c.
References buf, BUFSIZE, CloseTransientFile(), CurrentMemoryContext, ereport, errcode_for_file_access(), errmsg(), ERROR, fd(), filename, inv_close(), inv_open(), inv_read(), INV_READ, lo_cleanup_needed, MAXPGPATH, OpenTransientFilePerm(), PG_BINARY, PG_END_TRY, PG_FINALLY, PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_INT32, PG_TRY, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR, text_to_cstring_buffer(), and write.
Datum be_lo_from_bytea | ( | PG_FUNCTION_ARGS | ) |
Definition at line 827 of file be-fsstubs.c.
References Assert, CurrentMemoryContext, inv_close(), inv_create(), inv_open(), inv_write(), INV_WRITE, lo_cleanup_needed, PG_GETARG_BYTEA_PP, PG_GETARG_OID, PG_RETURN_OID, PG_USED_FOR_ASSERTS_ONLY, PreventCommandIfReadOnly(), str, VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Datum be_lo_get | ( | PG_FUNCTION_ARGS | ) |
Definition at line 792 of file be-fsstubs.c.
References lo_get_fragment_internal(), PG_GETARG_OID, and PG_RETURN_BYTEA_P.
Datum be_lo_get_fragment | ( | PG_FUNCTION_ARGS | ) |
Definition at line 806 of file be-fsstubs.c.
References ereport, errcode(), errmsg(), ERROR, lo_get_fragment_internal(), PG_GETARG_INT32, PG_GETARG_INT64, PG_GETARG_OID, and PG_RETURN_BYTEA_P.
Datum be_lo_import | ( | PG_FUNCTION_ARGS | ) |
Definition at line 398 of file be-fsstubs.c.
References filename, InvalidOid, lo_import_internal(), PG_GETARG_TEXT_PP, and PG_RETURN_OID.
Datum be_lo_import_with_oid | ( | PG_FUNCTION_ARGS | ) |
Definition at line 410 of file be-fsstubs.c.
References filename, lo_import_internal(), PG_GETARG_OID, PG_GETARG_TEXT_PP, and PG_RETURN_OID.
Datum be_lo_lseek | ( | PG_FUNCTION_ARGS | ) |
Definition at line 206 of file be-fsstubs.c.
References cookies, cookies_size, ereport, errcode(), errmsg(), ERROR, fd(), inv_seek(), PG_GETARG_INT32, and PG_RETURN_INT32.
Datum be_lo_lseek64 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 231 of file be-fsstubs.c.
References cookies, cookies_size, ereport, errcode(), errmsg(), ERROR, fd(), inv_seek(), PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_INT64.
Datum be_lo_open | ( | PG_FUNCTION_ARGS | ) |
Definition at line 87 of file be-fsstubs.c.
References Assert, cookies, DEBUG4, elog, fd(), fscxt, GetCurrentSubTransactionId(), inv_open(), INV_WRITE, mode, newLOfd(), PG_GETARG_INT32, PG_GETARG_OID, PG_RETURN_INT32, PreventCommandIfReadOnly(), RegisterSnapshotOnOwner(), LargeObjectDesc::snapshot, LargeObjectDesc::subid, and TopTransactionResourceOwner.
Datum be_lo_put | ( | PG_FUNCTION_ARGS | ) |
Definition at line 850 of file be-fsstubs.c.
References Assert, CurrentMemoryContext, inv_close(), inv_open(), inv_seek(), inv_write(), INV_WRITE, lo_cleanup_needed, PG_GETARG_BYTEA_PP, PG_GETARG_INT64, PG_GETARG_OID, PG_RETURN_VOID, PG_USED_FOR_ASSERTS_ONLY, PreventCommandIfReadOnly(), str, VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Datum be_lo_tell | ( | PG_FUNCTION_ARGS | ) |
Definition at line 275 of file be-fsstubs.c.
References cookies, cookies_size, ereport, errcode(), errmsg(), ERROR, fd(), inv_tell(), PG_GETARG_INT32, and PG_RETURN_INT32.
Datum be_lo_tell64 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 298 of file be-fsstubs.c.
References cookies, cookies_size, ereport, errcode(), errmsg(), ERROR, fd(), inv_tell(), PG_GETARG_INT32, and PG_RETURN_INT64.
Datum be_lo_truncate | ( | PG_FUNCTION_ARGS | ) |
Definition at line 574 of file be-fsstubs.c.
References fd(), len, lo_truncate_internal(), PG_GETARG_INT32, PG_RETURN_INT32, and PreventCommandIfReadOnly().
Datum be_lo_truncate64 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 586 of file be-fsstubs.c.
References fd(), len, lo_truncate_internal(), PG_GETARG_INT32, PG_GETARG_INT64, PG_RETURN_INT32, and PreventCommandIfReadOnly().
Datum be_lo_unlink | ( | PG_FUNCTION_ARGS | ) |
Definition at line 314 of file be-fsstubs.c.
References closeLOfd(), cookies, cookies_size, ereport, errcode(), errmsg(), ERROR, fscxt, GetUserId(), i, inv_drop(), lo_compat_privileges, object_ownercheck(), PG_GETARG_OID, PG_RETURN_INT32, and PreventCommandIfReadOnly().
Referenced by lo_manage().
Datum be_loread | ( | PG_FUNCTION_ARGS | ) |
Definition at line 357 of file be-fsstubs.c.
References fd(), len, lo_read(), palloc(), PG_GETARG_INT32, PG_RETURN_BYTEA_P, SET_VARSIZE, VARDATA, and VARHDRSZ.
Datum be_lowrite | ( | PG_FUNCTION_ARGS | ) |
Definition at line 375 of file be-fsstubs.c.
References fd(), lo_write(), PG_GETARG_BYTEA_PP, PG_GETARG_INT32, PG_RETURN_INT32, PreventCommandIfReadOnly(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.
|
static |
Definition at line 716 of file be-fsstubs.c.
References cookies, fd(), inv_close(), LargeObjectDesc::snapshot, TopTransactionResourceOwner, and UnregisterSnapshotFromOwner().
Referenced by AtEOSubXact_LargeObject(), AtEOXact_LargeObject(), be_lo_close(), and be_lo_unlink().
Definition at line 741 of file be-fsstubs.c.
References Assert, CurrentMemoryContext, ereport, errcode(), errmsg(), ERROR, inv_close(), inv_open(), inv_read(), INV_READ, inv_seek(), lo_cleanup_needed, MaxAllocSize, palloc(), PG_USED_FOR_ASSERTS_ONLY, SET_VARSIZE, VARDATA, and VARHDRSZ.
Referenced by be_lo_get(), and be_lo_get_fragment().
Definition at line 419 of file be-fsstubs.c.
References Assert, buf, BUFSIZE, CloseTransientFile(), CurrentMemoryContext, ereport, errcode_for_file_access(), errmsg(), ERROR, fd(), filename, inv_close(), inv_create(), inv_open(), inv_write(), INV_WRITE, lo_cleanup_needed, MAXPGPATH, OpenTransientFile(), PG_BINARY, PG_USED_FOR_ASSERTS_ONLY, PreventCommandIfReadOnly(), read, and text_to_cstring_buffer().
Referenced by be_lo_import(), and be_lo_import_with_oid().
int lo_read | ( | int | fd, |
char * | buf, | ||
int | len | ||
) |
Definition at line 154 of file be-fsstubs.c.
References buf, cookies, cookies_size, ereport, errcode(), errmsg(), ERROR, fd(), LargeObjectDesc::flags, IFS_RDLOCK, inv_read(), and len.
Referenced by be_loread(), dumpLOs(), exportFile(), and pickout().
|
static |
Definition at line 553 of file be-fsstubs.c.
References cookies, cookies_size, ereport, errcode(), errmsg(), ERROR, fd(), LargeObjectDesc::flags, IFS_WRLOCK, inv_truncate(), and len.
Referenced by be_lo_truncate(), and be_lo_truncate64().
int lo_write | ( | int | fd, |
const char * | buf, | ||
int | len | ||
) |
Definition at line 182 of file be-fsstubs.c.
References buf, cookies, cookies_size, ereport, errcode(), errmsg(), ERROR, fd(), LargeObjectDesc::flags, IFS_WRLOCK, inv_write(), and len.
Referenced by be_lowrite(), dump_lo_buf(), importFile(), and overwrite().
|
static |
Definition at line 675 of file be-fsstubs.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, cookies, cookies_size, fscxt, i, lo_cleanup_needed, MemoryContextAllocZero(), repalloc0_array, and TopMemoryContext.
Referenced by be_lo_open().
|
static |
Definition at line 71 of file be-fsstubs.c.
Referenced by AtEOSubXact_LargeObject(), AtEOXact_LargeObject(), be_lo_close(), be_lo_lseek(), be_lo_lseek64(), be_lo_open(), be_lo_tell(), be_lo_tell64(), be_lo_unlink(), closeLOfd(), lo_read(), lo_truncate_internal(), lo_write(), and newLOfd().
|
static |
Definition at line 72 of file be-fsstubs.c.
Referenced by AtEOSubXact_LargeObject(), AtEOXact_LargeObject(), be_lo_close(), be_lo_lseek(), be_lo_lseek64(), be_lo_tell(), be_lo_tell64(), be_lo_unlink(), lo_read(), lo_truncate_internal(), lo_write(), and newLOfd().
|
static |
Definition at line 75 of file be-fsstubs.c.
Referenced by AtEOSubXact_LargeObject(), AtEOXact_LargeObject(), be_lo_open(), be_lo_unlink(), and newLOfd().
Definition at line 74 of file be-fsstubs.c.
Referenced by AtEOXact_LargeObject(), be_lo_creat(), be_lo_create(), be_lo_export(), be_lo_from_bytea(), be_lo_put(), lo_get_fragment_internal(), lo_import_internal(), and newLOfd().