@@ -775,7 +775,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
775775
776776%type <str> Iconst Fconst Sconst TransactionStmt CreateStmt UserId
777777%type <str> CreateAsElement OptCreateAs CreateAsList CreateAsStmt
778- %type <str> OptInherit key_reference key_action
778+ %type <str> OptInherit key_reference key_action comment_text
779779%type <str> key_match ColLabel SpecialRuleRelation
780780%type <str> ColId ColQualifier columnDef ColQualList
781781%type <str> ColConstraint ColConstraintElem NumericOnly FloatOnly
@@ -827,16 +827,16 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
827827%type <str> ViewStmt LoadStmt CreatedbStmt opt_database1 opt_database2 location
828828%type <str> DestroydbStmt ClusterStmt grantee RevokeStmt encoding
829829%type <str> GrantStmt privileges operation_commalist operation
830- %type <str> opt_cursor opt_lmode ConstraintsSetStmt
830+ %type <str> opt_cursor opt_lmode ConstraintsSetStmt comment_tg
831831%type <str> case_expr when_clause_list case_default case_arg when_clause
832832%type <str> select_clause opt_select_limit select_limit_value
833833%type <str> select_offset_value table_list using_expr join_expr
834834%type <str> using_list from_expr table_expr join_clause join_type
835835%type <str> join_qual update_list join_clause join_clause_with_union
836836%type <str> opt_level opt_lock lock_type OptConstrTrigDeferrable ,
837- %type <str> OptConstrTrigInitdeferred OptConstrFromTable
838- %type <str> constraints_set_list constraints_set_namelist
839- %type <str> constraints_set_mode
837+ %type <str> OptConstrTrigInitdeferred OptConstrFromTable comment_op
838+ %type <str> constraints_set_list constraints_set_namelist comment_fn
839+ %type <str> constraints_set_mode comment_type comment_cl comment_ag
840840
841841%type <str> ECPGWhenever ECPGConnect connection_target ECPGOpen opt_using
842842%type <str> indicator ECPGExecute ecpg_expr ECPGPrepare
@@ -1895,21 +1895,65 @@ opt_portal_name: IN name{ $$ = cat2_str(make1_str("in"), $2); }
18951895
18961896/* ****************************************************************************
18971897 *
1898- * QUERY:
1899- * comment on [ table <relname> | column <relname>.<attribu
1900- * is 'text'
1898+ * The COMMENT ON statement can take different forms based upon the type of
1899+ * the object associated with the comment. The form of the statement is:
1900+ *
1901+ * COMMENT ON [ [ DATABASE | INDEX | RULE | SEQUENCE | TABLE | TYPE | VIEW ]
1902+ * <objname> | AGGREGATE <aggname> <aggtype> | FUNCTION
1903+ * <funcname> (arg1, arg2, ...) | OPERATOR <op>
1904+ * (leftoperand_typ rightoperand_typ) | TRIGGER <triggername> ON
1905+ * <relname> ] IS 'text'
19011906 *
19021907 *****************************************************************************/
1903- CommentStmt :COMMENT ON COLUMN relation_name ' . ' attr_name IS Sconst
1908+ CommentStmt :COMMENT ON comment_type name IS comment_text
19041909 {
1905- cat2_str ( cat5_str(make1_str(" comment on column " ), $4, make1_str( " , " ), $6 , make1_str(" is" )) , $8 );
1910+ $$ = cat5_str(make1_str(" comment on" ),$3 , $4 , make1_str(" is" ),$6 );
19061911 }
1907- | COMMENT ON TABLE relation_name IS Sconst
1912+ | COMMENT ON comment_cl relation_name ' .' attr_name IS comment_text
1913+ {
1914+ $$ = cat3_str(cat5_str(make1_str(" comment on" ),$3 ,$4 , make1_str(" ." ),$6 ), make1_str(" is" ),$8 );
1915+ }
1916+ | COMMENT ON comment_ag name aggr_argtype IS comment_text
1917+ {
1918+ cat2_str (cat5_str(make1_str(" comment on" ), $3, $4, $5, make1_str(" is" )), $7);
1919+ }
1920+ | COMMENT ON comment_fn func_name func_args IS comment_text
1921+ {
1922+ cat2_str (cat5_str(make1_str(" comment on" ), $3, $4, $5, make1_str(" is" )), $7);
1923+ }
1924+ | COMMENT ON comment_op all_Op ' (' oper_argtypes ' )' IS comment_text
1925+ {
1926+ cat3_str (cat5_str(make1_str(" comment on" ), $3, $4, make1_str(" (" ), $6), make1_str(" ) is" ), $9);
1927+ }
1928+ | COMMENT ON comment_tg name ON relation_name IS comment_text
19081929 {
1909- cat4_str ( make1_str(" comment on table " ), $4, make1_str(" is " ), $6);
1930+ cat3_str (cat5_str( make1_str(" comment on" ), $3, $ 4, make1_str(" on " ), $6), make1_str( " is " ), $8 );
19101931}
19111932;
1912-
1933+
1934+ comment_type :DATABASE {$$ = make1_str(" database" ); }
1935+ | INDEX {$$ = make1_str(" idnex" ); }
1936+ | RULE {$$ = make1_str(" rule" ); }
1937+ | SEQUENCE {$$ = make1_str(" sequence" ); }
1938+ | TABLE {$$ = make1_str(" table" ); }
1939+ | TYPE_P {$$ = make1_str(" type" ); }
1940+ | VIEW {$$ = make1_str(" view" ); }
1941+ ;
1942+
1943+ comment_cl :COLUMN {$$ = make1_str(" column" ); }
1944+
1945+ comment_ag :AGGREGATE {$$ = make1_str(" aggregate" ); }
1946+
1947+ comment_fn :FUNCTION {$$ = make1_str(" function" ); }
1948+
1949+ comment_op :OPERATOR {$$ = make1_str(" operator" ); }
1950+
1951+ comment_tg :TRIGGER {$$ = make1_str(" trigger" ); }
1952+
1953+ comment_text :Sconst {$$ =$1 ; }
1954+ | NULL_P {$$ = make1_str(" null" ); }
1955+ ;
1956+
19131957/* ****************************************************************************
19141958 *
19151959 *QUERY: