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

Commit80adb69

Browse files
author
Mikhail Samoylov
committed
Including indexes altertype bugfix
Tests for BUG PGPRO-818
1 parent3aeb193 commit80adb69

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
@@ -9009,6 +9009,7 @@ TryReuseIndex(Oid oldId, IndexStmt *stmt)
90099009
if (CheckIndexCompatible(oldId,
90109010
stmt->accessMethod,
90119011
stmt->indexParams,
9012+
stmt->indexIncludingParams,
90129013
stmt->excludeOpNames))
90139014
{
90149015
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
@@ -3016,12 +3016,12 @@ Table "public.test_add_column"
30163016
c4 | integer |
30173017

30183018
DROP TABLE test_add_column;
3019-
3019+
-- test CHANGE COLUMN SIZE WITH BTREE INDEX
30203020
CREATE TABLE test (test_column CHARACTER VARYING(128));
30213021
CREATE INDEX test_index ON test USING btree(upper(test_column));
30223022
ALTER TABLE test ALTER COLUMN test_column TYPE VARCHAR(2048);
30233023
DROP TABLE test;
3024-
3024+
-- test CHANGE COLUMN SIZE WITH HASH INDEX
30253025
CREATE TABLE test (test_column CHARACTER VARYING(128));
30263026
CREATE INDEX test_index ON test USING HASH(upper(test_column));
30273027
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
@@ -1915,7 +1915,7 @@ DROP TABLE test_add_column;
19151915

19161916
-- test CHANGE COLUMN SIZE WITH BTREE INDEX
19171917
CREATETABLEtest (test_columnCHARACTER VARYING(128));
1918-
CREATEINDEXtest_indexON test USING btree(upper(test_column);
1918+
CREATEINDEXtest_indexON test USING btree(upper(test_column));
19191919
ALTERTABLE test ALTER COLUMN test_column TYPEVARCHAR(2048);
19201920
DROPTABLE test;
19211921

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp