Jeevan Chalke <jeevan.cha...@enterprisedb.com> wrote:
> On Mon, Apr 22, 2013 at 6:41 PM, Andres Freund <and...@2ndquadrant.com> wrote:
>> On 2013-04-22 18:35:04 +0530, Jeevan Chalke wrote:

>>> I have observed that following sequence is causing server crash.
>>> 
>>> CREATE MATERIALIZED VIEW temp_class_mv AS
>>>   SELECT * FROM pg_class
>>>   WITH NO DATA;
>>> 
>>> CREATE OR REPLACE FUNCTION test_refresh_mv()
>>> RETURNS int
>>> AS $$
>>> BEGIN
>>>  REFRESH MATERIALIZED VIEW temp_class_mv;
>>>  return 1;
>>> END; $$ LANGUAGE plpgsql;
>>> 
>>> SELECT test_refresh_mv();
>>> 
>>> 
>>> I had a quick look over the crash and it is hitting following Assert in
>>> spi.c:
>>> 
>>>                 else if (IsA(stmt, RefreshMatViewStmt))
>>>                 {
>>>                     Assert(strncmp(completionTag,
>>>                                    "REFRESH MATERIALIZED VIEW ", 23) == 0);
>>>                     _SPI_current->processed = strtoul(completionTag + 23,
>>>                                                       NULL, 10);
>>>                 }
>>> 
>>> It seems like we are missing expected value for completionTag in
>>> ExecRefreshMatView()

>> Possibly independent from this issue, but where did that 23 come from?

When the consensus developed to change the syntax from LOAD
MATERIALIZED VIEW I failed to noticed the length here when making
the changes for that.

> BTW, attached is the patch which works well for me, but need details review.

I suggest that we just rip out this section of code.  Trying to
provide a number here is probably all wrong, anyway.  As the
features evolve, there may not be a readily accessible rowcount for
this command in all cases.

Any objections to the attached to fix this issue?

--
Kevin Grittner
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index cc7764d..de8d59a 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -2122,13 +2122,6 @@ _SPI_execute_plan(SPIPlanPtr plan, ParamListInfo paramLI,
 					if (((CreateTableAsStmt *) stmt)->is_select_into)
 						res = SPI_OK_SELINTO;
 				}
-				else if (IsA(stmt, RefreshMatViewStmt))
-				{
-					Assert(strncmp(completionTag,
-								   "REFRESH MATERIALIZED VIEW ", 23) == 0);
-					_SPI_current->processed = strtoul(completionTag + 23,
-													  NULL, 10);
-				}
 				else if (IsA(stmt, CopyStmt))
 				{
 					Assert(strncmp(completionTag, "COPY ", 5) == 0);
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to