diff options
| author | Pavan Deolasee | 2015-04-27 06:16:51 +0000 |
|---|---|---|
| committer | Pavan Deolasee | 2015-04-27 06:16:51 +0000 |
| commit | f205105325c2502852214872808941bc0794a59e (patch) | |
| tree | 2578203bceb5aac5623e796afeae0388e349706a /src/include/common | |
| parent | 7fc84ffa7045cc64fefba680b5ca556b2fab4554 (diff) | |
| parent | ab76208e3df6841b3770edeece57d0f048392237 (diff) | |
Merge commit 'ab76208e3df6841b3770edeece57d0f048392237' into XL_MASTER_MERGE_9_4
Diffstat (limited to 'src/include/common')
| -rw-r--r-- | src/include/common/fe_memutils.h | 34 | ||||
| -rw-r--r-- | src/include/common/relpath.h | 79 | ||||
| -rw-r--r-- | src/include/common/username.h | 15 |
3 files changed, 128 insertions, 0 deletions
diff --git a/src/include/common/fe_memutils.h b/src/include/common/fe_memutils.h new file mode 100644 index 0000000000..61c1b6fd2d --- /dev/null +++ b/src/include/common/fe_memutils.h @@ -0,0 +1,34 @@ +/* + * fe_memutils.h + * memory management support for frontend code + * + * Copyright (c) 2003-2014, PostgreSQL Global Development Group + * + * src/include/common/fe_memutils.h + */ +#ifndef FE_MEMUTILS_H +#define FE_MEMUTILS_H + +/* "Safe" memory allocation functions --- these exit(1) on failure */ +extern char *pg_strdup(const char *in); +extern void *pg_malloc(size_t size); +extern void *pg_malloc0(size_t size); +extern void *pg_realloc(void *pointer, size_t size); +extern void pg_free(void *pointer); + +/* Equivalent functions, deliberately named the same as backend functions */ +extern char *pstrdup(const char *in); +extern void *palloc(Size size); +extern void *palloc0(Size size); +extern void *repalloc(void *pointer, Size size); +extern void pfree(void *pointer); + +/* sprintf into a palloc'd buffer --- these are in psprintf.c */ +extern char * +psprintf(const char *fmt,...) +__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); +extern size_t +pvsnprintf(char *buf, size_t len, const char *fmt, va_list args) +__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 0))); + +#endif /* FE_MEMUTILS_H */ diff --git a/src/include/common/relpath.h b/src/include/common/relpath.h new file mode 100644 index 0000000000..bd56d47660 --- /dev/null +++ b/src/include/common/relpath.h @@ -0,0 +1,79 @@ +/*------------------------------------------------------------------------- + * + * relpath.h + * Declarations for GetRelationPath() and friends + * + * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/common/relpath.h + * + *------------------------------------------------------------------------- + */ +#ifndef RELPATH_H +#define RELPATH_H + +/* + * Stuff for fork names. + * + * The physical storage of a relation consists of one or more forks. + * The main fork is always created, but in addition to that there can be + * additional forks for storing various metadata. ForkNumber is used when + * we need to refer to a specific fork in a relation. + */ +typedef enum ForkNumber +{ + InvalidForkNumber = -1, + MAIN_FORKNUM = 0, + FSM_FORKNUM, + VISIBILITYMAP_FORKNUM, + INIT_FORKNUM + + /* + * NOTE: if you add a new fork, change MAX_FORKNUM and possibly + * FORKNAMECHARS below, and update the forkNames array in + * src/common/relpath.c + */ +} ForkNumber; + +#define MAX_FORKNUM INIT_FORKNUM + +#define FORKNAMECHARS 4 /* max chars for a fork name */ + +extern const char *const forkNames[]; + +extern ForkNumber forkname_to_number(const char *forkName); +extern int forkname_chars(const char *str, ForkNumber *fork); + +/* + * Stuff for computing filesystem pathnames for relations. + */ +extern char *GetDatabasePath(Oid dbNode, Oid spcNode); + +extern char *GetRelationPath(Oid dbNode, Oid spcNode, Oid relNode, + int backendId, ForkNumber forkNumber); + +/* + * Wrapper macros for GetRelationPath. Beware of multiple + * evaluation of the RelFileNode or RelFileNodeBackend argument! + */ + +/* First argument is a RelFileNode */ +#define relpathbackend(rnode, backend, forknum) \ + GetRelationPath((rnode).dbNode, (rnode).spcNode, (rnode).relNode, \ + backend, forknum) + +/* First argument is a RelFileNode */ +#define relpathperm(rnode, forknum) \ + relpathbackend(rnode, InvalidBackendId, forknum) + +/* First argument is a RelFileNodeBackend */ +#ifdef XCP +#define relpath(rnode, forknum) \ + relpathbackend((rnode).node, InvalidBackendId, (forknum)) +#else +#define relpath(rnode, forknum) \ + relpathbackend((rnode).node, (rnode).backend, forknum) +#endif + +#endif /* RELPATH_H */ diff --git a/src/include/common/username.h b/src/include/common/username.h new file mode 100644 index 0000000000..115d1ed450 --- /dev/null +++ b/src/include/common/username.h @@ -0,0 +1,15 @@ +/* + * username.h + * lookup effective username + * + * Copyright (c) 2003-2014, PostgreSQL Global Development Group + * + * src/include/common/username.h + */ +#ifndef USERNAME_H +#define USERNAME_H + +extern const char *get_user_name(char **errstr); +extern const char *get_user_name_or_exit(const char *progname); + +#endif /* USERNAME_H */ |
