PostgreSQL Source Code  git master
bootstrap.c File Reference
#include "postgres.h"
#include <unistd.h>
#include <signal.h>
#include "access/genam.h"
#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/tableam.h"
#include "access/xact.h"
#include "access/xlog_internal.h"
#include "bootstrap/bootstrap.h"
#include "catalog/index.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_type.h"
#include "common/link-canary.h"
#include "libpq/pqsignal.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "pg_getopt.h"
#include "pgstat.h"
#include "postmaster/bgwriter.h"
#include "postmaster/startup.h"
#include "postmaster/walwriter.h"
#include "replication/walreceiver.h"
#include "storage/bufmgr.h"
#include "storage/bufpage.h"
#include "storage/condition_variable.h"
#include "storage/ipc.h"
#include "storage/proc.h"
#include "tcop/tcopprot.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/memutils.h"
#include "utils/ps_status.h"
#include "utils/rel.h"
#include "utils/relmapper.h"
Include dependency graph for bootstrap.c:

Go to the source code of this file.

Data Structures

struct  typinfo
 
struct  typmap
 
struct  _IndexList
 

Typedefs

typedef struct _IndexList IndexList
 

Functions

static void CheckerModeMain (void)
 
static void BootstrapModeMain (void)
 
static void bootstrap_signals (void)
 
static void ShutdownAuxiliaryProcess (int code, Datum arg)
 
static Form_pg_attribute AllocateAttribute (void)
 
static void populate_typ_array (void)
 
static Oid gettype (char *type)
 
static void cleanup (void)
 
void AuxiliaryProcessMain (int argc, char *argv[])
 
void boot_openrel (char *relname)
 
void closerel (char *name)
 
void DefineAttr (char *name, char *type, int attnum, int nullness)
 
void InsertOneTuple (void)
 
void InsertOneValue (char *value, int i)
 
void InsertOneNull (int i)
 
void boot_get_type_io_data (Oid typid, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *typinput, Oid *typoutput)
 
void index_register (Oid heap, Oid ind, IndexInfo *indexInfo)
 
void build_indices (void)
 

Variables

uint32 bootstrap_data_checksum_version = 0
 
AuxProcType MyAuxProcType = NotAnAuxProcess
 
Relation boot_reldesc
 
Form_pg_attribute attrtypes [MAXATTR]
 
int numattr
 
static const struct typinfo TypInfo []
 
static const int n_types = sizeof(TypInfo) / sizeof(struct typinfo)
 
static struct typmap ** Typ = NULL
 
static struct typmapAp = NULL
 
static Datum values [MAXATTR]
 
static bool Nulls [MAXATTR]
 
static MemoryContext nogc = NULL
 
static IndexListILHead = NULL
 

Typedef Documentation

◆ IndexList

typedef struct _IndexList IndexList

Function Documentation

◆ AllocateAttribute()

static Form_pg_attribute AllocateAttribute ( void  )
static

Definition at line 1045 of file bootstrap.c.

References ATTRIBUTE_FIXED_PART_SIZE, MemoryContextAllocZero(), and TopMemoryContext.

Referenced by boot_openrel(), and DefineAttr().

1046 {
1047  return (Form_pg_attribute)
1049 }
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:193
#define ATTRIBUTE_FIXED_PART_SIZE
Definition: pg_attribute.h:185
MemoryContext TopMemoryContext
Definition: mcxt.c:44
void * MemoryContextAllocZero(MemoryContext context, Size size)
Definition: mcxt.c:840

◆ AuxiliaryProcessMain()

void AuxiliaryProcessMain ( int  argc,
char *  argv[] 
)

Definition at line 196 of file bootstrap.c.

References B_BG_WRITER, B_CHECKPOINTER, B_INVALID, B_STARTUP, B_WAL_RECEIVER, B_WAL_WRITER, BackgroundWriterMain(), BaseInit(), before_shmem_exit(), BgWriterProcess, bootstrap_data_checksum_version, bootstrap_signals(), BootstrapModeMain(), BootstrapProcess, BootstrapProcessing, BootStrapXLOG(), ChangeToDataDir(), checkDataDir(), CheckerModeMain(), CheckerProcess, CheckpointerMain(), CheckpointerProcess, CreateAuxProcessResourceOwner(), CreateDataDirLockFile(), elog, ereport, errcode(), errmsg(), ERROR, flag(), free, getopt(), IgnoreSystemIndexes, init_ps_display(), InitAuxiliaryProcess(), InitBufferPoolBackend(), InitializeGUCOptions(), InitializeMaxBackends(), InitStandaloneProcess(), InitXLOGAccess(), IsUnderPostmaster, IsValidWalSegSize, MaxBackends, MAXPGPATH, MyAuxProcType, MyBackendType, typinfo::name, NormalProcessing, optarg, optind, OutputFileName, PANIC, ParseLongOption(), pfree(), PG_DATA_CHECKSUM_VERSION, PGC_INTERNAL, PGC_POSTMASTER, PGC_S_ARGV, PGC_S_OVERRIDE, pgstat_bestart(), pgstat_initialize(), proc_exit(), ProcSignalInit(), progname, psprintf(), pstrdup(), SelectConfigFiles(), SetConfigOption(), SetProcessingMode, ShutdownAuxiliaryProcess(), StartupProcess, StartupProcessMain(), strlcpy(), userDoption, value, WalReceiverMain(), WalReceiverProcess, WalSegSz, WalWriterMain(), WalWriterProcess, and write_stderr.

Referenced by BackendRun(), main(), and StartChildProcess().

197 {
198  char *progname = argv[0];
199  int flag;
200  char *userDoption = NULL;
201 
202  /*
203  * Initialize process environment (already done if under postmaster, but
204  * not if standalone).
205  */
206  if (!IsUnderPostmaster)
207  InitStandaloneProcess(argv[0]);
208 
209  /*
210  * process command arguments
211  */
212 
213  /* Set defaults, to be overridden by explicit options below */
214  if (!IsUnderPostmaster)
216 
217  /* Ignore the initial --boot argument, if present */
218  if (argc > 1 && strcmp(argv[1], "--boot") == 0)
219  {
220  argv++;
221  argc--;
222  }
223 
224  /* If no -x argument, we are a CheckerProcess */
226 
227  while ((flag = getopt(argc, argv, "B:c:d:D:Fkr:x:X:-:")) != -1)
228  {
229  switch (flag)
230  {
231  case 'B':
232  SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, PGC_S_ARGV);
233  break;
234  case 'D':
235  userDoption = pstrdup(optarg);
236  break;
237  case 'd':
238  {
239  /* Turn on debugging for the bootstrap process. */
240  char *debugstr;
241 
242  debugstr = psprintf("debug%s", optarg);
243  SetConfigOption("log_min_messages", debugstr,
245  SetConfigOption("client_min_messages", debugstr,
247  pfree(debugstr);
248  }
249  break;
250  case 'F':
251  SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
252  break;
253  case 'k':
255  break;
256  case 'r':
258  break;
259  case 'x':
260  MyAuxProcType = atoi(optarg);
261  break;
262  case 'X':
263  {
264  int WalSegSz = strtoul(optarg, NULL, 0);
265 
266  if (!IsValidWalSegSize(WalSegSz))
267  ereport(ERROR,
268  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
269  errmsg("-X requires a power of two value between 1 MB and 1 GB")));
270  SetConfigOption("wal_segment_size", optarg, PGC_INTERNAL,
272  }
273  break;
274  case 'c':
275  case '-':
276  {
277  char *name,
278  *value;
279 
280  ParseLongOption(optarg, &name, &value);
281  if (!value)
282  {
283  if (flag == '-')
284  ereport(ERROR,
285  (errcode(ERRCODE_SYNTAX_ERROR),
286  errmsg("--%s requires a value",
287  optarg)));
288  else
289  ereport(ERROR,
290  (errcode(ERRCODE_SYNTAX_ERROR),
291  errmsg("-c %s requires a value",
292  optarg)));
293  }
294 
296  free(name);
297  if (value)
298  free(value);
299  break;
300  }
301  default:
302  write_stderr("Try \"%s --help\" for more information.\n",
303  progname);
304  proc_exit(1);
305  break;
306  }
307  }
308 
309  if (argc != optind)
310  {
311  write_stderr("%s: invalid command-line arguments\n", progname);
312  proc_exit(1);
313  }
314 
315  switch (MyAuxProcType)
316  {
317  case StartupProcess:
319  break;
320  case BgWriterProcess:
322  break;
323  case CheckpointerProcess:
325  break;
326  case WalWriterProcess:
328  break;
329  case WalReceiverProcess:
331  break;
332  default:
334  }
335  if (IsUnderPostmaster)
336  init_ps_display(NULL);
337 
338  /* Acquire configuration parameters, unless inherited from postmaster */
339  if (!IsUnderPostmaster)
340  {
341  if (!SelectConfigFiles(userDoption, progname))
342  proc_exit(1);
343  }
344 
345  /*
346  * Validate we have been given a reasonable-looking DataDir and change
347  * into it (if under postmaster, should be done already).
348  */
349  if (!IsUnderPostmaster)
350  {
351  checkDataDir();
352  ChangeToDataDir();
353  }
354 
355  /* If standalone, create lockfile for data directory */
356  if (!IsUnderPostmaster)
357  CreateDataDirLockFile(false);
358 
360  IgnoreSystemIndexes = true;
361 
362  /* Initialize MaxBackends (if under postmaster, was done already) */
363  if (!IsUnderPostmaster)
365 
366  BaseInit();
367 
368  /*
369  * When we are an auxiliary process, we aren't going to do the full
370  * InitPostgres pushups, but there are a couple of things that need to get
371  * lit up even in an auxiliary process.
372  */
373  if (IsUnderPostmaster)
374  {
375  /*
376  * Create a PGPROC so we can use LWLocks. In the EXEC_BACKEND case,
377  * this was already done by SubPostmasterMain().
378  */
379 #ifndef EXEC_BACKEND
381 #endif
382 
383  /*
384  * Assign the ProcSignalSlot for an auxiliary process. Since it
385  * doesn't have a BackendId, the slot is statically allocated based on
386  * the auxiliary process type (MyAuxProcType). Backends use slots
387  * indexed in the range from 1 to MaxBackends (inclusive), so we use
388  * MaxBackends + AuxProcType + 1 as the index of the slot for an
389  * auxiliary process.
390  *
391  * This will need rethinking if we ever want more than one of a
392  * particular auxiliary process type.
393  */
395 
396  /* finish setting up bufmgr.c */
398 
399  /*
400  * Auxiliary processes don't run transactions, but they may need a
401  * resource owner anyway to manage buffer pins acquired outside
402  * transactions (and, perhaps, other things in future).
403  */
405 
406  /* Initialize backend status information */
408  pgstat_bestart();
409 
410  /* register a before-shutdown callback for LWLock cleanup */
412  }
413 
414  /*
415  * XLOG operations
416  */
418 
419  switch (MyAuxProcType)
420  {
421  case CheckerProcess:
422  /* don't set signals, they're useless here */
423  CheckerModeMain();
424  proc_exit(1); /* should never return */
425 
426  case BootstrapProcess:
427 
428  /*
429  * There was a brief instant during which mode was Normal; this is
430  * okay. We need to be in bootstrap mode during BootStrapXLOG for
431  * the sake of multixact initialization.
432  */
435  BootStrapXLOG();
437  proc_exit(1); /* should never return */
438 
439  case StartupProcess:
440  /* don't set signals, startup process has its own agenda */
442  proc_exit(1); /* should never return */
443 
444  case BgWriterProcess:
445  /* don't set signals, bgwriter has its own agenda */
447  proc_exit(1); /* should never return */
448 
449  case CheckpointerProcess:
450  /* don't set signals, checkpointer has its own agenda */
452  proc_exit(1); /* should never return */
453 
454  case WalWriterProcess:
455  /* don't set signals, walwriter has its own agenda */
456  InitXLOGAccess();
457  WalWriterMain();
458  proc_exit(1); /* should never return */
459 
460  case WalReceiverProcess:
461  /* don't set signals, walreceiver has its own agenda */
462  WalReceiverMain();
463  proc_exit(1); /* should never return */
464 
465  default:
466  elog(PANIC, "unrecognized process type: %d", (int) MyAuxProcType);
467  proc_exit(1);
468  }
469 }
void InitAuxiliaryProcess(void)
Definition: proc.c:511
#define IsValidWalSegSize(size)
Definition: xlog_internal.h:94
void WalWriterMain(void)
Definition: walwriter.c:88
BackendType MyBackendType
Definition: miscinit.c:62
char * pstrdup(const char *in)
Definition: mcxt.c:1187
char * psprintf(const char *fmt,...)
Definition: psprintf.c:46
void InitStandaloneProcess(const char *argv0)
Definition: miscinit.c:165
void ParseLongOption(const char *string, char **name, char **value)
Definition: guc.c:10529
void StartupProcessMain(void)
Definition: startup.c:170
#define write_stderr(str)
Definition: parallel.c:186
void proc_exit(int code)
Definition: ipc.c:104
int errcode(int sqlerrcode)
Definition: elog.c:610
#define SetProcessingMode(mode)
Definition: miscadmin.h:399
void BootStrapXLOG(void)
Definition: xlog.c:5194
void BaseInit(void)
Definition: postinit.c:548
bool IgnoreSystemIndexes
Definition: miscinit.c:79
void checkDataDir(void)
Definition: miscinit.c:302
static void bootstrap_signals(void)
Definition: bootstrap.c:547
const char * progname
Definition: pg_standby.c:36
#define PANIC
Definition: elog.h:53
static void BootstrapModeMain(void)
Definition: bootstrap.c:491
int getopt(int nargc, char *const *nargv, const char *ostr)
Definition: getopt.c:71
void WalReceiverMain(void)
Definition: walreceiver.c:178
void pfree(void *pointer)
Definition: mcxt.c:1057
int optind
Definition: getopt.c:50
#define ERROR
Definition: elog.h:43
void CreateDataDirLockFile(bool amPostmaster)
Definition: miscinit.c:1273
void InitXLOGAccess(void)
Definition: xlog.c:8340
#define MAXPGPATH
int MaxBackends
Definition: globals.c:136
char OutputFileName[MAXPGPATH]
Definition: globals.c:70
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
Definition: guc.c:7714
bool IsUnderPostmaster
Definition: globals.c:109
char * flag(int b)
Definition: test-ctype.c:33
void before_shmem_exit(pg_on_exit_callback function, Datum arg)
Definition: ipc.c:333
void ChangeToDataDir(void)
Definition: miscinit.c:416
void pgstat_initialize(void)
Definition: pgstat.c:2881
static void ShutdownAuxiliaryProcess(int code, Datum arg)
Definition: bootstrap.c:570
bool SelectConfigFiles(const char *userDoption, const char *progname)
Definition: guc.c:5566
AuxProcType MyAuxProcType
Definition: bootstrap.c:70
void CheckpointerMain(void)
Definition: checkpointer.c:183
static struct @143 value
#define ereport(elevel,...)
Definition: elog.h:144
#define free(a)
Definition: header.h:65
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:45
void CreateAuxProcessResourceOwner(void)
Definition: resowner.c:858
void InitializeMaxBackends(void)
Definition: postinit.c:526
const char * name
Definition: encode.c:561
void BackgroundWriterMain(void)
Definition: bgwriter.c:94
int WalSegSz
Definition: pg_standby.c:38
static const char * userDoption
Definition: postgres.c:157
void ProcSignalInit(int pss_idx)
Definition: procsignal.c:151
#define PG_DATA_CHECKSUM_VERSION
Definition: bufpage.h:200
int errmsg(const char *fmt,...)
Definition: elog.c:824
void pgstat_bestart(void)
Definition: pgstat.c:2923
char * optarg
Definition: getopt.c:52
#define elog(elevel,...)
Definition: elog.h:214
static void CheckerModeMain(void)
Definition: bootstrap.c:478
void InitBufferPoolBackend(void)
Definition: bufmgr.c:2524
uint32 bootstrap_data_checksum_version
Definition: bootstrap.c:53
void init_ps_display(const char *fixed_part)
Definition: ps_status.c:258
void InitializeGUCOptions(void)
Definition: guc.c:5344

◆ 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 
)

Definition at line 971 of file bootstrap.c.

References typinfo::align, typmap::am_oid, typmap::am_typ, typinfo::byval, typinfo::elem, elog, ERROR, typinfo::inproc, typinfo::len, n_types, typinfo::oid, OidIsValid, typinfo::outproc, and Typ.

Referenced by get_type_io_data(), and InsertOneValue().

979 {
980  if (Typ != NULL)
981  {
982  /* We have the boot-time contents of pg_type, so use it */
983  struct typmap **app;
984  struct typmap *ap;
985 
986  app = Typ;
987  while (*app && (*app)->am_oid != typid)
988  ++app;
989  ap = *app;
990  if (ap == NULL)
991  elog(ERROR, "type OID %u not found in Typ list", typid);
992 
993  *typlen = ap->am_typ.typlen;
994  *typbyval = ap->am_typ.typbyval;
995  *typalign = ap->am_typ.typalign;
996  *typdelim = ap->am_typ.typdelim;
997 
998  /* XXX this logic must match getTypeIOParam() */
999  if (OidIsValid(ap->am_typ.typelem))
1000  *typioparam = ap->am_typ.typelem;
1001  else
1002  *typioparam = typid;
1003 
1004  *typinput = ap->am_typ.typinput;
1005  *typoutput = ap->am_typ.typoutput;
1006  }
1007  else
1008  {
1009  /* We don't have pg_type yet, so use the hard-wired TypInfo array */
1010  int typeindex;
1011 
1012  for (typeindex = 0; typeindex < n_types; typeindex++)
1013  {
1014  if (TypInfo[typeindex].oid == typid)
1015  break;
1016  }
1017  if (typeindex >= n_types)
1018  elog(ERROR, "type OID %u not found in TypInfo", typid);
1019 
1020  *typlen = TypInfo[typeindex].len;
1021  *typbyval = TypInfo[typeindex].byval;
1022  *typalign = TypInfo[typeindex].align;
1023  /* We assume typdelim is ',' for all boot-time types */
1024  *typdelim = ',';
1025 
1026  /* XXX this logic must match getTypeIOParam() */
1027  if (OidIsValid(TypInfo[typeindex].elem))
1028  *typioparam = TypInfo[typeindex].elem;
1029  else
1030  *typioparam = typid;
1031 
1032  *typinput = TypInfo[typeindex].inproc;
1033  *typoutput = TypInfo[typeindex].outproc;
1034  }
1035 }
int16 len
Definition: bootstrap.c:92
char align
Definition: bootstrap.c:94
Oid inproc
Definition: bootstrap.c:97
#define OidIsValid(objectId)
Definition: c.h:651
char typalign
Definition: pg_type.h:170
#define ERROR
Definition: elog.h:43
Oid elem
Definition: bootstrap.c:91
static struct typmap ** Typ
Definition: bootstrap.c:162
FormData_pg_type am_typ
Definition: bootstrap.c:159
static const int n_types
Definition: bootstrap.c:154
static const struct typinfo TypInfo[]
Definition: bootstrap.c:101
bool byval
Definition: bootstrap.c:93
Oid am_oid
Definition: bootstrap.c:158
#define elog(elevel,...)
Definition: elog.h:214
Oid outproc
Definition: bootstrap.c:98

◆ boot_openrel()

void boot_openrel ( char *  relname)

Definition at line 589 of file bootstrap.c.

References AllocateAttribute(), ATTRIBUTE_FIXED_PART_SIZE, attrtypes, closerel(), DEBUG4, elog, i, makeRangeVar(), NAMEDATALEN, NameStr, NoLock, numattr, populate_typ_array(), RelationData::rd_att, RelationGetNumberOfAttributes, table_openrv(), and TupleDescAttr.

590 {
591  int i;
592 
593  if (strlen(relname) >= NAMEDATALEN)
594  relname[NAMEDATALEN - 1] = '\0';
595 
596  /*
597  * pg_type must be filled before any OPEN command is executed, hence we
598  * can now populate the Typ array if we haven't yet.
599  */
600  if (Typ == NULL)
602 
603  if (boot_reldesc != NULL)
604  closerel(NULL);
605 
606  elog(DEBUG4, "open relation %s, attrsize %d",
608 
611  for (i = 0; i < numattr; i++)
612  {
613  if (attrtypes[i] == NULL)
615  memmove((char *) attrtypes[i],
616  (char *) TupleDescAttr(boot_reldesc->rd_att, i),
618 
619  {
621 
622  elog(DEBUG4, "create attribute %d name %s len %d num %d type %u",
623  i, NameStr(at->attname), at->attlen, at->attnum,
624  at->atttypid);
625  }
626  }
627 }
int numattr
Definition: bootstrap.c:75
#define RelationGetNumberOfAttributes(relation)
Definition: rel.h:462
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
Relation boot_reldesc
Definition: bootstrap.c:72
NameData relname
Definition: pg_class.h:38
void closerel(char *name)
Definition: bootstrap.c:634
#define DEBUG4
Definition: elog.h:22
static void populate_typ_array(void)
Definition: bootstrap.c:875
#define NAMEDATALEN
#define NoLock
Definition: lockdefs.h:34
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:193
#define ATTRIBUTE_FIXED_PART_SIZE
Definition: pg_attribute.h:185
static struct typmap ** Typ
Definition: bootstrap.c:162
TupleDesc rd_att
Definition: rel.h:110
Relation table_openrv(const RangeVar *relation, LOCKMODE lockmode)
Definition: table.c:102
static Form_pg_attribute AllocateAttribute(void)
Definition: bootstrap.c:1045
#define elog(elevel,...)
Definition: elog.h:214
int i
#define NameStr(name)
Definition: c.h:622
RangeVar * makeRangeVar(char *schemaname, char *relname, int location)
Definition: makefuncs.c:422
Form_pg_attribute attrtypes[MAXATTR]
Definition: bootstrap.c:74

◆ bootstrap_signals()

static void bootstrap_signals ( void  )
static

Definition at line 547 of file bootstrap.c.

References Assert, IsUnderPostmaster, pqsignal(), SIG_DFL, SIGHUP, and SIGQUIT.

Referenced by AuxiliaryProcessMain().

548 {
550 
551  /*
552  * We don't actually need any non-default signal handling in bootstrap
553  * mode; "curl up and die" is a sufficient response for all these cases.
554  * Let's set that handling explicitly, as documentation if nothing else.
555  */
557  pqsignal(SIGINT, SIG_DFL);
558  pqsignal(SIGTERM, SIG_DFL);
560 }
#define SIGQUIT
Definition: win32_port.h:154
bool IsUnderPostmaster
Definition: globals.c:109
#define SIGHUP
Definition: win32_port.h:153
pqsigfunc pqsignal(int signum, pqsigfunc handler)
Definition: signal.c:170
#define SIG_DFL
Definition: win32_port.h:148
#define Assert(condition)
Definition: c.h:745

◆ BootstrapModeMain()

static void BootstrapModeMain ( void  )
static

Definition at line 491 of file bootstrap.c.

References Assert, attrtypes, boot_yyparse(), cleanup(), CommitTransactionCommand(), elog, ERROR, i, InitPostgres(), InitProcess(), InvalidOid, IsBootstrapProcessingMode, IsUnderPostmaster, MAXATTR, pg_link_canary_is_frontend(), proc_exit(), RelationMapFinishBootstrap(), and StartTransactionCommand().

Referenced by AuxiliaryProcessMain().

492 {
493  int i;
494 
497 
498  /*
499  * To ensure that src/common/link-canary.c is linked into the backend, we
500  * must call it from somewhere. Here is as good as anywhere.
501  */
503  elog(ERROR, "backend is incorrectly linked to frontend functions");
504 
505  /*
506  * Do backend-like initialization for bootstrap mode
507  */
508  InitProcess();
509 
510  InitPostgres(NULL, InvalidOid, NULL, InvalidOid, NULL, false);
511 
512  /* Initialize stuff for bootstrap-file processing */
513  for (i = 0; i < MAXATTR; i++)
514  {
515  attrtypes[i] = NULL;
516  Nulls[i] = false;
517  }
518 
519  /*
520  * Process bootstrap input.
521  */
523  boot_yyparse();
525 
526  /*
527  * We should now know about all mapped relations, so it's okay to write
528  * out the initial relation mapping files.
529  */
531 
532  /* Clean up and exit */
533  cleanup();
534  proc_exit(0);
535 }
void RelationMapFinishBootstrap(void)
Definition: relmapper.c:560
void CommitTransactionCommand(void)
Definition: xact.c:2947
int boot_yyparse(void)
void proc_exit(int code)
Definition: ipc.c:104
#define ERROR
Definition: elog.h:43
void InitProcess(void)
Definition: proc.c:301
bool IsUnderPostmaster
Definition: globals.c:109
#define MAXATTR
Definition: bootstrap.h:24
static void cleanup(void)
Definition: bootstrap.c:862
#define InvalidOid
Definition: postgres_ext.h:36
void InitPostgres(const char *in_dbname, Oid dboid, const char *username, Oid useroid, char *out_dbname, bool override_allow_connections)
Definition: postinit.c:590
#define Assert(condition)
Definition: c.h:745
void StartTransactionCommand(void)
Definition: xact.c:2846
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:393
#define elog(elevel,...)
Definition: elog.h:214
int i
static bool Nulls[MAXATTR]
Definition: bootstrap.c:166
Form_pg_attribute attrtypes[MAXATTR]
Definition: bootstrap.c:74

◆ build_indices()

void build_indices ( void  )

Definition at line 1113 of file bootstrap.c.

References _IndexList::il_heap, _IndexList::il_ind, _IndexList::il_info, _IndexList::il_next, index_build(), index_close(), index_open(), NoLock, table_close(), and table_open().

1114 {
1115  for (; ILHead != NULL; ILHead = ILHead->il_next)
1116  {
1117  Relation heap;
1118  Relation ind;
1119 
1120  /* need not bother with locks during bootstrap */
1121  heap = table_open(ILHead->il_heap, NoLock);
1122  ind = index_open(ILHead->il_ind, NoLock);
1123 
1124  index_build(heap, ind, ILHead->il_info, false, false);
1125 
1126  index_close(ind, NoLock);
1127  table_close(heap, NoLock);
1128  }
1129 }
struct _IndexList * il_next
Definition: bootstrap.c:181
Oid il_ind
Definition: bootstrap.c:179
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:167
static IndexList * ILHead
Definition: bootstrap.c:184
#define NoLock
Definition: lockdefs.h:34
IndexInfo * il_info
Definition: bootstrap.c:180
void index_build(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo, bool isreindex, bool parallel)
Definition: index.c:2821
Oid il_heap
Definition: bootstrap.c:178
void index_close(Relation relation, LOCKMODE lockmode)
Definition: indexam.c:158
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:39
Relation index_open(Oid relationId, LOCKMODE lockmode)
Definition: indexam.c:132

◆ CheckerModeMain()

static void CheckerModeMain ( void  )
static

Definition at line 478 of file bootstrap.c.

References proc_exit().

Referenced by AuxiliaryProcessMain().

479 {
480  proc_exit(0);
481 }
void proc_exit(int code)
Definition: ipc.c:104

◆ cleanup()

static void cleanup ( void  )
static

◆ closerel()

void closerel ( char *  name)

Definition at line 634 of file bootstrap.c.

References DEBUG4, elog, ERROR, NoLock, RelationGetRelationName, and table_close().

Referenced by boot_openrel(), cleanup(), and DefineAttr().

635 {
636  if (name)
637  {
638  if (boot_reldesc)
639  {
640  if (strcmp(RelationGetRelationName(boot_reldesc), name) != 0)
641  elog(ERROR, "close of %s when %s was expected",
643  }
644  else
645  elog(ERROR, "close of %s before any relation was opened",
646  name);
647  }
648 
649  if (boot_reldesc == NULL)
650  elog(ERROR, "no open relation to close");
651  else
652  {
653  elog(DEBUG4, "close relation %s",
656  boot_reldesc = NULL;
657  }
658 }
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:167
Relation boot_reldesc
Definition: bootstrap.c:72
#define DEBUG4
Definition: elog.h:22
#define ERROR
Definition: elog.h:43
#define NoLock
Definition: lockdefs.h:34
#define RelationGetRelationName(relation)
Definition: rel.h:490
const char * name
Definition: encode.c:561
#define elog(elevel,...)
Definition: elog.h:214

◆ DefineAttr()

void DefineAttr ( char *  name,
char *  type,
int  attnum,
int  nullness 
)

Definition at line 671 of file bootstrap.c.

References typinfo::align, AllocateAttribute(), typmap::am_oid, typmap::am_typ, Assert, attcollation, attlen, attname, attnotnull, attnum, ATTRIBUTE_FIXED_PART_SIZE, attrtypes, BOOTCOL_NULL_AUTO, BOOTCOL_NULL_FORCE_NOT_NULL, BOOTCOL_NULL_FORCE_NULL, typinfo::byval, closerel(), typinfo::collation, DEBUG4, typinfo::elem, elog, gettype(), i, InvalidOid, typinfo::len, MemSet, NameStr, namestrcpy(), typinfo::oid, OidIsValid, typinfo::storage, and WARNING.

672 {
673  Oid typeoid;
674 
675  if (boot_reldesc != NULL)
676  {
677  elog(WARNING, "no open relations allowed with CREATE command");
678  closerel(NULL);
679  }
680 
681  if (attrtypes[attnum] == NULL)
684 
686  elog(DEBUG4, "column %s %s", NameStr(attrtypes[attnum]->attname), type);
687  attrtypes[attnum]->attnum = attnum + 1;
688 
689  typeoid = gettype(type);
690 
691  if (Typ != NULL)
692  {
693  attrtypes[attnum]->atttypid = Ap->am_oid;
694  attrtypes[attnum]->attlen = Ap->am_typ.typlen;
695  attrtypes[attnum]->attbyval = Ap->am_typ.typbyval;
696  attrtypes[attnum]->attstorage = Ap->am_typ.typstorage;
697  attrtypes[attnum]->attalign = Ap->am_typ.typalign;
698  attrtypes[attnum]->attcollation = Ap->am_typ.typcollation;
699  /* if an array type, assume 1-dimensional attribute */
700  if (Ap->am_typ.typelem != InvalidOid && Ap->am_typ.typlen < 0)
701  attrtypes[attnum]->attndims = 1;
702  else
703  attrtypes[attnum]->attndims = 0;
704  }
705  else
706  {
707  attrtypes[attnum]->atttypid = TypInfo[typeoid].oid;
708  attrtypes[attnum]->attlen = TypInfo[typeoid].len;
709  attrtypes[attnum]->attbyval = TypInfo[typeoid].byval;
710  attrtypes[attnum]->attstorage = TypInfo[typeoid].storage;
711  attrtypes[attnum]->attalign = TypInfo[typeoid].align;
712  attrtypes[attnum]->attcollation = TypInfo[typeoid].collation;
713  /* if an array type, assume 1-dimensional attribute */
714  if (TypInfo[typeoid].elem != InvalidOid &&
715  attrtypes[attnum]->attlen < 0)
716  attrtypes[attnum]->attndims = 1;
717  else
718  attrtypes[attnum]->attndims = 0;
719  }
720 
721  /*
722  * If a system catalog column is collation-aware, force it to use C
723  * collation, so that its behavior is independent of the database's
724  * collation. This is essential to allow template0 to be cloned with a
725  * different database collation.
726  */
728  attrtypes[attnum]->attcollation = C_COLLATION_OID;
729 
730  attrtypes[attnum]->attstattarget = -1;
731  attrtypes[attnum]->attcacheoff = -1;
732  attrtypes[attnum]->atttypmod = -1;
733  attrtypes[attnum]->attislocal = true;
734 
735  if (nullness == BOOTCOL_NULL_FORCE_NOT_NULL)
736  {
737  attrtypes[attnum]->attnotnull = true;
738  }
739  else if (nullness == BOOTCOL_NULL_FORCE_NULL)
740  {
741  attrtypes[attnum]->attnotnull = false;
742  }
743  else
744  {
745  Assert(nullness == BOOTCOL_NULL_AUTO);
746 
747  /*
748  * Mark as "not null" if type is fixed-width and prior columns are
749  * likewise fixed-width and not-null. This corresponds to case where
750  * column can be accessed directly via C struct declaration.
751  */
752  if (attrtypes[attnum]->attlen > 0)
753  {
754  int i;
755 
756  /* check earlier attributes */
757  for (i = 0; i < attnum; i++)
758  {
759  if (attrtypes[i]->attlen <= 0 ||
760  !attrtypes[i]->attnotnull)
761  break;
762  }
763  if (i == attnum)
764  attrtypes[attnum]->attnotnull = true;
765  }
766  }
767 }
#define BOOTCOL_NULL_FORCE_NULL
Definition: bootstrap.h:27
int16 len
Definition: bootstrap.c:92
bool attnotnull
Definition: pg_attribute.h:125
char align
Definition: bootstrap.c:94
void namestrcpy(Name name, const char *str)
Definition: name.c:233
Relation boot_reldesc
Definition: bootstrap.c:72
#define BOOTCOL_NULL_AUTO
Definition: bootstrap.h:26
#define MemSet(start, val, len)
Definition: c.h:949
unsigned int Oid
Definition: postgres_ext.h:31
void closerel(char *name)
Definition: bootstrap.c:634
static struct typmap * Ap
Definition: bootstrap.c:163
#define DEBUG4
Definition: elog.h:22
#define OidIsValid(objectId)
Definition: c.h:651
#define BOOTCOL_NULL_FORCE_NOT_NULL
Definition: bootstrap.h:28
NameData attname
Definition: pg_attribute.h:40
Oid attcollation
Definition: pg_attribute.h:157
#define ATTRIBUTE_FIXED_PART_SIZE
Definition: pg_attribute.h:185
int16 attlen
Definition: pg_attribute.h:64
#define WARNING
Definition: elog.h:40
Oid collation
Definition: bootstrap.c:96
static struct typmap ** Typ
Definition: bootstrap.c:162
#define InvalidOid
Definition: postgres_ext.h:36
int16 attnum
Definition: pg_attribute.h:79
#define Assert(condition)
Definition: c.h:745
char storage
Definition: bootstrap.c:95
FormData_pg_type am_typ
Definition: bootstrap.c:159
static Form_pg_attribute AllocateAttribute(void)
Definition: bootstrap.c:1045
static const struct typinfo TypInfo[]
Definition: bootstrap.c:101
const char * name
Definition: encode.c:561
bool byval
Definition: bootstrap.c:93
static Oid gettype(char *type)
Definition: bootstrap.c:926
Oid am_oid
Definition: bootstrap.c:158
#define elog(elevel,...)
Definition: elog.h:214
int i
#define NameStr(name)
Definition: c.h:622
Oid oid
Definition: bootstrap.c:90
Form_pg_attribute attrtypes[MAXATTR]
Definition: bootstrap.c:74

◆ gettype()

static Oid gettype ( char *  type)
static

Definition at line 926 of file bootstrap.c.

References typmap::am_oid, DEBUG4, elog, ERROR, i, n_types, typinfo::name, NAMEDATALEN, NameStr, and populate_typ_array().

Referenced by DefineAttr().

927 {
928  if (Typ != NULL)
929  {
930  struct typmap **app;
931 
932  for (app = Typ; *app != NULL; app++)
933  {
934  if (strncmp(NameStr((*app)->am_typ.typname), type, NAMEDATALEN) == 0)
935  {
936  Ap = *app;
937  return (*app)->am_oid;
938  }
939  }
940  }
941  else
942  {
943  int i;
944 
945  for (i = 0; i < n_types; i++)
946  {
947  if (strncmp(type, TypInfo[i].name, NAMEDATALEN) == 0)
948  return i;
949  }
950  /* Not in TypInfo, so we'd better be able to read pg_type now */
951  elog(DEBUG4, "external type: %s", type);
953  return gettype(type);
954  }
955  elog(ERROR, "unrecognized type \"%s\"", type);
956  /* not reached, here to make compiler happy */
957  return 0;
958 }
static struct typmap * Ap
Definition: bootstrap.c:163
#define DEBUG4
Definition: elog.h:22
static void populate_typ_array(void)
Definition: bootstrap.c:875
#define NAMEDATALEN
#define ERROR
Definition: elog.h:43
static struct typmap ** Typ
Definition: bootstrap.c:162
static const int n_types
Definition: bootstrap.c:154
static const struct typinfo TypInfo[]
Definition: bootstrap.c:101
const char * name
Definition: encode.c:561
static Oid gettype(char *type)
Definition: bootstrap.c:926
Oid am_oid
Definition: bootstrap.c:158
#define elog(elevel,...)
Definition: elog.h:214
int i
#define NameStr(name)
Definition: c.h:622

◆ index_register()

void index_register ( Oid  heap,
Oid  ind,
IndexInfo indexInfo 
)

Definition at line 1063 of file bootstrap.c.

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, copyObject, IndexInfo::ii_ExclusionOps, IndexInfo::ii_ExclusionProcs, IndexInfo::ii_ExclusionStrats, IndexInfo::ii_Expressions, IndexInfo::ii_ExpressionsState, IndexInfo::ii_Predicate, IndexInfo::ii_PredicateState, _IndexList::il_heap, _IndexList::il_ind, _IndexList::il_info, _IndexList::il_next, ILHead, MemoryContextSwitchTo(), NIL, and palloc().

Referenced by index_create().

1066 {
1067  IndexList *newind;
1068  MemoryContext oldcxt;
1069 
1070  /*
1071  * XXX mao 10/31/92 -- don't gc index reldescs, associated info at
1072  * bootstrap time. we'll declare the indexes now, but want to create them
1073  * later.
1074  */
1075 
1076  if (nogc == NULL)
1077  nogc = AllocSetContextCreate(NULL,
1078  "BootstrapNoGC",
1080 
1081  oldcxt = MemoryContextSwitchTo(nogc);
1082 
1083  newind = (IndexList *) palloc(sizeof(IndexList));
1084  newind->il_heap = heap;
1085  newind->il_ind = ind;
1086  newind->il_info = (IndexInfo *) palloc(sizeof(IndexInfo));
1087 
1088  memcpy(newind->il_info, indexInfo, sizeof(IndexInfo));
1089  /* expressions will likely be null, but may as well copy it */
1090  newind->il_info->ii_Expressions =
1091  copyObject(indexInfo->ii_Expressions);
1092  newind->il_info->ii_ExpressionsState = NIL;
1093  /* predicate will likely be null, but may as well copy it */
1094  newind->il_info->ii_Predicate =
1095  copyObject(indexInfo->ii_Predicate);
1096  newind->il_info->ii_PredicateState = NULL;
1097  /* no exclusion constraints at bootstrap time, so no need to copy */
1098  Assert(indexInfo->ii_ExclusionOps == NULL);
1099  Assert(indexInfo->ii_ExclusionProcs == NULL);
1100  Assert(indexInfo->ii_ExclusionStrats == NULL);
1101 
1102  newind->il_next = ILHead;
1103  ILHead = newind;
1104 
1105  MemoryContextSwitchTo(oldcxt);
1106 }
struct _IndexList * il_next
Definition: bootstrap.c:181
#define NIL
Definition: pg_list.h:65
#define AllocSetContextCreate
Definition: memutils.h:170
Oid il_ind
Definition: bootstrap.c:179
List * ii_Predicate
Definition: execnodes.h:163
ExprState * ii_PredicateState
Definition: execnodes.h:164
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
static IndexList * ILHead
Definition: bootstrap.c:184
Oid * ii_ExclusionProcs
Definition: execnodes.h:166
static MemoryContext nogc
Definition: bootstrap.c:168
List * ii_ExpressionsState
Definition: execnodes.h:162
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:192
IndexInfo * il_info
Definition: bootstrap.c:180
List * ii_Expressions
Definition: execnodes.h:161
#define Assert(condition)
Definition: c.h:745
Oid il_heap
Definition: bootstrap.c:178
Oid * ii_ExclusionOps
Definition: execnodes.h:165
void * palloc(Size size)
Definition: mcxt.c:950
#define copyObject(obj)
Definition: nodes.h:645
uint16 * ii_ExclusionStrats
Definition: execnodes.h:167

◆ InsertOneNull()

void InsertOneNull ( int  i)

Definition at line 844 of file bootstrap.c.

References Assert, DEBUG4, elog, ERROR, i, MAXATTR, NameStr, PointerGetDatum, RelationData::rd_att, RelationGetRelationName, and TupleDescAttr.

845 {
846  elog(DEBUG4, "inserting column %d NULL", i);
847  Assert(i >= 0 && i < MAXATTR);
848  if (TupleDescAttr(boot_reldesc->rd_att, i)->attnotnull)
849  elog(ERROR,
850  "NULL value specified for not-null column \"%s\" of relation \"%s\"",
853  values[i] = PointerGetDatum(NULL);
854  Nulls[i] = true;
855 }
#define PointerGetDatum(X)
Definition: postgres.h:556
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
Relation boot_reldesc
Definition: bootstrap.c:72
#define DEBUG4
Definition: elog.h:22
#define ERROR
Definition: elog.h:43
#define RelationGetRelationName(relation)
Definition: rel.h:490
#define MAXATTR
Definition: bootstrap.h:24
TupleDesc rd_att
Definition: rel.h:110
#define Assert(condition)
Definition: c.h:745
static Datum values[MAXATTR]
Definition: bootstrap.c:165
#define elog(elevel,...)
Definition: elog.h:214
int i
#define NameStr(name)
Definition: c.h:622
static bool Nulls[MAXATTR]
Definition: bootstrap.c:166

◆ InsertOneTuple()

void InsertOneTuple ( void  )

Definition at line 778 of file bootstrap.c.

References attrtypes, CreateTupleDesc(), DEBUG4, elog, heap_form_tuple(), heap_freetuple(), i, numattr, pfree(), and simple_heap_insert().

779 {
780  HeapTuple tuple;
781  TupleDesc tupDesc;
782  int i;
783 
784  elog(DEBUG4, "inserting row with %d columns", numattr);
785 
786  tupDesc = CreateTupleDesc(numattr, attrtypes);
787  tuple = heap_form_tuple(tupDesc, values, Nulls);
788  pfree(tupDesc); /* just free's tupDesc, not the attrtypes */
789 
791  heap_freetuple(tuple);
792  elog(DEBUG4, "row inserted");
793 
794  /*
795  * Reset null markers for next tuple
796  */
797  for (i = 0; i < numattr; i++)
798  Nulls[i] = false;
799 }
int numattr
Definition: bootstrap.c:75
Relation boot_reldesc
Definition: bootstrap.c:72
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1020
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1338
#define DEBUG4
Definition: elog.h:22
void pfree(void *pointer)
Definition: mcxt.c:1057
void simple_heap_insert(Relation relation, HeapTuple tup)
Definition: heapam.c:2384
static Datum values[MAXATTR]
Definition: bootstrap.c:165
#define elog(elevel,...)
Definition: elog.h:214
int i
TupleDesc CreateTupleDesc(int natts, Form_pg_attribute *attrs)
Definition: tupdesc.c:89
static bool Nulls[MAXATTR]
Definition: bootstrap.c:166
Form_pg_attribute attrtypes[MAXATTR]
Definition: bootstrap.c:74

◆ InsertOneValue()

void InsertOneValue ( char *  value,
int  i 
)

Definition at line 806 of file bootstrap.c.

References AssertArg, boot_get_type_io_data(), DEBUG4, elog, ereport, errmsg_internal(), i, MAXATTR, OidInputFunctionCall(), OidOutputFunctionCall(), RelationData::rd_att, TupleDescAttr, and typalign.

807 {
808  Oid typoid;
809  int16 typlen;
810  bool typbyval;
811  char typalign;
812  char typdelim;
813  Oid typioparam;
814  Oid typinput;
815  Oid typoutput;
816 
817  AssertArg(i >= 0 && i < MAXATTR);
818 
819  elog(DEBUG4, "inserting column %d value \"%s\"", i, value);
820 
821  typoid = TupleDescAttr(boot_reldesc->rd_att, i)->atttypid;
822 
823  boot_get_type_io_data(typoid,
824  &typlen, &typbyval, &typalign,
825  &typdelim, &typioparam,
826  &typinput, &typoutput);
827 
828  values[i] = OidInputFunctionCall(typinput, value, typioparam, -1);
829 
830  /*
831  * We use ereport not elog here so that parameters aren't evaluated unless
832  * the message is going to be printed, which generally it isn't
833  */
834  ereport(DEBUG4,
835  (errmsg_internal("inserted -> %s",
836  OidOutputFunctionCall(typoutput, values[i]))));
837 }
signed short int16
Definition: c.h:361
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92
Relation boot_reldesc
Definition: bootstrap.c:72
unsigned int Oid
Definition: postgres_ext.h:31
#define DEBUG4
Definition: elog.h:22
char typalign
Definition: pg_type.h:170
#define MAXATTR
Definition: bootstrap.h:24
#define AssertArg(condition)
Definition: c.h:747
TupleDesc rd_att
Definition: rel.h:110
static struct @143 value
#define ereport(elevel,...)
Definition: elog.h:144
int errmsg_internal(const char *fmt,...)
Definition: elog.c:911
static Datum values[MAXATTR]
Definition: bootstrap.c:165
char * OidOutputFunctionCall(Oid functionId, Datum val)
Definition: fmgr.c:1657
#define elog(elevel,...)
Definition: elog.h:214
int i
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:1648
void boot_get_type_io_data(Oid typid, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *typinput, Oid *typoutput)
Definition: bootstrap.c:971

◆ populate_typ_array()

static void populate_typ_array ( void  )
static

Definition at line 875 of file bootstrap.c.

References typmap::am_oid, typmap::am_typ, Assert, ForwardScanDirection, GETSTRUCT, heap_getnext(), i, MemoryContextAlloc(), NoLock, repalloc(), table_beginscan_catalog(), table_close(), table_endscan(), table_open(), and TopMemoryContext.

Referenced by boot_openrel(), and gettype().

876 {
877  Relation rel;
878  TableScanDesc scan;
879  HeapTuple tup;
880  int nalloc;
881  int i;
882 
883  Assert(Typ == NULL);
884 
885  nalloc = 512;
886  Typ = (struct typmap **)
887  MemoryContextAlloc(TopMemoryContext, nalloc * sizeof(struct typmap *));
888 
889  rel = table_open(TypeRelationId, NoLock);
890  scan = table_beginscan_catalog(rel, 0, NULL);
891  i = 0;
892  while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
893  {
894  Form_pg_type typForm = (Form_pg_type) GETSTRUCT(tup);
895 
896  /* make sure there will be room for a trailing NULL pointer */
897  if (i >= nalloc - 1)
898  {
899  nalloc *= 2;
900  Typ = (struct typmap **)
901  repalloc(Typ, nalloc * sizeof(struct typmap *));
902  }
903  Typ[i] = (struct typmap *)
904  MemoryContextAlloc(TopMemoryContext, sizeof(struct typmap));
905  Typ[i]->am_oid = typForm->oid;
906  memcpy(&(Typ[i]->am_typ), typForm, sizeof(Typ[i]->am_typ));
907  i++;
908  }
909  Typ[i] = NULL; /* Fill trailing NULL pointer */
910  table_endscan(scan);
911  table_close(rel, NoLock);
912 }
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:167
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
TableScanDesc table_beginscan_catalog(Relation relation, int nkeys, struct ScanKeyData *key)
Definition: tableam.c:112
#define NoLock
Definition: lockdefs.h:34
HeapTuple heap_getnext(TableScanDesc sscan, ScanDirection direction)
Definition: heapam.c:1286
MemoryContext TopMemoryContext
Definition: mcxt.c:44
static struct typmap ** Typ
Definition: bootstrap.c:162
#define Assert(condition)
Definition: c.h:745
FormData_pg_type am_typ
Definition: bootstrap.c:159
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255
void * repalloc(void *pointer, Size size)
Definition: mcxt.c:1070
static void table_endscan(TableScanDesc scan)
Definition: tableam.h:863
Oid am_oid
Definition: bootstrap.c:158
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:797
int i
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:39

◆ ShutdownAuxiliaryProcess()

static void ShutdownAuxiliaryProcess ( int  code,
Datum  arg 
)
static

Definition at line 570 of file bootstrap.c.

References ConditionVariableCancelSleep(), LWLockReleaseAll(), and pgstat_report_wait_end().

Referenced by AuxiliaryProcessMain().

571 {
575 }
void ConditionVariableCancelSleep(void)
static void pgstat_report_wait_end(void)
Definition: pgstat.h:1386
void LWLockReleaseAll(void)
Definition: lwlock.c:1911

Variable Documentation

◆ Ap

struct typmap* Ap = NULL
static

Definition at line 163 of file bootstrap.c.

◆ attrtypes

Definition at line 74 of file bootstrap.c.

Referenced by boot_openrel(), BootstrapModeMain(), DefineAttr(), and InsertOneTuple().

◆ boot_reldesc

Relation boot_reldesc

Definition at line 72 of file bootstrap.c.

◆ bootstrap_data_checksum_version

uint32 bootstrap_data_checksum_version = 0

Definition at line 53 of file bootstrap.c.

Referenced by AuxiliaryProcessMain(), and InitControlFile().

◆ ILHead

IndexList* ILHead = NULL
static

Definition at line 184 of file bootstrap.c.

Referenced by index_register().

◆ MyAuxProcType

AuxProcType MyAuxProcType = NotAnAuxProcess

Definition at line 70 of file bootstrap.c.

Referenced by AuxiliaryProcessMain(), and pgstat_initialize().

◆ n_types

const int n_types = sizeof(TypInfo) / sizeof(struct typinfo)
static

Definition at line 154 of file bootstrap.c.

Referenced by boot_get_type_io_data(), and gettype().

◆ nogc

MemoryContext nogc = NULL
static

Definition at line 168 of file bootstrap.c.

◆ Nulls

bool Nulls[MAXATTR]
static

Definition at line 166 of file bootstrap.c.

◆ numattr

int numattr

Definition at line 75 of file bootstrap.c.

Referenced by boot_openrel(), InsertOneTuple(), and tsvector_update_trigger().

◆ Typ

struct typmap** Typ = NULL
static

Definition at line 162 of file bootstrap.c.

Referenced by boot_get_type_io_data().

◆ TypInfo

const struct typinfo TypInfo[]
static

Definition at line 101 of file bootstrap.c.

◆ values

Datum values[MAXATTR]
static

Definition at line 165 of file bootstrap.c.

Referenced by _bt_check_unique(), aclexplode(), AddEnumLabel(), AddSubscriptionRelState(), AggregateCreate(), AlterCollation(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterOperator(), AlterPolicy(), AlterPublicationOptions(), AlterSetting(), AlterSubscription(), AlterTypeRecurse(), apply_returning_filter(), ApplyExtensionUpdates(), array_iterate(), array_map(), array_out(), array_replace_internal(), brin_deform_tuple(), brin_form_tuple(), brin_metapage_info(), brin_page_items(), bt_metap(), bt_page_print_tuples(), bt_page_stats(), build_pgstattuple_type(), build_sorted_items(), build_tuplestore_recursively(), CastCreate(), CatalogIndexInsert(), CollationCreate(), collectTSQueryValues(), comparetup_index_btree(), compute_index_stats(), compute_scalar_stats(), connect_pg_server(), connectDatabase(), ConnectDatabase(), ConversionCreate(), copy_replication_slot(), create_cursor(), CreateAccessMethod(), CreateComments(), CreateConstraintEntry(), CreateForeignDataWrapper(), CreateForeignServer(), CreateForeignTable(), CreateOpFamily(), CreatePolicy(), CreateProceduralLanguage(), CreatePublication(), CreateReplicationSlot(), CreateSharedComments(), CreateStatistics(), CreateSubscription(), CreateTableSpace(), CreateTransform(), CreateTrigger(), CreateUserMapping(), crosstab(), dblink_get_pkey(), DefineOpClass(), DefineTSConfiguration(), DefineTSDictionary(), DefineTSParser(), DefineTSTemplate(), deflist_to_tuplestore(), DiscreteKnapsack(), do_connect(), do_text_output_multiline(), doConnect(), each_object_field_end(), each_worker_jsonb(), elements_array_element_end(), elements_worker_jsonb(), EnumValuesCreate(), exec_move_row(), exec_rt_fetch(), ExecBuildAggTrans(), ExecCheckIndexConstraints(), ExecComputeStoredGenerated(), ExecEvalMinMax(), ExecEvalXmlExpr(), ExecFilterJunk(), ExecFindPartition(), ExecGrant_Attribute(), ExecGrant_Database(), ExecGrant_Fdw(), ExecGrant_ForeignServer(), ExecGrant_Function(), ExecGrant_Language(), ExecGrant_Largeobject(), ExecGrant_Namespace(), ExecGrant_Relation(), ExecGrant_Tablespace(), ExecGrant_Type(), ExecInitExprRec(), ExecInsertIndexTuples(), execute_dml_stmt(), ExtractReplicaIdentity(), file_acquire_sample_rows(), fill_hba_line(), fillRelOptions(), get_actual_variable_endpoint(), get_available_versions_for_extension(), get_crosstab_tuplestore(), get_text_array_contents(), GetConnection(), gin_leafpage_items(), gin_metapage_info(), gin_page_opaque_info(), hash_bitmap_info(), hash_metapage_info(), hash_page_items(), hash_page_stats(), heap_deform_tuple(), heap_modify_tuple(), heap_modify_tuple_by_cols(), heap_page_items(), heap_tuple_infomask_flags(), heapam_index_build_range_scan(), heapam_index_validate_scan(), heapam_relation_copy_for_cluster(), hstore_from_record(), hstore_populate_record(), IdentifySystem(), index_concurrently_swap(), index_truncate_tuple(), IndexCheckExclusion(), IndexSetParentIndex(), insert_event_trigger_tuple(), InsertExtensionTuple(), InsertPgClassTuple(), InsertRule(), intset_flush_buffered_values(), inv_truncate(), inv_write(), LargeObjectCreate(), LogicalOutputWrite(), logicalrep_write_tuple(), main(), make_tuple_from_result_row(), make_tuple_indirect(), MakeConfigurationMapping(), MakeOldSnapshotTimeMappingTuple(), materializeResult(), NamespaceCreate(), ndistinct_for_combination(), oid_array_to_list(), OperatorCreate(), OperatorShellMake(), page_header(), parse_key_value_arrays(), parseLocalRelOptions(), perform_pruning_base_step(), pg_armor(), pg_available_extensions(), pg_buffercache_pages(), pg_config(), pg_control_checkpoint(), pg_control_init(), pg_control_recovery(), pg_control_system(), pg_create_logical_replication_slot(), pg_create_physical_replication_slot(), pg_cursor(), pg_event_trigger_ddl_commands(), pg_event_trigger_dropped_objects(), pg_extension_update_paths(), pg_get_keywords(), pg_get_multixact_members(), pg_get_object_address(), pg_get_replication_slots(), pg_get_shmem_allocations(), pg_identify_object(), pg_identify_object_as_address(), pg_last_committed_xact(), pg_lock_status(), pg_logdir_ls_internal(), pg_ls_dir(), pg_ls_dir_files(), pg_partition_tree(), pg_prepared_statement(), pg_prepared_xact(), pg_replication_slot_advance(), pg_sequence_parameters(), pg_show_replication_origin_status(), pg_stat_file(), pg_stat_get_activity(), pg_stat_get_archiver(), pg_stat_get_progress_info(), pg_stat_get_slru(), pg_stat_get_subscription(), pg_stat_get_wal_receiver(), pg_stat_get_wal_senders(), pg_stat_statements_internal(), pg_stats_ext_mcvlist_items(), pg_stop_backup_v2(), pg_tablespace_databases(), pg_timezone_abbrevs(), pg_timezone_names(), pg_visibility(), pg_visibility_map(), pg_visibility_map_rel(), pg_visibility_map_summary(), pg_visibility_rel(), pg_walfile_name_offset(), pg_xact_commit_timestamp_origin(), pgp_armor_headers(), pgrowlocks(), pgstatginindex_internal(), pgstathashindex(), pgstatindex_impl(), pgstattuple_approx_internal(), plperl_build_tuple_result(), pltcl_build_tuple_result(), PLyGenericObject_ToComposite(), PLyMapping_ToComposite(), PLySequence_ToComposite(), populate_record(), pqPacketSend(), ProcedureCreate(), prs_process_call(), publication_add_relation(), PutMemoryContextsStatsTupleStore(), RangeCreate(), record_in(), record_out(), record_recv(), record_send(), recordExtensionInitPrivWorker(), RemoveRoleFromObjectPolicy(), replorigin_create(), SetDefaultACL(), SetSecurityLabel(), SetSharedSecurityLabel(), shdepAddDependency(), shdepChangeDep(), show_all_file_settings(), show_all_settings(), ShowAllGUCConfig(), slot_deform_heap_tuple(), split_text_accum_result(), sql_conn(), ssl_extension_info(), StartReplication(), statext_mcv_serialize(), statext_store(), StoreAttrDefault(), storeOperators(), StorePartitionKey(), storeProcedures(), StoreSingleInheritance(), test_huge_distances(), test_predtest(), tfuncLoadRows(), ts_process_call(), tsvector_unnest(), tt_process_call(), TypeCreate(), TypeShellMake(), unique_key_recheck(), update_attstats(), UpdateIndexRelation(), UpdateStatisticsForTypeChange(), UpdateSubscriptionRelState(), vacuumlo(), ValuesNext(), WaitForLockersMultiple(), and xpath_table().