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

Commit997ee51

Browse files
committed
Make functional index copy attstorage from the column data type, rather
than forcing 'plain'. This probably does not matter right now, but Ithink it needs to be consistent with the regular (not-functional) indexcase, where attstorage is copied from the underlying table. Clean upsome other dead and infelicitous code too.
1 parentc654c69 commit997ee51

File tree

1 file changed

+27
-35
lines changed

1 file changed

+27
-35
lines changed

‎src/backend/catalog/index.c

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.136 2001/01/23 04:32:21 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.137 2001/01/24 00:06:07 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -62,7 +62,7 @@
6262
staticOidGetHeapRelationOid(char*heapRelationName,char*indexRelationName,
6363
boolistemp);
6464
staticTupleDescBuildFuncTupleDesc(OidfuncOid);
65-
staticTupleDescConstructTupleDescriptor(Oidheapoid,RelationheapRelation,
65+
staticTupleDescConstructTupleDescriptor(RelationheapRelation,
6666
intnumatts,AttrNumber*attNums);
6767
staticvoidConstructIndexReldesc(RelationindexRelation,Oidamoid);
6868
staticOidUpdateRelationRelation(RelationindexRelation,char*temp_relname);
@@ -166,7 +166,7 @@ BuildFuncTupleDesc(Oid funcOid)
166166
OidretType;
167167

168168
/*
169-
* Allocate and zero a tuple descriptor.
169+
* Allocate and zero a tuple descriptor for a one-column tuple.
170170
*/
171171
funcTupDesc=CreateTemplateTupleDesc(1);
172172
funcTupDesc->attrs[0]= (Form_pg_attribute)palloc(ATTRIBUTE_TUPLE_SIZE);
@@ -208,7 +208,7 @@ BuildFuncTupleDesc(Oid funcOid)
208208
funcTupDesc->attrs[0]->attbyval= ((Form_pg_type)GETSTRUCT(tuple))->typbyval;
209209
funcTupDesc->attrs[0]->attcacheoff=-1;
210210
funcTupDesc->attrs[0]->atttypmod=-1;
211-
funcTupDesc->attrs[0]->attstorage='p';
211+
funcTupDesc->attrs[0]->attstorage=((Form_pg_type)GETSTRUCT(tuple))->typstorage;
212212
funcTupDesc->attrs[0]->attalign= ((Form_pg_type)GETSTRUCT(tuple))->typalign;
213213

214214
ReleaseSysCache(tuple);
@@ -223,8 +223,7 @@ BuildFuncTupleDesc(Oid funcOid)
223223
* ----------------------------------------------------------------
224224
*/
225225
staticTupleDesc
226-
ConstructTupleDescriptor(Oidheapoid,
227-
RelationheapRelation,
226+
ConstructTupleDescriptor(RelationheapRelation,
228227
intnumatts,
229228
AttrNumber*attNums)
230229
{
@@ -253,25 +252,16 @@ ConstructTupleDescriptor(Oid heapoid,
253252
{
254253
AttrNumberatnum;/* attributeNumber[attributeOffset] */
255254
AttrNumberatind;
256-
char*from;/* used to simplify memcpy below */
257-
char*to;/* used to simplify memcpy below */
255+
Form_pg_attributefrom;
256+
Form_pg_attributeto;
258257

259258
/* ----------------
260-
* get the attribute number and make sure it's valid
259+
* get the attribute number and make sure it's valid;
260+
* determine which attribute descriptor to copy
261261
* ----------------
262262
*/
263263
atnum=attNums[i];
264-
if (atnum>natts)
265-
elog(ERROR,"Cannot create index: attribute %d does not exist",
266-
atnum);
267264

268-
indexTupDesc->attrs[i]=
269-
(Form_pg_attribute)palloc(ATTRIBUTE_TUPLE_SIZE);
270-
271-
/* ----------------
272-
* determine which tuple descriptor to copy
273-
* ----------------
274-
*/
275265
if (!AttrNumberIsForUserDefinedAttr(atnum))
276266
{
277267
/* ----------------
@@ -285,44 +275,47 @@ ConstructTupleDescriptor(Oid heapoid,
285275
elog(ERROR,"Cannot create index on system attribute: attribute number out of range (%d)",atnum);
286276
atind= (-atnum)-1;
287277

288-
from=(char*) (&sysatts[atind]);
278+
from=&sysatts[atind];
289279
}
290280
else
291281
{
292282
/* ----------------
293283
* here we are indexing on a normal attribute (1...n)
294284
* ----------------
295285
*/
286+
if (atnum>natts)
287+
elog(ERROR,"Cannot create index: attribute %d does not exist",
288+
atnum);
296289
atind=AttrNumberGetAttrOffset(atnum);
297290

298-
from=(char*) (heapTupDesc->attrs[atind]);
291+
from=heapTupDesc->attrs[atind];
299292
}
300293

301294
/* ----------------
302295
* now that we've determined the "from", let's copy
303296
* the tuple desc data...
304297
* ----------------
305298
*/
306-
to= (char*) (indexTupDesc->attrs[i]);
299+
indexTupDesc->attrs[i]=to=
300+
(Form_pg_attribute)palloc(ATTRIBUTE_TUPLE_SIZE);
307301
memcpy(to,from,ATTRIBUTE_TUPLE_SIZE);
308302

309303
/*
310304
* Fix the stuff that should not be the same as the underlying attr
311305
*/
312-
((Form_pg_attribute)to)->attnum=i+1;
306+
to->attnum=i+1;
313307

314-
((Form_pg_attribute)to)->attdispersion=0.0;
315-
((Form_pg_attribute)to)->attnotnull= false;
316-
((Form_pg_attribute)to)->atthasdef= false;
317-
((Form_pg_attribute)to)->attcacheoff=-1;
308+
to->attdispersion=0.0;
309+
to->attnotnull= false;
310+
to->atthasdef= false;
311+
to->attcacheoff=-1;
318312

319-
/* ----------------
320-
* now we have to drop in the proper relation descriptor
321-
* into the copied tuple form's attrelid and we should be
322-
* all set.
323-
* ----------------
313+
/*
314+
* We do not yet have the correct relation OID for the index,
315+
* so just set it invalid for now. InitializeAttributeOids()
316+
* will fix it later.
324317
*/
325-
((Form_pg_attribute)to)->attrelid=heapoid;
318+
to->attrelid=InvalidOid;
326319
}
327320

328321
returnindexTupDesc;
@@ -916,8 +909,7 @@ index_create(char *heapRelationName,
916909
if (OidIsValid(indexInfo->ii_FuncOid))
917910
indexTupDesc=BuildFuncTupleDesc(indexInfo->ii_FuncOid);
918911
else
919-
indexTupDesc=ConstructTupleDescriptor(heapoid,
920-
heapRelation,
912+
indexTupDesc=ConstructTupleDescriptor(heapRelation,
921913
indexInfo->ii_NumKeyAttrs,
922914
indexInfo->ii_KeyAttrNumbers);
923915

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp