11
11
*
12
12
*
13
13
* 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 $
15
15
*
16
16
* HISTORY
17
17
* AUTHOR DATE MAJOR EVENT
@@ -216,7 +216,7 @@ static TypeName *TableFuncTypeName(List *columns);
216
216
%type <ival> opt_lock lock_type cast_context
217
217
%type <boolean> opt_force opt_or_replace
218
218
opt_grant_grant_option opt_grant_admin_option
219
- opt_nowait opt_if_exists
219
+ opt_nowait opt_if_exists opt_with_data
220
220
221
221
%type <list> OptRoleList
222
222
%type <defelt> OptRoleElem
@@ -485,7 +485,7 @@ static TypeName *TableFuncTypeName(List *columns);
485
485
* list and so can never be entered directly. The filter in parser.c
486
486
* creates these tokens when required.
487
487
*/
488
- %token NULLS_FIRST NULLS_LAST WITH_CASCADED WITH_LOCAL WITH_CHECK
488
+ %token NULLS_FIRST NULLS_LAST WITH_TIME
489
489
490
490
/* Special token types, not actually keywords - see the "lex" file */
491
491
%token <str> IDENT FCONST SCONST BCONST XCONST Op
@@ -2416,7 +2416,7 @@ OptConsTableSpace: USING INDEX TABLESPACE name { $$ = $4; }
2416
2416
*/
2417
2417
2418
2418
CreateAsStmt :
2419
- CREATE OptTemp TABLE create_as_target AS SelectStmt
2419
+ CREATE OptTemp TABLE create_as_target AS SelectStmt opt_with_data
2420
2420
{
2421
2421
/*
2422
2422
* When the SelectStmt is a set-operation tree, we must
@@ -2433,6 +2433,9 @@ CreateAsStmt:
2433
2433
scanner_errposition(exprLocation((Node *) n->intoClause))));
2434
2434
$4 ->rel->istemp = $2 ;
2435
2435
n->intoClause = $4 ;
2436
+ /* Implement WITH NO DATA by forcing top-level LIMIT 0 */
2437
+ if (!$7 )
2438
+ ((SelectStmt *) $6 )->limitCount = makeIntConst(0 , -1 );
2436
2439
$$ = $6 ;
2437
2440
}
2438
2441
;
@@ -2475,6 +2478,12 @@ CreateAsElement:
2475
2478
}
2476
2479
;
2477
2480
2481
+ opt_with_data :
2482
+ WITH DATA_P { $$ = TRUE ; }
2483
+ | WITH NO DATA_P { $$ = FALSE ; }
2484
+ | /* EMPTY*/ { $$ = TRUE ; }
2485
+ ;
2486
+
2478
2487
2479
2488
/* ****************************************************************************
2480
2489
*
@@ -5387,24 +5396,20 @@ ViewStmt: CREATE OptTemp VIEW qualified_name opt_column_list
5387
5396
}
5388
5397
;
5389
5398
5390
- /*
5391
- * We use merged tokens here to avoid creating shift/reduce conflicts against
5392
- * a whole lot of other uses of WITH.
5393
- */
5394
5399
opt_check_option:
5395
- WITH_CHECK OPTION
5400
+ WITH CHECK OPTION
5396
5401
{
5397
5402
ereport (ERROR,
5398
5403
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5399
5404
errmsg(" WITH CHECK OPTION is not implemented" )));
5400
5405
}
5401
- | WITH_CASCADED CHECK OPTION
5406
+ | WITH CASCADED CHECK OPTION
5402
5407
{
5403
5408
ereport (ERROR,
5404
5409
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5405
5410
errmsg(" WITH CHECK OPTION is not implemented" )));
5406
5411
}
5407
- | WITH_LOCAL CHECK OPTION
5412
+ | WITH LOCAL CHECK OPTION
5408
5413
{
5409
5414
ereport (ERROR,
5410
5415
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
@@ -7509,7 +7514,7 @@ ConstInterval:
7509
7514
;
7510
7515
7511
7516
opt_timezone:
7512
- WITH TIME ZONE { $$ = TRUE ; }
7517
+ WITH_TIME ZONE { $$ = TRUE ; }
7513
7518
| WITHOUT TIME ZONE { $$ = FALSE ; }
7514
7519
| /* EMPTY*/ { $$ = FALSE ; }
7515
7520
;
0 commit comments