|
14 | 14 | *
|
15 | 15 | *
|
16 | 16 | * IDENTIFICATION
|
17 |
| - * $PostgreSQL: pgsql/src/backend/access/common/tupconvert.c,v 1.1 2009/08/06 20:44:31 tgl Exp $ |
| 17 | + * $PostgreSQL: pgsql/src/backend/access/common/tupconvert.c,v 1.2 2009/08/17 20:34:31 tgl Exp $ |
18 | 18 | *
|
19 | 19 | *-------------------------------------------------------------------------
|
20 | 20 | */
|
@@ -146,11 +146,22 @@ convert_tuples_by_position(TupleDesc indesc,
|
146 | 146 | {
|
147 | 147 | for (i = 0; i < n; i++)
|
148 | 148 | {
|
149 |
| - if (attrMap[i] != (i+1)) |
150 |
| - { |
151 |
| - same = false; |
152 |
| - break; |
153 |
| - } |
| 149 | + if (attrMap[i] == (i+1)) |
| 150 | + continue; |
| 151 | + |
| 152 | + /* |
| 153 | + * If it's a dropped column and the corresponding input |
| 154 | + * column is also dropped, we needn't convert. However, |
| 155 | + * attlen and attalign must agree. |
| 156 | + */ |
| 157 | + if (attrMap[i] == 0 && |
| 158 | + indesc->attrs[i]->attisdropped && |
| 159 | + indesc->attrs[i]->attlen == outdesc->attrs[i]->attlen && |
| 160 | + indesc->attrs[i]->attalign == outdesc->attrs[i]->attalign) |
| 161 | + continue; |
| 162 | + |
| 163 | + same = false; |
| 164 | + break; |
154 | 165 | }
|
155 | 166 | }
|
156 | 167 | else
|
@@ -255,11 +266,22 @@ convert_tuples_by_name(TupleDesc indesc,
|
255 | 266 | same = true;
|
256 | 267 | for (i = 0; i < n; i++)
|
257 | 268 | {
|
258 |
| - if (attrMap[i] != (i+1)) |
259 |
| - { |
260 |
| - same = false; |
261 |
| - break; |
262 |
| - } |
| 269 | + if (attrMap[i] == (i+1)) |
| 270 | + continue; |
| 271 | + |
| 272 | + /* |
| 273 | + * If it's a dropped column and the corresponding input |
| 274 | + * column is also dropped, we needn't convert. However, |
| 275 | + * attlen and attalign must agree. |
| 276 | + */ |
| 277 | + if (attrMap[i] == 0 && |
| 278 | + indesc->attrs[i]->attisdropped && |
| 279 | + indesc->attrs[i]->attlen == outdesc->attrs[i]->attlen && |
| 280 | + indesc->attrs[i]->attalign == outdesc->attrs[i]->attalign) |
| 281 | + continue; |
| 282 | + |
| 283 | + same = false; |
| 284 | + break; |
263 | 285 | }
|
264 | 286 | }
|
265 | 287 | else
|
|
0 commit comments