1010 *
1111 *
1212 * IDENTIFICATION
13- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.129 2000/01/1806:12:03 momjian Exp $
13+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.130 2000/01/1819:08:13 momjian Exp $
1414 *
1515 * HISTORY
1616 * AUTHORDATEMAJOR EVENT
@@ -156,7 +156,7 @@ static Node *doNegate(Node *n);
156156database_name ,access_method_clause ,access_method ,attr_name ,
157157class ,index_name ,name ,func_name ,file_name ,aggr_argtype
158158
159- %type <str> opt_id ,opt_portal_name ,
159+ %type <str> opt_id ,
160160all_Op ,MathOp ,opt_name ,opt_unique ,
161161OptUseOp ,opt_class ,SpecialRuleRelation
162162
@@ -199,7 +199,7 @@ static Node *doNegate(Node *n);
199199opt_with_copy ,index_opt_unique ,opt_verbose ,opt_analyze
200200%type <boolean> opt_cursor
201201
202- %type <ival> copy_dirn ,def_type ,opt_direction ,remove_type ,
202+ %type <ival> copy_dirn ,def_type ,direction ,remove_type ,
203203opt_column ,event ,comment_type ,comment_cl ,
204204comment_ag ,comment_fn ,comment_op ,comment_tg
205205
@@ -1861,7 +1861,7 @@ comment_text:Sconst { $$ = $1; }
18611861 *
18621862 *****************************************************************************/
18631863
1864- FetchStmt :FETCH opt_direction fetch_how_many opt_portal_name
1864+ FetchStmt :FETCH direction fetch_how_many from_in name
18651865{
18661866FetchStmt *n = makeNode(FetchStmt);
18671867if ($2 == RELATIVE)
@@ -1877,11 +1877,60 @@ FetchStmt:FETCH opt_direction fetch_how_many opt_portal_name
18771877}
18781878n->direction =$2 ;
18791879n->howMany =$3 ;
1880+ n->portalname =$5 ;
1881+ n->ismove =false ;
1882+ $$ = (Node *)n;
1883+ }
1884+ | FETCH fetch_how_many from_in name
1885+ {
1886+ FetchStmt *n = makeNode(FetchStmt);
1887+ if ($2 <0 )
1888+ {
1889+ n->howMany = -$2 ;
1890+ n->direction = BACKWARD;
1891+ }
1892+ else
1893+ {
1894+ n->direction = FORWARD;
1895+ n->howMany =$2 ;
1896+ }
1897+ n->portalname =$4 ;
1898+ n->ismove =false ;
1899+ $$ = (Node *)n;
1900+ }
1901+ | FETCH direction from_in name
1902+ {
1903+ FetchStmt *n = makeNode(FetchStmt);
1904+ if ($2 == RELATIVE)
1905+ {
1906+ $2 = FORWARD;
1907+ }
1908+ n->direction =$2 ;
1909+ n->howMany =1 ;
18801910n->portalname =$4 ;
18811911n->ismove =false ;
18821912$$ = (Node *)n;
18831913}
1884- | MOVE opt_direction fetch_how_many opt_portal_name
1914+ | FETCH from_in name
1915+ {
1916+ FetchStmt *n = makeNode(FetchStmt);
1917+ n->direction = FORWARD;
1918+ n->howMany =1 ;
1919+ n->portalname =$3 ;
1920+ n->ismove =false ;
1921+ $$ = (Node *)n;
1922+ }
1923+ | FETCH name
1924+ {
1925+ FetchStmt *n = makeNode(FetchStmt);
1926+ n->direction = FORWARD;
1927+ n->howMany =1 ;
1928+ n->portalname =$2 ;
1929+ n->ismove =false ;
1930+ $$ = (Node *)n;
1931+ }
1932+
1933+ | MOVE direction fetch_how_many from_in name
18851934{
18861935FetchStmt *n = makeNode(FetchStmt);
18871936if ($3 <0 )
@@ -1891,35 +1940,76 @@ FetchStmt:FETCH opt_direction fetch_how_many opt_portal_name
18911940}
18921941n->direction =$2 ;
18931942n->howMany =$3 ;
1943+ n->portalname =$5 ;
1944+ n->ismove =TRUE ;
1945+ $$ = (Node *)n;
1946+ }
1947+ | MOVE fetch_how_many from_in name
1948+ {
1949+ FetchStmt *n = makeNode(FetchStmt);
1950+ if ($2 <0 )
1951+ {
1952+ n->howMany = -$2 ;
1953+ n->direction = BACKWARD;
1954+ }
1955+ else
1956+ {
1957+ n->direction = FORWARD;
1958+ n->howMany =$2 ;
1959+ }
18941960n->portalname =$4 ;
18951961n->ismove =TRUE ;
18961962$$ = (Node *)n;
18971963}
1964+ | MOVE direction from_in name
1965+ {
1966+ FetchStmt *n = makeNode(FetchStmt);
1967+ n->direction =$2 ;
1968+ n->howMany =1 ;
1969+ n->portalname =$4 ;
1970+ n->ismove =TRUE ;
1971+ $$ = (Node *)n;
1972+ }
1973+ | MOVE from_in name
1974+ {
1975+ FetchStmt *n = makeNode(FetchStmt);
1976+ n->direction = FORWARD;
1977+ n->howMany =1 ;
1978+ n->portalname =$3 ;
1979+ n->ismove =TRUE ;
1980+ $$ = (Node *)n;
1981+ }
1982+ | MOVE name
1983+ {
1984+ FetchStmt *n = makeNode(FetchStmt);
1985+ n->direction = FORWARD;
1986+ n->howMany =1 ;
1987+ n->portalname =$2 ;
1988+ n->ismove =TRUE ;
1989+ $$ = (Node *)n;
1990+ }
18981991;
18991992
1900- opt_direction :FORWARD {$$ = FORWARD; }
1993+ direction :FORWARD {$$ = FORWARD; }
19011994| BACKWARD {$$ = BACKWARD; }
19021995| RELATIVE {$$ = RELATIVE; }
19031996| ABSOLUTE
19041997{
19051998elog (NOTICE," FETCH/ABSOLUTE not supported, using RELATIVE" );
19061999$$ = RELATIVE;
19072000}
1908- | /* EMPTY*/ {$$ = FORWARD;/* default*/ }
19092001;
19102002
19112003fetch_how_many :Iconst {$$ =$1 ; }
19122004| ' -' Iconst {$$ = -$2 ; }
19132005| ALL {$$ =0 ;/* 0 means fetch all tuples*/ }
19142006| NEXT {$$ =1 ; }
19152007| PRIOR {$$ = -1 ; }
1916- | /* EMPTY*/ {$$ =1 ;/* default*/ }
19172008;
19182009
1919- opt_portal_name :IN name {$$ =$2 ; }
1920- | FROM name {$$ =$2 ; }
1921- | /* EMPTY*/ {$$ =NULL ; }
1922- ;
2010+ from_in :IN
2011+ | FROM
2012+ ;
19232013
19242014
19252015/* ****************************************************************************