---------- * exec_stmts Iterate over a list of statements * as long as their return code is OK * ---------- */
| 1948 | * ---------- |
| 1949 | */ |
| 1950 | static int |
| 1951 | exec_stmts(PLpgSQL_execstate *estate, List *stmts) |
| 1952 | { |
| 1953 | PLpgSQL_stmt *save_estmt = estate->err_stmt; |
| 1954 | ListCell *s; |
| 1955 | |
| 1956 | if (stmts == NIL) |
| 1957 | { |
| 1958 | /* |
| 1959 | * Ensure we do a CHECK_FOR_INTERRUPTS() even though there is no |
| 1960 | * statement. This prevents hangup in a tight loop if, for instance, |
| 1961 | * there is a LOOP construct with an empty body. |
| 1962 | */ |
| 1963 | CHECK_FOR_INTERRUPTS(); |
| 1964 | return PLPGSQL_RC_OK; |
| 1965 | } |
| 1966 | |
| 1967 | foreach(s, stmts) |
| 1968 | { |
| 1969 | PLpgSQL_stmt *stmt = (PLpgSQL_stmt *) lfirst(s); |
| 1970 | int rc; |
| 1971 | |
| 1972 | estate->err_stmt = stmt; |
| 1973 | |
| 1974 | /* Let the plugin know that we are about to execute this statement */ |
| 1975 | if (*plpgsql_plugin_ptr && (*plpgsql_plugin_ptr)->stmt_beg) |
| 1976 | ((*plpgsql_plugin_ptr)->stmt_beg) (estate, stmt); |
| 1977 | |
| 1978 | CHECK_FOR_INTERRUPTS(); |
| 1979 | |
| 1980 | switch (stmt->cmd_type) |
| 1981 | { |
| 1982 | case PLPGSQL_STMT_BLOCK: |
| 1983 | rc = exec_stmt_block(estate, (PLpgSQL_stmt_block *) stmt); |
| 1984 | break; |
| 1985 | |
| 1986 | case PLPGSQL_STMT_ASSIGN: |
| 1987 | rc = exec_stmt_assign(estate, (PLpgSQL_stmt_assign *) stmt); |
| 1988 | break; |
| 1989 | |
| 1990 | case PLPGSQL_STMT_PERFORM: |
| 1991 | rc = exec_stmt_perform(estate, (PLpgSQL_stmt_perform *) stmt); |
| 1992 | break; |
| 1993 | |
| 1994 | case PLPGSQL_STMT_CALL: |
| 1995 | rc = exec_stmt_call(estate, (PLpgSQL_stmt_call *) stmt); |
| 1996 | break; |
| 1997 | |
| 1998 | case PLPGSQL_STMT_GETDIAG: |
| 1999 | rc = exec_stmt_getdiag(estate, (PLpgSQL_stmt_getdiag *) stmt); |
| 2000 | break; |
| 2001 | |
| 2002 | case PLPGSQL_STMT_IF: |
| 2003 | rc = exec_stmt_if(estate, (PLpgSQL_stmt_if *) stmt); |
| 2004 | break; |
| 2005 | |
| 2006 | case PLPGSQL_STMT_CASE: |
| 2007 | rc = exec_stmt_case(estate, (PLpgSQL_stmt_case *) stmt); |
no test coverage detected