diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml index bd6f0254c3a..3ea1ac19b2d 100644 --- a/doc/src/sgml/plpgsql.sgml +++ b/doc/src/sgml/plpgsql.sgml @@ -1,5 +1,5 @@ @@ -2179,19 +2179,21 @@ DECLARE - <command>OPEN FOR SELECT</command> + <command>OPEN FOR</command> <replaceable>query</replaceable> -OPEN unbound_cursor FOR SELECT ...; +OPEN unbound_cursor FOR query ; - The cursor variable is opened and given the specified query to + The cursor variable is opened and given the specified query to execute. The cursor cannot be open already, and it must have been declared as an unbound cursor (that is, as a simple - refcursor variable). The SELECT query - is treated in the same way as other SELECT - statements in PL/pgSQL: PL/pgSQL + refcursor variable). The query must be a + SELECT, or something else that returns rows + (such as EXPLAIN). The query + is treated in the same way as other SQL commands in + PL/pgSQL: PL/pgSQL variable names are substituted, and the query plan is cached for possible reuse. @@ -2216,7 +2218,7 @@ OPEN unbound_cursor FOR EXECUTE dynquery = read_sql_stmt("SELECT "); - break; - - default: - plpgsql_error_lineno = $2; - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("syntax error at \"%s\"", - yytext))); + new->dynquery = read_sql_stmt("SELECT "); + } + else + { + plpgsql_push_back_token(tok); + new->query = read_sql_stmt(""); } - } else { @@ -1316,7 +1304,6 @@ stmt_open : K_OPEN lno cursor_varptr char *cp; tok = yylex(); - if (tok != '(') { plpgsql_error_lineno = plpgsql_scanner_lineno(); @@ -1369,7 +1356,6 @@ stmt_open : K_OPEN lno cursor_varptr else { tok = yylex(); - if (tok == '(') { plpgsql_error_lineno = plpgsql_scanner_lineno();