SQL-Admin

 view release on metacpan or  search on metacpan

lib/SQL/Admin/Driver/DB2/Grammar.pm  view on Meta::CPAN


{
    use SQL::Admin::Utils qw( :all );

}


parse_sql :
    statements
    /\s*/
    {
        die ('eof: ', substr $text, 0, 64) if length $text;
        $item[1];
    }

statements : statement(s?)                  { reflist aexp aexp @item }

statement :
    sql_command ';'                         { $item[1] }
  | ';'                                     { [] }
  | comment                                 { [] }

comment :
    /-.(.*)/

sql_command :
    connect_to
  | create_schema
  | create_sequence
  | create_index
  | create_table
#  | create_view
  | alter_table
  | comment_on
  | COMMIT WORK                             { +{ commit_work => 1 } }
  | CONNECT RESET                           { [] }
  | TERMINATE                               { [] }
#    | select_statement
#    | insert_statement
#    | update_statement
#    | delete_statement

######################################################################
# Keywords
######################################################################

ACTION        : /^\b (?: action           ) \b/ix { $item[0] }
ADD           : /^\b (?: add              ) \b/ix { $item[0] }
ALTER         : /^\b (?: alter            ) \b/ix { $item[0] }
ALWAYS        : /^\b (?: always           ) \b/ix { $item[0] }
APPEND        : /^\b (?: append           ) \b/ix { $item[0] }
AS            : /^\b (?: as               ) \b/ix { $item[0] }
ASC           : /^\b (?: asc              ) \b/ix { $item[0] }
ALL           : /^\b (?: all              ) \b/ix { $item[0] }
ALLOW         : /^\b (?: allow            ) \b/ix { $item[0] }
BIGINT        : /^\b (?: bigint           ) \b/ix { $item[0] }
BUILD         : /^\b (?: build            ) \b/ix { $item[0] }
BY            : /^\b (?: by               ) \b/ix { $item[0] }
CACHE         : /^\b (?: cache            ) \b/ix { $item[0] }
CAPTURE       : /^\b (?: capture          ) \b/ix { $item[0] }
CASCADE       : /^\b (?: cascade          ) \b/ix { $item[0] }
CHANGES       : /^\b (?: changes          ) \b/ix { $item[0] }
CHAR          : /^\b (?: character | char ) \b/ix { $item[0] }
COLUMN        : /^\b (?: column           ) \b/ix { $item[0] }
COMMENT       : /^\b (?: comment          ) \b/ix { $item[0] }
COMMIT        : /^\b (?: commit           ) \b/ix { $item[0] }
CONNECT       : /^\b (?: connect          ) \b/ix { $item[0] }
CONSTRAINT    : /^\b (?: constraint       ) \b/ix { $item[0] }
CREATE        : /^\b (?: create           ) \b/ix { $item[0] }
CURRENT       : /^\b (?: current          ) \b/ix { $item[0] }
CYCLE         : /^\b (?: cycle            ) \b/ix { $item[0] }
DATA          : /^\b (?: data             ) \b/ix { $item[0] }
DATE          : /^\b (?: date             ) \b/ix { $item[0] }
DECIMAL       : /^\b (?: decimal | dec | numeric | num ) \b/ix { $item[0] }
DEFAULT       : /^\b (?: default          ) \b/ix { $item[0] }
DELETE        : /^\b (?: delete           ) \b/ix { $item[0] }
DESC          : /^\b (?: desc             ) \b/ix { $item[0] }
DISABLE       : /^\b (?: disable          ) \b/ix { $item[0] }
DISALLOW      : /^\b (?: disallow         ) \b/ix { $item[0] }
DISTINCT      : /^\b (?: distinct         ) \b/ix { $item[0] }
DOUBLE        : /^\b (?: double           ) \b/ix { $item[0] }
DROP          : /^\b (?: drop             ) \b/ix { $item[0] }
ENABLE        : /^\b (?: enable           ) \b/ix { $item[0] }
ENFORCED      : /^\b (?: enforced         ) \b/ix { $item[0] }
EXCEPT        : /^\b (?: except           ) \b/ix { $item[0] }
FLOAT         : /^\b (?: float            ) \b/ix { $item[0] }
FOREIGN       : /^\b (?: foreign          ) \b/ix { $item[0] }
FROM          : /^\b (?: from             ) \b/ix { $item[0] }
GENERATED     : /^\b (?: generated        ) \b/ix { $item[0] }
IDENTITY      : /^\b (?: identity         ) \b/ix { $item[0] }
IN            : /^\b (?: in               ) \b/ix { $item[0] }
INCREMENT     : /^\b (?: increment        ) \b/ix { $item[0] }
INCLUDE       : /^\b (?: include          ) \b/ix { $item[0] }
INDEX         : /^\b (?: index            ) \b/ix { $item[0] }
INPUT         : /^\b (?: input            ) \b/ix { $item[0] }
INTEGER       : /^\b (?: integer|int      ) \b/ix { $item[0] }
INTERSECT     : /^\b (?: intersect        ) \b/ix { $item[0] }
IS            : /^\b (?: is               ) \b/ix { $item[0] }
KEY           : /^\b (?: key              ) \b/ix { $item[0] }
LOCKSIZE      : /^\b (?: locksize         ) \b/ix { $item[0] }
LOG           : /^\b (?: log              ) \b/ix { $item[0] }
MAXVALUE      : /^\b (?: maxvalue         ) \b/ix { $item[0] }
MINVALUE      : /^\b (?: minvalue         ) \b/ix { $item[0] }
NO            : /^\b (?: no               ) \b/ix { $item[0] }
NONE          : /^\b (?: none             ) \b/ix { $item[0] }
NOT           : /^\b (?: not              ) \b/ix { $item[0] }
NULL          : /^\b (?: null             ) \b/ix { $item[0] }
OFF           : /^\b (?: off              ) \b/ix { $item[0] }
ON            : /^\b (?: on               ) \b/ix { $item[0] }
ONLY          : /^\b (?: only             ) \b/ix { $item[0] }
OPTIMIZATION  : /^\b (?: optimization     ) \b/ix { $item[0] }
ORDER         : /^\b (?: order            ) \b/ix { $item[0] }
PARTITIONED   : /^\b (?: partitioned      ) \b/ix { $item[0] }
PCTFREE       : /^\b (?: pctfree          ) \b/ix { $item[0] }
PRECISION     : /^\b (?: precision        ) \b/ix { $item[0] }
PRIMARY       : /^\b (?: primary          ) \b/ix { $item[0] }
QUERY         : /^\b (?: query            ) \b/ix { $item[0] }
REAL          : /^\b (?: real             ) \b/ix { $item[0] }
RESET         : /^\b (?: reset            ) \b/ix { $item[0] }
ROW           : /^\b (?: row              ) \b/ix { $item[0] }
REFERENCES    : /^\b (?: references       ) \b/ix { $item[0] }

lib/SQL/Admin/Driver/DB2/Grammar.pm  view on Meta::CPAN

    table_name
    index_column_list
    db2_include_columns(?)
    index_options(?)
    { expr_stm @item }

db2_include_columns :
    INCLUDE index_column_list               { +{} }

index_unique :                           # TEST OK
    UNIQUE                                  { expr_key @item }

index_column_list :                      # TEST OK
    '(' ordered_column_names ')'
    { alias @item[0,2] }

index_options :                          # TEST OK
    index_option(s)                        { not_implemented }

index_option:                            # TEST parts
      db2_not_partitioned
    | db2_in_tablespace
    | db2_pctfree
    | db2_reverse_scan


######################################################################
## TABLE common
######################################################################

autoincrement_options :                  # TEST OK
    '(' sequence_option(s /,?/) ')'         { expr_set @item }

autoincrement :                          # TEST OK
    GENERATED
    (ALWAYS | BY DEFAULT)(?)
    AS IDENTITY
    autoincrement_options(?)
    { expr_stm @item }

default_clause :                         # TEST OK
    WITH(?)
    DEFAULT
    default_clause_value(?)
    { expr_stm @item[0,-1] }


default_clause_value:                    # TEST OK
      constant
    | date_time_special_register
    | { +{} }

generated_column_spec :                  # TEST parts
      default_clause
    | autoincrement
#    | generated_expression

######################################################################

referential_delete_action :              # TEST OK
      CASCADE                               { 'cascade' }
    | SET NULL                              { 'set_null' }
    | RESTRICT                              { 'restrict' }
    | NO ACTION                             { 'no_action' }

referential_update_action :              # TEST OK
      RESTRICT                              { 'restrict' }
    | NO ACTION                             { 'no_action' }

update_rule:                             # TEST OK
    ON UPDATE referential_update_action
    { href @item[0, -1] }

delete_rule:                             # TEST OK
    ON DELETE referential_delete_action
    { href @item[0, -1] }

referential_triggered_actions :          # TEST OK
      update_rule delete_rule(?)            { expr_set @item }
    | delete_rule update_rule(?)            { expr_set @item }

constraint_name_definition :             # TEST OK
    CONSTRAINT constraint_name              { $item[-1] }

unique_constraint :                      # TEST OK
    constraint_name_definition(?)
    UNIQUE column_list
    { expr_map @item }

primary_key_constraint :                 # TEST OK
    constraint_name_definition(?)
    PRIMARY KEY column_list
    { expr_map @item }

referenced_table_and_columns :           # TEST OK
    referenced_table
    referenced_column_list(?)
    { expr_set @item }

reference_specification :                # TEST OK
    REFERENCES
    referenced_table_and_columns
    referential_triggered_actions(?)
    db2_constraint_attribute(s?)
    { expr_set @item }

foreign_key_constraint :                 # TEST OK
    constraint_name_definition(?)
    FOREIGN KEY
    referencing_column_list
    reference_specification
    { expr_map @item }

table_constraint :                       # TEST parts
      unique_constraint
    | primary_key_constraint
    | foreign_key_constraint
##    | check_constraint

table_constraint_definition :            # TEST OK
    constraint_name_definition(?)



( run in 0.942 second using v1.01-cache-2.11-cpan-39bf76dae61 )