@@ -100,6 +100,7 @@ typedef struct PrivTarget
100100#define CAS_INITIALLY_IMMEDIATE 0x04
101101#define CAS_INITIALLY_DEFERRED 0x08
102102#define CAS_NOT_VALID 0x10
103+ #define CAS_NO_INHERIT 0x20
103104
104105
105106#define parser_yyerror (msg ) scanner_yyerror(msg, yyscanner)
@@ -143,7 +144,7 @@ static void SplitColQualList(List *qualList,
143144core_yyscan_t yyscanner);
144145static void processCASbits (int cas_bits,int location,const char *constrType,
145146bool *deferrable,bool *initdeferred,bool *not_valid,
146- core_yyscan_t yyscanner);
147+ bool *no_inherit, core_yyscan_t yyscanner);
147148
148149%}
149150
@@ -2701,13 +2702,13 @@ ColConstraintElem:
27012702n->indexspace =$4 ;
27022703$$ = (Node *)n;
27032704}
2704- | CHECK opt_no_inherit ' (' a_expr ' )'
2705+ | CHECK ' (' a_expr ' )' opt_no_inherit
27052706{
27062707Constraint *n = makeNode(Constraint);
27072708n->contype = CONSTR_CHECK;
27082709n->location =@1 ;
2709- n->is_no_inherit =$2 ;
2710- n->raw_expr =$4 ;
2710+ n->is_no_inherit =$5 ;
2711+ n->raw_expr =$3 ;
27112712n->cooked_expr =NULL ;
27122713$$ = (Node *)n;
27132714}
@@ -2747,10 +2748,10 @@ ColConstraintElem:
27472748 * combinations.
27482749 *
27492750 * See also ConstraintAttributeSpec, which can be used in places where
2750- * there is no parsing conflict. (Note: currently, NOT VALIDis an allowed
2751- *clause in ConstraintAttributeSpec, but not here. Someday we might need
2752- * to allowit here too, but for the moment it doesn't seem useful in the
2753- * statements that use ConstraintAttr.)
2751+ * there is no parsing conflict. (Note: currently, NOT VALIDand NO INHERIT
2752+ *are allowed clauses in ConstraintAttributeSpec, but not here. Someday we
2753+ *might need to allowthem here too, but for the moment it doesn't seem
2754+ *useful in the statements that use ConstraintAttr.)
27542755*/
27552756ConstraintAttr :
27562757DEFERRABLE
@@ -2827,17 +2828,16 @@ TableConstraint:
28272828;
28282829
28292830ConstraintElem :
2830- CHECK opt_no_inherit ' (' a_expr ' )' ConstraintAttributeSpec
2831+ CHECK ' (' a_expr ' )' ConstraintAttributeSpec
28312832{
28322833Constraint *n = makeNode(Constraint);
28332834n->contype = CONSTR_CHECK;
28342835n->location =@1 ;
2835- n->is_no_inherit =$2 ;
2836- n->raw_expr =$4 ;
2836+ n->raw_expr =$3 ;
28372837n->cooked_expr =NULL ;
2838- processCASbits ($6 , @6 ," CHECK" ,
2838+ processCASbits ($5 , @5 ," CHECK" ,
28392839NULL ,NULL , &n->skip_validation,
2840- yyscanner);
2840+ &n->is_no_inherit, yyscanner);
28412841n->initially_valid = !n->skip_validation;
28422842$$ = (Node *)n;
28432843}
@@ -2853,7 +2853,7 @@ ConstraintElem:
28532853n->indexspace =$6 ;
28542854processCASbits ($7 , @7 ," UNIQUE" ,
28552855 &n->deferrable, &n->initdeferred,NULL ,
2856- yyscanner);
2856+ NULL , yyscanner);
28572857$$ = (Node *)n;
28582858}
28592859| UNIQUE ExistingIndex ConstraintAttributeSpec
@@ -2867,7 +2867,7 @@ ConstraintElem:
28672867n->indexspace =NULL ;
28682868processCASbits ($3 , @3 ," UNIQUE" ,
28692869 &n->deferrable, &n->initdeferred,NULL ,
2870- yyscanner);
2870+ NULL , yyscanner);
28712871$$ = (Node *)n;
28722872}
28732873| PRIMARY KEY ' (' columnList ' )' opt_definition OptConsTableSpace
@@ -2882,7 +2882,7 @@ ConstraintElem:
28822882n->indexspace =$7 ;
28832883processCASbits ($8 , @8 ," PRIMARY KEY" ,
28842884 &n->deferrable, &n->initdeferred,NULL ,
2885- yyscanner);
2885+ NULL , yyscanner);
28862886$$ = (Node *)n;
28872887}
28882888| PRIMARY KEY ExistingIndex ConstraintAttributeSpec
@@ -2896,7 +2896,7 @@ ConstraintElem:
28962896n->indexspace =NULL ;
28972897processCASbits ($4 , @4 ," PRIMARY KEY" ,
28982898 &n->deferrable, &n->initdeferred,NULL ,
2899- yyscanner);
2899+ NULL , yyscanner);
29002900$$ = (Node *)n;
29012901}
29022902| EXCLUDE access_method_clause ' (' ExclusionConstraintList ' )'
@@ -2914,7 +2914,7 @@ ConstraintElem:
29142914n->where_clause=$8 ;
29152915processCASbits ($9 , @9 ," EXCLUDE" ,
29162916 &n->deferrable, &n->initdeferred,NULL ,
2917- yyscanner);
2917+ NULL , yyscanner);
29182918$$ = (Node *)n;
29192919}
29202920| FOREIGN KEY ' (' columnList ' )' REFERENCES qualified_name
@@ -2931,7 +2931,7 @@ ConstraintElem:
29312931n->fk_del_action= (char ) ($10 &0xFF );
29322932processCASbits ($11 , @11 ," FOREIGN KEY" ,
29332933 &n->deferrable, &n->initdeferred,
2934- &n->skip_validation,
2934+ &n->skip_validation,NULL ,
29352935 yyscanner);
29362936n->initially_valid = !n->skip_validation;
29372937$$ = (Node *)n;
@@ -4116,7 +4116,7 @@ CreateTrigStmt:
41164116n->isconstraint =TRUE ;
41174117processCASbits ($10 , @10 ," TRIGGER" ,
41184118 &n->deferrable, &n->initdeferred,NULL ,
4119- yyscanner);
4119+ NULL , yyscanner);
41204120n->constrrel =$9 ;
41214121$$ = (Node *)n;
41224122}
@@ -4253,6 +4253,7 @@ ConstraintAttributeElem:
42534253| INITIALLY IMMEDIATE {$$ = CAS_INITIALLY_IMMEDIATE; }
42544254| INITIALLY DEFERRED {$$ = CAS_INITIALLY_DEFERRED; }
42554255| NOT VALID {$$ = CAS_NOT_VALID; }
4256+ | NO INHERIT {$$ = CAS_NO_INHERIT; }
42564257;
42574258
42584259
@@ -4300,7 +4301,7 @@ CreateAssertStmt:
43004301n->isconstraint =TRUE ;
43014302processCASbits ($8 , @8 ," ASSERTION" ,
43024303 &n->deferrable, &n->initdeferred,NULL ,
4303- yyscanner);
4304+ NULL , yyscanner);
43044305
43054306ereport (ERROR,
43064307(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
@@ -13275,7 +13276,7 @@ SplitColQualList(List *qualList,
1327513276static void
1327613277processCASbits(int cas_bits, int location, const char *constrType,
1327713278 bool *deferrable, bool *initdeferred, bool *not_valid,
13278- core_yyscan_t yyscanner)
13279+ bool *no_inherit, core_yyscan_t yyscanner)
1327913280{
1328013281/* defaults*/
1328113282if (deferrable)
@@ -13323,6 +13324,19 @@ processCASbits(int cas_bits, int location, const char *constrType,
1332313324constrType),
1332413325 parser_errposition(location)));
1332513326}
13327+
13328+ if (cas_bits & CAS_NO_INHERIT)
13329+ {
13330+ if (no_inherit)
13331+ *no_inherit = true;
13332+ else
13333+ ereport(ERROR,
13334+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
13335+ /* translator: %s is CHECK, UNIQUE, or similar*/
13336+ errmsg("%s constraints cannot be marked NO INHERIT",
13337+ constrType),
13338+ parser_errposition(location)));
13339+ }
1332613340}
1332713341
1332813342/* parser_init()