Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9acb900

Browse files
committed
Fix oversight in tsearch type check
Use IsBinaryCoercible() method instead of customis_expected_type/is_text_type functions which was introduced when tsearch2was moved into core.Per report by David E. WheelerAnalysis by Tom LanePatch by me
1 parent5f7c804 commit9acb900

File tree

1 file changed

+4
-38
lines changed

1 file changed

+4
-38
lines changed

‎src/backend/utils/adt/tsvector_op.c

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -65,40 +65,6 @@ typedef struct
6565

6666
staticDatumtsvector_update_trigger(PG_FUNCTION_ARGS,boolconfig_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-
staticbool
77-
is_expected_type(Oidtypid,Oidexpected_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-
staticbool
89-
is_text_type(Oidtypid)
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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp