def p_createx(self,t):
    """expression : kw_create kw_table nexists NAME '(' tablespecs ')' opt_inheritx
                  | kw_create kw_table nexists NAME inheritx
    """
    if len(t)==6:
      t[0] = CreateX(t[3], t[4], [], None, [], t[5])
    else:
      all_constraints = {k:list(group) for k, group in itertools.groupby(t[6], lambda x:type(x))}
      pkey = (all_constraints.get(PKeyX) or [None])[0] # todo: get pkey from column constraints as well
      if PKeyX in all_constraints and len(all_constraints[PKeyX]) != 1:
        raise SQLSyntaxError('too_many_pkeyx', all_constraints[PKeyX])
      # note below: this is a rare case where issubclass is safe
      table_constraints = sum([v for k,v in all_constraints.items() if issubclass(k, TableConstraintX)], [])
      t[0] = CreateX(t[3], t[4], all_constraints.get(ColX) or [], pkey, table_constraints, t[8])
def p_createx ( self , t ) : if len ( t ) == 6 : t [ 0 ] = CreateX ( t [ 3 ] , t [ 4 ] , [ ] , None , [ ] , t [ 5 ] ) else : all_constraints = { k : list ( group ) for k , group in itertools . groupby ( t [ 6 ] , lambda x : type ( x ) ) } pkey = ( all_constraints . get ( PKeyX ) or [ None ] ) [ 0 ] if PKeyX in all_constraints and len ( all_constraints [ PKeyX ] ) != 1 : raise SQLSyntaxError ( 'too_many_pkeyx' , all_constraints [ PKeyX ] ) table_constraints = sum ( [ v for k , v in all_constraints . items ( ) if issubclass ( k , TableConstraintX ) ] , [ ] ) t [ 0 ] = CreateX ( t [ 3 ] , t [ 4 ] , all_constraints . get ( ColX ) or [ ] , pkey , table_constraints , t [ 8 ] )
expression : kw_create kw_table nexists NAME '(' tablespecs ')' opt_inheritx
                  | kw_create kw_table nexists NAME inheritx