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

Commit0814828

Browse files
Mikhail Samoylovdmpgpro
Mikhail Samoylov
authored andcommitted
Including indexes altertype bugfix
Tests for BUG PGPRO-818
1 parentfbcf580 commit0814828

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

‎src/backend/commands/indexcmds.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ bool
118118
CheckIndexCompatible(OidoldId,
119119
char*accessMethodName,
120120
List*attributeList,
121+
List*includingattributeList,
121122
List*exclusionOpNames)
122123
{
123124
boolisconstraint;
@@ -134,6 +135,7 @@ CheckIndexCompatible(Oid oldId,
134135
int16*coloptions;
135136
IndexInfo*indexInfo;
136137
intnumberOfAttributes;
138+
intnumberOfKeyAttributes;
137139
intold_natts;
138140
boolisnull;
139141
boolret= true;
@@ -153,6 +155,9 @@ CheckIndexCompatible(Oid oldId,
153155
isconstraint= false;
154156

155157
numberOfAttributes=list_length(attributeList);
158+
numberOfKeyAttributes=numberOfAttributes;
159+
if (includingattributeList!=NULL)
160+
numberOfKeyAttributes=list_length(attributeList)-list_length(includingattributeList);
156161
Assert(numberOfAttributes>0);
157162
Assert(numberOfAttributes <=INDEX_MAX_KEYS);
158163

@@ -178,6 +183,8 @@ CheckIndexCompatible(Oid oldId,
178183
* later on, and it would have failed then anyway.
179184
*/
180185
indexInfo=makeNode(IndexInfo);
186+
indexInfo->ii_NumIndexKeyAttrs=numberOfKeyAttributes;
187+
indexInfo->ii_NumIndexAttrs=numberOfAttributes;
181188
indexInfo->ii_Expressions=NIL;
182189
indexInfo->ii_ExpressionsState=NIL;
183190
indexInfo->ii_PredicateState=NIL;

‎src/backend/commands/tablecmds.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8941,6 +8941,7 @@ TryReuseIndex(Oid oldId, IndexStmt *stmt)
89418941
if (CheckIndexCompatible(oldId,
89428942
stmt->accessMethod,
89438943
stmt->indexParams,
8944+
stmt->indexIncludingParams,
89448945
stmt->excludeOpNames))
89458946
{
89468947
Relationirel=index_open(oldId,NoLock);

‎src/include/commands/defrem.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ extern char *ChooseRelationName(const char *name1, const char *name2,
4040
externboolCheckIndexCompatible(OidoldId,
4141
char*accessMethodName,
4242
List*attributeList,
43+
List*includingattributeList,
4344
List*exclusionOpNames);
4445
externOidGetDefaultOpClass(Oidtype_id,Oidam_id);
4546

‎src/test/regress/expected/alter_table.out‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3098,12 +3098,12 @@ Table "public.test_add_column"
30983098
c4 | integer |
30993099

31003100
DROP TABLE test_add_column;
3101-
3101+
-- test CHANGE COLUMN SIZE WITH BTREE INDEX
31023102
CREATE TABLE test (test_column CHARACTER VARYING(128));
31033103
CREATE INDEX test_index ON test USING btree(upper(test_column));
31043104
ALTER TABLE test ALTER COLUMN test_column TYPE VARCHAR(2048);
31053105
DROP TABLE test;
3106-
3106+
-- test CHANGE COLUMN SIZE WITH HASH INDEX
31073107
CREATE TABLE test (test_column CHARACTER VARYING(128));
31083108
CREATE INDEX test_index ON test USING HASH(upper(test_column));
31093109
WARNING: hash indexes are not WAL-logged and their use is discouraged

‎src/test/regress/sql/alter_table.sql‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1953,7 +1953,7 @@ DROP TABLE test_add_column;
19531953

19541954
-- test CHANGE COLUMN SIZE WITH BTREE INDEX
19551955
CREATETABLEtest (test_columnCHARACTER VARYING(128));
1956-
CREATEINDEXtest_indexON test USING btree(upper(test_column);
1956+
CREATEINDEXtest_indexON test USING btree(upper(test_column));
19571957
ALTERTABLE test ALTER COLUMN test_column TYPEVARCHAR(2048);
19581958
DROPTABLE test;
19591959

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp