Skip to content

Commit ec9ccb7

Browse files
authored
[PlSql] Introduce support for annotations_clause (#4638)
1 parent fd10c01 commit ec9ccb7

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

sql/plsql/PlSqlLexer.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ ANCESTOR : 'ANCESTOR';
8181
ANCILLARY : 'ANCILLARY';
8282
AND : 'AND';
8383
AND_EQUAL : 'AND_EQUAL';
84+
ANNOTATIONS : 'ANNOTATIONS';
8485
ANOMALY : 'ANOMALY';
8586
ANSI_REARCH : 'ANSI_REARCH';
8687
ANTIJOIN : 'ANTIJOIN';

sql/plsql/PlSqlParser.g4

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3511,6 +3511,7 @@ table_properties
35113511
| ROW ARCHIVAL
35123512
| AS select_only_statement
35133513
| FOR EXCHANGE WITH TABLE (schema_name '.')? table_name
3514+
| annotations_clause
35143515
;
35153516

35163517
read_only_clause
@@ -4991,6 +4992,7 @@ alter_table_properties
49914992
| READ ONLY
49924993
| READ WRITE
49934994
| REKEY CHAR_STRING
4995+
| annotations_clause
49944996
;
49954997

49964998
alter_table_partitioning
@@ -5284,7 +5286,7 @@ modify_column_clauses
52845286
;
52855287

52865288
modify_col_properties
5287-
: column_name datatype? (DEFAULT (ON NULL_)? expression)? (ENCRYPT encryption_spec | DECRYPT)? inline_constraint* lob_storage_clause?
5289+
: column_name datatype? (DEFAULT (ON NULL_)? expression)? (ENCRYPT encryption_spec | DECRYPT)? inline_constraint* lob_storage_clause? annotations_clause?
52885290
//TODO alter_xmlschema_clause
52895291
;
52905292

@@ -5456,7 +5458,7 @@ column_definition
54565458
)? (DEFAULT (ON NULL_)? expression | identity_clause)? (ENCRYPT encryption_spec)? (
54575459
inline_constraint+
54585460
| inline_ref_constraint
5459-
)?
5461+
)? annotations_clause?
54605462
;
54615463

54625464
column_collation_name
@@ -7119,6 +7121,24 @@ xmlserialize_param_ident_part
71197121
| INDENT (SIZE '=' concatenation)?
71207122
;
71217123

7124+
// Annotations
7125+
7126+
annotations_clause
7127+
: ANNOTATIONS '(' annotations_list ')'
7128+
;
7129+
7130+
annotations_list
7131+
: (
7132+
ADD (IF NOT EXISTS | OR REPLACE)?
7133+
| DROP (IF EXISTS)?
7134+
| REPLACE
7135+
)? annotation (',' annotations_list)*
7136+
;
7137+
7138+
annotation
7139+
: identifier CHAR_STRING?
7140+
;
7141+
71227142
// SqlPlus
71237143

71247144
sql_plus_command_no_semicolon

sql/plsql/examples/alter_table.sql

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,16 @@ ALTER TABLE USR_SAT_ADMCC.ACC_R65_OPERACAO
2525
MOVE SUBPARTITION SP_INICIAL
2626
COMPRESS FOR QUERY HIGH
2727
TABLESPACE TBS_SAT_ADMCC_DATA_2005
28-
UPDATE INDEXES;
28+
UPDATE INDEXES;
29+
30+
ALTER TABLE fruit ANNOTATIONS (Visibility 'Everyone');
31+
32+
ALTER TABLE fruit ANNOTATIONS (drop Visibility);
33+
34+
ALTER TABLE fruit ANNOTATIONS (add Visibility 'Everyone');
35+
36+
ALTER TABLE fruit MODIFY (id ANNOTATIONS (Visibility 'Hidden'));
37+
38+
ALTER TABLE fruit MODIFY (id ANNOTATIONS (drop Visibility));
39+
40+
ALTER TABLE fruit MODIFY (id ANNOTATIONS (add Visibility 'Hidden'));

sql/plsql/examples/create_table.sql

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,12 @@ CREATE TABLE "ETUDES"."IMPORT_EXMETI" (
255255
access_method VARCHAR2(16),
256256
template_table VARCHAR2(128),
257257
timezone VARCHAR2(64))
258-
SEGMENT CREATION IMMEDIATE NO INMEMORY INITRANS 100;
258+
SEGMENT CREATION IMMEDIATE NO INMEMORY INITRANS 100;
259+
260+
CREATE TABLE fruit (
261+
id NUMERIC(9,0) PRIMARY KEY ANNOTATIONS (Visibility 'Everyone'));
262+
263+
CREATE TABLE fruit (
264+
id NUMERIC(9,0) PRIMARY KEY,
265+
data varchar2(50))
266+
ANNOTATIONS (Visibility 'Everyone');

0 commit comments

Comments
 (0)