@@ -101,6 +101,7 @@ typedef struct PrivTarget
101101#define CAS_INITIALLY_IMMEDIATE 0x04
102102#define CAS_INITIALLY_DEFERRED 0x08
103103#define CAS_NOT_VALID 0x10
104+ #define CAS_NO_INHERIT 0x20
104105
105106
106107#define parser_yyerror (msg ) scanner_yyerror(msg, yyscanner)
@@ -144,7 +145,7 @@ static void SplitColQualList(List *qualList,
144145core_yyscan_t yyscanner);
145146static void processCASbits (int cas_bits,int location,const char *constrType,
146147bool *deferrable,bool *initdeferred,bool *not_valid,
147- core_yyscan_t yyscanner);
148+ bool *no_inherit, core_yyscan_t yyscanner);
148149
149150%}
150151
@@ -2709,13 +2710,13 @@ ColConstraintElem:
27092710n->indexspace =$4 ;
27102711$$ = (Node *)n;
27112712}
2712- | CHECK opt_no_inherit ' (' a_expr ' )'
2713+ | CHECK ' (' a_expr ' )' opt_no_inherit
27132714{
27142715Constraint *n = makeNode(Constraint);
27152716n->contype = CONSTR_CHECK;
27162717n->location =@1 ;
2717- n->is_no_inherit =$2 ;
2718- n->raw_expr =$4 ;
2718+ n->is_no_inherit =$5 ;
2719+ n->raw_expr =$3 ;
27192720n->cooked_expr =NULL ;
27202721$$ = (Node *)n;
27212722}
@@ -2755,10 +2756,10 @@ ColConstraintElem:
27552756 * combinations.
27562757 *
27572758 * See also ConstraintAttributeSpec, which can be used in places where
2758- * there is no parsing conflict. (Note: currently, NOT VALIDis an allowed
2759- *clause in ConstraintAttributeSpec, but not here. Someday we might need
2760- * to allowit here too, but for the moment it doesn't seem useful in the
2761- * statements that use ConstraintAttr.)
2759+ * there is no parsing conflict. (Note: currently, NOT VALIDand NO INHERIT
2760+ *are allowed clauses in ConstraintAttributeSpec, but not here. Someday we
2761+ *might need to allowthem here too, but for the moment it doesn't seem
2762+ *useful in the statements that use ConstraintAttr.)
27622763*/
27632764ConstraintAttr :
27642765DEFERRABLE
@@ -2835,17 +2836,16 @@ TableConstraint:
28352836;
28362837
28372838ConstraintElem :
2838- CHECK opt_no_inherit ' (' a_expr ' )' ConstraintAttributeSpec
2839+ CHECK ' (' a_expr ' )' ConstraintAttributeSpec
28392840{
28402841Constraint *n = makeNode(Constraint);
28412842n->contype = CONSTR_CHECK;
28422843n->location =@1 ;
2843- n->is_no_inherit =$2 ;
2844- n->raw_expr =$4 ;
2844+ n->raw_expr =$3 ;
28452845n->cooked_expr =NULL ;
2846- processCASbits ($6 , @6 ," CHECK" ,
2846+ processCASbits ($5 , @5 ," CHECK" ,
28472847NULL ,NULL , &n->skip_validation,
2848- yyscanner);
2848+ &n->is_no_inherit, yyscanner);
28492849n->initially_valid = !n->skip_validation;
28502850$$ = (Node *)n;
28512851}
@@ -2861,7 +2861,7 @@ ConstraintElem:
28612861n->indexspace =$6 ;
28622862processCASbits ($7 , @7 ," UNIQUE" ,
28632863 &n->deferrable, &n->initdeferred,NULL ,
2864- yyscanner);
2864+ NULL , yyscanner);
28652865$$ = (Node *)n;
28662866}
28672867| UNIQUE ExistingIndex ConstraintAttributeSpec
@@ -2875,7 +2875,7 @@ ConstraintElem:
28752875n->indexspace =NULL ;
28762876processCASbits ($3 , @3 ," UNIQUE" ,
28772877 &n->deferrable, &n->initdeferred,NULL ,
2878- yyscanner);
2878+ NULL , yyscanner);
28792879$$ = (Node *)n;
28802880}
28812881| PRIMARY KEY ' (' columnList ' )' opt_definition OptConsTableSpace
@@ -2890,7 +2890,7 @@ ConstraintElem:
28902890n->indexspace =$7 ;
28912891processCASbits ($8 , @8 ," PRIMARY KEY" ,
28922892 &n->deferrable, &n->initdeferred,NULL ,
2893- yyscanner);
2893+ NULL , yyscanner);
28942894$$ = (Node *)n;
28952895}
28962896| PRIMARY KEY ExistingIndex ConstraintAttributeSpec
@@ -2904,7 +2904,7 @@ ConstraintElem:
29042904n->indexspace =NULL ;
29052905processCASbits ($4 , @4 ," PRIMARY KEY" ,
29062906 &n->deferrable, &n->initdeferred,NULL ,
2907- yyscanner);
2907+ NULL , yyscanner);
29082908$$ = (Node *)n;
29092909}
29102910| EXCLUDE access_method_clause ' (' ExclusionConstraintList ' )'
@@ -2922,7 +2922,7 @@ ConstraintElem:
29222922n->where_clause=$8 ;
29232923processCASbits ($9 , @9 ," EXCLUDE" ,
29242924 &n->deferrable, &n->initdeferred,NULL ,
2925- yyscanner);
2925+ NULL , yyscanner);
29262926$$ = (Node *)n;
29272927}
29282928| FOREIGN KEY ' (' columnList ' )' REFERENCES qualified_name
@@ -2939,7 +2939,7 @@ ConstraintElem:
29392939n->fk_del_action= (char ) ($10 &0xFF );
29402940processCASbits ($11 , @11 ," FOREIGN KEY" ,
29412941 &n->deferrable, &n->initdeferred,
2942- &n->skip_validation,
2942+ &n->skip_validation,NULL ,
29432943 yyscanner);
29442944n->initially_valid = !n->skip_validation;
29452945$$ = (Node *)n;
@@ -4133,7 +4133,7 @@ CreateTrigStmt:
41334133n->isconstraint =TRUE ;
41344134processCASbits ($10 , @10 ," TRIGGER" ,
41354135 &n->deferrable, &n->initdeferred,NULL ,
4136- yyscanner);
4136+ NULL , yyscanner);
41374137n->constrrel =$9 ;
41384138$$ = (Node *)n;
41394139}
@@ -4270,6 +4270,7 @@ ConstraintAttributeElem:
42704270| INITIALLY IMMEDIATE {$$ = CAS_INITIALLY_IMMEDIATE; }
42714271| INITIALLY DEFERRED {$$ = CAS_INITIALLY_DEFERRED; }
42724272| NOT VALID {$$ = CAS_NOT_VALID; }
4273+ | NO INHERIT {$$ = CAS_NO_INHERIT; }
42734274;
42744275
42754276
@@ -4386,7 +4387,7 @@ CreateAssertStmt:
43864387n->isconstraint =TRUE ;
43874388processCASbits ($8 , @8 ," ASSERTION" ,
43884389 &n->deferrable, &n->initdeferred,NULL ,
4389- yyscanner);
4390+ NULL , yyscanner);
43904391
43914392ereport (ERROR,
43924393(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
@@ -13380,7 +13381,7 @@ SplitColQualList(List *qualList,
1338013381static void
1338113382processCASbits(int cas_bits, int location, const char *constrType,
1338213383 bool *deferrable, bool *initdeferred, bool *not_valid,
13383- core_yyscan_t yyscanner)
13384+ bool *no_inherit, core_yyscan_t yyscanner)
1338413385{
1338513386/* defaults*/
1338613387if (deferrable)
@@ -13428,6 +13429,19 @@ processCASbits(int cas_bits, int location, const char *constrType,
1342813429constrType),
1342913430 parser_errposition(location)));
1343013431}
13432+
13433+ if (cas_bits & CAS_NO_INHERIT)
13434+ {
13435+ if (no_inherit)
13436+ *no_inherit = true;
13437+ else
13438+ ereport(ERROR,
13439+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
13440+ /* translator: %s is CHECK, UNIQUE, or similar*/
13441+ errmsg("%s constraints cannot be marked NO INHERIT",
13442+ constrType),
13443+ parser_errposition(location)));
13444+ }
1343113445}
1343213446
1343313447/* parser_init()