Skip to content

Commit ae3711f

Browse files
committed
add virtual column definition
1 parent 7b35b43 commit ae3711f

File tree

1 file changed

+90
-2
lines changed

1 file changed

+90
-2
lines changed

src/pegjs/oracle.pegjs

+90-2
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ table_parent_clause
206206
return table;
207207
}
208208

209-
// TODO: replace default collation with a rule
210209
relational_table
211210
= relational_properties:(LPAR _ c:relational_properties _ RPAR { return c; })?
212211
blockchain_clauses:blockchain_table_clauses?_
@@ -2060,7 +2059,7 @@ alter_table_stmt_setting
20602059
20612060
alter_table_stmt_body
20622061
= alter_table_properties
2063-
// / column_clauses
2062+
/ column_clauses
20642063
/ x:constraint_clauses { return {...x, target: 'constraint' }; }
20652064
// / alter_table_partitioning
20662065
// / alter_external_table
@@ -2070,6 +2069,88 @@ alter_table_stmt_body
20702069
/ x:immutable_table_clauses { return {...x, target: 'immutable_table' }; }
20712070
/ x:blockchain_table_clauses { return {...x, target: 'blockchain_table' }; }
20722071

2072+
column_clauses
2073+
= rename_column_clause
2074+
/ (_ column_clauses_action_option _)+
2075+
2076+
column_clauses_action_option
2077+
= add_column_clause
2078+
2079+
add_column_clause
2080+
= action:KW_ADD _
2081+
column:(column_definition / virtua_column_definition)
2082+
2083+
virtua_column_definition
2084+
= name:identifier_name _
2085+
type:data_type _
2086+
collate:(KW_COLLATE _ n:identifier_name { return n; })? _
2087+
visibility:(KW_VISIBLE / KW_INVISIBLE)? _
2088+
generated_always:(KW_GENERATED _ KW_ALWAYS { return 'generated always'; })? _
2089+
KW_AS _ LPAR _ column_expression:expr _ RPAR _
2090+
virtual:KW_VIRTUAL? _
2091+
evaluation_edition:evaluation_edition_clause? _
2092+
unusable_editions:unusable_editions_cluase? _
2093+
constraints:((_ x:inline_constraint _ { return x; })+)? _ {
2094+
return {
2095+
name,
2096+
type,
2097+
collate,
2098+
visibility,
2099+
constraints,
2100+
resource: 'virtual column',
2101+
generated_always,
2102+
};
2103+
}
2104+
2105+
unusable_editions_cluase
2106+
= unusable_before_edititon:unusable_editions_clause_before? _
2107+
unusable_beginning_with_edititon:unusable_editions_clause_beginning? {
2108+
return {
2109+
unusable_before_edititon,
2110+
unusable_beginning_with_edititon
2111+
};
2112+
}
2113+
2114+
unusable_editions_clause_before
2115+
= KW_UNUSABLE _ KW_BEFORE _
2116+
unusable_before_edititon:(
2117+
KW_CURRENT _ KW_EDITION { return 'current'; } /
2118+
KW_EDITION _ edition:identifier_name { return { edition }; }
2119+
) {
2120+
return unusable_before_edititon;
2121+
}
2122+
2123+
unusable_editions_clause_beginning
2124+
= KW_UNUSABLE _ KW_BEGINNING _ KW_WITH _
2125+
unusable_beginning_with_edititon:(
2126+
KW_CURRENT _ KW_EDITION { return 'current'; } /
2127+
KW_EDITION _ edition:identifier_name { return { edition }; } /
2128+
KW_NULL _ KW_EDITION { return 'null'; }
2129+
) {
2130+
return unusable_beginning_with_edititon;
2131+
}
2132+
2133+
evaluation_edition_clause
2134+
= KW_EVALUATE _ KW_USING
2135+
evaluate_using_edition:(
2136+
KW_CURRENT _ KW_EDITION { return 'current'; } /
2137+
KW_EDITION _ edititon:identifier_name { return edition; } /
2138+
KW_NULL _ KW_EDITION { return 'null'; }
2139+
) {
2140+
return { evaluate_using_edition };
2141+
}
2142+
2143+
rename_column_clause
2144+
= operation:KW_RENAME _ KW_COLUMN _
2145+
old_name:identifier_name _ KW_TO _
2146+
new_name:identifier_name {
2147+
return {
2148+
old_name,
2149+
new_name,
2150+
operation,
2151+
};
2152+
}
2153+
20732154
alter_table_properties
20742155
= KW_READ _ KW_ONLY { return { read_only: 'read only' }; }
20752156
/ KW_READ _ KW_ONLY { return { read_write: 'read write' }; }
@@ -2666,6 +2747,13 @@ KW_UPGRADE = 'upgrade'i !ident_start { return '
26662747
KW_MINIMIZE = 'minimize'i !ident_start { return 'minimize'; }
26672748
KW_NOMINIMIZE = 'nominimize'i !ident_start { return 'nominimize'; }
26682749
KW_RECORDS_PER_BLOCK = 'records_per_block'i !ident_start { return 'records_per_block'; }
2750+
KW_VIRTUAL = 'virtual'i !ident_start { return 'virtual'; }
2751+
KW_EVALUATE = 'evaluate'i !ident_start { return 'evaluate'; }
2752+
KW_CURRENT = 'current'i !ident_start { return 'current'; }
2753+
KW_EDITION = 'edition'i !ident_start { return 'edition'; }
2754+
KW_UNUSABLE = 'unusable'i !ident_start { return 'unusable'; }
2755+
KW_BEFORE = 'before'i !ident_start { return 'before'; }
2756+
KW_BEGINNING = 'beginning'i !ident_start { return 'beginning'; }
26692757
26702758
KW_VARYING = 'varying'i !ident_start { return 'varying'; }
26712759
KW_VARCHAR = 'varchar'i !ident_start { return 'varchar'; }

0 commit comments

Comments
 (0)