94 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
95 errmsg(
"absolute path not allowed")));
99 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
100 errmsg(
"path must be in or below the data directory")));
114 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
115 errmsg(
"only superuser may access generic file functions")));
184 (
errcode(ERRCODE_DUPLICATE_FILE),
195 errmsg(
"could not open file \"%s\" for writing: %m",
318 if (
access(fn1, W_OK) < 0)
322 errmsg(
"file \"%s\" is not accessible: %m", fn1)));
327 if (fn3 &&
access(fn2, W_OK) < 0)
331 errmsg(
"file \"%s\" is not accessible: %m", fn2)));
336 rc =
access(fn3 ? fn3 : fn2, W_OK);
337 if (rc >= 0 || errno != ENOENT)
340 (
errcode(ERRCODE_DUPLICATE_FILE),
341 errmsg(
"cannot rename to target file \"%s\"",
347 if (rename(fn2, fn3) != 0)
351 errmsg(
"could not rename \"%s\" to \"%s\": %m",
354 if (rename(fn1, fn2) != 0)
358 errmsg(
"could not rename \"%s\" to \"%s\": %m",
361 if (rename(fn3, fn2) != 0)
365 errmsg(
"could not rename \"%s\" back to \"%s\": %m",
371 (
errcode(ERRCODE_UNDEFINED_FILE),
372 errmsg(
"renaming \"%s\" to \"%s\" was reverted",
377 else if (rename(fn1, fn2) != 0)
381 errmsg(
"could not rename \"%s\" to \"%s\": %m", fn1, fn2)));
475 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
476 errmsg(
"only superuser can list the log directory")));
510 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
511 errmsg(
"the log_filename parameter must equal 'postgresql-%%Y-%%m-%%d_%%H%%M%%S.log'")));
516 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
517 errmsg(
"set-valued function called in context that cannot accept a set")));
520 (
errcode(ERRCODE_SYNTAX_ERROR),
521 errmsg(
"materialize mode required, but it is not allowed in this context")));
528 TIMESTAMPOID, -1, 0);
547 char timestampbuf[32];
561 if (strlen(de->d_name) != 32
562 || strncmp(de->d_name,
"postgresql-", 11) != 0
563 || de->d_name[21] !=
'_'
564 || strcmp(de->d_name + 28,
".log") != 0)
568 strcpy(timestampbuf, de->d_name + 11);
569 timestampbuf[17] =
'\0';
576 &dtype, &
date, &fsec, &tz, &extra))
bool has_privs_of_role(Oid member, Oid role)
Datum pg_file_sync(PG_FUNCTION_ARGS)
static int64 pg_file_write_internal(text *file, text *data, bool replace)
Datum pg_file_rename(PG_FUNCTION_ARGS)
Datum pg_file_write_v1_1(PG_FUNCTION_ARGS)
Datum pg_file_unlink_v1_1(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(pg_file_write)
static char * convert_and_check_filename(text *arg)
static void requireSuperuser(void)
static Datum pg_logdir_ls_internal(FunctionCallInfo fcinfo)
Datum pg_file_unlink(PG_FUNCTION_ARGS)
Datum pg_file_write(PG_FUNCTION_ARGS)
Datum pg_logdir_ls_v1_1(PG_FUNCTION_ARGS)
Datum pg_file_rename_v1_1(PG_FUNCTION_ARGS)
static bool pg_file_rename_internal(text *file1, text *file2, text *file3)
Datum pg_logdir_ls(PG_FUNCTION_ARGS)
int ParseDateTime(const char *timestr, char *workbuf, size_t buflen, char **field, int *ftype, int maxfields, int *numfields)
int DecodeDateTime(char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp, DateTimeErrorExtra *extra)
static Datum values[MAXATTR]
int errcode_for_file_access(void)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
AttInMetadata * TupleDescGetAttInMetadata(TupleDesc tupdesc)
@ SFRM_Materialize_Random
struct dirent * ReadDir(DIR *dir, const char *dirname)
FILE * AllocateFile(const char *name, const char *mode)
int fsync_fname_ext(const char *fname, bool isdir, bool ignore_perm, int elevel)
DIR * AllocateDir(const char *dirname)
#define PG_GETARG_TEXT_PP(n)
#define PG_RETURN_INT64(x)
#define PG_GETARG_BOOL(n)
#define PG_RETURN_BOOL(x)
if(TABLE==NULL||TABLE_index==NULL)
#define IsA(nodeptr, _type_)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define is_absolute_path(filename)
bool path_is_prefix_of_path(const char *path1, const char *path2)
bool path_is_relative_and_below_cwd(const char *path)
void canonicalize_path(char *path)
char * psprintf(const char *fmt,...)
MemoryContext ecxt_per_query_memory
SetFunctionReturnMode returnMode
Tuplestorestate * setResult
TupleDesc CreateTemplateTupleDesc(int natts)
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
Tuplestorestate * tuplestore_begin_heap(bool randomAccess, bool interXact, int maxKBytes)
void tuplestore_puttuple(Tuplestorestate *state, HeapTuple tuple)
#define VARSIZE_ANY_EXHDR(PTR)
char * text_to_cstring(const text *t)