@@ -65,40 +65,6 @@ typedef struct
6565
6666static Datum tsvector_update_trigger (PG_FUNCTION_ARGS , bool config_column );
6767
68-
69- /*
70- * Check if datatype is the specified type or equivalent to it.
71- *
72- * Note: we could just do getBaseType() unconditionally, but since that's
73- * a relatively expensive catalog lookup that most users won't need, we
74- * try the straight comparison first.
75- */
76- static bool
77- is_expected_type (Oid typid , Oid expected_type )
78- {
79- if (typid == expected_type )
80- return true;
81- typid = getBaseType (typid );
82- if (typid == expected_type )
83- return true;
84- return false;
85- }
86-
87- /* Check if datatype is TEXT or binary-equivalent to it */
88- static bool
89- is_text_type (Oid typid )
90- {
91- /* varchar(n) and char(n) are binary-compatible with text */
92- if (typid == TEXTOID || typid == VARCHAROID || typid == BPCHAROID )
93- return true;
94- /* Allow domains over these types, too */
95- typid = getBaseType (typid );
96- if (typid == TEXTOID || typid == VARCHAROID || typid == BPCHAROID )
97- return true;
98- return false;
99- }
100-
101-
10268/*
10369 * Order: haspos, len, word, for all positions (pos, weight)
10470 */
@@ -1166,7 +1132,7 @@ ts_stat_sql(MemoryContext persistentContext, text *txt, text *ws)
11661132
11671133 if (SPI_tuptable == NULL ||
11681134 SPI_tuptable -> tupdesc -> natts != 1 ||
1169- !is_expected_type (SPI_gettypeid (SPI_tuptable -> tupdesc , 1 ),
1135+ !IsBinaryCoercible (SPI_gettypeid (SPI_tuptable -> tupdesc , 1 ),
11701136 TSVECTOROID ))
11711137 ereport (ERROR ,
11721138 (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
@@ -1352,7 +1318,7 @@ tsvector_update_trigger(PG_FUNCTION_ARGS, bool config_column)
13521318 (errcode (ERRCODE_UNDEFINED_COLUMN ),
13531319 errmsg ("tsvector column \"%s\" does not exist" ,
13541320 trigger -> tgargs [0 ])));
1355- if (!is_expected_type (SPI_gettypeid (rel -> rd_att , tsvector_attr_num ),
1321+ if (!IsBinaryCoercible (SPI_gettypeid (rel -> rd_att , tsvector_attr_num ),
13561322 TSVECTOROID ))
13571323 ereport (ERROR ,
13581324 (errcode (ERRCODE_DATATYPE_MISMATCH ),
@@ -1370,7 +1336,7 @@ tsvector_update_trigger(PG_FUNCTION_ARGS, bool config_column)
13701336 (errcode (ERRCODE_UNDEFINED_COLUMN ),
13711337 errmsg ("configuration column \"%s\" does not exist" ,
13721338 trigger -> tgargs [1 ])));
1373- if (!is_expected_type (SPI_gettypeid (rel -> rd_att , config_attr_num ),
1339+ if (!IsBinaryCoercible (SPI_gettypeid (rel -> rd_att , config_attr_num ),
13741340 REGCONFIGOID ))
13751341 ereport (ERROR ,
13761342 (errcode (ERRCODE_DATATYPE_MISMATCH ),
@@ -1416,7 +1382,7 @@ tsvector_update_trigger(PG_FUNCTION_ARGS, bool config_column)
14161382 (errcode (ERRCODE_UNDEFINED_COLUMN ),
14171383 errmsg ("column \"%s\" does not exist" ,
14181384 trigger -> tgargs [i ])));
1419- if (!is_text_type (SPI_gettypeid (rel -> rd_att , numattr )))
1385+ if (!IsBinaryCoercible (SPI_gettypeid (rel -> rd_att , numattr ), TEXTOID ))
14201386 ereport (ERROR ,
14211387 (errcode (ERRCODE_DATATYPE_MISMATCH ),
14221388 errmsg ("column \"%s\" is not of a character type" ,
0 commit comments