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

Commit1c92724

Browse files
committed
Set read_only = TRUE while evaluating input queries for ts_rewrite()
and ts_stat(), per my recent suggestion. Also add a possibly-not-needed-but-can't-hurt check for NULL SPI_tuptable, before we try to dereferencesame.
1 parent592c88a commit1c92724

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_rewrite.c,v 1.6 2007/10/2402:24:47 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_rewrite.c,v 1.7 2007/10/2403:30:03 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -259,7 +259,7 @@ tsquery_rewrite_query(PG_FUNCTION_ARGS)
259259
MemoryContextoldcontext;
260260
QTNode*tree;
261261
char*buf;
262-
void*plan;
262+
SPIPlanPtrplan;
263263
Portalportal;
264264
boolisnull;
265265
inti;
@@ -281,12 +281,13 @@ tsquery_rewrite_query(PG_FUNCTION_ARGS)
281281
if ((plan=SPI_prepare(buf,0,NULL))==NULL)
282282
elog(ERROR,"SPI_prepare(\"%s\") failed",buf);
283283

284-
if ((portal=SPI_cursor_open(NULL,plan,NULL,NULL,false))==NULL)
284+
if ((portal=SPI_cursor_open(NULL,plan,NULL,NULL,true))==NULL)
285285
elog(ERROR,"SPI_cursor_open(\"%s\") failed",buf);
286286

287287
SPI_cursor_fetch(portal, true,100);
288288

289-
if (SPI_tuptable->tupdesc->natts!=2||
289+
if (SPI_tuptable==NULL||
290+
SPI_tuptable->tupdesc->natts!=2||
290291
SPI_gettypeid(SPI_tuptable->tupdesc,1)!=TSQUERYOID||
291292
SPI_gettypeid(SPI_tuptable->tupdesc,2)!=TSQUERYOID)
292293
ereport(ERROR,

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.6 2007/10/23 00:51:23 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.7 2007/10/24 03:30:03 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1088,19 +1088,20 @@ ts_stat_sql(text *txt, text *ws)
10881088
*stat;
10891089
boolisnull;
10901090
Portalportal;
1091-
void*plan;
1091+
SPIPlanPtrplan;
10921092

10931093
if ((plan=SPI_prepare(query,0,NULL))==NULL)
10941094
/* internal error */
10951095
elog(ERROR,"SPI_prepare(\"%s\") failed",query);
10961096

1097-
if ((portal=SPI_cursor_open(NULL,plan,NULL,NULL,false))==NULL)
1097+
if ((portal=SPI_cursor_open(NULL,plan,NULL,NULL,true))==NULL)
10981098
/* internal error */
10991099
elog(ERROR,"SPI_cursor_open(\"%s\") failed",query);
11001100

11011101
SPI_cursor_fetch(portal, true,100);
11021102

1103-
if (SPI_tuptable->tupdesc->natts!=1||
1103+
if (SPI_tuptable==NULL||
1104+
SPI_tuptable->tupdesc->natts!=1||
11041105
SPI_gettypeid(SPI_tuptable->tupdesc,1)!=TSVECTOROID)
11051106
ereport(ERROR,
11061107
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp