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

Commitc92be3c

Browse files
committed
Avoid pre-determining index names during CREATE TABLE LIKE parsing.
Formerly, when trying to copy both indexes and comments, CREATE TABLE LIKEhad to pre-assign names to indexes that had comments, because it made up anexplicit CommentStmt command to apply the comment and so it had to know thename for the index. This creates bad interactions with other indexes, asshown in bug #6734 from Daniele Varrazzo: the preassignment logic couldn'ttake any other indexes into account so it could choose a conflicting name.To fix, add a field to IndexStmt that allows it to carry a comment to beassigned to the new index. (This isn't a user-exposed feature of CREATEINDEX, only an internal option.) Now we don't need preassignment of indexnames in any situation.I also took the opportunity to refactor DefineIndex to accept the IndexStmtas such, rather than passing all its fields individually in a mile-longparameter list.Back-patch to 9.2, but no further, because it seems too dangerous to changeIndexStmt or DefineIndex's API in released branches. The bug exists backto 9.0 where CREATE TABLE LIKE grew the ability to copy comments, but giventhe lack of prior complaints we'll just let it go unfixed before 9.2.
1 parent54fd196 commitc92be3c

File tree

11 files changed

+147
-204
lines changed

11 files changed

+147
-204
lines changed

‎src/backend/bootstrap/bootparse.y

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -279,37 +279,69 @@ Boot_InsertStmt:
279279
Boot_DeclareIndexStmt:
280280
XDECLAREINDEXboot_identoidspecONboot_identUSINGboot_identLPARENboot_index_paramsRPAREN
281281
{
282+
IndexStmt *stmt = makeNode(IndexStmt);
283+
282284
do_start();
283285

284-
DefineIndex(makeRangeVar(NULL, $6, -1),
285-
$3,
286+
stmt->idxname =$3;
287+
stmt->relation = makeRangeVar(NULL,$6, -1);
288+
stmt->accessMethod =$8;
289+
stmt->tableSpace =NULL;
290+
stmt->indexParams =$10;
291+
stmt->options = NIL;
292+
stmt->whereClause =NULL;
293+
stmt->excludeOpNames = NIL;
294+
stmt->idxcomment =NULL;
295+
stmt->indexOid = InvalidOid;
296+
stmt->oldNode = InvalidOid;
297+
stmt->unique =false;
298+
stmt->primary =false;
299+
stmt->isconstraint =false;
300+
stmt->deferrable =false;
301+
stmt->initdeferred =false;
302+
stmt->concurrent =false;
303+
304+
DefineIndex(stmt,
286305
$4,
287-
InvalidOid,
288-
$8,
289-
NULL,
290-
$10,
291-
NULL, NIL, NIL,
292-
false, false, false, false, false,
293-
false, false, true, false, false);
306+
false,
307+
false,
308+
true,/* skip_build*/
309+
false);
294310
do_end();
295311
}
296312
;
297313

298314
Boot_DeclareUniqueIndexStmt:
299315
XDECLAREUNIQUEINDEXboot_identoidspecONboot_identUSINGboot_identLPARENboot_index_paramsRPAREN
300316
{
317+
IndexStmt *stmt = makeNode(IndexStmt);
318+
301319
do_start();
302320

303-
DefineIndex(makeRangeVar(NULL, $7, -1),
304-
$4,
321+
stmt->idxname =$4;
322+
stmt->relation = makeRangeVar(NULL,$7, -1);
323+
stmt->accessMethod =$9;
324+
stmt->tableSpace =NULL;
325+
stmt->indexParams =$11;
326+
stmt->options = NIL;
327+
stmt->whereClause =NULL;
328+
stmt->excludeOpNames = NIL;
329+
stmt->idxcomment =NULL;
330+
stmt->indexOid = InvalidOid;
331+
stmt->oldNode = InvalidOid;
332+
stmt->unique =true;
333+
stmt->primary =false;
334+
stmt->isconstraint =false;
335+
stmt->deferrable =false;
336+
stmt->initdeferred =false;
337+
stmt->concurrent =false;
338+
339+
DefineIndex(stmt,
305340
$5,
306-
InvalidOid,
307-
$9,
308-
NULL,
309-
$11,
310-
NULL, NIL, NIL,
311-
true, false, false, false, false,
312-
false, false, true, false, false);
341+
false,
342+
false,
343+
true,/* skip_build*/
344+
false);
313345
do_end();
314346
}
315347
;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp