Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit12d8fae

Browse files
committed
Simplify the bootstrap (BKI) code by getting rid of a useless table of all
the strings seen during the bootstrap run. There might have been someactual point to doing that, many years ago, but as far as I can see the onlyvalue now is to conserve a bit of memory. Even if we cared about wastinga megabyte or so during the initdb run, it'd be far more effective toarrange to release memory at the end of each BKI command, instead ofintentionally hanging onto strings that might never be used again.Not maintaining the table probably makes it faster too; but the main pointof this patch is to get rid of a couple hundred lines of unnecessary andrather crufty code.
1 parent23cf415 commit12d8fae

File tree

4 files changed

+65
-254
lines changed

4 files changed

+65
-254
lines changed

‎src/backend/bootstrap/bootparse.y

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.98 2009/09/26 22:42:01 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootparse.y,v 1.99 2009/09/27 01:32:11 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -87,7 +87,7 @@ do_end(void)
8787
}
8888

8989

90-
int num_columns_read =0;
90+
staticint num_columns_read =0;
9191

9292
%}
9393

@@ -105,16 +105,16 @@ int num_columns_read = 0;
105105

106106
%type<list>boot_index_params
107107
%type<ielem>boot_index_param
108-
%type<ival>boot_constboot_ident
108+
%type<str>boot_constboot_ident
109109
%type<ival>optbootstrapoptsharedrelationoptwithoutoids
110-
%type<ival>boot_tupleboot_tuplelist
111110
%type<oidval>oidspecoptoideqoptrowtypeoid
112111

113-
%token<ival>CONST_PID
112+
%token<str>CONST_PID
114113
%tokenOPENXCLOSEXCREATEINSERT_TUPLE
115114
%tokenXDECLAREINDEXONUSINGXBUILDINDICESUNIQUEXTOAST
116115
%tokenCOMMAEQUALSLPARENRPAREN
117116
%tokenOBJ_IDXBOOTSTRAPXSHARED_RELATIONXWITHOUT_OIDSXROWTYPE_OIDNULLVAL
117+
118118
%startTopLevel
119119

120120
%nonassoclow
@@ -147,7 +147,7 @@ Boot_OpenStmt:
147147
OPENboot_ident
148148
{
149149
do_start();
150-
boot_openrel(LexIDStr($2));
150+
boot_openrel($2);
151151
do_end();
152152
}
153153
;
@@ -156,7 +156,7 @@ Boot_CloseStmt:
156156
XCLOSEboot_ident %preclow
157157
{
158158
do_start();
159-
closerel(LexIDStr($2));
159+
closerel($2);
160160
do_end();
161161
}
162162
|XCLOSE %prechigh
@@ -175,10 +175,10 @@ Boot_CreateStmt:
175175
elog(DEBUG4,"creating%s%s relation %s %u",
176176
$4 ?" bootstrap" :"",
177177
$5 ?" shared" :"",
178-
LexIDStr($2),
178+
$2,
179179
$3);
180180
}
181-
boot_typelist
181+
boot_column_list
182182
{
183183
do_end();
184184
}
@@ -198,7 +198,7 @@ Boot_CreateStmt:
198198
closerel(NULL);
199199
}
200200

201-
boot_reldesc =heap_create(LexIDStr($2),
201+
boot_reldesc = heap_create($2,
202202
PG_CATALOG_NAMESPACE,
203203
$5 ? GLOBALTABLESPACE_OID :0,
204204
$3,
@@ -212,7 +212,7 @@ Boot_CreateStmt:
212212
{
213213
Oid id;
214214

215-
id =heap_create_with_catalog(LexIDStr($2),
215+
id = heap_create_with_catalog($2,
216216
PG_CATALOG_NAMESPACE,
217217
$5 ? GLOBALTABLESPACE_OID :0,
218218
$3,
@@ -243,7 +243,7 @@ Boot_InsertStmt:
243243
elog(DEBUG4,"inserting row");
244244
num_columns_read =0;
245245
}
246-
LPAREN boot_tuplelist RPAREN
246+
LPARENboot_column_val_listRPAREN
247247
{
248248
if (num_columns_read != numattr)
249249
elog(ERROR,"incorrect number of columns in row (expected %d, got %d)",
@@ -260,10 +260,10 @@ Boot_DeclareIndexStmt:
260260
{
261261
do_start();
262262

263-
DefineIndex(makeRangeVar(NULL,LexIDStr($6), -1),
264-
LexIDStr($3),
263+
DefineIndex(makeRangeVar(NULL,$6, -1),
264+
$3,
265265
$4,
266-
LexIDStr($8),
266+
$8,
267267
NULL,
268268
$10,
269269
NULL, NIL,
@@ -278,10 +278,10 @@ Boot_DeclareUniqueIndexStmt:
278278
{
279279
do_start();
280280

281-
DefineIndex(makeRangeVar(NULL,LexIDStr($7), -1),
282-
LexIDStr($4),
281+
DefineIndex(makeRangeVar(NULL,$7, -1),
282+
$4,
283283
$5,
284-
LexIDStr($9),
284+
$9,
285285
NULL,
286286
$11,
287287
NULL, NIL,
@@ -296,7 +296,7 @@ Boot_DeclareToastStmt:
296296
{
297297
do_start();
298298

299-
BootstrapToastTable(LexIDStr($6), $3, $4);
299+
BootstrapToastTable($6, $3, $4);
300300
do_end();
301301
}
302302
;
@@ -320,9 +320,9 @@ boot_index_param:
320320
boot_identboot_ident
321321
{
322322
IndexElem *n = makeNode(IndexElem);
323-
n->name =LexIDStr($1);
323+
n->name =$1;
324324
n->expr =NULL;
325-
n->opclass =list_make1(makeString(LexIDStr($2)));
325+
n->opclass = list_make1(makeString($2));
326326
n->ordering = SORTBY_DEFAULT;
327327
n->nulls_ordering = SORTBY_NULLS_DEFAULT;
328328
$$ = n;
@@ -349,50 +349,50 @@ optrowtypeoid:
349349
|{$$ = InvalidOid; }
350350
;
351351

352-
boot_typelist:
353-
boot_type_thing
354-
|boot_typelist COMMAboot_type_thing
352+
boot_column_list:
353+
boot_column_def
354+
|boot_column_listCOMMAboot_column_def
355355
;
356356

357-
boot_type_thing:
357+
boot_column_def:
358358
boot_identEQUALSboot_ident
359359
{
360360
if (++numattr > MAXATTR)
361361
elog(FATAL,"too many columns");
362-
DefineAttr(LexIDStr($1),LexIDStr($3),numattr-1);
362+
DefineAttr($1, $3,numattr-1);
363363
}
364364
;
365365

366366
oidspec:
367-
boot_ident{ $$ =atooid(LexIDStr($1)); }
367+
boot_ident{$$ = atooid($1); }
368368
;
369369

370370
optoideq:
371371
OBJ_IDEQUALSoidspec{$$ =$3; }
372372
|{$$ = InvalidOid; }
373373
;
374374

375-
boot_tuplelist:
376-
boot_tuple
377-
|boot_tuplelist boot_tuple
378-
|boot_tuplelist COMMAboot_tuple
375+
boot_column_val_list:
376+
boot_column_val
377+
|boot_column_val_listboot_column_val
378+
|boot_column_val_listCOMMAboot_column_val
379379
;
380380

381-
boot_tuple:
381+
boot_column_val:
382382
boot_ident
383-
{InsertOneValue(LexIDStr($1), num_columns_read++); }
383+
{ InsertOneValue($1, num_columns_read++); }
384384
|boot_const
385-
{InsertOneValue(LexIDStr($1), num_columns_read++); }
385+
{ InsertOneValue($1, num_columns_read++); }
386386
|NULLVAL
387387
{ InsertOneNull(num_columns_read++); }
388388
;
389389

390390
boot_const :
391-
CONST_P { $$=yylval.ival; }
391+
CONST_P {$$ =yylval.str; }
392392
;
393393

394394
boot_ident :
395-
ID{ $$=yylval.ival; }
395+
ID{$$ =yylval.str; }
396396
;
397397
%%
398398

‎src/backend/bootstrap/bootscanner.l

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootscanner.l,v 1.49 2009/09/26 22:42:01 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootscanner.l,v 1.50 2009/09/27 01:32:11 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -104,29 +104,24 @@ insert{ return(INSERT_TUPLE); }
104104
"toast"{return(XTOAST); }
105105

106106
{arrayid}{
107-
yylval.ival =EnterString(MapArrayTypeName((char*)yytext));
107+
yylval.str =pstrdup(MapArrayTypeName(yytext));
108108
return(ID);
109109
}
110110
{id}{
111-
char *newid =scanstr((char*)yytext);
112-
yylval.ival =EnterString(newid);
113-
pfree(newid);
111+
yylval.str =scanstr(yytext);
114112
return(ID);
115113
}
116114
{sid}{
117-
char *newid;
118115
yytext[strlen(yytext)-1] ='\0';/* strip off quotes */
119-
newid =scanstr((char*)yytext+1);
120-
yylval.ival =EnterString(newid);
121-
pfree(newid);
116+
yylval.str =scanstr(yytext+1);
122117
yytext[strlen(yytext)] ='"';/* restore quotes */
123118
return(ID);
124119
}
125120

126121
(-)?{D}+"."{D}*({Exp})? |
127122
(-)?{D}*"."{D}+({Exp})? |
128123
(-)?{D}+{Exp}{
129-
yylval.ival =EnterString((char*)yytext);
124+
yylval.str =pstrdup(yytext);
130125
return(CONST_P);
131126
}
132127

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp