1111 *
1212 *
1313 * IDENTIFICATION
14- * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.630 2008/10/27 09:37:47 petere Exp $
14+ * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.631 2008/10/28 14: 09:45 petere Exp $
1515 *
1616 * HISTORY
1717 * AUTHORDATEMAJOR EVENT
@@ -216,7 +216,7 @@ static TypeName *TableFuncTypeName(List *columns);
216216%type <ival> opt_lock lock_type cast_context
217217%type <boolean> opt_force opt_or_replace
218218opt_grant_grant_option opt_grant_admin_option
219- opt_nowait opt_if_exists
219+ opt_nowait opt_if_exists opt_with_data
220220
221221%type <list> OptRoleList
222222%type <defelt> OptRoleElem
@@ -485,7 +485,7 @@ static TypeName *TableFuncTypeName(List *columns);
485485 * list and so can never be entered directly. The filter in parser.c
486486 * creates these tokens when required.
487487*/
488- %token NULLS_FIRST NULLS_LAST WITH_CASCADED WITH_LOCAL WITH_CHECK
488+ %token NULLS_FIRST NULLS_LAST WITH_TIME
489489
490490/* Special token types, not actually keywords - see the "lex" file*/
491491%token <str> IDENT FCONST SCONST BCONST XCONST Op
@@ -2416,7 +2416,7 @@ OptConsTableSpace: USING INDEX TABLESPACE name{ $$ = $4; }
24162416*/
24172417
24182418CreateAsStmt :
2419- CREATE OptTemp TABLE create_as_target AS SelectStmt
2419+ CREATE OptTemp TABLE create_as_target AS SelectStmt opt_with_data
24202420{
24212421/*
24222422 * When the SelectStmt is a set-operation tree, we must
@@ -2433,6 +2433,9 @@ CreateAsStmt:
24332433 scanner_errposition(exprLocation((Node *) n->intoClause))));
24342434$4 ->rel->istemp =$2 ;
24352435n->intoClause =$4 ;
2436+ /* Implement WITH NO DATA by forcing top-level LIMIT 0*/
2437+ if (!$7 )
2438+ ((SelectStmt *)$6 )->limitCount = makeIntConst(0 , -1 );
24362439$$ =$6 ;
24372440}
24382441;
@@ -2475,6 +2478,12 @@ CreateAsElement:
24752478}
24762479;
24772480
2481+ opt_with_data :
2482+ WITH DATA_P {$$ =TRUE ; }
2483+ | WITH NO DATA_P {$$ =FALSE ; }
2484+ | /* EMPTY*/ {$$ =TRUE ; }
2485+ ;
2486+
24782487
24792488/* ****************************************************************************
24802489 *
@@ -5387,24 +5396,20 @@ ViewStmt: CREATE OptTemp VIEW qualified_name opt_column_list
53875396}
53885397;
53895398
5390- /*
5391- * We use merged tokens here to avoid creating shift/reduce conflicts against
5392- * a whole lot of other uses of WITH.
5393- */
53945399opt_check_option:
5395- WITH_CHECK OPTION
5400+ WITH CHECK OPTION
53965401{
53975402ereport (ERROR,
53985403(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
53995404 errmsg(" WITH CHECK OPTION is not implemented" )));
54005405}
5401- |WITH_CASCADED CHECK OPTION
5406+ |WITH CASCADED CHECK OPTION
54025407{
54035408ereport (ERROR,
54045409(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
54055410 errmsg(" WITH CHECK OPTION is not implemented" )));
54065411}
5407- |WITH_LOCAL CHECK OPTION
5412+ |WITH LOCAL CHECK OPTION
54085413{
54095414ereport (ERROR,
54105415(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
@@ -7509,7 +7514,7 @@ ConstInterval:
75097514;
75107515
75117516opt_timezone:
7512- WITH TIME ZONE{$$ =TRUE ; }
7517+ WITH_TIME ZONE{$$ =TRUE ; }
75137518| WITHOUT TIME ZONE{$$ =FALSE ; }
75147519|/* EMPTY*/ {$$ =FALSE ; }
75157520;