Skip to content

Commit a885ecd

Browse files
author
Neil Conway
committed
Change heap_modifytuple() to require a TupleDesc rather than a
Relation. Patch from Alvaro Herrera, minor editorializing by Neil Conway.
1 parent 728775d commit a885ecd

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(HeapTuple tuple,
672-
Relation relation,
669+
TupleDesc tupleDesc,
673670
Datum *replValues,
674671
char *replNulls,
675672
char *replActions)
676673
{
677-
TupleDesc tupleDesc = RelationGetDescr(relation);
678674
int numberOfAttributes = tupleDesc->natts;
679675
int attoff;
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
char replaces[Natts_pg_type];
180180
Datum values[Natts_pg_type];
181181
NameData name;
182-
TupleDesc tupDesc;
183182
int i;
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
ItemPointerData ctid;
524524
int result;
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
#ifdef NOT_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);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy