0002-Improve-error-message-for-property-typmod-mi.patch.nocfbot
text/plain
Filename: 0002-Improve-error-message-for-property-typmod-mi.patch.nocfbot
Type: text/plain
Part: 1
From 29afc47421916649825ca173a060da791e4ca21f Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Wed, 17 Dec 2025 08:39:47 +0100
Subject: [PATCH 2/3] Improve error message for property typmod mismatch
We should print the formatted type, not the raw typmod.
---
src/backend/commands/propgraphcmds.c | 21 ++-----------------
.../expected/create_property_graph.out | 4 ++--
2 files changed, 4 insertions(+), 21 deletions(-)
diff --git a/src/backend/commands/propgraphcmds.c b/src/backend/commands/propgraphcmds.c
index c1a9e553f16..9d8291e1b4e 100644
--- a/src/backend/commands/propgraphcmds.c
+++ b/src/backend/commands/propgraphcmds.c
@@ -974,12 +974,12 @@ insert_property_record(Oid graphid, Oid ellabeloid, Oid pgerelid, const char *pr
* subclause "Consistency check of a tabular property graph
* descriptor".)
*/
- if (proptypid != exprtypid)
+ if (proptypid != exprtypid || proptypmod != exprtypmod)
{
ereport(ERROR,
errcode(ERRCODE_SYNTAX_ERROR),
errmsg("property \"%s\" data type mismatch: %s vs. %s",
- propname, format_type_be(proptypid), format_type_be(exprtypid)),
+ propname, format_type_with_typemod(proptypid, proptypmod), format_type_with_typemod(exprtypid, exprtypmod)),
errdetail("In a property graph, a property of the same name has to have the same data type in each label."));
}
@@ -992,23 +992,6 @@ insert_property_record(Oid graphid, Oid ellabeloid, Oid pgerelid, const char *pr
propname, get_collation_name(propcollation), get_collation_name(exprcollation)),
errdetail("In a property graph, a property of the same name has to have the same collation in each label."));
}
-
- /*
- * And typmod. It does not seem to be necessary to enforce typmod
- * consistency across properties with the same name. But when
- * properties with the same name have different typmods, it is not
- * clear which one should be used as the typmod of the graph property
- * when typmod of a property is requested before fetching any of the
- * property expressions.
- */
- if (proptypmod != exprtypmod)
- {
- ereport(ERROR,
- errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("property \"%s\" data type modifier mismatch: %d vs. %d",
- propname, proptypmod, exprtypmod),
- errdetail("In a property graph, a property of the same name has to have the same type modifier in each label."));
- }
}
/*
diff --git a/src/test/regress/expected/create_property_graph.out b/src/test/regress/expected/create_property_graph.out
index d177159ed72..0e21600e8d7 100644
--- a/src/test/regress/expected/create_property_graph.out
+++ b/src/test/regress/expected/create_property_graph.out
@@ -169,8 +169,8 @@ CREATE PROPERTY GRAPH gx
t1x KEY (a) PROPERTIES (b AS p1),
t2x KEY (i) PROPERTIES (j AS p1) -- typmod mismatch
);
-ERROR: property "p1" data type modifier mismatch: 14 vs. 19
-DETAIL: In a property graph, a property of the same name has to have the same type modifier in each label.
+ERROR: property "p1" data type mismatch: character varying(10) vs. character varying(15)
+DETAIL: In a property graph, a property of the same name has to have the same data type in each label.
DROP TABLE t1x, t2x;
CREATE PROPERTY GRAPH gx
VERTEX TABLES (
--
2.52.0