40 #include "utils/fmgroids.h"
50 #define ALLOC(t, c) ((t *) calloc((unsigned)(c), sizeof(t)))
100 F_BYTEAIN, F_BYTEAOUT},
102 F_CHARIN, F_CHAROUT},
104 F_INT2IN, F_INT2OUT},
106 F_INT4IN, F_INT4OUT},
108 F_FLOAT4IN, F_FLOAT4OUT},
110 F_NAMEIN, F_NAMEOUT},
112 F_REGCLASSIN, F_REGCLASSOUT},
114 F_REGPROCIN, F_REGPROCOUT},
116 F_REGTYPEIN, F_REGTYPEOUT},
118 F_REGROLEIN, F_REGROLEOUT},
120 F_REGNAMESPACEIN, F_REGNAMESPACEOUT},
122 F_TEXTIN, F_TEXTOUT},
132 F_PG_NODE_TREE_IN, F_PG_NODE_TREE_OUT},
134 F_INT2VECTORIN, F_INT2VECTOROUT},
136 F_OIDVECTORIN, F_OIDVECTOROUT},
138 F_ARRAY_IN, F_ARRAY_OUT},
140 F_ARRAY_IN, F_ARRAY_OUT},
142 F_ARRAY_IN, F_ARRAY_OUT},
144 F_ARRAY_IN, F_ARRAY_OUT},
146 F_ARRAY_IN, F_ARRAY_OUT}
213 if (argc > 1 && strcmp(argv[1],
"--boot") == 0)
222 while ((flag =
getopt(argc, argv,
"B:c:d:D:Fkr:x:-:")) != -1)
230 userDoption = strdup(
optarg);
268 (
errcode(ERRCODE_SYNTAX_ERROR),
269 errmsg(
"--%s requires a value",
273 (
errcode(ERRCODE_SYNTAX_ERROR),
274 errmsg(
"-c %s requires a value",
285 write_stderr(
"Try \"%s --help\" for more information.\n",
294 write_stderr(
"%s: invalid command-line arguments\n", progname);
308 statmsg =
"startup process";
311 statmsg =
"writer process";
314 statmsg =
"checkpointer process";
317 statmsg =
"wal writer process";
320 statmsg =
"wal receiver process";
323 statmsg =
"??? process";
580 memcpy((
char *) &(*app)->am_typ,
582 sizeof((*app)->am_typ));
589 if (boot_reldesc !=
NULL)
603 ATTRIBUTE_FIXED_PART_SIZE);
608 elog(
DEBUG4,
"create attribute %d name %s len %d num %d type %u",
609 i,
NameStr(at->attname), at->attlen, at->attnum,
627 elog(
ERROR,
"close of %s when %s was expected",
631 elog(
ERROR,
"close of %s before any relation was opened",
635 if (boot_reldesc ==
NULL)
636 elog(
ERROR,
"no open relation to close");
661 if (boot_reldesc !=
NULL)
663 elog(
WARNING,
"no open relations allowed with CREATE command");
732 #define MARKNOTNULL(att) \
733 ((att)->attlen > 0 || \
734 (att)->atttypid == OIDVECTOROID || \
735 (att)->atttypid == INT2VECTOROID)
742 for (i = 0; i < attnum; i++)
774 if (objectid != (
Oid) 0)
807 elog(
DEBUG4,
"inserting column %d value \"%s\"", i, value);
812 &typlen, &typbyval, &typalign,
813 &typdelim, &typioparam,
814 &typinput, &typoutput);
847 if (boot_reldesc !=
NULL)
873 for (app = Typ; *app !=
NULL; app++)
907 sizeof((*app)->am_typ));
913 elog(
ERROR,
"unrecognized type \"%s\"", type);
945 while (*app && (*app)->
am_oid != typid)
949 elog(
ERROR,
"type OID %u not found in Typ list", typid);
951 *typlen = ap->
am_typ.typlen;
952 *typbyval = ap->
am_typ.typbyval;
953 *typalign = ap->
am_typ.typalign;
954 *typdelim = ap->
am_typ.typdelim;
958 *typioparam = ap->
am_typ.typelem;
962 *typinput = ap->
am_typ.typinput;
963 *typoutput = ap->
am_typ.typoutput;
970 for (typeindex = 0; typeindex <
n_types; typeindex++)
972 if (TypInfo[typeindex].oid == typid)
975 if (typeindex >= n_types)
976 elog(
ERROR,
"type OID %u not found in TypInfo", typid);
978 *typlen = TypInfo[typeindex].
len;
979 *typbyval = TypInfo[typeindex].
byval;
980 *typalign = TypInfo[typeindex].
align;
986 *typioparam = TypInfo[typeindex].
elem;
990 *typinput = TypInfo[typeindex].
inproc;
991 *typoutput = TypInfo[typeindex].
outproc;
1035 for (i = 0; i <
NAMEDATALEN - 2 && s[
i] !=
'['; i++, j++)
void InitAuxiliaryProcess(void)
struct _IndexList * il_next
void RelationMapFinishBootstrap(void)
#define BOOTCOL_NULL_FORCE_NULL
void heap_endscan(HeapScanDesc scan)
#define PointerGetDatum(X)
void InsertOneTuple(Oid objectid)
char * pstrdup(const char *in)
#define RelationGetForm(relation)
char * psprintf(const char *fmt,...)
void InitStandaloneProcess(const char *argv0)
void ParseLongOption(const char *string, char **name, char **value)
#define BOOTCOL_NULL_AUTO
void StartupProcessMain(void)
void ValidatePgVersion(const char *path)
Form_pg_attribute * attrs
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static IndexList * ILHead
int errcode(int sqlerrcode)
#define MemSet(start, val, len)
#define SetProcessingMode(mode)
static MemoryContext nogc
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
TupleDesc CreateTupleDesc(int natts, bool hasoid, Form_pg_attribute *attrs)
void heap_freetuple(HeapTuple htup)
void closerel(char *name)
static void bootstrap_signals(void)
static struct typmap * Ap
int namestrcpy(Name name, const char *str)
#define OidIsValid(objectId)
#define BOOTCOL_NULL_FORCE_NOT_NULL
static void BootstrapModeMain(void)
int getopt(int nargc, char *const *nargv, const char *ostr)
#define ALLOCSET_DEFAULT_MINSIZE
void * copyObject(const void *from)
#define HeapTupleSetOid(tuple, oid)
static char * relname(char const *dir, char const *base)
void WalReceiverMain(void)
List * ii_ExpressionsState
void pfree(void *pointer)
void InsertOneValue(char *value, int i)
void CreateDataDirLockFile(bool amPostmaster)
void InitXLOGAccess(void)
struct _IndexList IndexList
char OutputFileName[MAXPGPATH]
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
#define DEFAULT_COLLATION_OID
void before_shmem_exit(pg_on_exit_callback function, Datum arg)
#define RelationGetRelationName(relation)
void ChangeToDataDir(void)
FormData_pg_attribute * Form_pg_attribute
void boot_openrel(char *relname)
static void pgstat_report_wait_end(void)
HeapScanDesc heap_beginscan_catalog(Relation relation, int nkeys, ScanKey key)
#define write_stderr(str)
#define ATTRIBUTE_FIXED_PART_SIZE
void index_register(Oid heap, Oid ind, IndexInfo *indexInfo)
#define ereport(elevel, rest)
void DefineAttr(char *name, char *type, int attnum, int nullness)
#define AssertArg(condition)
void index_build(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo, bool isprimary, bool isreindex)
MemoryContext AllocSetContextCreate(MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize)
static struct typmap ** Typ
static void ShutdownAuxiliaryProcess(int code, Datum arg)
bool SelectConfigFiles(const char *userDoption, const char *progname)
AuxProcType MyAuxProcType
static void cleanup(void)
Oid simple_heap_insert(Relation relation, HeapTuple tup)
HeapTuple heap_getnext(HeapScanDesc scan, ScanDirection direction)
Relation heap_open(Oid relationId, LOCKMODE lockmode)
Relation heap_openrv(const RangeVar *relation, LOCKMODE lockmode)
void CheckpointerMain(void)
pqsigfunc pqsignal(int signum, pqsigfunc handler)
size_t strlcpy(char *dst, const char *src, size_t siz)
int errmsg_internal(const char *fmt,...)
#define Assert(condition)
void InitializeMaxBackends(void)
static Form_pg_attribute AllocateAttribute(void)
static const struct typinfo TypInfo[]
void BackgroundWriterMain(void)
void index_close(Relation relation, LOCKMODE lockmode)
static const char * userDoption
static Datum values[MAXATTR]
#define IsBootstrapProcessingMode()
void ProcSignalInit(int pss_idx)
#define PG_DATA_CHECKSUM_VERSION
static Oid gettype(char *type)
void InitPostgres(const char *in_dbname, Oid dboid, const char *username, Oid useroid, char *out_dbname)
char * OidOutputFunctionCall(Oid functionId, Datum val)
int errmsg(const char *fmt,...)
#define ALLOCSET_DEFAULT_INITSIZE
static void CheckerModeMain(void)
void AuxiliaryProcessMain(int argc, char *argv[])
#define ALLOCSET_DEFAULT_MAXSIZE
void InitBufferPoolBackend(void)
uint32 bootstrap_data_checksum_version
char * MapArrayTypeName(const char *s)
void LWLockReleaseAll(void)
#define HeapTupleGetOid(tuple)
uint16 * ii_ExclusionStrats
void InsertOneNull(int i)
#define PointerIsValid(pointer)
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
Relation index_open(Oid relationId, LOCKMODE lockmode)
RangeVar * makeRangeVar(char *schemaname, char *relname, int location)
void init_ps_display(const char *username, const char *dbname, const char *host_info, const char *initial_str)
void InitializeGUCOptions(void)
void boot_get_type_io_data(Oid typid, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *typinput, Oid *typoutput)
static bool Nulls[MAXATTR]
Form_pg_attribute attrtypes[MAXATTR]