PostgreSQL Source Code: src/include/bootstrap/bootstrap.h File Reference (original) (raw)


Go to the source code of this file.
| Macros | |
|---|---|
| #define | MAXATTR 40 |
| #define | BOOTCOL_NULL_AUTO 1 |
| #define | BOOTCOL_NULL_FORCE_NULL 2 |
| #define | BOOTCOL_NULL_FORCE_NOT_NULL 3 |
| Functions | |
|---|---|
| pg_noreturn void | BootstrapModeMain (int argc, char *argv[], bool check_only) |
| void | closerel (char *relname) |
| void | boot_openrel (char *relname) |
| void | DefineAttr (char *name, char *type, int attnum, int nullness) |
| void | InsertOneTuple (void) |
| void | InsertOneValue (char *value, int i) |
| void | InsertOneNull (int i) |
| void | index_register (Oid heap, Oid ind, const IndexInfo *indexInfo) |
| void | build_indices (void) |
| void | boot_get_type_io_data (Oid typid, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *typinput, Oid *typoutput, Oid *typcollation) |
| Oid | boot_get_role_oid (const char *rolname) |
| int | boot_yyparse (yyscan_t yyscanner) |
| int | boot_yylex_init (yyscan_t *yyscannerp) |
| int | boot_yylex (union YYSTYPE *yylval_param, yyscan_t yyscanner) |
| pg_noreturn void | boot_yyerror (yyscan_t yyscanner, const char *message) |
| Variables | |
|---|---|
| PGDLLIMPORT Relation | boot_reldesc |
| PGDLLIMPORT Form_pg_attribute | attrtypes [MAXATTR] |
| PGDLLIMPORT int | numattr |
◆ BOOTCOL_NULL_AUTO
◆ BOOTCOL_NULL_FORCE_NOT_NULL
#define BOOTCOL_NULL_FORCE_NOT_NULL 3
◆ BOOTCOL_NULL_FORCE_NULL
#define BOOTCOL_NULL_FORCE_NULL 2
◆ MAXATTR
◆ yyscan_t
◆ boot_get_role_oid()
◆ boot_get_type_io_data()
| void boot_get_type_io_data ( Oid typid, int16 * typlen, bool * typbyval, char * typalign, char * typdelim, Oid * typioparam, Oid * typinput, Oid * typoutput, Oid * typcollation ) | extern |
|---|
Definition at line 1003 of file bootstrap.c.
1012{
1014 {
1015
1018
1020 {
1022 if (ap->am_oid == typid)
1023 break;
1024 }
1025
1026 if ( || ap->am_oid != typid)
1027 elog(ERROR, "type OID %u not found in Typ list", typid);
1028
1029 *typlen = ap->am_typ.typlen;
1030 *typbyval = ap->am_typ.typbyval;
1032 *typdelim = ap->am_typ.typdelim;
1033
1034
1036 *typioparam = ap->am_typ.typelem;
1037 else
1038 *typioparam = typid;
1039
1041 *typoutput = ap->am_typ.typoutput;
1042
1043 *typcollation = ap->am_typ.typcollation;
1044 }
1045 else
1046 {
1047
1049
1051 {
1053 break;
1054 }
1056 elog(ERROR, "type OID %u not found in TypInfo", typid);
1057
1061
1062 *typdelim = ',';
1063
1064
1067 else
1068 *typioparam = typid;
1069
1072
1074 }
1075}
static const struct typinfo TypInfo[]
#define OidIsValid(objectId)
References typinfo::align, typinfo::byval, typinfo::collation, typinfo::elem, elog, ERROR, fb(), typinfo::inproc, typinfo::len, lfirst, n_types, NIL, OidIsValid, typinfo::outproc, Typ, typalign, and TypInfo.
Referenced by get_type_io_data(), InsertOneProargdefaultsValue(), and InsertOneValue().
◆ boot_openrel()
| void boot_openrel ( char * relname) | extern |
|---|
Definition at line 476 of file bootstrap.c.
477{
478 int i;
479
482
483
484
485
486
489
492
493 elog(DEBUG4, "open relation %s, attrsize %d",
495
499 {
505
506 {
508
509 elog(DEBUG4, "create attribute %d name %s len %d num %d type %u",
510 i, NameStr(at->attname), at->attlen, at->attnum,
511 at->atttypid);
512 }
513 }
514}
void closerel(char *relname)
static void populate_typ_list(void)
Form_pg_attribute attrtypes[MAXATTR]
static Form_pg_attribute AllocateAttribute(void)
RangeVar * makeRangeVar(char *schemaname, char *relname, int location)
#define ATTRIBUTE_FIXED_PART_SIZE
FormData_pg_attribute * Form_pg_attribute
#define RelationGetNumberOfAttributes(relation)
Relation table_openrv(const RangeVar *relation, LOCKMODE lockmode)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
References AllocateAttribute(), ATTRIBUTE_FIXED_PART_SIZE, attrtypes, boot_reldesc, closerel(), DEBUG4, elog, fb(), i, makeRangeVar(), NAMEDATALEN, NameStr, NIL, NoLock, numattr, populate_typ_list(), RelationData::rd_att, RelationGetNumberOfAttributes, relname, table_openrv(), TupleDescAttr(), and Typ.
◆ boot_yyerror()
◆ boot_yylex()
◆ boot_yylex_init()
◆ boot_yyparse()
◆ BootstrapModeMain()
Definition at line 234 of file bootstrap.c.
235{
236 int i;
242
244
246
247
249
250
252 && (strcmp(argv[1], "--boot") == 0
253 || strcmp(argv[1], "--check") == 0));
254 argv++;
255 argc--;
256
257 while ((flag = getopt(argc, argv, "B:c:d:D:Fkr:X:-:")) != -1)
258 {
259 switch (flag)
260 {
261 case 'B':
263 break;
264 case '-':
265
266
267
268
269
270
271
275 errmsg("--%s must be first argument", optarg)));
276
278 case 'c':
279 {
282
285 {
286 if (flag == '-')
289 errmsg("--%s requires a value",
291 else
294 errmsg("-c %s requires a value",
296 }
297
301 break;
302 }
303 case 'D':
305 break;
306 case 'd':
307 {
308
310
317 }
318 break;
319 case 'F':
321 break;
322 case 'k':
324 break;
325 case 'r':
327 break;
328 case 'X':
330 break;
331 default:
332 write_stderr("Try \"%s --help\" for more information.\n",
335 break;
336 }
337 }
338
340 {
343 }
344
345
348
349
350
351
352
355
357
360
362
363
364
365
366
367
369
371
373
374
375
376
377
379
380
381
382
383
384
386 {
390 }
391
392
393
394
396
398
401
402
403
404
405
407 elog(ERROR, "backend is incorrectly linked to frontend functions");
408
410
411
413 {
416 }
417
419 elog(ERROR, "yylex_init() failed: %m");
420
421
422
423
427
428
429
430
431
433
434
437}
#define write_stderr(str)
static void CheckerModeMain(void)
static void cleanup(void)
static void bootstrap_signals(void)
static bool Nulls[MAXATTR]
int boot_yylex_init(yyscan_t *yyscannerp)
int boot_yyparse(yyscan_t yyscanner)
#define PG_DATA_CHECKSUM_VERSION
#define Assert(condition)
int errcode(int sqlerrcode)
#define ereport(elevel,...)
void set_max_safe_fds(void)
char OutputFileName[MAXPGPATH]
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
bool SelectConfigFiles(const char *userDoption, const char *progname)
void ParseLongOption(const char *string, char **name, char **value)
void InitializeGUCOptions(void)
void CreateSharedMemoryAndSemaphores(void)
bool pg_link_canary_is_frontend(void)
DispatchOption parse_dispatch_option(const char *name)
char * pstrdup(const char *in)
void pfree(void *pointer)
#define SetProcessingMode(mode)
void ChangeToDataDir(void)
void InitStandaloneProcess(const char *argv0)
void CreateDataDirLockFile(bool amPostmaster)
int getopt(int nargc, char *const *nargv, const char *ostr)
PGDLLIMPORT char * optarg
void InitPostmasterChildSlots(void)
size_t strlcpy(char *dst, const char *src, size_t siz)
static const char * userDoption
void InitializeMaxBackends(void)
void InitializeFastPathLocks(void)
void InitPostgres(const char *in_dbname, Oid dboid, const char *username, Oid useroid, bits32 flags, char *out_dbname)
char * psprintf(const char *fmt,...)
void RelationMapFinishBootstrap(void)
void StartTransactionCommand(void)
void CommitTransactionCommand(void)
void BootStrapXLOG(uint32 data_checksum_version)
References Assert, attrtypes, BaseInit(), boot_yylex_init(), boot_yyparse(), bootstrap_signals(), BootstrapProcessing, BootStrapXLOG(), ChangeToDataDir(), checkDataDir(), CheckerModeMain(), cleanup(), CommitTransactionCommand(), CreateDataDirLockFile(), CreateSharedMemoryAndSemaphores(), DISPATCH_POSTMASTER, elog, ereport, errcode(), errmsg, ERROR, fb(), flag(), getopt(), i, IgnoreSystemIndexes, InitializeFastPathLocks(), InitializeGUCOptions(), InitializeMaxBackends(), InitPostgres(), InitPostmasterChildSlots(), InitProcess(), InitStandaloneProcess(), InvalidOid, IsUnderPostmaster, MAXATTR, MAXPGPATH, name, NormalProcessing, Nulls, optarg, optind, OutputFileName, parse_dispatch_option(), ParseLongOption(), pfree(), PG_DATA_CHECKSUM_VERSION, pg_fallthrough, pg_link_canary_is_frontend(), PGC_INTERNAL, PGC_POSTMASTER, PGC_S_ARGV, PGC_S_DYNAMIC_DEFAULT, proc_exit(), progname, psprintf(), pstrdup(), RelationMapFinishBootstrap(), SelectConfigFiles(), set_max_safe_fds(), SetConfigOption(), SetProcessingMode, StartTransactionCommand(), strlcpy(), userDoption, value, and write_stderr.
Referenced by main().
◆ build_indices()
Definition at line 1172 of file bootstrap.c.
1173{
1175 {
1178
1179
1182
1184
1187 }
1188}
static IndexList * ILHead
void index_build(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo, bool isreindex, bool parallel)
void index_close(Relation relation, LOCKMODE lockmode)
Relation index_open(Oid relationId, LOCKMODE lockmode)
struct _IndexList * il_next
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
References fb(), _IndexList::il_heap, _IndexList::il_ind, _IndexList::il_info, _IndexList::il_next, ILHead, index_build(), index_close(), index_open(), NoLock, table_close(), and table_open().
◆ closerel()
Definition at line 521 of file bootstrap.c.
522{
524 {
526 {
528 elog(ERROR, "close of %s when %s was expected",
530 }
531 else
532 elog(ERROR, "close of %s before any relation was opened",
534 }
535
537 elog(ERROR, "no open relation to close");
538 else
539 {
544 }
545}
#define RelationGetRelationName(relation)
References boot_reldesc, DEBUG4, elog, ERROR, fb(), NoLock, RelationGetRelationName, relname, and table_close().
Referenced by boot_openrel(), cleanup(), and DefineAttr().
◆ DefineAttr()
Definition at line 558 of file bootstrap.c.
559{
560 Oid typeoid;
561
563 {
564 elog(WARNING, "no open relations allowed with CREATE command");
566 }
567
571
575
577
579 {
587
590 else
592 }
593 else
594 {
602
606 else
608 }
609
610
611
612
613
614
615
618
621
623 {
625 }
627 {
629 }
630 else
631 {
633
634
635
636
637
638
640 {
641 int i;
642
643
645 {
648 break;
649 }
652 }
653 }
654}
static Oid gettype(char *type)
static struct typmap * Ap
#define BOOTCOL_NULL_FORCE_NULL
#define BOOTCOL_NULL_FORCE_NOT_NULL
#define BOOTCOL_NULL_AUTO
#define MemSet(start, val, len)
void namestrcpy(Name name, const char *str)
#define InvalidCompressionMethod
References typinfo::align, AllocateAttribute(), typmap::am_oid, typmap::am_typ, Ap, Assert, attlen, attname, attnotnull, attnum, ATTRIBUTE_FIXED_PART_SIZE, attrtypes, boot_reldesc, BOOTCOL_NULL_AUTO, BOOTCOL_NULL_FORCE_NOT_NULL, BOOTCOL_NULL_FORCE_NULL, typinfo::byval, closerel(), typinfo::collation, DEBUG4, elog, fb(), gettype(), i, InvalidCompressionMethod, InvalidOid, typinfo::len, MemSet, name, NameStr, namestrcpy(), NIL, typinfo::oid, OidIsValid, typinfo::storage, Typ, type, TypInfo, and WARNING.
◆ index_register()
Definition at line 1122 of file bootstrap.c.
1125{
1128
1129
1130
1131
1132
1133
1134
1137 "BootstrapNoGC",
1139
1141
1143 newind->il_heap = heap;
1146
1148
1149 newind->il_info->ii_Expressions =
1151 newind->il_info->ii_ExpressionsState = NIL;
1152
1153 newind->il_info->ii_Predicate =
1155 newind->il_info->ii_PredicateState = NULL;
1156
1160
1163
1165}
static MemoryContext nogc
#define palloc_object(type)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
uint16 * ii_ExclusionStrats
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, copyObject, fb(), IndexInfo::ii_ExclusionOps, IndexInfo::ii_ExclusionProcs, IndexInfo::ii_ExclusionStrats, IndexInfo::ii_Expressions, IndexInfo::ii_Predicate, ILHead, MemoryContextSwitchTo(), NIL, nogc, and palloc_object.
Referenced by index_create().
◆ InsertOneNull()
Definition at line 860 of file bootstrap.c.
861{
862 elog(DEBUG4, "inserting column %d NULL", i);
866 "NULL value specified for not-null column \"%s\" of relation \"%s\"",
871}
static Datum values[MAXATTR]
static Datum PointerGetDatum(const void *X)
References Assert, boot_reldesc, DEBUG4, elog, ERROR, fb(), i, MAXATTR, NameStr, Nulls, PointerGetDatum(), RelationData::rd_att, RelationGetRelationName, TupleDescAttr(), and values.
◆ InsertOneTuple()
Definition at line 665 of file bootstrap.c.
666{
669 int i;
670
672
675 pfree(tupDesc);
676
680
681
682
683
686}
void simple_heap_insert(Relation relation, HeapTuple tup)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_freetuple(HeapTuple htup)
TupleDesc CreateTupleDesc(int natts, Form_pg_attribute *attrs)
References attrtypes, boot_reldesc, CreateTupleDesc(), DEBUG4, elog, heap_form_tuple(), heap_freetuple(), i, Nulls, numattr, pfree(), simple_heap_insert(), and values.
◆ InsertOneValue()
Definition at line 693 of file bootstrap.c.
694{
696 Oid typoid;
698 bool typbyval;
700 char typdelim;
701 Oid typioparam;
703 Oid typoutput;
704 Oid typcollation;
705
707
709
711 typoid = attr->atttypid;
712
714 &typlen, &typbyval, &typalign,
715 &typdelim, &typioparam,
717 &typcollation);
718
719
720
721
722
723
725 {
726
730 else
731 elog(ERROR, "can't handle pg_node_tree input for %s.%s",
734 }
735 else
736 {
737
739 }
740
741
742
743
744
748}
void boot_get_type_io_data(Oid typid, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *typinput, Oid *typoutput, Oid *typcollation)
static void InsertOneProargdefaultsValue(char *value)
int int errmsg_internal(const char *fmt,...) pg_attribute_printf(1
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
char * OidOutputFunctionCall(Oid functionId, Datum val)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
References Assert, boot_get_type_io_data(), boot_reldesc, DEBUG4, elog, ereport, errmsg_internal(), ERROR, fb(), i, InsertOneProargdefaultsValue(), MAXATTR, NameStr, OidInputFunctionCall(), OidOutputFunctionCall(), RelationGetDescr, RelationGetRelationName, RelationGetRelid, TupleDescAttr(), typalign, value, and values.