PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
bootstrap.c File Reference
#include "postgres.h"
#include <unistd.h>
#include <signal.h>
#include "access/htup_details.h"
#include "bootstrap/bootstrap.h"
#include "catalog/index.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_type.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 "utils/tqual.h"
Include dependency graph for bootstrap.c:

Go to the source code of this file.

Data Structures

struct  typinfo
 
struct  typmap
 
struct  _IndexList
 

Macros

#define ALLOC(t, c)   ((t *) MemoryContextAllocZero(TopMemoryContext, (unsigned)(c) * sizeof(t)))
 
#define MARKNOTNULL(att)
 

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 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 (Oid objectid)
 
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)
 
char * MapArrayTypeName (const char *s)
 
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
 

Macro Definition Documentation

#define ALLOC (   t,
  c 
)    ((t *) MemoryContextAllocZero(TopMemoryContext, (unsigned)(c) * sizeof(t)))

Definition at line 51 of file bootstrap.c.

Referenced by boot_openrel(), and gettype().

#define MARKNOTNULL (   att)
Value:
((att)->attlen > 0 || \
(att)->atttypid == OIDVECTOROID || \
(att)->atttypid == INT2VECTOROID)
#define INT2VECTOROID
Definition: pg_type.h:312
#define OIDVECTOROID
Definition: pg_type.h:344

Referenced by DefineAttr().

Typedef Documentation

Function Documentation

static Form_pg_attribute AllocateAttribute ( void  )
static

Definition at line 1006 of file bootstrap.c.

References ATTRIBUTE_FIXED_PART_SIZE, MemoryContextAllocZero(), and TopMemoryContext.

Referenced by boot_openrel(), and DefineAttr().

1007 {
1008  return (Form_pg_attribute)
1010 }
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:184
#define ATTRIBUTE_FIXED_PART_SIZE
Definition: pg_attribute.h:176
MemoryContext TopMemoryContext
Definition: mcxt.c:43
void * MemoryContextAllocZero(MemoryContext context, Size size)
Definition: mcxt.c:784
void AuxiliaryProcessMain ( int  argc,
char *  argv[] 
)

Definition at line 193 of file bootstrap.c.

References Assert, BackgroundWriterMain(), BaseInit(), before_shmem_exit(), BgWriterProcess, bootstrap_data_checksum_version, bootstrap_signals(), BootstrapModeMain(), BootstrapProcess, BootstrapProcessing, BootStrapXLOG(), ChangeToDataDir(), CheckerModeMain(), CheckerProcess, CheckpointerMain(), CheckpointerProcess, CreateDataDirLockFile(), DataDir, elog, ereport, errcode(), errmsg(), ERROR, flag(), free, getopt(), IgnoreSystemIndexes, init_ps_display(), InitAuxiliaryProcess(), InitBufferPoolBackend(), InitializeGUCOptions(), InitializeMaxBackends(), InitStandaloneProcess(), InitXLOGAccess(), IsUnderPostmaster, MaxBackends, MAXPGPATH, MyAuxProcType, name, NormalProcessing, NULL, optarg, optind, OutputFileName, PANIC, ParseLongOption(), pfree(), PG_DATA_CHECKSUM_VERSION, PGC_POSTMASTER, PGC_S_ARGV, proc_exit(), ProcSignalInit(), progname, psprintf(), pstrdup(), SelectConfigFiles(), SetConfigOption(), SetProcessingMode, ShutdownAuxiliaryProcess(), StartupProcess, StartupProcessMain(), strlcpy(), userDoption, ValidatePgVersion(), value, WalReceiverMain(), WalReceiverProcess, WalWriterMain(), WalWriterProcess, and write_stderr.

Referenced by main(), and StartChildProcess().

194 {
195  char *progname = argv[0];
196  int flag;
197  char *userDoption = NULL;
198 
199  /*
200  * Initialize process environment (already done if under postmaster, but
201  * not if standalone).
202  */
203  if (!IsUnderPostmaster)
204  InitStandaloneProcess(argv[0]);
205 
206  /*
207  * process command arguments
208  */
209 
210  /* Set defaults, to be overridden by explicit options below */
211  if (!IsUnderPostmaster)
213 
214  /* Ignore the initial --boot argument, if present */
215  if (argc > 1 && strcmp(argv[1], "--boot") == 0)
216  {
217  argv++;
218  argc--;
219  }
220 
221  /* If no -x argument, we are a CheckerProcess */
223 
224  while ((flag = getopt(argc, argv, "B:c:d:D:Fkr:x:-:")) != -1)
225  {
226  switch (flag)
227  {
228  case 'B':
229  SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, PGC_S_ARGV);
230  break;
231  case 'D':
232  userDoption = pstrdup(optarg);
233  break;
234  case 'd':
235  {
236  /* Turn on debugging for the bootstrap process. */
237  char *debugstr;
238 
239  debugstr = psprintf("debug%s", optarg);
240  SetConfigOption("log_min_messages", debugstr,
242  SetConfigOption("client_min_messages", debugstr,
244  pfree(debugstr);
245  }
246  break;
247  case 'F':
248  SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
249  break;
250  case 'k':
252  break;
253  case 'r':
255  break;
256  case 'x':
257  MyAuxProcType = atoi(optarg);
258  break;
259  case 'c':
260  case '-':
261  {
262  char *name,
263  *value;
264 
265  ParseLongOption(optarg, &name, &value);
266  if (!value)
267  {
268  if (flag == '-')
269  ereport(ERROR,
270  (errcode(ERRCODE_SYNTAX_ERROR),
271  errmsg("--%s requires a value",
272  optarg)));
273  else
274  ereport(ERROR,
275  (errcode(ERRCODE_SYNTAX_ERROR),
276  errmsg("-c %s requires a value",
277  optarg)));
278  }
279 
281  free(name);
282  if (value)
283  free(value);
284  break;
285  }
286  default:
287  write_stderr("Try \"%s --help\" for more information.\n",
288  progname);
289  proc_exit(1);
290  break;
291  }
292  }
293 
294  if (argc != optind)
295  {
296  write_stderr("%s: invalid command-line arguments\n", progname);
297  proc_exit(1);
298  }
299 
300  /*
301  * Identify myself via ps
302  */
303  if (IsUnderPostmaster)
304  {
305  const char *statmsg;
306 
307  switch (MyAuxProcType)
308  {
309  case StartupProcess:
310  statmsg = "startup process";
311  break;
312  case BgWriterProcess:
313  statmsg = "writer process";
314  break;
315  case CheckpointerProcess:
316  statmsg = "checkpointer process";
317  break;
318  case WalWriterProcess:
319  statmsg = "wal writer process";
320  break;
321  case WalReceiverProcess:
322  statmsg = "wal receiver process";
323  break;
324  default:
325  statmsg = "??? process";
326  break;
327  }
328  init_ps_display(statmsg, "", "", "");
329  }
330 
331  /* Acquire configuration parameters, unless inherited from postmaster */
332  if (!IsUnderPostmaster)
333  {
334  if (!SelectConfigFiles(userDoption, progname))
335  proc_exit(1);
336  }
337 
338  /* Validate we have been given a reasonable-looking DataDir */
339  Assert(DataDir);
341 
342  /* Change into DataDir (if under postmaster, should be done already) */
343  if (!IsUnderPostmaster)
344  ChangeToDataDir();
345 
346  /* If standalone, create lockfile for data directory */
347  if (!IsUnderPostmaster)
348  CreateDataDirLockFile(false);
349 
351  IgnoreSystemIndexes = true;
352 
353  /* Initialize MaxBackends (if under postmaster, was done already) */
354  if (!IsUnderPostmaster)
356 
357  BaseInit();
358 
359  /*
360  * When we are an auxiliary process, we aren't going to do the full
361  * InitPostgres pushups, but there are a couple of things that need to get
362  * lit up even in an auxiliary process.
363  */
364  if (IsUnderPostmaster)
365  {
366  /*
367  * Create a PGPROC so we can use LWLocks. In the EXEC_BACKEND case,
368  * this was already done by SubPostmasterMain().
369  */
370 #ifndef EXEC_BACKEND
372 #endif
373 
374  /*
375  * Assign the ProcSignalSlot for an auxiliary process. Since it
376  * doesn't have a BackendId, the slot is statically allocated based on
377  * the auxiliary process type (MyAuxProcType). Backends use slots
378  * indexed in the range from 1 to MaxBackends (inclusive), so we use
379  * MaxBackends + AuxProcType + 1 as the index of the slot for an
380  * auxiliary process.
381  *
382  * This will need rethinking if we ever want more than one of a
383  * particular auxiliary process type.
384  */
386 
387  /* finish setting up bufmgr.c */
389 
390  /* register a before-shutdown callback for LWLock cleanup */
392  }
393 
394  /*
395  * XLOG operations
396  */
398 
399  switch (MyAuxProcType)
400  {
401  case CheckerProcess:
402  /* don't set signals, they're useless here */
403  CheckerModeMain();
404  proc_exit(1); /* should never return */
405 
406  case BootstrapProcess:
407 
408  /*
409  * There was a brief instant during which mode was Normal; this is
410  * okay. We need to be in bootstrap mode during BootStrapXLOG for
411  * the sake of multixact initialization.
412  */
415  BootStrapXLOG();
417  proc_exit(1); /* should never return */
418 
419  case StartupProcess:
420  /* don't set signals, startup process has its own agenda */
422  proc_exit(1); /* should never return */
423 
424  case BgWriterProcess:
425  /* don't set signals, bgwriter has its own agenda */
427  proc_exit(1); /* should never return */
428 
429  case CheckpointerProcess:
430  /* don't set signals, checkpointer has its own agenda */
432  proc_exit(1); /* should never return */
433 
434  case WalWriterProcess:
435  /* don't set signals, walwriter has its own agenda */
436  InitXLOGAccess();
437  WalWriterMain();
438  proc_exit(1); /* should never return */
439 
440  case WalReceiverProcess:
441  /* don't set signals, walreceiver has its own agenda */
442  WalReceiverMain();
443  proc_exit(1); /* should never return */
444 
445  default:
446  elog(PANIC, "unrecognized process type: %d", (int) MyAuxProcType);
447  proc_exit(1);
448  }
449 }
void InitAuxiliaryProcess(void)
Definition: proc.c:482
static struct @76 value
void WalWriterMain(void)
Definition: walwriter.c:98
char * pstrdup(const char *in)
Definition: mcxt.c:1165
char * psprintf(const char *fmt,...)
Definition: psprintf.c:46
void InitStandaloneProcess(const char *argv0)
Definition: miscinit.c:219
void ParseLongOption(const char *string, char **name, char **value)
Definition: guc.c:9327
void StartupProcessMain(void)
Definition: startup.c:178
void ValidatePgVersion(const char *path)
Definition: miscinit.c:1333
#define write_stderr(str)
Definition: parallel.c:182
void proc_exit(int code)
Definition: ipc.c:99
int errcode(int sqlerrcode)
Definition: elog.c:575
#define SetProcessingMode(mode)
Definition: miscadmin.h:371
void BootStrapXLOG(void)
Definition: xlog.c:4907
void BaseInit(void)
Definition: postinit.c:517
bool IgnoreSystemIndexes
Definition: miscinit.c:73
static void bootstrap_signals(void)
Definition: bootstrap.c:518
const char * progname
Definition: pg_standby.c:37
#define PANIC
Definition: elog.h:53
static void BootstrapModeMain(void)
Definition: bootstrap.c:471
int getopt(int nargc, char *const *nargv, const char *ostr)
Definition: getopt.c:72
void WalReceiverMain(void)
Definition: walreceiver.c:187
void pfree(void *pointer)
Definition: mcxt.c:992
int optind
Definition: getopt.c:51
#define ERROR
Definition: elog.h:43
void CreateDataDirLockFile(bool amPostmaster)
Definition: miscinit.c:1073
void InitXLOGAccess(void)
Definition: xlog.c:8072
#define MAXPGPATH
int MaxBackends
Definition: globals.c:126
char OutputFileName[MAXPGPATH]
Definition: globals.c:61
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
Definition: guc.c:6629
bool IsUnderPostmaster
Definition: globals.c:100
char * flag(int b)
Definition: test-ctype.c:33
void before_shmem_exit(pg_on_exit_callback function, Datum arg)
Definition: ipc.c:320
void ChangeToDataDir(void)
Definition: miscinit.c:115
#define ereport(elevel, rest)
Definition: elog.h:122
static void ShutdownAuxiliaryProcess(int code, Datum arg)
Definition: bootstrap.c:537
bool SelectConfigFiles(const char *userDoption, const char *progname)
Definition: guc.c:4646
AuxProcType MyAuxProcType
Definition: bootstrap.c:67
void CheckpointerMain(void)
Definition: checkpointer.c:193
#define free(a)
Definition: header.h:60
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:45
#define NULL
Definition: c.h:226
#define Assert(condition)
Definition: c.h:671
void InitializeMaxBackends(void)
Definition: postinit.c:495
const char * name
Definition: encode.c:521
void BackgroundWriterMain(void)
Definition: bgwriter.c:110
static const char * userDoption
Definition: postgres.c:159
void ProcSignalInit(int pss_idx)
Definition: procsignal.c:104
#define PG_DATA_CHECKSUM_VERSION
Definition: bufpage.h:197
int errmsg(const char *fmt,...)
Definition: elog.c:797
char * optarg
Definition: getopt.c:53
static void CheckerModeMain(void)
Definition: bootstrap.c:458
char * DataDir
Definition: globals.c:59
void InitBufferPoolBackend(void)
Definition: bufmgr.c:2444
uint32 bootstrap_data_checksum_version
Definition: bootstrap.c:48
#define elog
Definition: elog.h:219
void init_ps_display(const char *username, const char *dbname, const char *host_info, const char *initial_str)
Definition: ps_status.c:244
void InitializeGUCOptions(void)
Definition: guc.c:4424
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 932 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, NULL, OidIsValid, typinfo::outproc, and Typ.

Referenced by get_type_io_data(), and InsertOneValue().

940 {
941  if (Typ != NULL)
942  {
943  /* We have the boot-time contents of pg_type, so use it */
944  struct typmap **app;
945  struct typmap *ap;
946 
947  app = Typ;
948  while (*app && (*app)->am_oid != typid)
949  ++app;
950  ap = *app;
951  if (ap == NULL)
952  elog(ERROR, "type OID %u not found in Typ list", typid);
953 
954  *typlen = ap->am_typ.typlen;
955  *typbyval = ap->am_typ.typbyval;
956  *typalign = ap->am_typ.typalign;
957  *typdelim = ap->am_typ.typdelim;
958 
959  /* XXX this logic must match getTypeIOParam() */
960  if (OidIsValid(ap->am_typ.typelem))
961  *typioparam = ap->am_typ.typelem;
962  else
963  *typioparam = typid;
964 
965  *typinput = ap->am_typ.typinput;
966  *typoutput = ap->am_typ.typoutput;
967  }
968  else
969  {
970  /* We don't have pg_type yet, so use the hard-wired TypInfo array */
971  int typeindex;
972 
973  for (typeindex = 0; typeindex < n_types; typeindex++)
974  {
975  if (TypInfo[typeindex].oid == typid)
976  break;
977  }
978  if (typeindex >= n_types)
979  elog(ERROR, "type OID %u not found in TypInfo", typid);
980 
981  *typlen = TypInfo[typeindex].len;
982  *typbyval = TypInfo[typeindex].byval;
983  *typalign = TypInfo[typeindex].align;
984  /* We assume typdelim is ',' for all boot-time types */
985  *typdelim = ',';
986 
987  /* XXX this logic must match getTypeIOParam() */
988  if (OidIsValid(TypInfo[typeindex].elem))
989  *typioparam = TypInfo[typeindex].elem;
990  else
991  *typioparam = typid;
992 
993  *typinput = TypInfo[typeindex].inproc;
994  *typoutput = TypInfo[typeindex].outproc;
995  }
996 }
int16 len
Definition: bootstrap.c:89
char align
Definition: bootstrap.c:91
Oid inproc
Definition: bootstrap.c:94
#define OidIsValid(objectId)
Definition: c.h:534
#define ERROR
Definition: elog.h:43
Oid elem
Definition: bootstrap.c:88
static struct typmap ** Typ
Definition: bootstrap.c:159
#define NULL
Definition: c.h:226
FormData_pg_type am_typ
Definition: bootstrap.c:156
static const int n_types
Definition: bootstrap.c:151
static const struct typinfo TypInfo[]
Definition: bootstrap.c:98
bool byval
Definition: bootstrap.c:90
Oid am_oid
Definition: bootstrap.c:155
Oid outproc
Definition: bootstrap.c:95
#define elog
Definition: elog.h:219
void boot_openrel ( char *  relname)

Definition at line 554 of file bootstrap.c.

References ALLOC, AllocateAttribute(), typmap::am_oid, ATTRIBUTE_FIXED_PART_SIZE, tupleDesc::attrs, attrtypes, closerel(), DEBUG4, elog, ForwardScanDirection, GETSTRUCT, heap_beginscan_catalog(), heap_close, heap_endscan(), heap_getnext(), heap_open(), heap_openrv(), HeapTupleGetOid, i, makeRangeVar(), memmove, NAMEDATALEN, NameStr, NoLock, NULL, numattr, RelationData::rd_att, RelationData::rd_rel, Typ, and TypeRelationId.

555 {
556  int i;
557  struct typmap **app;
558  Relation rel;
559  HeapScanDesc scan;
560  HeapTuple tup;
561 
562  if (strlen(relname) >= NAMEDATALEN)
563  relname[NAMEDATALEN - 1] = '\0';
564 
565  if (Typ == NULL)
566  {
567  /* We can now load the pg_type data */
569  scan = heap_beginscan_catalog(rel, 0, NULL);
570  i = 0;
571  while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
572  ++i;
573  heap_endscan(scan);
574  app = Typ = ALLOC(struct typmap *, i + 1);
575  while (i-- > 0)
576  *app++ = ALLOC(struct typmap, 1);
577  *app = NULL;
578  scan = heap_beginscan_catalog(rel, 0, NULL);
579  app = Typ;
580  while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
581  {
582  (*app)->am_oid = HeapTupleGetOid(tup);
583  memcpy((char *) &(*app)->am_typ,
584  (char *) GETSTRUCT(tup),
585  sizeof((*app)->am_typ));
586  app++;
587  }
588  heap_endscan(scan);
589  heap_close(rel, NoLock);
590  }
591 
592  if (boot_reldesc != NULL)
593  closerel(NULL);
594 
595  elog(DEBUG4, "open relation %s, attrsize %d",
596  relname, (int) ATTRIBUTE_FIXED_PART_SIZE);
597 
598  boot_reldesc = heap_openrv(makeRangeVar(NULL, relname, -1), NoLock);
599  numattr = boot_reldesc->rd_rel->relnatts;
600  for (i = 0; i < numattr; i++)
601  {
602  if (attrtypes[i] == NULL)
604  memmove((char *) attrtypes[i],
605  (char *) boot_reldesc->rd_att->attrs[i],
607 
608  {
610 
611  elog(DEBUG4, "create attribute %d name %s len %d num %d type %u",
612  i, NameStr(at->attname), at->attlen, at->attnum,
613  at->atttypid);
614  }
615  }
616 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
void heap_endscan(HeapScanDesc scan)
Definition: heapam.c:1581
int numattr
Definition: bootstrap.c:72
Relation boot_reldesc
Definition: bootstrap.c:69
Form_pg_attribute * attrs
Definition: tupdesc.h:74
#define heap_close(r, l)
Definition: heapam.h:97
Form_pg_class rd_rel
Definition: rel.h:113
void closerel(char *name)
Definition: bootstrap.c:623
#define TypeRelationId
Definition: pg_type.h:34
#define DEBUG4
Definition: elog.h:22
#define NAMEDATALEN
#define NoLock
Definition: lockdefs.h:34
#define memmove(d, s, c)
Definition: c.h:1058
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:184
HeapScanDesc heap_beginscan_catalog(Relation relation, int nkeys, ScanKey key)
Definition: heapam.c:1402
#define ATTRIBUTE_FIXED_PART_SIZE
Definition: pg_attribute.h:176
static struct typmap ** Typ
Definition: bootstrap.c:159
HeapTuple heap_getnext(HeapScanDesc scan, ScanDirection direction)
Definition: heapam.c:1781
Relation heap_open(Oid relationId, LOCKMODE lockmode)
Definition: heapam.c:1287
TupleDesc rd_att
Definition: rel.h:114
Relation heap_openrv(const RangeVar *relation, LOCKMODE lockmode)
Definition: heapam.c:1315
#define NULL
Definition: c.h:226
#define ALLOC(t, c)
Definition: bootstrap.c:51
static Form_pg_attribute AllocateAttribute(void)
Definition: bootstrap.c:1006
Oid am_oid
Definition: bootstrap.c:155
int i
#define NameStr(name)
Definition: c.h:495
#define elog
Definition: elog.h:219
#define HeapTupleGetOid(tuple)
Definition: htup_details.h:695
RangeVar * makeRangeVar(char *schemaname, char *relname, int location)
Definition: makefuncs.c:419
Form_pg_attribute attrtypes[MAXATTR]
Definition: bootstrap.c:71
static void bootstrap_signals ( void  )
static

Definition at line 518 of file bootstrap.c.

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

Referenced by AuxiliaryProcessMain().

519 {
521 
522  /* Set up appropriately for interactive use */
523  pqsignal(SIGHUP, die);
524  pqsignal(SIGINT, die);
525  pqsignal(SIGTERM, die);
526  pqsignal(SIGQUIT, die);
527 }
#define SIGQUIT
Definition: win32.h:197
bool IsUnderPostmaster
Definition: globals.c:100
#define SIGHUP
Definition: win32.h:196
pqsigfunc pqsignal(int signum, pqsigfunc handler)
Definition: signal.c:168
#define Assert(condition)
Definition: c.h:671
void die(SIGNAL_ARGS)
Definition: postgres.c:2617
static void BootstrapModeMain ( void  )
static

Definition at line 471 of file bootstrap.c.

References Assert, attrtypes, boot_yyparse(), cleanup(), i, InitPostgres(), InitProcess(), InvalidOid, IsBootstrapProcessingMode, IsUnderPostmaster, MAXATTR, NULL, proc_exit(), and RelationMapFinishBootstrap().

Referenced by AuxiliaryProcessMain().

472 {
473  int i;
474 
477 
478  /*
479  * Do backend-like initialization for bootstrap mode
480  */
481  InitProcess();
482 
484 
485  /* Initialize stuff for bootstrap-file processing */
486  for (i = 0; i < MAXATTR; i++)
487  {
488  attrtypes[i] = NULL;
489  Nulls[i] = false;
490  }
491 
492  /*
493  * Process bootstrap input.
494  */
495  boot_yyparse();
496 
497  /*
498  * We should now know about all mapped relations, so it's okay to write
499  * out the initial relation mapping files.
500  */
502 
503  /* Clean up and exit */
504  cleanup();
505  proc_exit(0);
506 }
void RelationMapFinishBootstrap(void)
Definition: relmapper.c:537
int boot_yyparse(void)
void proc_exit(int code)
Definition: ipc.c:99
void InitProcess(void)
Definition: proc.c:287
bool IsUnderPostmaster
Definition: globals.c:100
#define MAXATTR
Definition: bootstrap.h:24
static void cleanup(void)
Definition: bootstrap.c:848
#define InvalidOid
Definition: postgres_ext.h:36
#define NULL
Definition: c.h:226
#define Assert(condition)
Definition: c.h:671
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:365
void InitPostgres(const char *in_dbname, Oid dboid, const char *username, Oid useroid, char *out_dbname)
Definition: postinit.c:558
int i
static bool Nulls[MAXATTR]
Definition: bootstrap.c:163
Form_pg_attribute attrtypes[MAXATTR]
Definition: bootstrap.c:71
void build_indices ( void  )

Definition at line 1104 of file bootstrap.c.

References heap_close, heap_open(), _IndexList::il_heap, _IndexList::il_ind, _IndexList::il_info, _IndexList::il_next, index_build(), index_close(), index_open(), NoLock, and NULL.

1105 {
1106  for (; ILHead != NULL; ILHead = ILHead->il_next)
1107  {
1108  Relation heap;
1109  Relation ind;
1110 
1111  /* need not bother with locks during bootstrap */
1112  heap = heap_open(ILHead->il_heap, NoLock);
1113  ind = index_open(ILHead->il_ind, NoLock);
1114 
1115  index_build(heap, ind, ILHead->il_info, false, false);
1116 
1117  index_close(ind, NoLock);
1118  heap_close(heap, NoLock);
1119  }
1120 }
struct _IndexList * il_next
Definition: bootstrap.c:178
Oid il_ind
Definition: bootstrap.c:176
static IndexList * ILHead
Definition: bootstrap.c:181
#define heap_close(r, l)
Definition: heapam.h:97
#define NoLock
Definition: lockdefs.h:34
IndexInfo * il_info
Definition: bootstrap.c:177
void index_build(Relation heapRelation, Relation indexRelation, IndexInfo *indexInfo, bool isprimary, bool isreindex)
Definition: index.c:2000
Relation heap_open(Oid relationId, LOCKMODE lockmode)
Definition: heapam.c:1287
#define NULL
Definition: c.h:226
Oid il_heap
Definition: bootstrap.c:175
void index_close(Relation relation, LOCKMODE lockmode)
Definition: indexam.c:176
Relation index_open(Oid relationId, LOCKMODE lockmode)
Definition: indexam.c:151
static void CheckerModeMain ( void  )
static

Definition at line 458 of file bootstrap.c.

References proc_exit().

Referenced by AuxiliaryProcessMain().

459 {
460  proc_exit(0);
461 }
void proc_exit(int code)
Definition: ipc.c:99
static void cleanup ( void  )
static

Definition at line 848 of file bootstrap.c.

References closerel(), and NULL.

Referenced by BootstrapModeMain(), conninfo_uri_parse_options(), ExecQueryUsingCursor(), pg_regexec(), print_aligned_text(), RecordTransactionCommit(), ReorderBufferRestoreChanges(), and SetWALFileNameForCleanup().

849 {
850  if (boot_reldesc != NULL)
851  closerel(NULL);
852 }
Relation boot_reldesc
Definition: bootstrap.c:69
void closerel(char *name)
Definition: bootstrap.c:623
#define NULL
Definition: c.h:226
void closerel ( char *  name)

Definition at line 623 of file bootstrap.c.

References DEBUG4, elog, ERROR, heap_close, NoLock, NULL, and RelationGetRelationName.

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

624 {
625  if (name)
626  {
627  if (boot_reldesc)
628  {
629  if (strcmp(RelationGetRelationName(boot_reldesc), name) != 0)
630  elog(ERROR, "close of %s when %s was expected",
632  }
633  else
634  elog(ERROR, "close of %s before any relation was opened",
635  name);
636  }
637 
638  if (boot_reldesc == NULL)
639  elog(ERROR, "no open relation to close");
640  else
641  {
642  elog(DEBUG4, "close relation %s",
645  boot_reldesc = NULL;
646  }
647 }
Relation boot_reldesc
Definition: bootstrap.c:69
#define heap_close(r, l)
Definition: heapam.h:97
#define DEBUG4
Definition: elog.h:22
#define ERROR
Definition: elog.h:43
#define NoLock
Definition: lockdefs.h:34
#define RelationGetRelationName(relation)
Definition: rel.h:433
#define NULL
Definition: c.h:226
const char * name
Definition: encode.c:521
#define elog
Definition: elog.h:219
void DefineAttr ( char *  name,
char *  type,
int  attnum,
int  nullness 
)

Definition at line 660 of file bootstrap.c.

References typinfo::align, AllocateAttribute(), typmap::am_oid, typmap::am_typ, Assert, ATTRIBUTE_FIXED_PART_SIZE, attrtypes, BOOTCOL_NULL_AUTO, BOOTCOL_NULL_FORCE_NOT_NULL, BOOTCOL_NULL_FORCE_NULL, typinfo::byval, closerel(), typinfo::collation, DEBUG4, elog, gettype(), i, InvalidOid, typinfo::len, MARKNOTNULL, MemSet, NameStr, namestrcpy(), NULL, typinfo::oid, typinfo::storage, and WARNING.

661 {
662  Oid typeoid;
663 
664  if (boot_reldesc != NULL)
665  {
666  elog(WARNING, "no open relations allowed with CREATE command");
667  closerel(NULL);
668  }
669 
670  if (attrtypes[attnum] == NULL)
671  attrtypes[attnum] = AllocateAttribute();
673 
674  namestrcpy(&attrtypes[attnum]->attname, name);
675  elog(DEBUG4, "column %s %s", NameStr(attrtypes[attnum]->attname), type);
676  attrtypes[attnum]->attnum = attnum + 1; /* fillatt */
677 
678  typeoid = gettype(type);
679 
680  if (Typ != NULL)
681  {
682  attrtypes[attnum]->atttypid = Ap->am_oid;
683  attrtypes[attnum]->attlen = Ap->am_typ.typlen;
684  attrtypes[attnum]->attbyval = Ap->am_typ.typbyval;
685  attrtypes[attnum]->attstorage = Ap->am_typ.typstorage;
686  attrtypes[attnum]->attalign = Ap->am_typ.typalign;
687  attrtypes[attnum]->attcollation = Ap->am_typ.typcollation;
688  /* if an array type, assume 1-dimensional attribute */
689  if (Ap->am_typ.typelem != InvalidOid && Ap->am_typ.typlen < 0)
690  attrtypes[attnum]->attndims = 1;
691  else
692  attrtypes[attnum]->attndims = 0;
693  }
694  else
695  {
696  attrtypes[attnum]->atttypid = TypInfo[typeoid].oid;
697  attrtypes[attnum]->attlen = TypInfo[typeoid].len;
698  attrtypes[attnum]->attbyval = TypInfo[typeoid].byval;
699  attrtypes[attnum]->attstorage = TypInfo[typeoid].storage;
700  attrtypes[attnum]->attalign = TypInfo[typeoid].align;
701  attrtypes[attnum]->attcollation = TypInfo[typeoid].collation;
702  /* if an array type, assume 1-dimensional attribute */
703  if (TypInfo[typeoid].elem != InvalidOid &&
704  attrtypes[attnum]->attlen < 0)
705  attrtypes[attnum]->attndims = 1;
706  else
707  attrtypes[attnum]->attndims = 0;
708  }
709 
710  attrtypes[attnum]->attstattarget = -1;
711  attrtypes[attnum]->attcacheoff = -1;
712  attrtypes[attnum]->atttypmod = -1;
713  attrtypes[attnum]->attislocal = true;
714 
715  if (nullness == BOOTCOL_NULL_FORCE_NOT_NULL)
716  {
717  attrtypes[attnum]->attnotnull = true;
718  }
719  else if (nullness == BOOTCOL_NULL_FORCE_NULL)
720  {
721  attrtypes[attnum]->attnotnull = false;
722  }
723  else
724  {
725  Assert(nullness == BOOTCOL_NULL_AUTO);
726 
727  /*
728  * Mark as "not null" if type is fixed-width and prior columns are
729  * too. This corresponds to case where column can be accessed
730  * directly via C struct declaration.
731  *
732  * oidvector and int2vector are also treated as not-nullable, even
733  * though they are no longer fixed-width.
734  */
735 #define MARKNOTNULL(att) \
736  ((att)->attlen > 0 || \
737  (att)->atttypid == OIDVECTOROID || \
738  (att)->atttypid == INT2VECTOROID)
739 
740  if (MARKNOTNULL(attrtypes[attnum]))
741  {
742  int i;
743 
744  /* check earlier attributes */
745  for (i = 0; i < attnum; i++)
746  {
747  if (!attrtypes[i]->attnotnull)
748  break;
749  }
750  if (i == attnum)
751  attrtypes[attnum]->attnotnull = true;
752  }
753  }
754 }
#define BOOTCOL_NULL_FORCE_NULL
Definition: bootstrap.h:27
int16 len
Definition: bootstrap.c:89
char align
Definition: bootstrap.c:91
Relation boot_reldesc
Definition: bootstrap.c:69
#define BOOTCOL_NULL_AUTO
Definition: bootstrap.h:26
#define MARKNOTNULL(att)
#define MemSet(start, val, len)
Definition: c.h:853
unsigned int Oid
Definition: postgres_ext.h:31
void closerel(char *name)
Definition: bootstrap.c:623
static struct typmap * Ap
Definition: bootstrap.c:160
int namestrcpy(Name name, const char *str)
Definition: name.c:217
#define DEBUG4
Definition: elog.h:22
#define BOOTCOL_NULL_FORCE_NOT_NULL
Definition: bootstrap.h:28
#define ATTRIBUTE_FIXED_PART_SIZE
Definition: pg_attribute.h:176
#define WARNING
Definition: elog.h:40
Oid collation
Definition: bootstrap.c:93
static struct typmap ** Typ
Definition: bootstrap.c:159
#define InvalidOid
Definition: postgres_ext.h:36
#define NULL
Definition: c.h:226
#define Assert(condition)
Definition: c.h:671
char storage
Definition: bootstrap.c:92
FormData_pg_type am_typ
Definition: bootstrap.c:156
static Form_pg_attribute AllocateAttribute(void)
Definition: bootstrap.c:1006
static const struct typinfo TypInfo[]
Definition: bootstrap.c:98
const char * name
Definition: encode.c:521
bool byval
Definition: bootstrap.c:90
static Oid gettype(char *type)
Definition: bootstrap.c:866
Oid am_oid
Definition: bootstrap.c:155
int i
#define NameStr(name)
Definition: c.h:495
Oid oid
Definition: bootstrap.c:87
#define elog
Definition: elog.h:219
Form_pg_attribute attrtypes[MAXATTR]
Definition: bootstrap.c:71
static Oid gettype ( char *  type)
static

Definition at line 866 of file bootstrap.c.

References ALLOC, typmap::am_oid, typmap::am_typ, DEBUG4, elog, ERROR, ForwardScanDirection, GETSTRUCT, heap_beginscan_catalog(), heap_close, heap_endscan(), heap_getnext(), heap_open(), HeapTupleGetOid, i, memmove, n_types, name, NAMEDATALEN, NameStr, NoLock, NULL, Typ, and TypeRelationId.

Referenced by DefineAttr().

867 {
868  int i;
869  Relation rel;
870  HeapScanDesc scan;
871  HeapTuple tup;
872  struct typmap **app;
873 
874  if (Typ != NULL)
875  {
876  for (app = Typ; *app != NULL; app++)
877  {
878  if (strncmp(NameStr((*app)->am_typ.typname), type, NAMEDATALEN) == 0)
879  {
880  Ap = *app;
881  return (*app)->am_oid;
882  }
883  }
884  }
885  else
886  {
887  for (i = 0; i < n_types; i++)
888  {
889  if (strncmp(type, TypInfo[i].name, NAMEDATALEN) == 0)
890  return i;
891  }
892  elog(DEBUG4, "external type: %s", type);
894  scan = heap_beginscan_catalog(rel, 0, NULL);
895  i = 0;
896  while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
897  ++i;
898  heap_endscan(scan);
899  app = Typ = ALLOC(struct typmap *, i + 1);
900  while (i-- > 0)
901  *app++ = ALLOC(struct typmap, 1);
902  *app = NULL;
903  scan = heap_beginscan_catalog(rel, 0, NULL);
904  app = Typ;
905  while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
906  {
907  (*app)->am_oid = HeapTupleGetOid(tup);
908  memmove((char *) &(*app++)->am_typ,
909  (char *) GETSTRUCT(tup),
910  sizeof((*app)->am_typ));
911  }
912  heap_endscan(scan);
913  heap_close(rel, NoLock);
914  return gettype(type);
915  }
916  elog(ERROR, "unrecognized type \"%s\"", type);
917  /* not reached, here to make compiler happy */
918  return 0;
919 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
void heap_endscan(HeapScanDesc scan)
Definition: heapam.c:1581
#define heap_close(r, l)
Definition: heapam.h:97
static struct typmap * Ap
Definition: bootstrap.c:160
#define TypeRelationId
Definition: pg_type.h:34
#define DEBUG4
Definition: elog.h:22
#define NAMEDATALEN
#define ERROR
Definition: elog.h:43
#define NoLock
Definition: lockdefs.h:34
#define memmove(d, s, c)
Definition: c.h:1058
HeapScanDesc heap_beginscan_catalog(Relation relation, int nkeys, ScanKey key)
Definition: heapam.c:1402
static struct typmap ** Typ
Definition: bootstrap.c:159
HeapTuple heap_getnext(HeapScanDesc scan, ScanDirection direction)
Definition: heapam.c:1781
Relation heap_open(Oid relationId, LOCKMODE lockmode)
Definition: heapam.c:1287
#define NULL
Definition: c.h:226
#define ALLOC(t, c)
Definition: bootstrap.c:51
FormData_pg_type am_typ
Definition: bootstrap.c:156
static const int n_types
Definition: bootstrap.c:151
static const struct typinfo TypInfo[]
Definition: bootstrap.c:98
const char * name
Definition: encode.c:521
static Oid gettype(char *type)
Definition: bootstrap.c:866
Oid am_oid
Definition: bootstrap.c:155
int i
#define NameStr(name)
Definition: c.h:495
#define elog
Definition: elog.h:219
#define HeapTupleGetOid(tuple)
Definition: htup_details.h:695
void index_register ( Oid  heap,
Oid  ind,
IndexInfo indexInfo 
)

Definition at line 1054 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, NULL, and palloc().

Referenced by index_create().

1057 {
1058  IndexList *newind;
1059  MemoryContext oldcxt;
1060 
1061  /*
1062  * XXX mao 10/31/92 -- don't gc index reldescs, associated info at
1063  * bootstrap time. we'll declare the indexes now, but want to create them
1064  * later.
1065  */
1066 
1067  if (nogc == NULL)
1069  "BootstrapNoGC",
1071 
1072  oldcxt = MemoryContextSwitchTo(nogc);
1073 
1074  newind = (IndexList *) palloc(sizeof(IndexList));
1075  newind->il_heap = heap;
1076  newind->il_ind = ind;
1077  newind->il_info = (IndexInfo *) palloc(sizeof(IndexInfo));
1078 
1079  memcpy(newind->il_info, indexInfo, sizeof(IndexInfo));
1080  /* expressions will likely be null, but may as well copy it */
1081  newind->il_info->ii_Expressions = (List *)
1082  copyObject(indexInfo->ii_Expressions);
1083  newind->il_info->ii_ExpressionsState = NIL;
1084  /* predicate will likely be null, but may as well copy it */
1085  newind->il_info->ii_Predicate = (List *)
1086  copyObject(indexInfo->ii_Predicate);
1087  newind->il_info->ii_PredicateState = NIL;
1088  /* no exclusion constraints at bootstrap time, so no need to copy */
1089  Assert(indexInfo->ii_ExclusionOps == NULL);
1090  Assert(indexInfo->ii_ExclusionProcs == NULL);
1091  Assert(indexInfo->ii_ExclusionStrats == NULL);
1092 
1093  newind->il_next = ILHead;
1094  ILHead = newind;
1095 
1096  MemoryContextSwitchTo(oldcxt);
1097 }
struct _IndexList * il_next
Definition: bootstrap.c:178
#define NIL
Definition: pg_list.h:69
Oid il_ind
Definition: bootstrap.c:176
List * ii_Predicate
Definition: execnodes.h:69
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
static IndexList * ILHead
Definition: bootstrap.c:181
Oid * ii_ExclusionProcs
Definition: execnodes.h:72
static MemoryContext nogc
Definition: bootstrap.c:165
void * copyObject(const void *from)
Definition: copyfuncs.c:4475
List * ii_ExpressionsState
Definition: execnodes.h:68
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:145
List * ii_PredicateState
Definition: execnodes.h:70
IndexInfo * il_info
Definition: bootstrap.c:177
MemoryContext AllocSetContextCreate(MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize)
Definition: aset.c:440
#define NULL
Definition: c.h:226
List * ii_Expressions
Definition: execnodes.h:67
#define Assert(condition)
Definition: c.h:671
Oid il_heap
Definition: bootstrap.c:175
Oid * ii_ExclusionOps
Definition: execnodes.h:71
void * palloc(Size size)
Definition: mcxt.c:891
uint16 * ii_ExclusionStrats
Definition: execnodes.h:73
Definition: pg_list.h:45
void InsertOneNull ( int  i)

Definition at line 835 of file bootstrap.c.

References Assert, DEBUG4, elog, i, MAXATTR, NULL, and PointerGetDatum.

836 {
837  elog(DEBUG4, "inserting column %d NULL", i);
838  Assert(i >= 0 && i < MAXATTR);
840  Nulls[i] = true;
841 }
#define PointerGetDatum(X)
Definition: postgres.h:564
#define DEBUG4
Definition: elog.h:22
#define MAXATTR
Definition: bootstrap.h:24
#define NULL
Definition: c.h:226
#define Assert(condition)
Definition: c.h:671
static Datum values[MAXATTR]
Definition: bootstrap.c:162
int i
#define elog
Definition: elog.h:219
static bool Nulls[MAXATTR]
Definition: bootstrap.c:163
void InsertOneTuple ( Oid  objectid)

Definition at line 765 of file bootstrap.c.

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

766 {
767  HeapTuple tuple;
768  TupleDesc tupDesc;
769  int i;
770 
771  elog(DEBUG4, "inserting row oid %u, %d columns", objectid, numattr);
772 
773  tupDesc = CreateTupleDesc(numattr,
774  RelationGetForm(boot_reldesc)->relhasoids,
775  attrtypes);
776  tuple = heap_form_tuple(tupDesc, values, Nulls);
777  if (objectid != (Oid) 0)
778  HeapTupleSetOid(tuple, objectid);
779  pfree(tupDesc); /* just free's tupDesc, not the attrtypes */
780 
782  heap_freetuple(tuple);
783  elog(DEBUG4, "row inserted");
784 
785  /*
786  * Reset null markers for next tuple
787  */
788  for (i = 0; i < numattr; i++)
789  Nulls[i] = false;
790 }
int numattr
Definition: bootstrap.c:72
#define RelationGetForm(relation)
Definition: rel.h:407
Relation boot_reldesc
Definition: bootstrap.c:69
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:692
TupleDesc CreateTupleDesc(int natts, bool hasoid, Form_pg_attribute *attrs)
Definition: tupdesc.c:112
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1374
unsigned int Oid
Definition: postgres_ext.h:31
#define DEBUG4
Definition: elog.h:22
#define HeapTupleSetOid(tuple, oid)
Definition: htup_details.h:698
void pfree(void *pointer)
Definition: mcxt.c:992
Oid simple_heap_insert(Relation relation, HeapTuple tup)
Definition: heapam.c:2926
static Datum values[MAXATTR]
Definition: bootstrap.c:162
int i
#define elog
Definition: elog.h:219
static bool Nulls[MAXATTR]
Definition: bootstrap.c:163
Form_pg_attribute attrtypes[MAXATTR]
Definition: bootstrap.c:71
void InsertOneValue ( char *  value,
int  i 
)

Definition at line 797 of file bootstrap.c.

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

798 {
799  Oid typoid;
800  int16 typlen;
801  bool typbyval;
802  char typalign;
803  char typdelim;
804  Oid typioparam;
805  Oid typinput;
806  Oid typoutput;
807 
808  AssertArg(i >= 0 && i < MAXATTR);
809 
810  elog(DEBUG4, "inserting column %d value \"%s\"", i, value);
811 
812  typoid = boot_reldesc->rd_att->attrs[i]->atttypid;
813 
814  boot_get_type_io_data(typoid,
815  &typlen, &typbyval, &typalign,
816  &typdelim, &typioparam,
817  &typinput, &typoutput);
818 
819  values[i] = OidInputFunctionCall(typinput, value, typioparam, -1);
820 
821  /*
822  * We use ereport not elog here so that parameters aren't evaluated unless
823  * the message is going to be printed, which generally it isn't
824  */
825  ereport(DEBUG4,
826  (errmsg_internal("inserted -> %s",
827  OidOutputFunctionCall(typoutput, values[i]))));
828 }
signed short int16
Definition: c.h:252
static struct @76 value
Relation boot_reldesc
Definition: bootstrap.c:69
Form_pg_attribute * attrs
Definition: tupdesc.h:74
unsigned int Oid
Definition: postgres_ext.h:31
#define DEBUG4
Definition: elog.h:22
#define MAXATTR
Definition: bootstrap.h:24
#define ereport(elevel, rest)
Definition: elog.h:122
#define AssertArg(condition)
Definition: c.h:673
TupleDesc rd_att
Definition: rel.h:114
int errmsg_internal(const char *fmt,...)
Definition: elog.c:827
static Datum values[MAXATTR]
Definition: bootstrap.c:162
char * OidOutputFunctionCall(Oid functionId, Datum val)
Definition: fmgr.c:2006
int i
#define elog
Definition: elog.h:219
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:1997
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:932
char* MapArrayTypeName ( const char *  s)

Definition at line 1025 of file bootstrap.c.

References i, NAMEDATALEN, and pstrdup().

1026 {
1027  int i,
1028  j;
1029  char newStr[NAMEDATALEN];
1030 
1031  newStr[0] = '_';
1032  j = 1;
1033  for (i = 0; i < NAMEDATALEN - 2 && s[i] != '['; i++, j++)
1034  newStr[j] = s[i];
1035 
1036  newStr[j] = '\0';
1037 
1038  return pstrdup(newStr);
1039 }
char * pstrdup(const char *in)
Definition: mcxt.c:1165
#define NAMEDATALEN
int i
static void ShutdownAuxiliaryProcess ( int  code,
Datum  arg 
)
static

Definition at line 537 of file bootstrap.c.

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

Referenced by AuxiliaryProcessMain().

538 {
542 }
void ConditionVariableCancelSleep(void)
static void pgstat_report_wait_end(void)
Definition: pgstat.h:1124
void LWLockReleaseAll(void)
Definition: lwlock.c:1813

Variable Documentation

struct typmap* Ap = NULL
static

Definition at line 160 of file bootstrap.c.

Definition at line 71 of file bootstrap.c.

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

Relation boot_reldesc

Definition at line 69 of file bootstrap.c.

uint32 bootstrap_data_checksum_version = 0

Definition at line 48 of file bootstrap.c.

Referenced by AuxiliaryProcessMain(), and BootStrapXLOG().

IndexList* ILHead = NULL
static

Definition at line 181 of file bootstrap.c.

Referenced by index_register().

AuxProcType MyAuxProcType = NotAnAuxProcess

Definition at line 67 of file bootstrap.c.

Referenced by AuxiliaryProcessMain().

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

Definition at line 151 of file bootstrap.c.

Referenced by boot_get_type_io_data(), and gettype().

MemoryContext nogc = NULL
static

Definition at line 165 of file bootstrap.c.

bool Nulls[MAXATTR]
static

Definition at line 163 of file bootstrap.c.

int numattr

Definition at line 72 of file bootstrap.c.

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

struct typmap** Typ = NULL
static

Definition at line 159 of file bootstrap.c.

Referenced by boot_get_type_io_data(), boot_openrel(), and gettype().

const struct typinfo TypInfo[]
static

Definition at line 98 of file bootstrap.c.

Datum values[MAXATTR]
static

Definition at line 162 of file bootstrap.c.

Referenced by _bt_check_unique(), _connectDB(), _int_matchsel(), aclexplode(), AddEnumLabel(), AggregateCreate(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterOperator(), AlterPolicy(), AlterPublicationOptions(), AlterSetting(), AlterSubscription(), ApplyExtensionUpdates(), array_iterate(), array_map(), array_out(), array_replace_internal(), ATRewriteTable(), booltestsel(), brin_deform_tuple(), brin_form_tuple(), brin_metapage_info(), brin_page_items(), bt_metap(), bt_page_items(), bt_page_stats(), build_dummy_tuple(), build_pgstattuple_type(), build_tuplestore_recursively(), calc_arraycontsel(), CatalogIndexInsert(), CollationCreate(), collectTSQueryValues(), comparetup_index_btree(), compute_index_stats(), compute_scalar_stats(), connect_pg_server(), connectDatabase(), ConnectDatabase(), ConversionCreate(), copy_heap_data(), CopyFrom(), copyTemplateDependencies(), CopyTo(), create_cursor(), create_proc_lang(), CreateAccessMethod(), CreateCast(), CreateComments(), CreateConstraintEntry(), CreateForeignDataWrapper(), CreateForeignServer(), CreateForeignTable(), CreateOpFamily(), CreatePolicy(), CreatePublication(), CreateReplicationSlot(), CreateSharedComments(), CreateSubscription(), CreateTableSpace(), CreateTransform(), CreateTrigger(), CreateUserMapping(), crosstab(), dblink_get_notify(), dblink_get_pkey(), DefineOpClass(), DefineTSConfiguration(), DefineTSDictionary(), DefineTSParser(), DefineTSTemplate(), deflist_to_tuplestore(), do_connect(), do_text_output_multiline(), doConnect(), each_object_field_end(), each_worker_jsonb(), elements_array_element_end(), elements_worker_jsonb(), EnumValuesCreate(), exec_assign_value(), ExecCheckIndexConstraints(), ExecEvalFieldStore(), ExecEvalRow(), ExecEvalXml(), ExecFilterJunk(), ExecGrant_Attribute(), ExecGrant_Database(), ExecGrant_Fdw(), ExecGrant_ForeignServer(), ExecGrant_Function(), ExecGrant_Language(), ExecGrant_Largeobject(), ExecGrant_Namespace(), ExecGrant_Relation(), ExecGrant_Tablespace(), ExecGrant_Type(), ExecHashBuildSkewHash(), ExecInsertIndexTuples(), ExecProject(), execute_dml_stmt(), ExtractReplicaIdentity(), file_acquire_sample_rows(), fill_hba_line(), fillRelOptions(), get_actual_variable_range(), get_available_versions_for_extension(), get_crosstab_tuplestore(), get_partition_for_tuple(), get_text_array_contents(), get_variable_range(), GetConnection(), gin_leafpage_items(), gin_metapage_info(), gin_page_opaque_info(), hash_bitmap_info(), hash_metapage_info(), hash_page_items(), hash_page_stats(), heap_modify_tuple(), heap_modify_tuple_by_cols(), heap_page_items(), histogram_selectivity(), hstore_from_record(), hstore_populate_record(), IdentifySystem(), IndexBuildHeapRangeScan(), IndexCheckExclusion(), ineq_histogram_selectivity(), insert_event_trigger_tuple(), InsertExtensionTuple(), InsertPgAttributeTuple(), InsertPgClassTuple(), InsertRule(), inv_truncate(), inv_write(), LargeObjectCreate(), LogicalOutputWrite(), logicalrep_write_tuple(), main(), make_row_from_rec_and_jsonb(), make_tuple_from_result_row(), make_tuple_indirect(), MakeConfigurationMapping(), materializeQueryResult(), materializeResult(), mcv_selectivity(), NamespaceCreate(), oid_array_to_list(), OperatorCreate(), OperatorShellMake(), page_header(), parse_key_value_arrays(), 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_identify_object(), pg_identify_object_as_address(), pg_last_committed_xact(), pg_lock_status(), pg_logdir_ls(), pg_prepared_statement(), pg_prepared_xact(), 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_subscription(), pg_stat_get_wal_receiver(), pg_stat_get_wal_senders(), pg_stat_statements_internal(), pg_stop_backup_v2(), 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(), 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_worker(), populate_recordset_object_end(), ProcedureCreate(), prs_process_call(), publication_add_relation(), RangeCreate(), record_in(), record_out(), record_recv(), record_send(), recordExtensionInitPrivWorker(), recordMultipleDependencies(), RemoveRoleFromObjectPolicy(), replorigin_create(), scalararraysel_containment(), SetDefaultACL(), SetSecurityLabel(), SetSharedSecurityLabel(), shdepAddDependency(), shdepChangeDep(), show_all_file_settings(), show_all_settings(), ShowAllGUCConfig(), slot_deform_tuple(), sql_conn(), ssl_extension_info(), StartReplication(), StoreAttrDefault(), StoreCatalogInheritance1(), StoreIndexTuple(), storeOperators(), StorePartitionKey(), storeProcedures(), TQExamineRecord(), TQRemapTuple(), ts_process_call(), tsquerysel(), tsvector_unnest(), tt_process_call(), tuple_equals_slot(), TypeCreate(), TypeShellMake(), unique_key_recheck(), update_attstats(), UpdateIndexRelation(), vacuumlo(), validate_index_heapscan(), ValuesNext(), var_eq_const(), and xpath_table().