-
Notifications
You must be signed in to change notification settings - Fork 215
/
sql3.y
4588 lines (4024 loc) · 144 KB
/
sql3.y
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* sql3.y
*
* $Id$
*
* SQL Parser
*
* This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
* project.
*
* Copyright (C) 1998-2023 OpenLink Software
*
* This project is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; only version 2 of the License, dated June 1991.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
%pure-parser
%parse-param {yyscan_t scanner}
%lex-param {yyscan_t scanner}
/*%parse-param {sql_comp_context_t* scs_arg}*/
/*%lex-param {sql_comp_context_t* scs_arg}*/
%expect 19
%{
#include "libutil.h"
#include "sqlnode.h"
#include "sqlpar.h"
#include "sqlpfn.h"
#include "crsr.h"
#include "sqltype.h"
#include "sqlbif.h"
#include "soap.h" /* a SOAP related constants */
#include "subseq.h"
#include "sqlcmps.h"
#include "sqlcstate.h"
/* We are a little bit lazy here. Instead of converting NAME tokens
like d and ts to stringdate, and t to stringtime, and maybe the
rest to "unimplemented_odbc_brace_escape_keyword:%s"
we just let them be as they are, and define aliases d and ts
for stringdate and t for stringtime in sqlbif.c.
In effect, syntax like {any-name any-single-atom} in the place
of atom will be converted to function call any-name(any-single-atom)
Having funny one- or two-character bif-function names like d or ts
does not make any of them reserved keywords, and they can be used
to one's heart's contents as the names of tables, columns, etc.
*/
#define obe_keyword_to_bif_fun_name(X) ((X))
extern void scn3yyerror (const char *strg);
#ifdef DEBUG
#define yyerror(scanner,strg) yyerror_1(/* no scanner */ yystate, yyssa, yyssp, strg)
#define yyfatalerror(strg) yyfatalerror_1(/* no scanner */ yyssa, yyssp, strg)
#else
#define yyerror(scanner,strg) scn3yyerror(/* no scanner */ strg)
#endif
extern int scn3yylex (void *void_yylval, yyscan_t yyscanner);
#define YY_DECL int scn3yylex (void *void_yylval, yyscan_t yyscanner)
#define assert_ms_compat(text)
%}
/* symbolic tokens */
%union {
long intval;
char *strval;
sql_tree_t *tree;
caddr_t box;
dk_set_t list;
long subtok;
sqlp_join_t join;
}
%token <box> NAME
%token <box> STRING
%token <box> WSTRING
%token <box> UNAME_LITERAL
%token <box> INTNUM
%token <box> IRI_LIT
%token <box> APPROXNUM
%token <box> NUM_ERROR
%token <subtok> AMMSC
%token <box> PARAMETER_L
%token <box> NAMED_PARAMETER
%token <box> BEGIN_EQCALL_X
%token <box> HTMLSTR
%token <subtok> SQL_TSI
%token <subtok> TIMESTAMP_FUNC
%token <box> BINARYNUM
%token <box> MSSQL_XMLCOL_NAME
%token <box> MSSQL_XMLCOL_NAME1
%token <box> MSSQL_XMLCOL_NAMEYZ
%token <box> MSSQL_XMLCOL_NAMEZ
%token <box> MSSQL_XMLCOL_INTNUM
%type <box> identifier
%type <strval> table
%type <strval> column
%type <strval> index
/* %type <strval> table_name */
%type <strval> q_table_name
%type <strval> attach_q_table_name
/* pmn %type <box> proc_call_name */
%type <strval> new_proc_or_bif_name
%type <strval> new_table_name
%type <tree> selectinto_statement
%type <tree> query_opt_from_spec
%type <tree> query_spec
/*%type <tree> query_no_from_spec*/
%type <tree> query_exp
%type <tree> sqlonly_query_exp
%type <tree> query_or_sparql_exp
%type <tree> non_final_union_exp
%type <tree> non_final_query_term
%type <tree> non_final_query_spec
%type <tree> non_final_table_exp
%type <tree> opt_corresponding
%type <tree> sqlonly_query_term
%type <tree> sparqlonly_query_term
%type <tree> query_term
%type <tree> table_exp_opt
%type <tree> table_exp
%type <box> assignment
%type <list> assignment_commalist
%type <list> insert_atom_commalist
%type <tree> insert_atom
%type <tree> update_statement_positioned
%type <tree> admin_statement
%type <tree> opt_log
%type <tree> comma_opt_log
%type <tree> insert_statement
%type <subtok> insert_mode
%type <list> column_commalist
%type <list> index_column_commalist
%type <tree> opt_column_commalist
%type <tree> priv_opt_column_commalist
%type <tree> values_or_query_spec
%type <tree> delete_statement_searched
%type <tree> delete_statement_positioned
%type <tree> update_statement_searched
%type <tree> scalar_exp
%type <tree> scalar_exp_no_col_ref
%type <tree> scalar_exp_no_col_ref_no_mem_obs_chain
%type <tree> array_ref
%type <tree> lvalue_array_ref
%type <tree> function_call
%type <box> function_name
%type <tree> obe_literal
%type <list> scalar_exp_commalist
%type <list> select_scalar_exp_commalist
%type <tree> string_concatenation_operator
%type <list> opt_scalar_exp_commalist
%type <tree> selection
%type <list> breakup_list
%type <list> breakup_term
%type <box> atom
%type <box> atom_no_obe
%type <box> parameter_ref
%type <box> parameter
%type <box> cursor
%type <box> literal
%type <box> signed_literal
%type <box> tail_of_tag_of
%type <tree> column_ref
%type <tree> aggregate_ref
%type <tree> sql
%type <tree> manipulative_statement
%type <intval> opt_all_distinct /* operators */
/*%type <intval> opt_percent*/
%type <intval> opt_ties
%type <tree> opt_top
%type <tree> trans_decl
%type <tree> from_clause
%type <tree> opt_where_clause
%type <tree> where_clause
%type <tree> opt_group_by_clause
%type <tree> opt_having_clause
%type <list> table_ref_commalist
%type <box> table_ref
%type <box> table_ref_nj
%type <box> opt_table
%type <tree> joined_table
%type <tree> joined_table_1
%type <tree> join_condition
%type <subtok> jtype
%type <join> join
%type <tree> search_condition
%type <tree> predicate
%type <tree> comparison_predicate
%type <tree> scalar_exp_predicate
%type <tree> between_predicate
%type <tree> test_for_null
%type <tree> like_predicate
%type <tree> in_predicate
%type <tree> all_or_any_predicate
%type <tree> existence_test
/* pmn %type <list> atom_commalist */
%type <intval> any_all_some
%type <list> target_commalist
%type <tree> target
/* pmn %type <box> range_variable */
/* pmn %type <list> column_ref_commalist */
%type <tree> scalar_subquery
%type <tree> subquery
%type <box> opt_escape
%type <intval> opt_with_data
%type <intval> base_table_opt
%type <intval> opt_not_exists
%type <intval> opt_if_exists
%type <tree> base_table_def
%type <tree> view_def
%type <tree> view_def_select_and_opt
%type <tree> view_query_spec
%type <tree> create_index_def
%type <list> base_table_element_commalist
%type <list> base_table_element
%type <box> index_option
%type <list> index_option_list
%type <tree> opt_index_option_list
%type <list> column_def
%type <tree> column_def_opt
%type <tree> column_xml_schema_def
%type <list> column_def_opt_list
%type <list> identity_opt_list
%type <tree> identity_opt
%type <tree> compression_spec
%type <tree> data_type
%type <tree> data_type_ref
%type <tree> base_data_type
%type <tree> column_data_type
%type <tree> table_constraint_def
%type <tree> opt_table_constraint_def
%type <tree> references
%type <tree> drop_index
%type <tree> drop_table
%type <list> add_col_column_def_list
%type <list> add_col_column_list
%type <list> add_column
%type <intval> opt_col_add_column
%type <tree> table_rename
%type <tree> schema_element
%type <list> schema_element_list
%type <tree> create_xml_schema
%type <tree> drop_xml_schema
%type <tree> open_statement
%type <tree> close_statement
%type <tree> fetch_statement
%type <tree> cursor_def
%type <intval> cursor_type
/* procedures */
%type <tree> user_aggregate_declaration
%type <box> user_aggregate_merge_opt
%type <box> user_aggregate_order_opt
%type <tree> routine_declaration
%type <tree> module_body_part
%type <tree> module_declaration
%type <list> module_body
%type <tree> opt_return
%type <tree> rout_parameter
%type <box> rout_parameter_list
%type <list> parameter_commalist
%type <box> rout_alt_type
%type <list> soap_proc_opt_list
%type <list> soap_proc_opt
%type <intval> soap_kwd
%type <subtok> parameter_mode
%type <subtok> opt_parameter_mode
%type <subtok> opt_soap_enc_mode
%type <tree> commit_statement
%type <tree> rollback_statement
%type <tree> routine_statement
%type <tree> statement
%type <tree> statement_in_cs
%type <tree> statement_in_cs_oper
%type <tree> local_declaration
%type <list> statement_list
%type <tree> assignment_statement
%type <list> array_index_list
%type <tree> lvalue
%type <tree> if_statement
%type <tree> while_statement
%type <tree> for_statement
%type <list> for_init_statement_list
%type <tree> for_init_statement
%type <list> for_inc_statement_list
%type <tree> for_opt_search_cond
%type <tree> for_inc_statement
%type <tree> goto_statement
%type <tree> return_statement
%type <tree> call_statement
%type <tree> set_statement
%type <box> txn_isolation_level
%type <subtok> routine_head
%type <tree> compound_statement
%type <tree> control_statement
%type <list> variable_list
%type <tree> variable_declaration
%type <tree> handler_declaration
%type <tree> handler_statement
%type <intval> handler_type
%type <list> cond_value_list
/* pmn %type <tree> elseif_clause */
/* pmn %type <list> elseif_list */
%type <tree> opt_else
%type <tree> cursor_option
%type <list> cursor_options_commalist
%type <box> opt_cursor_options_list
%type <box> with_opt_cursor_options_list
%type <tree> create_user_statement
%type <tree> delete_user_statement
%type <tree> set_group_stmt
%type <tree> add_group_stmt
%type <tree> delete_group_stmt
%type <tree> attach_table
%type <box> opt_as
%type <tree> opt_attach_primary_key
%type <tree> opt_login
%type <box> opt_not_select
%type <tree> opt_remote_name
%type <tree> set_pass
%type <box> user
%type <box> grantee
%type <list> grantee_commalist
%type <tree> privilege_def
%type <tree> privilege_revoke
%type <box> privileges
%type <tree> operation
%type <list> operation_commalist
%type <subtok> opt_with_admin_option
%type <subtok> opt_with_grant_option
%type <subtok> opt_asc_desc
%type <tree> ordering_spec
%type <list> ordering_spec_commalist
%type <box> opt_order_by_clause
%type <box> grouping_set
%type <list> grouping_set_list
%type <tree> trigger_def
%type <tree> trig_action
%type <box> opt_order
%type <subtok> action_time
%type <box> event
%type <box> opt_old_ref
%type <list> old_commalist
%type <tree> old_alias
%type <tree> drop_trigger
%type <tree> drop_proc
%type <box> condition
/* pmn %type <box> opt_prefix */
%type <tree> as_expression
%type <tree> cast_exp
%type <tree> cvt_exp
%type <tree> use_statement
%type <subtok> opt_lock_mode
%type <tree> simple_case
%type <tree> searched_case
%type <list> searched_when_list
%type <list> simple_when_list
%type <list> simple_when
%type <list> searched_when
%type <tree> coalesce_exp
%type <tree> nullif_exp
%type <subtok> opt_with_check_option
%type <box> xmlview_param_value
%type <tree> xmlview_param
%type <list> xmlview_params
%type <list> opt_xmlview_params
%type <box> opt_element
%type <list> xml_col_list
%type <list> xml_join_list
%type <tree> xml_col
%type <tree> xml_join_elt
%type <tree> xml_view
%type <tree> drop_xml_view
/*%type <tree> xml_doc */
%type <tree> opt_join
%type <tree> opt_pk
%type <tree> opt_xml_col_list
%type <tree> create_snapshot_log
%type <tree> drop_snapshot_log
%type <tree> purge_snapshot_log
%type <box> opt_snapshot_string_literal
%type <box> opt_snapshot_where_clause
%type <tree> create_snapshot
%type <box> opt_with_delete
%type <tree> drop_snapshot
%type <subtok> opt_nonincremental
%type <tree> refresh_snapshot
%type <tree> create_freetext_index
%type <tree> create_freetext_trigger
%type <tree> drop_freetext_trigger
%type <box> opt_xml
%type <box> opt_deffer_generation
%type <box> opt_with_key
%type <tree> opt_with
%type <box> opt_data_modification_action
%type <box> opt_lang
%type <box> opt_enc
%type <strval> opt_collate_exp
%type <tree> opt_xml_child
%type <tree> top_xml_child
%type <box> opt_interval
%type <box> opt_persist
/* IvAn/XmlView/000810 opt_metas added */
%type <tree> opt_metas
%type <tree> opt_publish
%type <subtok> opt_elt
%type <tree> alter_constraint
%type <box> opt_with_permission_set
%type <box> opt_with_autoregister
%type <tree> create_library
%type <tree> create_assembly
%type <tree> drop_library
%type <tree> drop_assembly
%type <subtok> constraint_op
/*%type <subtok> xml_col_dir*/
%type <tree> mssql_xml_col
%type <list> proc_col_list
%type <tree> opt_proc_col_list
%type <tree> column_commalist_or_empty
%type <subtok> opt_best
%type <box> opt_constraint_name
%type <box> opt_column
%type <intval> opt_drop_behavior
%type <tree> opt_referential_triggered_action
%type <tree> referential_rule
%type <intval> referential_action
%type <intval> referential_state
%type <list> kwd_commalist
%type <list> as_commalist /*sqlxml*/
%type <list> opt_arg_commalist
%type <list> sql_option
%type <list> sql_opt_commalist
%type <tree> opt_sql_opt
%type <tree> opt_table_opt
/* user defined types */
%type <tree> user_defined_type
%type <tree> user_defined_type_drop
%type <tree> delete_referential_rule
%type <tree> opt_on_delete_referential_rule
%type <strval> q_type_name
%type <strval> q_old_type_name
%type <strval> new_type_name
%type <strval> opt_subtype_clause
%type <tree> opt_as_type_representation
%type <tree> opt_external_clause
%type <tree> opt_external_type
%type <tree> opt_soap_clause
%type <tree> type_representation
%type <list> type_member_list
%type <tree> opt_external_and_language_clause
%type <tree> type_member
%type <tree> opt_reference_scope_check
%type <box> opt_default_clause
%type <tree> opt_type_option_list
%type <list> type_option_list
%type <tree> type_option
%type <list> method_specification_list
%type <tree> opt_method_specification_list
%type <tree> method_specification
%type <tree> partial_method_specification
%type <intval> method_type
%type <strval> opt_specific_method_name
%type <intval> opt_self_result
%type <tree> opt_method_characteristics
%type <list> method_characteristics
%type <tree> method_characteristic
%type <intval> external_language_name
%type <intval> language_name
%type <tree> method_declaration
%type <tree> static_method_invocation
%type <tree> opt_constructor_return
%type <tree> decl_parameter
%type <box> decl_parameter_list
%type <list> decl_parameter_commalist
%type <tree> method_invocation
%type <tree> top_level_method_invocation
%type <box> method_identifier
%type <tree> member_observer
%type <tree> member_observer_no_id_chain
%type <list> identifier_chain
%type <list> identifier_chain_method
%type <tree> new_invocation
%type <tree> user_defined_type_alter
%type <tree> alter_type_action
%type <box> array_modifier
%type <tree> cost_decl
%type <tree> vectored_decl
%type <list> cost_number_list
%type <box> cost_number
%type <tree> cluster_def
%type <box> opt_cluster
%type <tree> partition_def
%type <list> col_part_list
%type <list> col_part_commalist
%type <list> host_group_list
%type <list> host_list
%type <box> host
%type <box> range
%type <list> range_list
%type <box> opt_modulo
%type <tree> col_partition
%type <tree> host_group
%type <box> opt_index
%type <list> colnum_commalist_2
%type <box> colnum_commalist
%type <list> vectored_list
%type <tree> vectored_var
%type <intval> opt_modify
%token <box> TYPE FINAL_L METHOD CHECKED SYSTEM GENERATED SOURCE RESULT LOCATOR INSTANCE_L CONSTRUCTOR SELF_L OVERRIDING STYLE SQL_L GENERAL DETERMINISTIC NO_L CONTAINS READS DATA DISABLE_L NOVALIDATE_L ENABLE_L VALIDATE_L
%token <box> MODIFIES INPUT CALLED ADA C_L3 COBOL FORTRAN MUMPS PASCAL_L PLI NAME_L TEXT_L JAVA INOUT_L REMOTE KEYSET VALUE PARAMETER VARIABLE ADMIN_L ROLE_L TEMPORARY CLR ATTRIBUTE
%token <box> __SOAP_DOC __SOAP_DOCW __SOAP_HEADER __SOAP_HTTP __SOAP_NAME __SOAP_TYPE __SOAP_XML_TYPE __SOAP_FAULT __SOAP_DIME_ENC __SOAP_ENC_MIME __SOAP_OPTIONS FOREACH POSITION_L
%token ARE REF STATIC_L SPECIFIC DYNAMIC COLUMN START_L
%token __LOCK __TAG_L RDF_BOX_L VECTOR_L VECTORED FOR_VECTORED FOR_ROWS NOT_VECTORED VECTORING HANDLE_L STREAM_L
%nonassoc ORDER FOR
%left UNION EXCEPT
%left INTERSECT
%nonassoc AS
%nonassoc DOUBLE_COLON
%nonassoc COLON
%left OR
%left AND
%left NOT
%left <subtok> COMPARISON /* = <> < > <= >= */
%left EQUALS
%left STRING_CONCAT_OPERATOR
%left '+' '-'
%left '*' '/'
%nonassoc UMINUS
/* literal keyword tokens */
%token ALL ANY ATTACH ASC AUTHORIZATION BETWEEN BIGINT BREAKUP BY
%token CASCADE CHARACTER CHECK CLOSE COMMIT CONSTRAINT CONTINUE CREATE CUBE CURRENT
%token CURSOR DECIMAL_L DECLARE DEFAULT DELETE_L DESC DISTINCT DOUBLE_L
%token DROP ESCAPE EXISTS FETCH FLOAT_L FOREIGN FOUND FROM GOTO GO
%token GRANT GROUP GROUPING_L HAVING IN_L INDEX INDEX_NO_FILL INDEX_ONLY INDICATOR INSERT INTEGER INTO
%token IS KEY LANGUAGE ENCODING LIKE NULLX NUMERIC OF ON OPEN OPTION
%token PRECISION PRIMARY PRIVILEGES PROCEDURE
%token PUBLIC REAL REFERENCES RESTRICT ROLLBACK ROLLUP SCHEMA SELECT SET
%token SMALLINT SOME SQLCODE SQLERROR TABLE TO UNION
%token UNIQUE UPDATE USER VALUES VIEW WHENEVER WHERE WITH WORK WITHOUT_L
%token ARRAY SETS
/* Extensions */
%token CONTIGUOUS OBJECT_ID BITMAPPED UNDER CLUSTER __ELASTIC CLUSTERED VARCHAR VARBINARY BINARY LONG_L REPLACING SOFT HASH LOOP IRI_ID IRI_ID_8 SAME_AS TRANSITIVE QUIETCAST_L SPARQL_L UNAME_L
%token DICTIONARY_L REFERENCE_L
/* Admin statements */
%token SHUTDOWN CHECKPOINT BACKUP REPLICATION
%token SYNC ALTER ADD RENAME DISCONNECT MODIFY
%token BEFORE AFTER INSTEAD TRIGGER REFERENCING OLD
/* procedures */
%token AGGREGATE FUNCTION OUT_L HANDLER IF THEN ELSE ELSEIF WHILE
%token BEGINX ENDX RETURN CALL RETURNS DO EXCLUSIVE PREFETCH
%token SQLSTATE_L SQLWARNING SQLEXCEPTION EXIT RESIGNAL
%token REVOKE PASSWORD OFF LOGX TIMESTAMP DATE_L DATETIME TIME EXECUTE REXECUTE
%token MODULE
/* ODBC brace-escaped keywords. BEGINX_FN_X = "{fn"
User should not write procedures with calls to functions named
like fn (or maybe also fnac?) from the beginning of a block
statement without leaving a space or two after opening brace.
E.g. if(call_fn is not NULL) {fn(arg1,arg2);} will result
a syntax error. Other possibility would be make fn itself
a token and reserved keyword, but I think that is even more
stupid.
*/
%token BEGIN_FN_X BEGIN_CALL_X BEGIN_OJ_X BEGIN_U_X CONVERT CASE WHEN IDENTITY LEFT RIGHT FULL OUTER
/*%token BEGIN_FN_X BEGIN_CALL_X BEGIN_OJ_X BEGIN_U_X CONVERT CASE WHEN THEN IDENTITY FULL OUTER*/
%token INNER CROSS NATURAL USING JOIN USE COALESCE CAST NULLIF NEW
%token CORRESPONDING EXCEPT INTERSECT BEST TOP PERCENT TIES XML XPATH
%token PERSISTENT INTERVAL INCREMENT_L COMPRESS PARTITION
/* IvAn/XmlView/000810 Options added for "create xml view" statement */
%token DTD INTERNAL EXTERNAL
/* %token SCHEMA is already reserved */
/*%token STRING_CONCAT_OPERATOR*/
/* internationalization keywords */
%token COLLATE NCHAR NVARCHAR
/* replication keywords */
%token INCREMENTAL NONINCREMENTAL PURGE SNAPSHOT
%token IDENTIFIED EXTRACT
%token KWD_TAG
/* IvAn/Fix4AritmSql/000828 Invalid lexems should be handled explicitly */
%token LEXICAL_ERROR
/* ANSI SQL 92 DATE_L/TIME/TIMESTAMP functions */
%token CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP
/* CLR CREATE LIBRARY/ASSEMBLY ext keywords */
%token PERMISSION_SET AUTOREGISTER_L LIBRARY_L ASSEMBLY_L SAFE_L UNRESTRICTED_L
/* set transaction isolation level */
%token <box> TRANSACTION_L ISOLATION_L LEVEL_L READ_L COMMITTED_L UNCOMMITTED_L REPEATABLE_L SERIALIZABLE_L
/* transitive subquery options */
%token T_FINAL_AS T_MIN T_MAX T_IN T_OUT T_SHORTEST_ONLY T_DISTINCT T_EXISTS T_NO_ORDER T_NO_CYCLES T_CYCLES_ONLY T_END_FLAG T_DIRECTION
/* Skip and ws lexems for scn3split.c */
%token WS_WHITESPACE /* This should be the first whitespace token */
%token WS_SPARQL_SKIP
%token WS_PRAGMA_LINE
%token WS_PRAGMA_PREFIX_1 WS_PRAGMA_PREFIX_2 WS_PRAGMA_PREFIX_3
%token WS_PRAGMA_C_ESC WS_PGRAGMA_UTF8_ESC WS_PRAGMA_PL_DEBUG WS_PRAGMA_SRC
%token WS_COMMENT_EOL WS_COMMENT_BEGIN WS_COMMENT_END WS_COMMENT_LONG __COST
/* Important! Do NOT add meaningful SQL tokens at the end of this list!
Instead, add them _before_ WS_WHITESPACE. Tokens after WS_WHITESPACE are
treated as garbage by sql_split_text(). */
%%
/* IvAn/Fix4AritmSql/000828 Trailing semicolon should be trailing explicitly */
sql_list
: sql_list1 ';' { }
| sql_list1 { }
;
sql_list1
: sql { parse_tree = $1; }
/* | sql_list1 ';' sql { }*/
;
/* schema definition language */
sql
: schema_element_list { $$ = t_listst (2, SCHEMA_ELEMENT_LIST,
t_list_to_array ($1)); }
| view_def { $$ = t_listst (2, SCHEMA_ELEMENT_LIST, t_list (1, $1)); }
| xml_view { $$ = t_listst (2, SCHEMA_ELEMENT_LIST, t_list (1, $1)); }
| create_xml_schema { $$ = $1; }
| drop_xml_schema { $$ = $1; }
| alter_constraint { $$ = $1; }
| create_library { $$ = $1; }
| create_assembly { $$ = $1; }
| drop_library { $$ = $1; }
| drop_assembly { $$ = $1; }
;
/*
schema
: CREATE SCHEMA AUTHORIZATION user opt_schema_element_list
;
opt_schema_element_list
: { $$ = NULL; }
| schema_element_list
;
*/
schema_element_list
: schema_element { $$ = t_CONS ($1, NULL); }
| add_column { $$ = $1; }
| schema_element_list schema_element { $$ = t_NCONC ($1, t_CONS ($2, NULL)); }
| schema_element_list add_column { $$ = t_NCONC ($1, $2); }
;
schema_element
: base_table_def
/* | view_def */
| create_index_def
| partition_def
| drop_table
| drop_index
| table_rename
| privilege_def
| privilege_revoke
| create_user_statement
| delete_user_statement
| set_pass
| set_group_stmt
| add_group_stmt
| delete_group_stmt
| user_defined_type
| user_defined_type_drop
| user_defined_type_alter
| cluster_def
;
identifier
: NAME { $$ = $1; }
| TYPE { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| FINAL_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| METHOD { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| CHECKED { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| SYSTEM { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| GENERATED { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| SOURCE { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| RESULT { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| LOCATOR { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| INSTANCE_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| CONSTRUCTOR { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| SELF_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| OVERRIDING { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| STYLE { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| SQL_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| GENERAL { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| DETERMINISTIC { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| DICTIONARY_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| NO_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| DISABLE_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| NOVALIDATE_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| VALIDATE_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| ENABLE_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| CONTAINS { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| READS { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| DATA { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| MODIFIES { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| INPUT { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| CALLED { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| ADA { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| C_L3 { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| COBOL { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| FORTRAN { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| MUMPS { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| PASCAL_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| PLI { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| NAME_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| TEXT_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| JAVA { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| INOUT_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| REMOTE { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| REFERENCE_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| KEYSET { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| VALUE { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| PARAMETER { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| VARIABLE { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| CLR { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| TEMPORARY { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| ADMIN_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| __SOAP_DOC { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| __SOAP_DOCW { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| __SOAP_HEADER { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| __SOAP_HTTP { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| __SOAP_NAME { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| __SOAP_TYPE { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| __SOAP_XML_TYPE { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| __SOAP_FAULT { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| __SOAP_DIME_ENC { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| __SOAP_ENC_MIME { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| __SOAP_OPTIONS { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| START_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| ATTRIBUTE { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| REXECUTE { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| PERMISSION_SET { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| AUTOREGISTER_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| LIBRARY_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| ASSEMBLY_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| SAFE_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| UNRESTRICTED_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| INCREMENT_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| FOREACH { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| POSITION_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| TRANSACTION_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| ISOLATION_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| LEVEL_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| READ_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| COMMITTED_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| UNCOMMITTED_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| REPEATABLE_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| SERIALIZABLE_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| __TAG_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| RDF_BOX_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| VECTOR_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| UNAME_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| HANDLE_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
| STREAM_L { $$ = t_sqlp_box_id_upcase_nchars (global_scs->scs_scn3c.last_keyword_yytext, global_scs->scs_scn3c.last_keyword_yyleng); }
;
opt_with_data
: /* empty */ { $$ = 0; }
| WITH DATA { $$ = 1; }
| WITHOUT_L DATA { $$ = 0; }
;
base_table_opt
: { $$ = T_ROW; }
| COLUMN { $$ = T_COLUMN; }
| DISTINCT COLUMN { $$ = T_DISTINCT_COLUMNS; }
;
opt_not_exists
: { $$ = 0; }
| IF NOT EXISTS { $$ = 1; }
;
opt_if_exists
: { $$ = 0; }
| IF EXISTS { $$ = 1; }
;
base_table_def
: CREATE TABLE new_table_name '(' base_table_element_commalist ')' base_table_opt opt_not_exists
{ $$ = t_listst (5, TABLE_DEF, $3,
t_list_to_array (sqlc_ensure_primary_key (sqlp_process_col_options ($3, $5))), (ptrlong) $7, (ptrlong) $8); }
| CREATE TABLE new_table_name AS query_exp opt_with_data
{ $$ = t_listst (4, CREATE_TABLE_AS, $3, sqlp_view_def (NULL, $5, 1), t_box_num ((ptrlong) $6)); }
;
base_table_element_commalist
: base_table_element
| base_table_element_commalist ',' base_table_element
{ $$ = t_NCONC ($1, $3); }
;
base_table_element
: column_def
| table_constraint_def { $$ = t_CONS (NULL, t_CONS ($1, NULL)); }
;
column_def
: column column_data_type column_def_opt_list
{ $$ = t_CONS ($1, t_CONS (t_list (2, $2, t_list_to_array ($3)), NULL)); }
;
opt_referential_triggered_action
: /* empty */ { $$ = t_listst (2, 0, 0); }
| referential_rule {
caddr_t *l = (caddr_t *)$1;
$$ = (l[0] ? t_listst (2, 0, l[1]) : t_listst (2, l[1], 0));
}
| referential_rule referential_rule
{
caddr_t *l = (caddr_t *)$1;
caddr_t *ll = (caddr_t *)$2;
if (l[0] == ll [0])
yyerror (scanner,"duplicated referential actions");
$$ = (l[0] ? t_listst (2, ll[1], l[1]) : t_listst (2, l[1], ll[1]));
}
;
referential_rule
: ON UPDATE referential_action { $$ = t_listst (2, 0, (ptrlong) $3); }
| delete_referential_rule { $$ = $1; }
;
delete_referential_rule
: ON DELETE_L referential_action { $$ = t_listst (2, (ptrlong) 1, (ptrlong) $3); }
;
opt_on_delete_referential_rule
: /* empty */ { $$ = NULL; }
| delete_referential_rule { $$ = $1; }
;
referential_action
: CASCADE { $$ = 1; }
| SET NULLX { $$ = 2; }
| SET DEFAULT { $$ = 3; }
;
referential_state
: { $$ = 0; }
| ENABLE_L VALIDATE_L { $$ = 0; }
| ENABLE_L NOVALIDATE_L { $$ = 1; }
| DISABLE_L VALIDATE_L { $$ = 2; }
| DISABLE_L NOVALIDATE_L { $$ = 3; }
;
references
: REFERENCES q_table_name opt_column_commalist opt_referential_triggered_action referential_state
{
caddr_t *l = (caddr_t *) $4;
$$ = t_listst (9, FOREIGN_KEY, NULL, $2, $3, NULL, l[0], l[1], NULL, (ptrlong) $5);
}
;
column_def_opt_list
: /* empty */ { $$ = NULL; }
| column_def_opt_list column_def_opt { $$ = $2 ? t_NCONC ($1, t_CONS ($2, NULL)) : $1; }
;
identity_opt
: START_L WITH signed_literal { $$ = t_listst (2, CO_ID_START, $3); }
| INCREMENT_L BY INTNUM { $$ = t_listst (2, CO_ID_INCREMENT_BY, $3); }
/* one day ... ;-)
| MAXVALUE signed_literal
| NO_L MAXVALUE
| MINVALUE signed_literal
| NO_L MINVALUE
| CYCLE
| NO_L CYCLE
*/
;
compression_spec
: NO_L COMPRESS { $$ = t_listst (2, CO_COMPRESS, (ptrlong)CC_NONE); }
| COMPRESS ANY { $$ = t_listst (2, CO_COMPRESS, (ptrlong)CC_OFFSET); }
| COMPRESS TEXT_L { $$ = t_listst (2, CO_COMPRESS, (ptrlong)CC_PREFIX); }
;
identity_opt_list
: identity_opt { $$ = t_CONS ($1, NULL); }
| identity_opt_list ',' identity_opt { $$ = t_NCONC ($1, t_CONS ($3, NULL)); }
;
column_def_opt
: NOT NULLX { $$ = (ST *) COL_NOT_NULL; }
| NULLX { $$ = (ST *) NULL; }
| IDENTITY { $$ = (ST *) CO_IDENTITY; }
| IDENTITY '(' identity_opt_list ')' { $$ = t_listst (2, CO_IDENTITY, t_list_to_array ($3)); }
| PRIMARY KEY '('opt_index_option_list ')' { $$ = t_listst (5, INDEX_DEF, NULL, NULL, NULL, $4); }
| PRIMARY KEY { dk_set_t opts = sqlp_index_default_opts (NULL); caddr_t * oa = opts ? (caddr_t*)t_list_to_array (opts) : NULL; $$ = t_listst (5, INDEX_DEF, NULL, NULL, NULL, oa); }
| compression_spec { $$ = $1; }
| DEFAULT signed_literal { $$ = t_listst (2, COL_DEFAULT, $2); }
| COLLATE q_table_name { $$ = t_listst (2, COL_COLLATE, $2); }
| references { $$ = $1; }
| IDENTIFIED BY column { $$ = t_listst (2, COL_XML_ID, $3); }
/* | DEFAULT USER */
| CHECK '(' search_condition ')' { $$ = t_listst (3, CHECK_CONSTR, $3, NULL); }
| WITH SCHEMA column_xml_schema_def
{
ST * check;
BIN_OP (check, BOP_NULL,
t_listst (3, CALL_STMT,
t_sqlp_box_id_upcase ("DB.DBA.XML_COLUMN_SCHEMA_VALIDATE"), $3 ),
NULL );
$$ = t_listst (3, CHECK_XMLSCHEMA_CONSTR, check, NULL);
}
| UNIQUE { dk_set_t opts = t_CONS (t_box_string ("unique"), sqlp_index_default_opts (NULL));
$$ = t_listst (5, UNIQUE_DEF, NULL, NULL, NULL,
t_list_to_array (opts) ); }
| UNIQUE '(' index_option_list ')' { dk_set_t opts = t_CONS (t_box_string ("unique"), $3);
$$ = t_listst (5, UNIQUE_DEF, NULL, NULL, NULL,
(ST *) t_list_to_array (opts)); }
;
column_xml_schema_def
: '(' STRING ',' STRING ')' { $$ = t_listst (6, NULL, NULL, NULL, $2, $4, (caddr_t) t_NULLCONST); }
| '(' STRING ',' STRING ',' STRING ')' { $$ = t_listst (6, NULL, NULL, NULL, $2, $4, $6); }
;
table_constraint_def
: UNDER q_table_name
{ $$ = t_listst (2, TABLE_UNDER, t_list (1, $2)); }