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

Commit3727240

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 parent1116c9d commit3727240

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
@@ -280,37 +280,69 @@ Boot_InsertStmt:
280280
Boot_DeclareIndexStmt:
281281
XDECLAREINDEXboot_identoidspecONboot_identUSINGboot_identLPARENboot_index_paramsRPAREN
282282
{
283+
IndexStmt *stmt = makeNode(IndexStmt);
284+
283285
do_start();
284286

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

299315
Boot_DeclareUniqueIndexStmt:
300316
XDECLAREUNIQUEINDEXboot_identoidspecONboot_identUSINGboot_identLPARENboot_index_paramsRPAREN
301317
{
318+
IndexStmt *stmt = makeNode(IndexStmt);
319+
302320
do_start();
303321

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp