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 "access/xact.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 52 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 1013 of file bootstrap.c.

References ATTRIBUTE_FIXED_PART_SIZE, MemoryContextAllocZero(), and TopMemoryContext.

Referenced by boot_openrel(), and DefineAttr().

1014 {
1015  return (Form_pg_attribute)
1017 }
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:187
#define ATTRIBUTE_FIXED_PART_SIZE
Definition: pg_attribute.h:179
MemoryContext TopMemoryContext
Definition: mcxt.c:43
void * MemoryContextAllocZero(MemoryContext context, Size size)
Definition: mcxt.c:742
void AuxiliaryProcessMain ( int  argc,
char *  argv[] 
)

Definition at line 194 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, pgstat_bestart(), pgstat_initialize(), 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().

195 {
196  char *progname = argv[0];
197  int flag;
198  char *userDoption = NULL;
199 
200  /*
201  * Initialize process environment (already done if under postmaster, but
202  * not if standalone).
203  */
204  if (!IsUnderPostmaster)
205  InitStandaloneProcess(argv[0]);
206 
207  /*
208  * process command arguments
209  */
210 
211  /* Set defaults, to be overridden by explicit options below */
212  if (!IsUnderPostmaster)
214 
215  /* Ignore the initial --boot argument, if present */
216  if (argc > 1 && strcmp(argv[1], "--boot") == 0)
217  {
218  argv++;
219  argc--;
220  }
221 
222  /* If no -x argument, we are a CheckerProcess */
224 
225  while ((flag = getopt(argc, argv, "B:c:d:D:Fkr:x:-:")) != -1)
226  {
227  switch (flag)
228  {
229  case 'B':
230  SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, PGC_S_ARGV);
231  break;
232  case 'D':
233  userDoption = pstrdup(optarg);
234  break;
235  case 'd':
236  {
237  /* Turn on debugging for the bootstrap process. */
238  char *debugstr;
239 
240  debugstr = psprintf("debug%s", optarg);
241  SetConfigOption("log_min_messages", debugstr,
243  SetConfigOption("client_min_messages", debugstr,
245  pfree(debugstr);
246  }
247  break;
248  case 'F':
249  SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV);
250  break;
251  case 'k':
253  break;
254  case 'r':
256  break;
257  case 'x':
258  MyAuxProcType = atoi(optarg);
259  break;
260  case 'c':
261  case '-':
262  {
263  char *name,
264  *value;
265 
266  ParseLongOption(optarg, &name, &value);
267  if (!value)
268  {
269  if (flag == '-')
270  ereport(ERROR,
271  (errcode(ERRCODE_SYNTAX_ERROR),
272  errmsg("--%s requires a value",
273  optarg)));
274  else
275  ereport(ERROR,
276  (errcode(ERRCODE_SYNTAX_ERROR),
277  errmsg("-c %s requires a value",
278  optarg)));
279  }
280 
282  free(name);
283  if (value)
284  free(value);
285  break;
286  }
287  default:
288  write_stderr("Try \"%s --help\" for more information.\n",
289  progname);
290  proc_exit(1);
291  break;
292  }
293  }
294 
295  if (argc != optind)
296  {
297  write_stderr("%s: invalid command-line arguments\n", progname);
298  proc_exit(1);
299  }
300 
301  /*
302  * Identify myself via ps
303  */
304  if (IsUnderPostmaster)
305  {
306  const char *statmsg;
307 
308  switch (MyAuxProcType)
309  {
310  case StartupProcess:
311  statmsg = "startup process";
312  break;
313  case BgWriterProcess:
314  statmsg = "writer process";
315  break;
316  case CheckpointerProcess:
317  statmsg = "checkpointer process";
318  break;
319  case WalWriterProcess:
320  statmsg = "wal writer process";
321  break;
322  case WalReceiverProcess:
323  statmsg = "wal receiver process";
324  break;
325  default:
326  statmsg = "??? process";
327  break;
328  }
329  init_ps_display(statmsg, "", "", "");
330  }
331 
332  /* Acquire configuration parameters, unless inherited from postmaster */
333  if (!IsUnderPostmaster)
334  {
335  if (!SelectConfigFiles(userDoption, progname))
336  proc_exit(1);
337  }
338 
339  /* Validate we have been given a reasonable-looking DataDir */
340  Assert(DataDir);
342 
343  /* Change into DataDir (if under postmaster, should be done already) */
344  if (!IsUnderPostmaster)
345  ChangeToDataDir();
346 
347  /* If standalone, create lockfile for data directory */
348  if (!IsUnderPostmaster)
349  CreateDataDirLockFile(false);
350 
352  IgnoreSystemIndexes = true;
353 
354  /* Initialize MaxBackends (if under postmaster, was done already) */
355  if (!IsUnderPostmaster)
357 
358  BaseInit();
359 
360  /*
361  * When we are an auxiliary process, we aren't going to do the full
362  * InitPostgres pushups, but there are a couple of things that need to get
363  * lit up even in an auxiliary process.
364  */
365  if (IsUnderPostmaster)
366  {
367  /*
368  * Create a PGPROC so we can use LWLocks. In the EXEC_BACKEND case,
369  * this was already done by SubPostmasterMain().
370  */
371 #ifndef EXEC_BACKEND
373 #endif
374 
375  /*
376  * Assign the ProcSignalSlot for an auxiliary process. Since it
377  * doesn't have a BackendId, the slot is statically allocated based on
378  * the auxiliary process type (MyAuxProcType). Backends use slots
379  * indexed in the range from 1 to MaxBackends (inclusive), so we use
380  * MaxBackends + AuxProcType + 1 as the index of the slot for an
381  * auxiliary process.
382  *
383  * This will need rethinking if we ever want more than one of a
384  * particular auxiliary process type.
385  */
387 
388  /* finish setting up bufmgr.c */
390 
391  /* Initialize backend status information */
393  pgstat_bestart();
394 
395  /* register a before-shutdown callback for LWLock cleanup */
397  }
398 
399  /*
400  * XLOG operations
401  */
403 
404  switch (MyAuxProcType)
405  {
406  case CheckerProcess:
407  /* don't set signals, they're useless here */
408  CheckerModeMain();
409  proc_exit(1); /* should never return */
410 
411  case BootstrapProcess:
412 
413  /*
414  * There was a brief instant during which mode was Normal; this is
415  * okay. We need to be in bootstrap mode during BootStrapXLOG for
416  * the sake of multixact initialization.
417  */
420  BootStrapXLOG();
422  proc_exit(1); /* should never return */
423 
424  case StartupProcess:
425  /* don't set signals, startup process has its own agenda */
427  proc_exit(1); /* should never return */
428 
429  case BgWriterProcess:
430  /* don't set signals, bgwriter has its own agenda */
432  proc_exit(1); /* should never return */
433 
434  case CheckpointerProcess:
435  /* don't set signals, checkpointer has its own agenda */
437  proc_exit(1); /* should never return */
438 
439  case WalWriterProcess:
440  /* don't set signals, walwriter has its own agenda */
441  InitXLOGAccess();
442  WalWriterMain();
443  proc_exit(1); /* should never return */
444 
445  case WalReceiverProcess:
446  /* don't set signals, walreceiver has its own agenda */
447  WalReceiverMain();
448  proc_exit(1); /* should never return */
449 
450  default:
451  elog(PANIC, "unrecognized process type: %d", (int) MyAuxProcType);
452  proc_exit(1);
453  }
454 }
void InitAuxiliaryProcess(void)
Definition: proc.c:482
void WalWriterMain(void)
Definition: walwriter.c:98
char * pstrdup(const char *in)
Definition: mcxt.c:1077
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:9378
void StartupProcessMain(void)
Definition: startup.c:179
void ValidatePgVersion(const char *path)
Definition: miscinit.c:1349
#define write_stderr(str)
Definition: parallel.c:180
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:4947
void BaseInit(void)
Definition: postinit.c:517
bool IgnoreSystemIndexes
Definition: miscinit.c:73
static void bootstrap_signals(void)
Definition: bootstrap.c:525
const char * progname
Definition: pg_standby.c:37
#define PANIC
Definition: elog.h:53
static void BootstrapModeMain(void)
Definition: bootstrap.c:476
int getopt(int nargc, char *const *nargv, const char *ostr)
Definition: getopt.c:72
void WalReceiverMain(void)
Definition: walreceiver.c:188
void pfree(void *pointer)
Definition: mcxt.c:950
int optind
Definition: getopt.c:51
#define ERROR
Definition: elog.h:43
void CreateDataDirLockFile(bool amPostmaster)
Definition: miscinit.c:1080
void InitXLOGAccess(void)
Definition: xlog.c:8141
#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:6676
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
void pgstat_initialize(void)
Definition: pgstat.c:2709
#define ereport(elevel, rest)
Definition: elog.h:122
static void ShutdownAuxiliaryProcess(int code, Datum arg)
Definition: bootstrap.c:544
bool SelectConfigFiles(const char *userDoption, const char *progname)
Definition: guc.c:4693
AuxProcType MyAuxProcType
Definition: bootstrap.c:68
void CheckpointerMain(void)
Definition: checkpointer.c:193
#define free(a)
Definition: header.h:65
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:45
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
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
void pgstat_bestart(void)
Definition: pgstat.c:2749
char * optarg
Definition: getopt.c:53
static void CheckerModeMain(void)
Definition: bootstrap.c:463
char * DataDir
Definition: globals.c:59
void InitBufferPoolBackend(void)
Definition: bufmgr.c:2461
uint32 bootstrap_data_checksum_version
Definition: bootstrap.c:49
#define elog
Definition: elog.h:219
static struct @121 value
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:4471
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 939 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().

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

Definition at line 561 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.

562 {
563  int i;
564  struct typmap **app;
565  Relation rel;
566  HeapScanDesc scan;
567  HeapTuple tup;
568 
569  if (strlen(relname) >= NAMEDATALEN)
570  relname[NAMEDATALEN - 1] = '\0';
571 
572  if (Typ == NULL)
573  {
574  /* We can now load the pg_type data */
576  scan = heap_beginscan_catalog(rel, 0, NULL);
577  i = 0;
578  while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
579  ++i;
580  heap_endscan(scan);
581  app = Typ = ALLOC(struct typmap *, i + 1);
582  while (i-- > 0)
583  *app++ = ALLOC(struct typmap, 1);
584  *app = NULL;
585  scan = heap_beginscan_catalog(rel, 0, NULL);
586  app = Typ;
587  while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
588  {
589  (*app)->am_oid = HeapTupleGetOid(tup);
590  memcpy((char *) &(*app)->am_typ,
591  (char *) GETSTRUCT(tup),
592  sizeof((*app)->am_typ));
593  app++;
594  }
595  heap_endscan(scan);
596  heap_close(rel, NoLock);
597  }
598 
599  if (boot_reldesc != NULL)
600  closerel(NULL);
601 
602  elog(DEBUG4, "open relation %s, attrsize %d",
603  relname, (int) ATTRIBUTE_FIXED_PART_SIZE);
604 
605  boot_reldesc = heap_openrv(makeRangeVar(NULL, relname, -1), NoLock);
606  numattr = boot_reldesc->rd_rel->relnatts;
607  for (i = 0; i < numattr; i++)
608  {
609  if (attrtypes[i] == NULL)
611  memmove((char *) attrtypes[i],
612  (char *) boot_reldesc->rd_att->attrs[i],
614 
615  {
617 
618  elog(DEBUG4, "create attribute %d name %s len %d num %d type %u",
619  i, NameStr(at->attname), at->attlen, at->attnum,
620  at->atttypid);
621  }
622  }
623 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
void heap_endscan(HeapScanDesc scan)
Definition: heapam.c:1578
int numattr
Definition: bootstrap.c:73
Relation boot_reldesc
Definition: bootstrap.c:70
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:114
void closerel(char *name)
Definition: bootstrap.c:630
#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:187
HeapScanDesc heap_beginscan_catalog(Relation relation, int nkeys, ScanKey key)
Definition: heapam.c:1399
#define ATTRIBUTE_FIXED_PART_SIZE
Definition: pg_attribute.h:179
static struct typmap ** Typ
Definition: bootstrap.c:160
HeapTuple heap_getnext(HeapScanDesc scan, ScanDirection direction)
Definition: heapam.c:1794
Relation heap_open(Oid relationId, LOCKMODE lockmode)
Definition: heapam.c:1284
TupleDesc rd_att
Definition: rel.h:115
Relation heap_openrv(const RangeVar *relation, LOCKMODE lockmode)
Definition: heapam.c:1312
#define NULL
Definition: c.h:229
#define ALLOC(t, c)
Definition: bootstrap.c:52
static Form_pg_attribute AllocateAttribute(void)
Definition: bootstrap.c:1013
Oid am_oid
Definition: bootstrap.c:156
int i
#define NameStr(name)
Definition: c.h:499
#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:72
static void bootstrap_signals ( void  )
static

Definition at line 525 of file bootstrap.c.

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

Referenced by AuxiliaryProcessMain().

526 {
528 
529  /* Set up appropriately for interactive use */
530  pqsignal(SIGHUP, die);
531  pqsignal(SIGINT, die);
532  pqsignal(SIGTERM, die);
533  pqsignal(SIGQUIT, die);
534 }
#define SIGQUIT
Definition: win32.h:189
bool IsUnderPostmaster
Definition: globals.c:100
#define SIGHUP
Definition: win32.h:188
pqsigfunc pqsignal(int signum, pqsigfunc handler)
Definition: signal.c:168
#define Assert(condition)
Definition: c.h:675
void die(SIGNAL_ARGS)
Definition: postgres.c:2623
static void BootstrapModeMain ( void  )
static

Definition at line 476 of file bootstrap.c.

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

Referenced by AuxiliaryProcessMain().

477 {
478  int i;
479 
482 
483  /*
484  * Do backend-like initialization for bootstrap mode
485  */
486  InitProcess();
487 
489 
490  /* Initialize stuff for bootstrap-file processing */
491  for (i = 0; i < MAXATTR; i++)
492  {
493  attrtypes[i] = NULL;
494  Nulls[i] = false;
495  }
496 
497  /*
498  * Process bootstrap input.
499  */
501  boot_yyparse();
503 
504  /*
505  * We should now know about all mapped relations, so it's okay to write
506  * out the initial relation mapping files.
507  */
509 
510  /* Clean up and exit */
511  cleanup();
512  proc_exit(0);
513 }
void RelationMapFinishBootstrap(void)
Definition: relmapper.c:538
void CommitTransactionCommand(void)
Definition: xact.c:2747
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:855
#define InvalidOid
Definition: postgres_ext.h:36
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
void StartTransactionCommand(void)
Definition: xact.c:2677
#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:164
Form_pg_attribute attrtypes[MAXATTR]
Definition: bootstrap.c:72
void build_indices ( void  )

Definition at line 1111 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.

1112 {
1113  for (; ILHead != NULL; ILHead = ILHead->il_next)
1114  {
1115  Relation heap;
1116  Relation ind;
1117 
1118  /* need not bother with locks during bootstrap */
1119  heap = heap_open(ILHead->il_heap, NoLock);
1120  ind = index_open(ILHead->il_ind, NoLock);
1121 
1122  index_build(heap, ind, ILHead->il_info, false, false);
1123 
1124  index_close(ind, NoLock);
1125  heap_close(heap, NoLock);
1126  }
1127 }
struct _IndexList * il_next
Definition: bootstrap.c:179
Oid il_ind
Definition: bootstrap.c:177
static IndexList * ILHead
Definition: bootstrap.c:182
#define heap_close(r, l)
Definition: heapam.h:97
#define NoLock
Definition: lockdefs.h:34
IndexInfo * il_info
Definition: bootstrap.c:178
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:1284
#define NULL
Definition: c.h:229
Oid il_heap
Definition: bootstrap.c:176
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 463 of file bootstrap.c.

References proc_exit().

Referenced by AuxiliaryProcessMain().

464 {
465  proc_exit(0);
466 }
void proc_exit(int code)
Definition: ipc.c:99
static void cleanup ( void  )
static

Definition at line 855 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().

856 {
857  if (boot_reldesc != NULL)
858  closerel(NULL);
859 }
Relation boot_reldesc
Definition: bootstrap.c:70
void closerel(char *name)
Definition: bootstrap.c:630
#define NULL
Definition: c.h:229
void closerel ( char *  name)

Definition at line 630 of file bootstrap.c.

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

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

631 {
632  if (name)
633  {
634  if (boot_reldesc)
635  {
636  if (strcmp(RelationGetRelationName(boot_reldesc), name) != 0)
637  elog(ERROR, "close of %s when %s was expected",
639  }
640  else
641  elog(ERROR, "close of %s before any relation was opened",
642  name);
643  }
644 
645  if (boot_reldesc == NULL)
646  elog(ERROR, "no open relation to close");
647  else
648  {
649  elog(DEBUG4, "close relation %s",
652  boot_reldesc = NULL;
653  }
654 }
Relation boot_reldesc
Definition: bootstrap.c:70
#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:437
#define NULL
Definition: c.h:229
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 667 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.

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

Definition at line 873 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().

874 {
875  int i;
876  Relation rel;
877  HeapScanDesc scan;
878  HeapTuple tup;
879  struct typmap **app;
880 
881  if (Typ != NULL)
882  {
883  for (app = Typ; *app != NULL; app++)
884  {
885  if (strncmp(NameStr((*app)->am_typ.typname), type, NAMEDATALEN) == 0)
886  {
887  Ap = *app;
888  return (*app)->am_oid;
889  }
890  }
891  }
892  else
893  {
894  for (i = 0; i < n_types; i++)
895  {
896  if (strncmp(type, TypInfo[i].name, NAMEDATALEN) == 0)
897  return i;
898  }
899  elog(DEBUG4, "external type: %s", type);
901  scan = heap_beginscan_catalog(rel, 0, NULL);
902  i = 0;
903  while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
904  ++i;
905  heap_endscan(scan);
906  app = Typ = ALLOC(struct typmap *, i + 1);
907  while (i-- > 0)
908  *app++ = ALLOC(struct typmap, 1);
909  *app = NULL;
910  scan = heap_beginscan_catalog(rel, 0, NULL);
911  app = Typ;
912  while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
913  {
914  (*app)->am_oid = HeapTupleGetOid(tup);
915  memmove((char *) &(*app++)->am_typ,
916  (char *) GETSTRUCT(tup),
917  sizeof((*app)->am_typ));
918  }
919  heap_endscan(scan);
920  heap_close(rel, NoLock);
921  return gettype(type);
922  }
923  elog(ERROR, "unrecognized type \"%s\"", type);
924  /* not reached, here to make compiler happy */
925  return 0;
926 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
void heap_endscan(HeapScanDesc scan)
Definition: heapam.c:1578
#define heap_close(r, l)
Definition: heapam.h:97
static struct typmap * Ap
Definition: bootstrap.c:161
#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:1399
static struct typmap ** Typ
Definition: bootstrap.c:160
HeapTuple heap_getnext(HeapScanDesc scan, ScanDirection direction)
Definition: heapam.c:1794
Relation heap_open(Oid relationId, LOCKMODE lockmode)
Definition: heapam.c:1284
#define NULL
Definition: c.h:229
#define ALLOC(t, c)
Definition: bootstrap.c:52
FormData_pg_type am_typ
Definition: bootstrap.c:157
static const int n_types
Definition: bootstrap.c:152
static const struct typinfo TypInfo[]
Definition: bootstrap.c:99
const char * name
Definition: encode.c:521
static Oid gettype(char *type)
Definition: bootstrap.c:873
Oid am_oid
Definition: bootstrap.c:156
int i
#define NameStr(name)
Definition: c.h:499
#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 1061 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().

1064 {
1065  IndexList *newind;
1066  MemoryContext oldcxt;
1067 
1068  /*
1069  * XXX mao 10/31/92 -- don't gc index reldescs, associated info at
1070  * bootstrap time. we'll declare the indexes now, but want to create them
1071  * later.
1072  */
1073 
1074  if (nogc == NULL)
1076  "BootstrapNoGC",
1078 
1079  oldcxt = MemoryContextSwitchTo(nogc);
1080 
1081  newind = (IndexList *) palloc(sizeof(IndexList));
1082  newind->il_heap = heap;
1083  newind->il_ind = ind;
1084  newind->il_info = (IndexInfo *) palloc(sizeof(IndexInfo));
1085 
1086  memcpy(newind->il_info, indexInfo, sizeof(IndexInfo));
1087  /* expressions will likely be null, but may as well copy it */
1088  newind->il_info->ii_Expressions =
1089  copyObject(indexInfo->ii_Expressions);
1090  newind->il_info->ii_ExpressionsState = NIL;
1091  /* predicate will likely be null, but may as well copy it */
1092  newind->il_info->ii_Predicate =
1093  copyObject(indexInfo->ii_Predicate);
1094  newind->il_info->ii_PredicateState = NULL;
1095  /* no exclusion constraints at bootstrap time, so no need to copy */
1096  Assert(indexInfo->ii_ExclusionOps == NULL);
1097  Assert(indexInfo->ii_ExclusionProcs == NULL);
1098  Assert(indexInfo->ii_ExclusionStrats == NULL);
1099 
1100  newind->il_next = ILHead;
1101  ILHead = newind;
1102 
1103  MemoryContextSwitchTo(oldcxt);
1104 }
struct _IndexList * il_next
Definition: bootstrap.c:179
#define NIL
Definition: pg_list.h:69
Oid il_ind
Definition: bootstrap.c:177
List * ii_Predicate
Definition: execnodes.h:138
ExprState * ii_PredicateState
Definition: execnodes.h:139
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
static IndexList * ILHead
Definition: bootstrap.c:182
Oid * ii_ExclusionProcs
Definition: execnodes.h:141
static MemoryContext nogc
Definition: bootstrap.c:166
List * ii_ExpressionsState
Definition: execnodes.h:137
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:165
IndexInfo * il_info
Definition: bootstrap.c:178
MemoryContext AllocSetContextCreate(MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize)
Definition: aset.c:322
#define NULL
Definition: c.h:229
List * ii_Expressions
Definition: execnodes.h:136
#define Assert(condition)
Definition: c.h:675
Oid il_heap
Definition: bootstrap.c:176
Oid * ii_ExclusionOps
Definition: execnodes.h:140
void * palloc(Size size)
Definition: mcxt.c:849
#define copyObject(obj)
Definition: nodes.h:621
uint16 * ii_ExclusionStrats
Definition: execnodes.h:142
void InsertOneNull ( int  i)

Definition at line 842 of file bootstrap.c.

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

843 {
844  elog(DEBUG4, "inserting column %d NULL", i);
845  Assert(i >= 0 && i < MAXATTR);
847  Nulls[i] = true;
848 }
#define PointerGetDatum(X)
Definition: postgres.h:562
#define DEBUG4
Definition: elog.h:22
#define MAXATTR
Definition: bootstrap.h:24
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
static Datum values[MAXATTR]
Definition: bootstrap.c:163
int i
#define elog
Definition: elog.h:219
static bool Nulls[MAXATTR]
Definition: bootstrap.c:164
void InsertOneTuple ( Oid  objectid)

Definition at line 772 of file bootstrap.c.

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

773 {
774  HeapTuple tuple;
775  TupleDesc tupDesc;
776  int i;
777 
778  elog(DEBUG4, "inserting row oid %u, %d columns", objectid, numattr);
779 
780  tupDesc = CreateTupleDesc(numattr,
781  RelationGetForm(boot_reldesc)->relhasoids,
782  attrtypes);
783  tuple = heap_form_tuple(tupDesc, values, Nulls);
784  if (objectid != (Oid) 0)
785  HeapTupleSetOid(tuple, objectid);
786  pfree(tupDesc); /* just free's tupDesc, not the attrtypes */
787 
789  heap_freetuple(tuple);
790  elog(DEBUG4, "row inserted");
791 
792  /*
793  * Reset null markers for next tuple
794  */
795  for (i = 0; i < numattr; i++)
796  Nulls[i] = false;
797 }
int numattr
Definition: bootstrap.c:73
#define RelationGetForm(relation)
Definition: rel.h:411
Relation boot_reldesc
Definition: bootstrap.c:70
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:950
Oid simple_heap_insert(Relation relation, HeapTuple tup)
Definition: heapam.c:2939
static Datum values[MAXATTR]
Definition: bootstrap.c:163
int i
#define elog
Definition: elog.h:219
static bool Nulls[MAXATTR]
Definition: bootstrap.c:164
Form_pg_attribute attrtypes[MAXATTR]
Definition: bootstrap.c:72
void InsertOneValue ( char *  value,
int  i 
)

Definition at line 804 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.

805 {
806  Oid typoid;
807  int16 typlen;
808  bool typbyval;
809  char typalign;
810  char typdelim;
811  Oid typioparam;
812  Oid typinput;
813  Oid typoutput;
814 
815  AssertArg(i >= 0 && i < MAXATTR);
816 
817  elog(DEBUG4, "inserting column %d value \"%s\"", i, value);
818 
819  typoid = boot_reldesc->rd_att->attrs[i]->atttypid;
820 
821  boot_get_type_io_data(typoid,
822  &typlen, &typbyval, &typalign,
823  &typdelim, &typioparam,
824  &typinput, &typoutput);
825 
826  values[i] = OidInputFunctionCall(typinput, value, typioparam, -1);
827 
828  /*
829  * We use ereport not elog here so that parameters aren't evaluated unless
830  * the message is going to be printed, which generally it isn't
831  */
832  ereport(DEBUG4,
833  (errmsg_internal("inserted -> %s",
834  OidOutputFunctionCall(typoutput, values[i]))));
835 }
signed short int16
Definition: c.h:255
Relation boot_reldesc
Definition: bootstrap.c:70
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:677
TupleDesc rd_att
Definition: rel.h:115
int errmsg_internal(const char *fmt,...)
Definition: elog.c:827
static Datum values[MAXATTR]
Definition: bootstrap.c:163
char * OidOutputFunctionCall(Oid functionId, Datum val)
Definition: fmgr.c:1747
int i
#define elog
Definition: elog.h:219
static struct @121 value
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:1738
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:939
char* MapArrayTypeName ( const char *  s)

Definition at line 1032 of file bootstrap.c.

References i, NAMEDATALEN, and pstrdup().

1033 {
1034  int i,
1035  j;
1036  char newStr[NAMEDATALEN];
1037 
1038  newStr[0] = '_';
1039  j = 1;
1040  for (i = 0; i < NAMEDATALEN - 2 && s[i] != '['; i++, j++)
1041  newStr[j] = s[i];
1042 
1043  newStr[j] = '\0';
1044 
1045  return pstrdup(newStr);
1046 }
char * pstrdup(const char *in)
Definition: mcxt.c:1077
#define NAMEDATALEN
int i
static void ShutdownAuxiliaryProcess ( int  code,
Datum  arg 
)
static

Definition at line 544 of file bootstrap.c.

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

Referenced by AuxiliaryProcessMain().

545 {
549 }
void ConditionVariableCancelSleep(void)
static void pgstat_report_wait_end(void)
Definition: pgstat.h:1232
void LWLockReleaseAll(void)
Definition: lwlock.c:1814

Variable Documentation

struct typmap* Ap = NULL
static

Definition at line 161 of file bootstrap.c.

Definition at line 72 of file bootstrap.c.

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

Relation boot_reldesc

Definition at line 70 of file bootstrap.c.

uint32 bootstrap_data_checksum_version = 0

Definition at line 49 of file bootstrap.c.

Referenced by AuxiliaryProcessMain(), and BootStrapXLOG().

IndexList* ILHead = NULL
static

Definition at line 182 of file bootstrap.c.

Referenced by index_register().

AuxProcType MyAuxProcType = NotAnAuxProcess

Definition at line 68 of file bootstrap.c.

Referenced by AuxiliaryProcessMain(), pgstat_bestart(), and pgstat_initialize().

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

Definition at line 152 of file bootstrap.c.

Referenced by boot_get_type_io_data(), and gettype().

MemoryContext nogc = NULL
static

Definition at line 166 of file bootstrap.c.

bool Nulls[MAXATTR]
static

Definition at line 164 of file bootstrap.c.

int numattr

Definition at line 73 of file bootstrap.c.

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

struct typmap** Typ = NULL
static

Definition at line 160 of file bootstrap.c.

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

const struct typinfo TypInfo[]
static

Definition at line 99 of file bootstrap.c.

Datum values[MAXATTR]
static

Definition at line 163 of file bootstrap.c.

Referenced by _bt_check_unique(), _connectDB(), _int_matchsel(), aclexplode(), AddEnumLabel(), AggregateCreate(), AlterCollation(), 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_print_tuples(), 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(), CreateStatistics(), CreateSubscription(), CreateTableSpace(), CreateTransform(), CreateTrigger(), CreateUserMapping(), crosstab(), dblink_get_notify(), dblink_get_pkey(), DefineOpClass(), DefineTSConfiguration(), DefineTSDictionary(), DefineTSParser(), DefineTSTemplate(), deflist_to_tuplestore(), dependency_degree(), DiscreteKnapsack(), 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(), ExecEvalMinMax(), ExecEvalXmlExpr(), ExecFilterJunk(), ExecGrant_Attribute(), ExecGrant_Database(), ExecGrant_Fdw(), ExecGrant_ForeignServer(), ExecGrant_Function(), ExecGrant_Language(), ExecGrant_Largeobject(), ExecGrant_Namespace(), ExecGrant_Relation(), ExecGrant_Tablespace(), ExecGrant_Type(), ExecHashBuildSkewHash(), ExecInitExprRec(), ExecInsertIndexTuples(), 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_tuple_from_result_row(), make_tuple_indirect(), MakeConfigurationMapping(), materializeQueryResult(), materializeResult(), mcv_selectivity(), NamespaceCreate(), ndistinct_for_combination(), 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_ls_dir_files(), 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(), 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(), SetSubscriptionRelState(), shdepAddDependency(), shdepChangeDep(), show_all_file_settings(), show_all_settings(), ShowAllGUCConfig(), slot_deform_tuple(), sql_conn(), ssl_extension_info(), StartReplication(), statext_store(), StoreAttrDefault(), StoreCatalogInheritance1(), StoreIndexTuple(), storeOperators(), StorePartitionKey(), storeProcedures(), tfuncLoadRows(), 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().