/
parse.y
6352 lines (5475 loc) · 153 KB
/
parse.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
%{
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: parse.y
* DESCRIPTION: Dynamic SQL parser
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*
* 2002-02-24 Sean Leyne - Code Cleanup of old Win 3.1 port (WINDOWS_ONLY)
* 2001.05.20 Neil McCalden: Allow a udf to be used in a 'group by' clause.
* 2001.05.30 Claudio Valderrama: DROP TABLE and DROP VIEW lead now to two
* different node types so DDL can tell which is which.
* 2001.06.13 Claudio Valderrama: SUBSTRING is being surfaced.
* 2001.06.30 Claudio valderrama: Feed (line,column) for each node. See node.h.
* 2001.07.10 Claudio Valderrama: Better (line,column) report and "--" for comments.
* 2001.07.28 John Bellardo: Changes to support parsing LIMIT and FIRST
* 2001.08.03 John Bellardo: Finalized syntax for LIMIT, change LIMIT to SKIP
* 2001.08.05 Claudio Valderrama: closed Bug #448062 and other spaces that appear
* in rdb$*_source fields when altering domains plus one unexpected null pointer.
* 2001.08.12 Claudio Valderrama: adjust SUBSTRING's starting pos argument here
* and not in gen.c; this closes Bug #450301.
* 2001.10.01 Claudio Valderrama: enable explicit GRANT...to ROLE role_name.
* 2001.10.06 Claudio Valderrama: Honor explicit USER keyword in GRANTs and REVOKEs.
* 2002.07.05 Mark O'Donohue: change keyword DEBUG to KW_DEBUG to avoid
* clashes with normal DEBUG macro.
* 2002.07.30 Arno Brinkman:
* 2002.07.30 Let IN predicate handle value_expressions
* 2002.07.30 tokens CASE, NULLIF, COALESCE added
* 2002.07.30 See block < CASE expression > what is added to value as case_expression
* 2002.07.30 function is split up into aggregate_function, numeric_value_function, string_value_function, generate_value_function
* 2002.07.30 new group_by_function and added to grp_column_elem
* 2002.07.30 cast removed from function and added as cast_specification to value
* 2002.08.04 Claudio Valderrama: allow declaring and defining variables at the same time
* 2002.08.04 Dmitry Yemanov: ALTER VIEW
* 2002.08.06 Arno Brinkman: ordinal added to grp_column_elem for using positions in group by
* 2002.08.07 Dmitry Yemanov: INT64/LARGEINT are replaced with BIGINT and available in dialect 3 only
* 2002.08.31 Dmitry Yemanov: allowed user-defined index names for PK/FK/UK constraints
* 2002.09.01 Dmitry Yemanov: RECREATE VIEW
* 2002.09.28 Dmitry Yemanov: Reworked internal_info stuff, enhanced
* exception handling in SPs/triggers,
* implemented ROWS_AFFECTED system variable
* 2002.10.21 Nickolay Samofatov: Added support for explicit pessimistic locks
* 2002.10.29 Nickolay Samofatov: Added support for savepoints
* 2002.12.03 Dmitry Yemanov: Implemented ORDER BY clause in subqueries.
* 2002.12.18 Dmitry Yemanov: Added support for SQL-compliant labels and LEAVE statement
* 2002.12.28 Dmitry Yemanov: Added support for parametrized events.
* 2003.01.14 Dmitry Yemanov: Fixed bug with cursors in triggers.
* 2003.01.15 Dmitry Yemanov: Added support for runtime trigger action checks.
* 2003.02.10 Mike Nordell : Undefined Microsoft introduced macros to get a clean compile.
* 2003.05.24 Nickolay Samofatov: Make SKIP and FIRST non-reserved keywords
* 2003.06.13 Nickolay Samofatov: Make INSERTING/UPDATING/DELETING non-reserved keywords
* 2003.07.01 Blas Rodriguez Somoza: Change DEBUG and IN to avoid conflicts in win32 build/bison
* 2003.08.11 Arno Brinkman: Changed GROUP BY to support all expressions and added "AS" support
* with table alias. Also removed group_by_function and ordinal.
* 2003.08.14 Arno Brinkman: Added support for derived tables.
* 2003.10.05 Dmitry Yemanov: Added support for explicit cursors in PSQL.
* 2004.01.16 Vlad Horsun: added support for default parameters and
* EXECUTE BLOCK statement
* Adriano dos Santos Fernandes
*/
#include "firebird.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../jrd/common.h"
#include <stdarg.h>
#include "gen/iberror.h"
#include "../dsql/dsql.h"
#include "../dsql/node.h"
#include "../jrd/ibase.h"
#include "../jrd/flags.h"
#include "../jrd/jrd.h"
#include "../dsql/errd_proto.h"
#include "../dsql/hsh_proto.h"
#include "../dsql/make_proto.h"
#include "../dsql/keywords.h"
#include "../dsql/misc_func.h"
#include "../jrd/gds_proto.h"
#include "../jrd/err_proto.h"
#include "../jrd/intlobj_new.h"
#include "../common/StatusArg.h"
/* since UNIX isn't standard, we have to define
stuff which is in <limits.h> (which isn't available
on all UNIXes... */
const long SHRT_POS_MAX = 32767;
const long SHRT_UNSIGNED_MAX = 65535;
const long SHRT_NEG_MAX = 32768;
const long LONG_POS_MAX = 2147483647;
const int POSITIVE = 0;
const int NEGATIVE = 1;
const int UNSIGNED = 2;
//const int MIN_CACHE_BUFFERS = 250;
//const int DEF_CACHE_BUFFERS = 1000;
/* Fix 69th procedure problem - solution from Oleg Loa */
#define YYSTACKSIZE 2048
#define YYMAXDEPTH 2048
/* Make bison allocate static stack */
#define YYINITDEPTH 2048
// Using this option causes build problems on Win32 with bison 1.28
//#define YYSTACK_USE_ALLOCA 1
#define YYSTYPE YYSTYPE
#if defined(DEBUG) || defined(DEV_BUILD)
#define YYDEBUG 1
#endif
#define YYMALLOC gds__alloc
#define YYFREE gds__free
static const char INTERNAL_FIELD_NAME[] = "DSQL internal"; /* NTX: placeholder */
inline SLONG trigger_type_suffix(const int slot1, const int slot2, const int slot3)
{
return ((slot1 << 1) | (slot2 << 3) | (slot3 << 5));
}
#include "../dsql/chars.h"
const int MAX_TOKEN_LEN = 256;
using namespace Jrd;
using namespace Dsql;
using namespace Firebird;
#ifdef NOT_USED_OR_REPLACED
static bool long_int(dsql_nod*, SLONG*);
#endif
static dsql_fld* make_field (dsql_nod*);
static dsql_fil* make_file();
#ifdef NOT_USED_OR_REPLACED
static bool short_int(dsql_nod*, SLONG*, SSHORT);
#endif
static void stack_nodes (dsql_nod*, DsqlNodStack&);
static Firebird::MetaName toName(dsql_nod* node);
static void yyabandon (SLONG, ISC_STATUS);
inline void check_bound(const char* const to, const char* const string)
{
if ((to - string) >= MAX_TOKEN_LEN)
yyabandon (-104, isc_token_too_long);
}
inline void check_copy_incr(char*& to, const char ch, const char* const string)
{
check_bound(to, string);
*to++ = ch;
}
%}
/* token declarations */
/* Tokens are organized chronologically by date added.
See dsql/keywords.cpp for a list organized alphabetically */
/* Tokens in v4.0 -- not separated into v3 and v4 tokens */
%token ACTIVE
%token ADD
%token AFTER
%token ALL
%token ALTER
%token AND
%token ANY
%token AS
%token ASC
%token AT
%token AVG
%token AUTO
%token BEFORE
%token BEGIN
%token BETWEEN
%token BLOB
%token BY
%token CAST
%token CHARACTER
%token CHECK
%token COLLATE
%token COMMA
%token COMMIT
%token COMMITTED
%token COMPUTED
%token CONCATENATE
%token CONDITIONAL
%token CONSTRAINT
%token CONTAINING
%token COUNT
%token CREATE
%token CSTRING
%token CURRENT
%token CURSOR
%token DATABASE
%token DATE
%token DB_KEY
%token DECIMAL
%token DECLARE
%token DEFAULT
%token KW_DELETE
%token DESC
%token DISTINCT
%token DO
%token DOMAIN
%token DROP
%token ELSE
%token END
%token ENTRY_POINT
%token EQL
%token ESCAPE
%token EXCEPTION
%token EXECUTE
%token EXISTS
%token EXIT
%token EXTERNAL
%token FILTER
%token FOR
%token FOREIGN
%token FROM
%token FULL
%token FUNCTION
%token GDSCODE
%token GEQ
%token GENERATOR
%token GEN_ID
%token GRANT
%token GROUP
%token GTR
%token HAVING
%token IF
%token KW_IN
%token INACTIVE
%token INNER
%token INPUT_TYPE
%token INDEX
%token INSERT
%token INTEGER
%token INTO
%token IS
%token ISOLATION
%token JOIN
%token KEY
%token KW_CHAR
%token KW_DEC
%token KW_DOUBLE
%token KW_FILE
%token KW_FLOAT
%token KW_INT
%token KW_LONG
%token KW_NULL
%token KW_NUMERIC
%token KW_UPPER
%token KW_VALUE
%token LENGTH
%token LPAREN
%token LEFT
%token LEQ
%token LEVEL
%token LIKE
%token LSS
%token MANUAL
%token MAXIMUM
%token MAX_SEGMENT
%token MERGE
%token MINIMUM
%token MODULE_NAME
%token NAMES
%token NATIONAL
%token NATURAL
%token NCHAR
%token NEQ
%token NO
%token NOT
%token NOT_GTR
%token NOT_LSS
%token OF
%token ON
%token ONLY
%token OPTION
%token OR
%token ORDER
%token OUTER
%token OUTPUT_TYPE
%token OVERFLOW
%token PAGE
%token PAGES
%token KW_PAGE_SIZE
%token PARAMETER
%token PASSWORD
%token PLAN
%token POSITION
%token POST_EVENT
%token PRECISION
%token PRIMARY
%token PRIVILEGES
%token PROCEDURE
%token PROTECTED
%token READ
%token REAL
%token REFERENCES
%token RESERVING
%token RETAIN
%token RETURNING_VALUES
%token RETURNS
%token REVOKE
%token RIGHT
%token RPAREN
%token ROLLBACK
%token SEGMENT
%token SELECT
%token SET
%token SHADOW
%token KW_SHARED
%token SINGULAR
%token KW_SIZE
%token SMALLINT
%token SNAPSHOT
%token SOME
%token SORT
%token SQLCODE
%token STABILITY
%token STARTING
%token STATISTICS
%token SUB_TYPE
%token SUSPEND
%token SUM
%token TABLE
%token THEN
%token TO
%token TRANSACTION
%token TRIGGER
%token UNCOMMITTED
%token UNION
%token UNIQUE
%token UPDATE
%token USER
%token VALUES
%token VARCHAR
%token VARIABLE
%token VARYING
%token VERSION
%token VIEW
%token WAIT
%token WHEN
%token WHERE
%token WHILE
%token WITH
%token WORK
%token WRITE
%token FLOAT_NUMBER NUMBER NUMERIC SYMBOL STRING INTRODUCER
/* New tokens added v5.0 */
%token ACTION
%token ADMIN
%token CASCADE
%token FREE_IT /* ISC SQL extension */
%token RESTRICT
%token ROLE
/* New tokens added v6.0 */
%token COLUMN
%token KW_TYPE
%token EXTRACT
%token YEAR
%token MONTH
%token DAY
%token HOUR
%token MINUTE
%token SECOND
%token WEEKDAY /* ISC SQL extension */
%token YEARDAY /* ISC SQL extension */
%token TIME
%token TIMESTAMP
%token CURRENT_DATE
%token CURRENT_TIME
%token CURRENT_TIMESTAMP
/* special aggregate token types returned by lex in v6.0 */
%token NUMBER64BIT SCALEDINT
/* CVC: Special Firebird additions. */
%token CURRENT_USER
%token CURRENT_ROLE
%token KW_BREAK
%token SUBSTRING
%token RECREATE
%token KW_DESCRIPTOR
%token FIRST
%token SKIP
/* tokens added for Firebird 1.5 */
%token CURRENT_CONNECTION
%token CURRENT_TRANSACTION
%token BIGINT
%token CASE
%token NULLIF
%token COALESCE
%token USING
%token NULLS
%token LAST
%token ROW_COUNT
%token LOCK
%token SAVEPOINT
%token RELEASE
%token STATEMENT
%token LEAVE
%token INSERTING
%token UPDATING
%token DELETING
/* tokens added for Firebird 2.0 */
%token BACKUP
%token KW_DIFFERENCE
%token OPEN
%token CLOSE
%token FETCH
%token ROWS
%token BLOCK
%token IIF
%token SCALAR_ARRAY
%token CROSS
%token NEXT
%token SEQUENCE
%token RESTART
%token BOTH
%token COLLATION
%token COMMENT
%token BIT_LENGTH
%token CHAR_LENGTH
%token CHARACTER_LENGTH
%token LEADING
%token KW_LOWER
%token OCTET_LENGTH
%token TRAILING
%token TRIM
%token RETURNING
%token KW_IGNORE
%token LIMBO
%token UNDO
%token REQUESTS
%token TIMEOUT
/* tokens added for Firebird 2.1 */
%token ABS
%token ACCENT
%token ACOS
%token ALWAYS
%token ASCII_CHAR
%token ASCII_VAL
%token ASIN
%token ATAN
%token ATAN2
%token BIN_AND
%token BIN_OR
%token BIN_SHL
%token BIN_SHR
%token BIN_XOR
%token CEIL
%token CONNECT
%token COS
%token COSH
%token COT
%token DATEADD
%token DATEDIFF
%token DECODE
%token DISCONNECT
%token EXP
%token FLOOR
%token GEN_UUID
%token GENERATED
%token GLOBAL
%token HASH
%token INSENSITIVE
%token LIST
%token LN
%token LOG
%token LOG10
%token LPAD
%token MATCHED
%token MATCHING
%token MAXVALUE
%token MILLISECOND
%token MINVALUE
%token MOD
%token OVERLAY
%token PAD
%token PI
%token PLACING
%token POWER
%token PRESERVE
%token RAND
%token RECURSIVE
%token REPLACE
%token REVERSE
%token ROUND
%token RPAD
%token SENSITIVE
%token SIGN
%token SIN
%token SINH
%token SPACE
%token SQRT
%token START
%token TAN
%token TANH
%token TEMPORARY
%token TRUNC
%token WEEK
// tokens added for Firebird 2.5
%token AUTONOMOUS
%token CHAR_TO_UUID
%token FIRSTNAME
%token GRANTED
%token LASTNAME
%token MIDDLENAME
%token MAPPING
%token OS_NAME
%token SIMILAR
%token UUID_TO_CHAR
%token DUMP
// new execute statement
%token CALLER
%token COMMON
%token DATA
%token SOURCE
%token TWO_PHASE
%token BIND_PARAM
%token BIN_NOT
%token SQLSTATE
%token LOCALTIME
%token LOCALTIMESTAMP
/* precedence declarations for expression evaluation */
%left OR
%left AND
%left NOT
%left '=' '<' '>' LIKE EQL NEQ GTR LSS GEQ LEQ NOT_GTR NOT_LSS
%left '+' '-'
%left '*' '/'
%left UMINUS UPLUS
%left CONCATENATE
%left COLLATE
/* Fix the dangling IF-THEN-ELSE problem */
%nonassoc THEN
%nonassoc ELSE
/* The same issue exists with ALTER COLUMN now that keywords can be used
in order to change their names. The syntax which shows the issue is:
ALTER COLUMN where column is part of the alter statement
or
ALTER COLUMN where column is the name of the column in the relation
*/
%nonassoc ALTER
%nonassoc COLUMN
%%
/* list of possible statements */
top : statement
{ DSQL_parse = $1; }
| statement ';'
{ DSQL_parse = $1; }
;
statement : alter
| blob_io
| comment
| commit
| create
| create_or_alter
| declare
| delete
| drop
| grant
| insert
| merge
| exec_procedure
| exec_block
| recreate
| revoke
| rollback
| savepoint
| select
| set
| update
| update_or_insert
| dump
;
/* GRANT statement */
grant : GRANT privileges ON table_noise simple_table_name
TO non_role_grantee_list grant_option granted_by
{ $$ = make_node (nod_grant, (int) e_grant_count,
$2, $5, make_list($7), $8, $9); }
| GRANT proc_privileges ON PROCEDURE simple_proc_name
TO non_role_grantee_list grant_option granted_by
{ $$ = make_node (nod_grant, (int) e_grant_count,
$2, $5, make_list($7), $8, $9); }
| GRANT role_name_list TO role_grantee_list role_admin_option granted_by
{ $$ = make_node (nod_grant, (int) e_grant_count,
make_list($2), make_list($4), NULL, $5, $6); }
;
table_noise : TABLE
|
;
privileges : ALL
{ $$ = make_node (nod_all, (int) 0, NULL); }
| ALL PRIVILEGES
{ $$ = make_node (nod_all, (int) 0, NULL); }
| privilege_list
{ $$ = make_list ($1); }
;
privilege_list : privilege
| privilege_list ',' privilege
{ $$ = make_node (nod_list, (int) 2, $1, $3); }
;
proc_privileges : EXECUTE
{ $$ = make_list (make_node (nod_execute, (int) 0, NULL)); }
;
privilege : SELECT
{ $$ = make_node (nod_select, (int) 0, NULL); }
| INSERT
{ $$ = make_node (nod_insert, (int) 0, NULL); }
| KW_DELETE
{ $$ = make_node (nod_delete, (int) 0, NULL); }
| UPDATE column_parens_opt
{ $$ = make_node (nod_update, (int) 1, $2); }
| REFERENCES column_parens_opt
{ $$ = make_node (nod_references, (int) 1, $2); }
;
grant_option : WITH GRANT OPTION
{ $$ = make_node (nod_grant, (int) 0, NULL); }
|
{ $$ = NULL; }
;
role_admin_option : WITH ADMIN OPTION
{ $$ = make_node (nod_grant_admin, (int) 0, NULL); }
|
{ $$ = NULL; }
;
granted_by : granted_by_text grantor
{ $$ = $2; }
|
{ $$ = NULL; }
;
granted_by_text : GRANTED BY
| AS
;
grantor : role_grantee
{ $$ = $1; }
;
simple_proc_name: symbol_procedure_name
{ $$ = make_node (nod_procedure_name, (int) 1, $1); }
;
/* REVOKE statement */
revoke : REVOKE rev_grant_option privileges ON table_noise simple_table_name
FROM non_role_grantee_list granted_by
{ $$ = make_node (nod_revoke, (int) e_grant_count,
$3, $6, make_list($8), $2, $9); }
| REVOKE rev_grant_option proc_privileges ON PROCEDURE simple_proc_name
FROM non_role_grantee_list granted_by
{ $$ = make_node (nod_revoke, (int) e_grant_count,
$3, $6, make_list($8), $2, $9); }
| REVOKE rev_admin_option role_name_list FROM role_grantee_list granted_by
{ $$ = make_node (nod_revoke, (int) e_grant_count,
make_list($3), make_list($5), NULL, $2, $6); }
| REVOKE ALL ON ALL FROM non_role_grantee_list
{ $$ = make_node (nod_revoke, (int) e_grant_count,
NULL, NULL, make_list($6), NULL, NULL); }
;
rev_grant_option : GRANT OPTION FOR
{ $$ = make_node (nod_grant, (int) 0, NULL); }
|
{ $$ = NULL; }
;
rev_admin_option : ADMIN OPTION FOR
{ $$ = make_node (nod_grant_admin, (int) 0, NULL); }
|
{ $$ = NULL; }
;
non_role_grantee_list : grantee_list
| user_grantee_list
;
grantee_list : grantee
| grantee_list ',' grantee
{ $$ = make_node (nod_list, (int) 2, $1, $3); }
| grantee_list ',' user_grantee
{ $$ = make_node (nod_list, (int) 2, $1, $3); }
| user_grantee_list ',' grantee
{ $$ = make_node (nod_list, (int) 2, $1, $3); }
;
grantee : PROCEDURE symbol_procedure_name
{ $$ = make_node (nod_proc_obj, (int) 1, $2); }
| TRIGGER symbol_trigger_name
{ $$ = make_node (nod_trig_obj, (int) 1, $2); }
| VIEW symbol_view_name
{ $$ = make_node (nod_view_obj, (int) 1, $2); }
| ROLE symbol_role_name
{ $$ = make_node (nod_role_name, (int) 1, $2); }
;
user_grantee_list : user_grantee
| user_grantee_list ',' user_grantee
{ $$ = make_node (nod_list, (int) 2, $1, $3); }
;
/* CVC: In the future we can deprecate the first implicit form since we'll support
explicit grant/revoke for both USER and ROLE keywords & object types. */
user_grantee : symbol_user_name
{ $$ = make_node (nod_user_name, (int) 1, $1); }
| USER symbol_user_name
{ $$ = make_node (nod_user_name, (int) 2, $2, NULL); }
| GROUP symbol_user_name
{ $$ = make_node (nod_user_group, (int) 1, $2); }
;
role_name_list : role_name
| role_name_list ',' role_name
{ $$ = make_node (nod_list, (int) 2, $1, $3); }
;
role_name : symbol_role_name
{ $$ = make_node (nod_role_name, (int) 1, $1); }
;
role_grantee_list : role_grantee
| role_grantee_list ',' role_grantee
{ $$ = make_node (nod_list, (int) 2, $1, $3); }
;
role_grantee : symbol_user_name
{ $$ = make_node (nod_user_name, (int) 1, $1); }
| USER symbol_user_name
{ $$ = make_node (nod_user_name, (int) 1, $2); }
;
/* DECLARE operations */
declare : DECLARE declare_clause
{ $$ = $2;}
;
declare_clause : FILTER filter_decl_clause
{ $$ = $2; }
| EXTERNAL FUNCTION udf_decl_clause
{ $$ = $3; }
;
udf_decl_clause : symbol_UDF_name arg_desc_list1 RETURNS return_value1
ENTRY_POINT sql_string MODULE_NAME sql_string
{ $$ = make_node (nod_def_udf, (int) e_udf_count,
$1, $6, $8, make_list ($2), $4); }
;
udf_data_type : simple_type
| BLOB
{ lex.g_field->fld_dtype = dtype_blob; }
| CSTRING '(' pos_short_integer ')' charset_clause
{
lex.g_field->fld_dtype = dtype_cstring;
lex.g_field->fld_character_length = (USHORT)(IPTR) $3; }
;
arg_desc_list1 :
{ $$ = NULL; }
| arg_desc_list
| '(' arg_desc_list ')'
{ $$ = $2; }
;
arg_desc_list : arg_desc
| arg_desc_list ',' arg_desc
{ $$ = make_node (nod_list, (int) 2, $1, $3); }
;
/*arg_desc : init_data_type udf_data_type
{ $$ = $1; } */
arg_desc : init_data_type udf_data_type param_mechanism
{ $$ = make_node (nod_udf_param, (int) e_udf_param_count,
$1, $3); }
;
param_mechanism :
{ $$ = NULL; } /* Beware: ddl.cpp converts this to mean FUN_reference. */
| BY KW_DESCRIPTOR
{ $$ = MAKE_const_slong (FUN_descriptor); }
| BY SCALAR_ARRAY
{ $$ = MAKE_const_slong (FUN_scalar_array); }
| KW_NULL
{ $$ = MAKE_const_slong (FUN_ref_with_null); }
;
return_value1 : return_value
| '(' return_value ')'
{ $$ = $2; }
;
return_value : init_data_type udf_data_type return_mechanism
{ $$ = make_node (nod_udf_return_value, (int) e_udf_param_count,
$1, $3); }
| PARAMETER pos_short_integer
{ $$ = make_node (nod_udf_return_value, (int) e_udf_param_count,
NULL, MAKE_const_slong ((IPTR) $2));}
;
return_mechanism :
{ $$ = MAKE_const_slong (FUN_reference); }
| BY KW_VALUE
{ $$ = MAKE_const_slong (FUN_value); }
| BY KW_DESCRIPTOR
{ $$ = MAKE_const_slong (FUN_descriptor); }
| FREE_IT
{ $$ = MAKE_const_slong (-1 * FUN_reference); }
/* FUN_refrence with FREE_IT is -ve */
| BY KW_DESCRIPTOR FREE_IT
{ $$ = MAKE_const_slong (-1 * FUN_descriptor); }
;
filter_decl_clause : symbol_filter_name INPUT_TYPE blob_filter_subtype OUTPUT_TYPE blob_filter_subtype
ENTRY_POINT sql_string MODULE_NAME sql_string
{ $$ = make_node (nod_def_filter, (int) e_filter_count,
$1, $3, $5, $7, $9); }
;
blob_filter_subtype : symbol_blob_subtype_name
{ $$ = MAKE_constant ((dsql_str*) $1, CONSTANT_STRING); }
|
signed_short_integer
{ $$ = MAKE_const_slong ((IPTR) $1); }
;
/* CREATE metadata operations */
create : CREATE create_clause
{ $$ = $2; }
;
create_clause : EXCEPTION exception_clause
{ $$ = $2; }
| unique_opt order_direction INDEX symbol_index_name ON simple_table_name index_definition
{ $$ = make_node (nod_def_index, (int) e_idx_count,
$1, $2, $4, $6, $7); }
| PROCEDURE procedure_clause
{ $$ = $2; }
| TABLE table_clause
{ $$ = $2; }
| GLOBAL TEMPORARY TABLE gtt_table_clause
{ $$ = $4; }
| TRIGGER trigger_clause
{ $$ = $2; }
| VIEW view_clause
{ $$ = $2; }
| GENERATOR generator_clause
{ $$ = $2; }
| SEQUENCE generator_clause
{ $$ = $2; }
| DATABASE db_clause
{ $$ = $2; }
| DOMAIN domain_clause
{ $$ = $2; }
| SHADOW shadow_clause
{ $$ = $2; }
| ROLE role_clause
{ $$ = $2; }
| COLLATION collation_clause
{ $$ = $2; }
| USER create_user_clause
{ $$ = $2; }
;
recreate : RECREATE recreate_clause
{ $$ = $2; }
;
recreate_clause : PROCEDURE rprocedure_clause
{ $$ = $2; }
| TABLE rtable_clause
{ $$ = $2; }
| GLOBAL TEMPORARY TABLE gtt_recreate_clause
{ $$ = $4; }
| VIEW rview_clause
{ $$ = $2; }
| TRIGGER rtrigger_clause
{ $$ = $2; }
/*
| DOMAIN rdomain_clause
{ $$ = $2; }
*/
| EXCEPTION rexception_clause
{ $$ = $2; }
;
create_or_alter : CREATE OR ALTER replace_clause
{ $$ = $4; }
;
replace_clause : PROCEDURE replace_procedure_clause
{ $$ = $2; }
| TRIGGER replace_trigger_clause
{ $$ = $2; }
| VIEW replace_view_clause
{ $$ = $2; }
| EXCEPTION replace_exception_clause
{ $$ = $2; }
;
/* CREATE EXCEPTION */
exception_clause : symbol_exception_name sql_string
{ $$ = make_node (nod_def_exception, (int) e_xcp_count,
$1, $2); }
;
rexception_clause : symbol_exception_name sql_string
{ $$ = make_node (nod_redef_exception, (int) e_xcp_count,
$1, $2); }
;
replace_exception_clause : symbol_exception_name sql_string
{ $$ = make_node (nod_replace_exception, (int) e_xcp_count,
$1, $2); }
;
alter_exception_clause : symbol_exception_name sql_string
{ $$ = make_node (nod_mod_exception, (int) e_xcp_count,
$1, $2); }
;
/* CREATE INDEX */
unique_opt : UNIQUE
{ $$ = make_node (nod_unique, 0, NULL); }
|