aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/functioncmds.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2017-01-31 18:42:24 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2017-01-31 18:42:24 -0300
commit2f5c9d9c9cec436e55847ec580606d7e88067df6 (patch)
treeec1776d80b7ae8a7b4b0ba357d78eab660dc0f12 /src/backend/commands/functioncmds.c
parente2090d9d20d8091c9478a674d9c22fc8006909ce (diff)
downloadpostgresql-2f5c9d9c9cec436e55847ec580606d7e88067df6.tar.gz
postgresql-2f5c9d9c9cec436e55847ec580606d7e88067df6.zip
Tweak catalog indexing abstraction for upcoming WARM
Split the existing CatalogUpdateIndexes into two different routines, CatalogTupleInsert and CatalogTupleUpdate, which do both the heap insert/update plus the index update. This removes over 300 lines of boilerplate code all over src/backend/catalog/ and src/backend/commands. The resulting code is much more pleasing to the eye. Also, by encapsulating what happens in detail during an UPDATE, this facilitates the upcoming WARM patch, which is going to add a few more lines to the update case making the boilerplate even more boring. The original CatalogUpdateIndexes is removed; there was only one use left, and since it's just three lines, we can as well expand it in place there. We could keep it, but WARM is going to break all the UPDATE out-of-core callsites anyway, so there seems to be no benefit in doing so. Author: Pavan Deolasee Discussion: https://www.postgr.es/m/CABOikdOcFYSZ4vA2gYfs=M2cdXzXX4qGHeEiW3fu9PCfkHLa2A@mail.gmail.com
Diffstat (limited to 'src/backend/commands/functioncmds.c')
-rw-r--r--src/backend/commands/functioncmds.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index ec833c382dc..f4fa8d35a4e 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -1292,8 +1292,7 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
procForm->proparallel = interpret_func_parallel(parallel_item);
/* Do the update */
- simple_heap_update(rel, &tup->t_self, tup);
- CatalogUpdateIndexes(rel, tup);
+ CatalogTupleUpdate(rel, &tup->t_self, tup);
InvokeObjectPostAlterHook(ProcedureRelationId, funcOid, 0);
@@ -1333,9 +1332,7 @@ SetFunctionReturnType(Oid funcOid, Oid newRetType)
procForm->prorettype = newRetType;
/* update the catalog and its indexes */
- simple_heap_update(pg_proc_rel, &tup->t_self, tup);
-
- CatalogUpdateIndexes(pg_proc_rel, tup);
+ CatalogTupleUpdate(pg_proc_rel, &tup->t_self, tup);
heap_close(pg_proc_rel, RowExclusiveLock);
}
@@ -1368,9 +1365,7 @@ SetFunctionArgType(Oid funcOid, int argIndex, Oid newArgType)
procForm->proargtypes.values[argIndex] = newArgType;
/* update the catalog and its indexes */
- simple_heap_update(pg_proc_rel, &tup->t_self, tup);
-
- CatalogUpdateIndexes(pg_proc_rel, tup);
+ CatalogTupleUpdate(pg_proc_rel, &tup->t_self, tup);
heap_close(pg_proc_rel, RowExclusiveLock);
}
@@ -1656,9 +1651,7 @@ CreateCast(CreateCastStmt *stmt)
tuple = heap_form_tuple(RelationGetDescr(relation), values, nulls);
- castid = simple_heap_insert(relation, tuple);
-
- CatalogUpdateIndexes(relation, tuple);
+ castid = CatalogTupleInsert(relation, tuple);
/* make dependency entries */
myself.classId = CastRelationId;
@@ -1921,7 +1914,7 @@ CreateTransform(CreateTransformStmt *stmt)
replaces[Anum_pg_transform_trftosql - 1] = true;
newtuple = heap_modify_tuple(tuple, RelationGetDescr(relation), values, nulls, replaces);
- simple_heap_update(relation, &newtuple->t_self, newtuple);
+ CatalogTupleUpdate(relation, &newtuple->t_self, newtuple);
transformid = HeapTupleGetOid(tuple);
ReleaseSysCache(tuple);
@@ -1930,12 +1923,10 @@ CreateTransform(CreateTransformStmt *stmt)
else
{
newtuple = heap_form_tuple(RelationGetDescr(relation), values, nulls);
- transformid = simple_heap_insert(relation, newtuple);
+ transformid = CatalogTupleInsert(relation, newtuple);
is_replace = false;
}
- CatalogUpdateIndexes(relation, newtuple);
-
if (is_replace)
deleteDependencyRecordsFor(TransformRelationId, transformid, true);