mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Defend against crash while processing Describe Statement or Describe Portal
messages, when client attempts to execute these outside a transaction (start one) or in a failed transaction (reject message, except for COMMIT/ROLLBACK statements which we can handle). Per report from Francisco Figueiredo Jr.
This commit is contained in:
@ -10,7 +10,7 @@
|
||||
* Copyright (c) 2002-2005, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.43 2005/11/29 01:25:49 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.44 2005/12/14 17:06:27 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -447,6 +447,30 @@ FetchPreparedStatementResultDesc(PreparedStatement *stmt)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Given a prepared statement, determine whether it will return tuples.
|
||||
*
|
||||
* Note: this is used rather than just testing the result of
|
||||
* FetchPreparedStatementResultDesc() because that routine can fail if
|
||||
* invoked in an aborted transaction. This one is safe to use in any
|
||||
* context. Be sure to keep the two routines in sync!
|
||||
*/
|
||||
bool
|
||||
PreparedStatementReturnsTuples(PreparedStatement *stmt)
|
||||
{
|
||||
switch (ChoosePortalStrategy(stmt->query_list))
|
||||
{
|
||||
case PORTAL_ONE_SELECT:
|
||||
case PORTAL_UTIL_SELECT:
|
||||
return true;
|
||||
|
||||
case PORTAL_MULTI_QUERY:
|
||||
/* will not return tuples */
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Given a prepared statement that returns tuples, extract the query
|
||||
* targetlist. Returns NIL if the statement doesn't have a determinable
|
||||
|
Reference in New Issue
Block a user