aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-10-24 03:30:03 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-10-24 03:30:03 +0000
commit1c92724985faf15a2cce29e7d95157fc74718d9d (patch)
treec2fa2f7141d84912c7d1a33ec1ea66f9b02e831e /src
parent592c88a0d2d9059576ad4f823dcc6e1ffbd1acfc (diff)
downloadpostgresql-1c92724985faf15a2cce29e7d95157fc74718d9d.tar.gz
postgresql-1c92724985faf15a2cce29e7d95157fc74718d9d.zip
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 dereference same.
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/adt/tsquery_rewrite.c9
-rw-r--r--src/backend/utils/adt/tsvector_op.c9
2 files changed, 10 insertions, 8 deletions
diff --git a/src/backend/utils/adt/tsquery_rewrite.c b/src/backend/utils/adt/tsquery_rewrite.c
index ccf5e67debf..f7a335b337e 100644
--- a/src/backend/utils/adt/tsquery_rewrite.c
+++ b/src/backend/utils/adt/tsquery_rewrite.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_rewrite.c,v 1.6 2007/10/24 02:24:47 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_rewrite.c,v 1.7 2007/10/24 03:30:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -259,7 +259,7 @@ tsquery_rewrite_query(PG_FUNCTION_ARGS)
MemoryContext oldcontext;
QTNode *tree;
char *buf;
- void *plan;
+ SPIPlanPtr plan;
Portal portal;
bool isnull;
int i;
@@ -281,12 +281,13 @@ tsquery_rewrite_query(PG_FUNCTION_ARGS)
if ((plan = SPI_prepare(buf, 0, NULL)) == NULL)
elog(ERROR, "SPI_prepare(\"%s\") failed", buf);
- if ((portal = SPI_cursor_open(NULL, plan, NULL, NULL, false)) == NULL)
+ if ((portal = SPI_cursor_open(NULL, plan, NULL, NULL, true)) == NULL)
elog(ERROR, "SPI_cursor_open(\"%s\") failed", buf);
SPI_cursor_fetch(portal, true, 100);
- if (SPI_tuptable->tupdesc->natts != 2 ||
+ if (SPI_tuptable == NULL ||
+ SPI_tuptable->tupdesc->natts != 2 ||
SPI_gettypeid(SPI_tuptable->tupdesc, 1) != TSQUERYOID ||
SPI_gettypeid(SPI_tuptable->tupdesc, 2) != TSQUERYOID)
ereport(ERROR,
diff --git a/src/backend/utils/adt/tsvector_op.c b/src/backend/utils/adt/tsvector_op.c
index 44b69ac76e3..f67b53407a6 100644
--- a/src/backend/utils/adt/tsvector_op.c
+++ b/src/backend/utils/adt/tsvector_op.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.6 2007/10/23 00:51:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.7 2007/10/24 03:30:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1088,19 +1088,20 @@ ts_stat_sql(text *txt, text *ws)
*stat;
bool isnull;
Portal portal;
- void *plan;
+ SPIPlanPtr plan;
if ((plan = SPI_prepare(query, 0, NULL)) == NULL)
/* internal error */
elog(ERROR, "SPI_prepare(\"%s\") failed", query);
- if ((portal = SPI_cursor_open(NULL, plan, NULL, NULL, false)) == NULL)
+ if ((portal = SPI_cursor_open(NULL, plan, NULL, NULL, true)) == NULL)
/* internal error */
elog(ERROR, "SPI_cursor_open(\"%s\") failed", query);
SPI_cursor_fetch(portal, true, 100);
- if (SPI_tuptable->tupdesc->natts != 1 ||
+ if (SPI_tuptable == NULL ||
+ SPI_tuptable->tupdesc->natts != 1 ||
SPI_gettypeid(SPI_tuptable->tupdesc, 1) != TSVECTOROID)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),