mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
Use castNode() in a bunch of statement-list-related code.
When I wrote commit ab1f0c822
, I really missed the castNode() macro that
Peter E. had proposed shortly before. This back-fills the uses I would
have put it to. It's probably not all that significant, but there are
more assertions here than there were before, and conceivably they will
help catch any bugs associated with those representation changes.
I left behind a number of usages like "(Query *) copyObject(query_var)".
Those could have been converted as well, but Peter has proposed another
notational improvement that would handle copyObject cases automatically,
so I let that be for now.
This commit is contained in:
@ -962,7 +962,7 @@ exec_simple_query(const char *query_string)
|
||||
*/
|
||||
foreach(parsetree_item, parsetree_list)
|
||||
{
|
||||
RawStmt *parsetree = (RawStmt *) lfirst(parsetree_item);
|
||||
RawStmt *parsetree = castNode(RawStmt, lfirst(parsetree_item));
|
||||
bool snapshot_set = false;
|
||||
const char *commandTag;
|
||||
char completionTag[COMPLETION_TAG_BUFSIZE];
|
||||
@ -1286,7 +1286,7 @@ exec_parse_message(const char *query_string, /* string to execute */
|
||||
bool snapshot_set = false;
|
||||
int i;
|
||||
|
||||
raw_parse_tree = (RawStmt *) linitial(parsetree_list);
|
||||
raw_parse_tree = castNode(RawStmt, linitial(parsetree_list));
|
||||
|
||||
/*
|
||||
* Get the command name for possible use in status display.
|
||||
@ -2148,7 +2148,7 @@ errdetail_execute(List *raw_parsetree_list)
|
||||
|
||||
foreach(parsetree_item, raw_parsetree_list)
|
||||
{
|
||||
RawStmt *parsetree = (RawStmt *) lfirst(parsetree_item);
|
||||
RawStmt *parsetree = castNode(RawStmt, lfirst(parsetree_item));
|
||||
|
||||
if (IsA(parsetree->stmt, ExecuteStmt))
|
||||
{
|
||||
@ -2502,9 +2502,8 @@ IsTransactionExitStmtList(List *pstmts)
|
||||
{
|
||||
if (list_length(pstmts) == 1)
|
||||
{
|
||||
PlannedStmt *pstmt = (PlannedStmt *) linitial(pstmts);
|
||||
PlannedStmt *pstmt = castNode(PlannedStmt, linitial(pstmts));
|
||||
|
||||
Assert(IsA(pstmt, PlannedStmt));
|
||||
if (pstmt->commandType == CMD_UTILITY &&
|
||||
IsTransactionExitStmt(pstmt->utilityStmt))
|
||||
return true;
|
||||
@ -2518,9 +2517,8 @@ IsTransactionStmtList(List *pstmts)
|
||||
{
|
||||
if (list_length(pstmts) == 1)
|
||||
{
|
||||
PlannedStmt *pstmt = (PlannedStmt *) linitial(pstmts);
|
||||
PlannedStmt *pstmt = castNode(PlannedStmt, linitial(pstmts));
|
||||
|
||||
Assert(IsA(pstmt, PlannedStmt));
|
||||
if (pstmt->commandType == CMD_UTILITY &&
|
||||
IsA(pstmt->utilityStmt, TransactionStmt))
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user