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

Commita885ecd

Browse files
author
Neil Conway
committed
Change heap_modifytuple() to require a TupleDesc rather than a
Relation. Patch from Alvaro Herrera, minor editorializing byNeil Conway.
1 parent728775d commita885ecd

File tree

18 files changed

+54
-60
lines changed

18 files changed

+54
-60
lines changed

‎src/backend/access/common/heaptuple.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.95 2004/12/31 21:59:07 pgsql Exp $
12+
* $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.96 2005/01/27 23:23:49 neilc Exp $
1313
*
1414
* NOTES
1515
* The old interface functions have been converted to macros
@@ -662,19 +662,15 @@ heap_formtuple(TupleDesc tupleDescriptor,
662662
*
663663
*forms a new tuple from an old tuple and a set of replacement values.
664664
*returns a new palloc'ed tuple.
665-
*
666-
*XXX it is misdesign that this is passed a Relation and not just a
667-
*TupleDesc to describe the tuple structure.
668665
* ----------------
669666
*/
670667
HeapTuple
671668
heap_modifytuple(HeapTupletuple,
672-
Relationrelation,
669+
TupleDesctupleDesc,
673670
Datum*replValues,
674671
char*replNulls,
675672
char*replActions)
676673
{
677-
TupleDesctupleDesc=RelationGetDescr(relation);
678674
intnumberOfAttributes=tupleDesc->natts;
679675
intattoff;
680676
Datum*values;

‎src/backend/catalog/aclchk.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.108 2004/12/31 21:59:38 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.109 2005/01/27 23:23:51 neilc Exp $
1212
*
1313
* NOTES
1414
* See acl.h.
@@ -373,7 +373,7 @@ ExecuteGrantStmt_Relation(GrantStmt *stmt)
373373
replaces[Anum_pg_class_relacl-1]='r';
374374
values[Anum_pg_class_relacl-1]=PointerGetDatum(new_acl);
375375

376-
newtuple=heap_modifytuple(tuple,relation,values,nulls,replaces);
376+
newtuple=heap_modifytuple(tuple,RelationGetDescr(relation),values,nulls,replaces);
377377

378378
ReleaseSysCache(tuple);
379379

@@ -531,7 +531,7 @@ ExecuteGrantStmt_Database(GrantStmt *stmt)
531531
replaces[Anum_pg_database_datacl-1]='r';
532532
values[Anum_pg_database_datacl-1]=PointerGetDatum(new_acl);
533533

534-
newtuple=heap_modifytuple(tuple,relation,values,nulls,replaces);
534+
newtuple=heap_modifytuple(tuple,RelationGetDescr(relation),values,nulls,replaces);
535535

536536
simple_heap_update(relation,&newtuple->t_self,newtuple);
537537

@@ -685,7 +685,7 @@ ExecuteGrantStmt_Function(GrantStmt *stmt)
685685
replaces[Anum_pg_proc_proacl-1]='r';
686686
values[Anum_pg_proc_proacl-1]=PointerGetDatum(new_acl);
687687

688-
newtuple=heap_modifytuple(tuple,relation,values,nulls,replaces);
688+
newtuple=heap_modifytuple(tuple,RelationGetDescr(relation),values,nulls,replaces);
689689

690690
ReleaseSysCache(tuple);
691691

@@ -848,7 +848,7 @@ ExecuteGrantStmt_Language(GrantStmt *stmt)
848848
replaces[Anum_pg_language_lanacl-1]='r';
849849
values[Anum_pg_language_lanacl-1]=PointerGetDatum(new_acl);
850850

851-
newtuple=heap_modifytuple(tuple,relation,values,nulls,replaces);
851+
newtuple=heap_modifytuple(tuple,RelationGetDescr(relation),values,nulls,replaces);
852852

853853
ReleaseSysCache(tuple);
854854

@@ -1002,7 +1002,7 @@ ExecuteGrantStmt_Namespace(GrantStmt *stmt)
10021002
replaces[Anum_pg_namespace_nspacl-1]='r';
10031003
values[Anum_pg_namespace_nspacl-1]=PointerGetDatum(new_acl);
10041004

1005-
newtuple=heap_modifytuple(tuple,relation,values,nulls,replaces);
1005+
newtuple=heap_modifytuple(tuple,RelationGetDescr(relation),values,nulls,replaces);
10061006

10071007
ReleaseSysCache(tuple);
10081008

@@ -1160,7 +1160,7 @@ ExecuteGrantStmt_Tablespace(GrantStmt *stmt)
11601160
replaces[Anum_pg_tablespace_spcacl-1]='r';
11611161
values[Anum_pg_tablespace_spcacl-1]=PointerGetDatum(new_acl);
11621162

1163-
newtuple=heap_modifytuple(tuple,relation,values,nulls,replaces);
1163+
newtuple=heap_modifytuple(tuple,RelationGetDescr(relation),values,nulls,replaces);
11641164

11651165
simple_heap_update(relation,&newtuple->t_self,newtuple);
11661166

‎src/backend/catalog/pg_operator.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/pg_operator.c,v 1.87 2004/12/31 21:59:38 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/pg_operator.c,v 1.88 2005/01/27 23:23:51 neilc Exp $
1212
*
1313
* NOTES
1414
* these routines moved here from commands/define.c and somewhat cleaned up.
@@ -637,7 +637,7 @@ OperatorCreate(const char *operatorName,
637637
operatorObjectId);
638638

639639
tup=heap_modifytuple(tup,
640-
pg_operator_desc,
640+
RelationGetDescr(pg_operator_desc),
641641
values,
642642
nulls,
643643
replaces);
@@ -807,7 +807,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
807807
}
808808

809809
tup=heap_modifytuple(tup,
810-
pg_operator_desc,
810+
RelationGetDescr(pg_operator_desc),
811811
values,
812812
nulls,
813813
replaces);
@@ -832,7 +832,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
832832
replaces[Anum_pg_operator_oprcom-1]='r';
833833

834834
tup=heap_modifytuple(tup,
835-
pg_operator_desc,
835+
RelationGetDescr(pg_operator_desc),
836836
values,
837837
nulls,
838838
replaces);
@@ -858,7 +858,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
858858
replaces[Anum_pg_operator_oprnegate-1]='r';
859859

860860
tup=heap_modifytuple(tup,
861-
pg_operator_desc,
861+
RelationGetDescr(pg_operator_desc),
862862
values,
863863
nulls,
864864
replaces);

‎src/backend/catalog/pg_proc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.122 2004/12/31 21:59:38 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.123 2005/01/27 23:23:51 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -180,7 +180,7 @@ ProcedureCreate(const char *procedureName,
180180
/* proacl will be handled below */
181181

182182
rel=heap_openr(ProcedureRelationName,RowExclusiveLock);
183-
tupDesc=rel->rd_att;
183+
tupDesc=RelationGetDescr(rel);
184184

185185
/* Check for pre-existing definition */
186186
oldtup=SearchSysCache(PROCNAMENSP,
@@ -234,7 +234,7 @@ ProcedureCreate(const char *procedureName,
234234
replaces[Anum_pg_proc_proacl-1]=' ';
235235

236236
/* Okay, do it... */
237-
tup=heap_modifytuple(oldtup,rel,values,nulls,replaces);
237+
tup=heap_modifytuple(oldtup,tupDesc,values,nulls,replaces);
238238
simple_heap_update(rel,&tup->t_self,tup);
239239

240240
ReleaseSysCache(oldtup);

‎src/backend/catalog/pg_type.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.97 2004/12/31 21:59:38 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.98 2005/01/27 23:23:51 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -179,7 +179,6 @@ TypeCreate(const char *typeName,
179179
charreplaces[Natts_pg_type];
180180
Datumvalues[Natts_pg_type];
181181
NameDataname;
182-
TupleDesctupDesc;
183182
inti;
184183

185184
/*
@@ -296,7 +295,7 @@ TypeCreate(const char *typeName,
296295
* Okay to update existing "shell" type tuple
297296
*/
298297
tup=heap_modifytuple(tup,
299-
pg_type_desc,
298+
RelationGetDescr(pg_type_desc),
300299
values,
301300
nulls,
302301
replaces);
@@ -309,9 +308,7 @@ TypeCreate(const char *typeName,
309308
}
310309
else
311310
{
312-
tupDesc=pg_type_desc->rd_att;
313-
314-
tup=heap_formtuple(tupDesc,
311+
tup=heap_formtuple(RelationGetDescr(pg_type_desc),
315312
values,
316313
nulls);
317314

‎src/backend/commands/analyze.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.80 2004/12/31 21:59:41 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.81 2005/01/27 23:23:53 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1193,7 +1193,7 @@ update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats)
11931193
{
11941194
/* Yes, replace it */
11951195
stup=heap_modifytuple(oldtup,
1196-
sd,
1196+
RelationGetDescr(sd),
11971197
values,
11981198
nulls,
11991199
replaces);

‎src/backend/commands/async.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.118 2004/12/31 21:59:41 pgsql Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.119 2005/01/27 23:23:54 neilc Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -523,7 +523,7 @@ AtCommit_Notify(void)
523523
ItemPointerDatactid;
524524
intresult;
525525

526-
rTuple=heap_modifytuple(lTuple,lRel,
526+
rTuple=heap_modifytuple(lTuple,tdesc,
527527
value,nulls,repl);
528528

529529
/*
@@ -942,7 +942,7 @@ ProcessIncomingNotify(void)
942942
* tried to UNLISTEN us, so there can be no uncommitted
943943
* changes.
944944
*/
945-
rTuple=heap_modifytuple(lTuple,lRel,value,nulls,repl);
945+
rTuple=heap_modifytuple(lTuple,tdesc,value,nulls,repl);
946946
simple_heap_update(lRel,&lTuple->t_self,rTuple);
947947

948948
#ifdefNOT_USED/* currently there are no indexes */

‎src/backend/commands/comment.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 1996-2005, PostgreSQL Global Development Group
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.80 2004/12/31 21:59:41 pgsql Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.81 2005/01/27 23:23:54 neilc Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -203,7 +203,7 @@ CreateComments(Oid oid, Oid classoid, int32 subid, char *comment)
203203
simple_heap_delete(description,&oldtuple->t_self);
204204
else
205205
{
206-
newtuple=heap_modifytuple(oldtuple,description,values,
206+
newtuple=heap_modifytuple(oldtuple,RelationGetDescr(description),values,
207207
nulls,replaces);
208208
simple_heap_update(description,&oldtuple->t_self,newtuple);
209209
}

‎src/backend/commands/dbcommands.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.148 2004/12/31 21:59:41 pgsql Exp $
12+
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.149 2005/01/27 23:23:55 neilc Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -816,7 +816,7 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
816816
repl_null[Anum_pg_database_datconfig-1]='n';
817817
}
818818

819-
newtuple=heap_modifytuple(tuple,rel,repl_val,repl_null,repl_repl);
819+
newtuple=heap_modifytuple(tuple,RelationGetDescr(rel),repl_val,repl_null,repl_repl);
820820
simple_heap_update(rel,&tuple->t_self,newtuple);
821821

822822
/* Update indexes */
@@ -911,7 +911,7 @@ AlterDatabaseOwner(const char *dbname, AclId newOwnerSysId)
911911
repl_val[Anum_pg_database_datacl-1]=PointerGetDatum(newAcl);
912912
}
913913

914-
newtuple=heap_modifytuple(tuple,rel,repl_val,repl_null,repl_repl);
914+
newtuple=heap_modifytuple(tuple,RelationGetDescr(rel),repl_val,repl_null,repl_repl);
915915
simple_heap_update(rel,&newtuple->t_self,newtuple);
916916
CatalogUpdateIndexes(rel,newtuple);
917917

‎src/backend/commands/functioncmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.53 2004/12/31 21:59:41 pgsql Exp $
13+
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.54 2005/01/27 23:23:55 neilc Exp $
1414
*
1515
* DESCRIPTION
1616
* These routines take the parse tree and pick out the
@@ -793,7 +793,7 @@ AlterFunctionOwner(List *name, List *argtypes, AclId newOwnerSysId)
793793
repl_val[Anum_pg_proc_proacl-1]=PointerGetDatum(newAcl);
794794
}
795795

796-
newtuple=heap_modifytuple(tup,rel,repl_val,repl_null,repl_repl);
796+
newtuple=heap_modifytuple(tup,RelationGetDescr(rel),repl_val,repl_null,repl_repl);
797797

798798
simple_heap_update(rel,&newtuple->t_self,newtuple);
799799
CatalogUpdateIndexes(rel,newtuple);

‎src/backend/commands/schemacmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.27 2004/12/31 21:59:41 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.28 2005/01/27 23:23:55 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -339,7 +339,7 @@ AlterSchemaOwner(const char *name, AclId newOwnerSysId)
339339
repl_val[Anum_pg_namespace_nspacl-1]=PointerGetDatum(newAcl);
340340
}
341341

342-
newtuple=heap_modifytuple(tup,rel,repl_val,repl_null,repl_repl);
342+
newtuple=heap_modifytuple(tup,RelationGetDescr(rel),repl_val,repl_null,repl_repl);
343343

344344
simple_heap_update(rel,&newtuple->t_self,newtuple);
345345
CatalogUpdateIndexes(rel,newtuple);

‎src/backend/commands/tablecmds.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.144 2005/01/2703:17:30 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.145 2005/01/2723:23:55 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1760,7 +1760,7 @@ update_ri_trigger_args(Oid relid,
17601760
values[Anum_pg_trigger_tgargs-1]=PointerGetDatum(newtgargs);
17611761
replaces[Anum_pg_trigger_tgargs-1]='r';
17621762

1763-
tuple=heap_modifytuple(tuple,tgrel,values,nulls,replaces);
1763+
tuple=heap_modifytuple(tuple,RelationGetDescr(tgrel),values,nulls,replaces);
17641764

17651765
/*
17661766
* Update pg_trigger and its indexes
@@ -5302,7 +5302,7 @@ ATExecChangeOwner(Oid relationOid, int32 newOwnerSysId)
53025302
repl_val[Anum_pg_class_relacl-1]=PointerGetDatum(newAcl);
53035303
}
53045304

5305-
newtuple=heap_modifytuple(tuple,class_rel,repl_val,repl_null,repl_repl);
5305+
newtuple=heap_modifytuple(tuple,RelationGetDescr(class_rel),repl_val,repl_null,repl_repl);
53065306

53075307
simple_heap_update(class_rel,&newtuple->t_self,newtuple);
53085308
CatalogUpdateIndexes(class_rel,newtuple);

‎src/backend/commands/tablespace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.15 2004/12/31 21:59:41 pgsql Exp $
40+
* $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.16 2005/01/27 23:23:55 neilc Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -860,7 +860,7 @@ AlterTableSpaceOwner(const char *name, AclId newOwnerSysId)
860860
repl_val[Anum_pg_tablespace_spcacl-1]=PointerGetDatum(newAcl);
861861
}
862862

863-
newtuple=heap_modifytuple(tup,rel,repl_val,repl_null,repl_repl);
863+
newtuple=heap_modifytuple(tup,RelationGetDescr(rel),repl_val,repl_null,repl_repl);
864864

865865
simple_heap_update(rel,&newtuple->t_self,newtuple);
866866
CatalogUpdateIndexes(rel,newtuple);

‎src/backend/commands/typecmds.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.66 2005/01/24 23:21:57 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.67 2005/01/27 23:23:56 neilc Exp $
1212
*
1313
* DESCRIPTION
1414
* The "DefineFoo" routines take the parse tree and pick out the
@@ -1230,8 +1230,9 @@ AlterDomainDefault(List *names, Node *defaultRaw)
12301230
new_record_repl[Anum_pg_type_typdefault-1]='r';
12311231
}
12321232

1233-
newtuple=heap_modifytuple(tup,rel,
1234-
new_record,new_record_nulls,new_record_repl);
1233+
newtuple=heap_modifytuple(tup,RelationGetDescr(rel),
1234+
new_record,new_record_nulls,
1235+
new_record_repl);
12351236

12361237
simple_heap_update(rel,&tup->t_self,newtuple);
12371238

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp