summaryrefslogtreecommitdiff
path: root/src/backend/bootstrap
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/bootstrap')
-rw-r--r--src/backend/bootstrap/bootparse.y32
-rw-r--r--src/backend/bootstrap/bootscanner.l10
-rw-r--r--src/backend/bootstrap/bootstrap.c35
3 files changed, 36 insertions, 41 deletions
diff --git a/src/backend/bootstrap/bootparse.y b/src/backend/bootstrap/bootparse.y
index 41d2fd4a5f..de3695c7e0 100644
--- a/src/backend/bootstrap/bootparse.y
+++ b/src/backend/bootstrap/bootparse.y
@@ -4,7 +4,7 @@
* bootparse.y
* yacc grammar for the "bootstrap" mode (BKI file format)
*
- * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
@@ -22,7 +22,6 @@
#include "access/htup.h"
#include "access/itup.h"
#include "access/tupdesc.h"
-#include "access/xact.h"
#include "bootstrap/bootstrap.h"
#include "catalog/catalog.h"
#include "catalog/heap.h"
@@ -49,10 +48,9 @@
#include "storage/off.h"
#include "storage/smgr.h"
#include "tcop/dest.h"
+#include "utils/memutils.h"
#include "utils/rel.h"
-#define atooid(x) ((Oid) strtoul((x), NULL, 10))
-
/*
* Bison doesn't allocate anything that needs to live across parser calls,
@@ -65,19 +63,27 @@
#define YYMALLOC palloc
#define YYFREE pfree
+static MemoryContext per_line_ctx = NULL;
+
static void
do_start(void)
{
- StartTransactionCommand();
- elog(DEBUG4, "start transaction");
+ Assert(CurrentMemoryContext == CurTransactionContext);
+ /* First time through, create the per-line working context */
+ if (per_line_ctx == NULL)
+ per_line_ctx = AllocSetContextCreate(CurTransactionContext,
+ "bootstrap per-line processing",
+ ALLOCSET_DEFAULT_SIZES);
+ MemoryContextSwitchTo(per_line_ctx);
}
static void
do_end(void)
{
- CommitTransactionCommand();
- elog(DEBUG4, "commit transaction");
+ /* Reclaim memory allocated while processing this line */
+ MemoryContextSwitchTo(CurTransactionContext);
+ MemoryContextReset(per_line_ctx);
CHECK_FOR_INTERRUPTS(); /* allow SIGINT to kill bootstrap run */
if (isatty(0))
{
@@ -105,11 +111,11 @@ static int num_columns_read = 0;
%type <list> boot_index_params
%type <ielem> boot_index_param
-%type <str> boot_const boot_ident
+%type <str> boot_ident
%type <ival> optbootstrap optsharedrelation optwithoutoids boot_column_nullness
%type <oidval> oidspec optoideq optrowtypeoid
-%token <str> CONST_P ID
+%token <str> ID
%token OPEN XCLOSE XCREATE INSERT_TUPLE
%token XDECLARE INDEX ON USING XBUILD INDICES UNIQUE XTOAST
%token COMMA EQUALS LPAREN RPAREN
@@ -464,16 +470,10 @@ boot_column_val_list:
boot_column_val:
boot_ident
{ InsertOneValue($1, num_columns_read++); }
- | boot_const
- { InsertOneValue($1, num_columns_read++); }
| NULLVAL
{ InsertOneNull(num_columns_read++); }
;
-boot_const :
- CONST_P { $$ = yylval.str; }
- ;
-
boot_ident :
ID { $$ = yylval.str; }
;
diff --git a/src/backend/bootstrap/bootscanner.l b/src/backend/bootstrap/bootscanner.l
index 0e1413bff9..6467882fa3 100644
--- a/src/backend/bootstrap/bootscanner.l
+++ b/src/backend/bootstrap/bootscanner.l
@@ -4,7 +4,7 @@
* bootscanner.l
* a lexical scanner for the bootstrap parser
*
- * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
@@ -66,7 +66,6 @@ static int yyline = 1; /* line number for error reporting */
D [0-9]
oct \\{D}{D}{D}
-Exp [Ee][-+]?{D}+
id ([A-Za-z0-9_]|{oct}|\-)+
sid \"([^\"])*\"
arrayid [A-Za-z0-9_]+\[{D}*\]
@@ -127,13 +126,6 @@ insert { return(INSERT_TUPLE); }
return(ID);
}
-(-)?{D}+"."{D}*({Exp})? |
-(-)?{D}*"."{D}+({Exp})? |
-(-)?{D}+{Exp} {
- yylval.str = pstrdup(yytext);
- return(CONST_P);
- }
-
. {
elog(ERROR, "syntax error at line %d: unexpected character \"%s\"", yyline, yytext);
}
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 86732f73d8..c2274ae2ff 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -5,7 +5,7 @@
* bootstrap mode is used to create the initial template database
*
* Portions Copyright (c) 2012-2014, TransLattice, Inc.
- * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 2010-2012 Postgres-XC Development Group
*
@@ -20,6 +20,7 @@
#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"
@@ -36,6 +37,7 @@
#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"
@@ -56,7 +58,8 @@
uint32 bootstrap_data_checksum_version = 0; /* No checksum */
-#define ALLOC(t, c) ((t *) calloc((unsigned)(c), sizeof(t)))
+#define ALLOC(t, c) \
+ ((t *) MemoryContextAllocZero(TopMemoryContext, (unsigned)(c) * sizeof(t)))
static void CheckerModeMain(void);
static void BootstrapModeMain(void);
@@ -236,7 +239,7 @@ AuxiliaryProcessMain(int argc, char *argv[])
SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, PGC_S_ARGV);
break;
case 'D':
- userDoption = strdup(optarg);
+ userDoption = pstrdup(optarg);
break;
case 'd':
{
@@ -408,6 +411,10 @@ AuxiliaryProcessMain(int argc, char *argv[])
/* finish setting up bufmgr.c */
InitBufferPoolBackend();
+ /* Initialize backend status information */
+ pgstat_initialize();
+ pgstat_bestart();
+
/* register a before-shutdown callback for LWLock cleanup */
before_shmem_exit(ShutdownAuxiliaryProcess, 0);
}
@@ -525,7 +532,9 @@ BootstrapModeMain(void)
/*
* Process bootstrap input.
*/
+ StartTransactionCommand();
boot_yyparse();
+ CommitTransactionCommand();
/*
* We should now know about all mapped relations, so it's okay to write
@@ -570,6 +579,7 @@ static void
ShutdownAuxiliaryProcess(int code, Datum arg)
{
LWLockReleaseAll();
+ ConditionVariableCancelSleep();
pgstat_report_wait_end();
}
@@ -1037,13 +1047,8 @@ boot_get_type_io_data(Oid typid,
static Form_pg_attribute
AllocateAttribute(void)
{
- Form_pg_attribute attribute = (Form_pg_attribute) malloc(ATTRIBUTE_FIXED_PART_SIZE);
-
- if (!PointerIsValid(attribute))
- elog(FATAL, "out of memory");
- MemSet(attribute, 0, ATTRIBUTE_FIXED_PART_SIZE);
-
- return attribute;
+ return (Form_pg_attribute)
+ MemoryContextAllocZero(TopMemoryContext, ATTRIBUTE_FIXED_PART_SIZE);
}
/*
@@ -1104,9 +1109,7 @@ index_register(Oid heap,
if (nogc == NULL)
nogc = AllocSetContextCreate(NULL,
"BootstrapNoGC",
- ALLOCSET_DEFAULT_MINSIZE,
- ALLOCSET_DEFAULT_INITSIZE,
- ALLOCSET_DEFAULT_MAXSIZE);
+ ALLOCSET_DEFAULT_SIZES);
oldcxt = MemoryContextSwitchTo(nogc);
@@ -1117,13 +1120,13 @@ index_register(Oid heap,
memcpy(newind->il_info, indexInfo, sizeof(IndexInfo));
/* expressions will likely be null, but may as well copy it */
- newind->il_info->ii_Expressions = (List *)
+ newind->il_info->ii_Expressions =
copyObject(indexInfo->ii_Expressions);
newind->il_info->ii_ExpressionsState = NIL;
/* predicate will likely be null, but may as well copy it */
- newind->il_info->ii_Predicate = (List *)
+ newind->il_info->ii_Predicate =
copyObject(indexInfo->ii_Predicate);
- newind->il_info->ii_PredicateState = NIL;
+ newind->il_info->ii_PredicateState = NULL;
/* no exclusion constraints at bootstrap time, so no need to copy */
Assert(indexInfo->ii_ExclusionOps == NULL);
Assert(indexInfo->ii_ExclusionProcs == NULL);