diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2024-03-17 05:58:04 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2024-03-17 05:58:04 +0100 |
commit | 20e58105badff383bd43f0b97e532771768f94df (patch) | |
tree | 4bff7fadb1d4fbf269477787dae80b81c27c4596 /src/backend/commands/view.c | |
parent | b7831865159d5fb6f0d263e6023f0986589fe254 (diff) | |
download | postgresql-20e58105badff383bd43f0b97e532771768f94df.tar.gz postgresql-20e58105badff383bd43f0b97e532771768f94df.zip |
Separate equalRowTypes() from equalTupleDescs()
This introduces a new function equalRowTypes() that is effectively a
subset of equalTupleDescs() but only compares the number of attributes
and attribute name, type, typmod, and collation. This is enough for
most existing uses of equalTupleDescs(), which are changed to use the
new function. The only remaining callers of equalTupleDescs() are
those that really want to check the full tuple descriptor as such,
without concern about record or row or record type semantics.
The existing function hashTupleDesc() is renamed to hashRowType(),
because it now corresponds more to equalRowTypes().
The purpose of this change is to be clearer about the semantics of the
equality asked for by each caller. (At least one caller had a comment
that questioned whether equalTupleDescs() was too restrictive.) For
example, 4f622503d6d removed attstattarget from the tuple descriptor
structure. It was not fully clear at the time how this should affect
equalTupleDescs(). Now the answer is clear: By their own definitions,
equalRowTypes() does not care, and equalTupleDescs() just compares
whatever is in the tuple descriptor but does not care why it is in
there.
Reviewed-by: Tomas Vondra <tomas.vondra@enterprisedb.com>
Discussion: https://www.postgresql.org/message-id/flat/f656d6d9-6660-4518-a006-2f65cafbebd1%40eisentraut.org
Diffstat (limited to 'src/backend/commands/view.c')
-rw-r--r-- | src/backend/commands/view.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c index becc1fb4583..fdad8338324 100644 --- a/src/backend/commands/view.c +++ b/src/backend/commands/view.c @@ -30,7 +30,7 @@ #include "utils/lsyscache.h" #include "utils/rel.h" -static void checkViewTupleDesc(TupleDesc newdesc, TupleDesc olddesc); +static void checkViewColumns(TupleDesc newdesc, TupleDesc olddesc); /*--------------------------------------------------------------------- * DefineVirtualRelation @@ -130,7 +130,7 @@ DefineVirtualRelation(RangeVar *relation, List *tlist, bool replace, * column list. */ descriptor = BuildDescForRelation(attrList); - checkViewTupleDesc(descriptor, rel->rd_att); + checkViewColumns(descriptor, rel->rd_att); /* * If new attributes have been added, we must add pg_attribute entries @@ -258,13 +258,13 @@ DefineVirtualRelation(RangeVar *relation, List *tlist, bool replace, } /* - * Verify that tupledesc associated with proposed new view definition - * matches tupledesc of old view. This is basically a cut-down version - * of equalTupleDescs(), with code added to generate specific complaints. - * Also, we allow the new tupledesc to have more columns than the old. + * Verify that the columns associated with proposed new view definition match + * the columns of the old view. This is similar to equalRowTypes(), with code + * added to generate specific complaints. Also, we allow the new view to have + * more columns than the old. */ static void -checkViewTupleDesc(TupleDesc newdesc, TupleDesc olddesc) +checkViewColumns(TupleDesc newdesc, TupleDesc olddesc) { int i; |