LCOV - code coverage report
Current view: top level - parser - xg_gram_psql.y (source / functions) Hit Total Coverage
Test: XuGu SQL Lines: 2330 8910 26.2 %
Date: 2022-10-19 11:25:02 Functions: 7 15 46.7 %
Legend: Lines: hit not hit

          Line data    Source code
     157             : 
     158             : %type <node>      CreateAsElement /*,TriggerFuncArg*/
     159             : %type <node>      select_limit_value select_offset_value FuncArg
     160             : %type <node>      table_ref base_table_ref case_expr case_arg when_clause case_default
     161             : %type <node>      join_outer table_element ConstraintElem columnDef
     162             : %type <vptr>    OptSeqElem
     163             : %type <node>      opt_where_clause bool_expr bool_expr1 sortby insert_rest index_elem joined_table opt_keep_clause 
     164             :                                 rela_expr b_expr c_expr in_expr AexprConst alias_clause opt_having_clause target_el opt_parti_clip_clause/* bysdc@20200915 *//*add <in_expr> bywsy@20210306 bug3597*/
     165             :                                 autoextend_clause IntegerOnly relation_expr with_name opt_delete_where_clause insert_merge
     166             : %type <node>      stmt sql_stmt opt_trig_cond AlterRoleStmt AlterSchemaStmt AlterUserStmt AnalyzeStmt 
     167             :                                 CloseCursorStmt ClusterStmt ConstraintsSetStmt AlterTableStmt AlterIndexStmt CreateAsStmt CreateRoleStmt 
     168             :                                 CreateSchemaStmt CreateSeqStmt AlterSeqStmt CreateTabStmt CreateTrigStmt CreateUserStmt 
     169             :                                 CreatespacStmt CreatedbStmt CursorStmt DropdbStmt DropspacStmt DropSchemaStmt DropTabStmt DropIdxStmt 
     170             :                                 DropViewStmt DropSeqStmt DropRoleStmt DropUserStmt DropTrigStmt DropProcedureStmt DeleteStmt ExplainStmt 
     171             :                                 ExtendStmt FetchStmt GrantStmt IndexStmt opt_idx_parti InsertStmt ListenStmt LoadStmt LockStmt 
     172             :                                 NotifyStmt dml_stmt ReindexStmt RenameStmt RevokeStmt SelectStmt TransactionStmt TruncateStmt 
     173             :                                 UnlistenStmt UpdateStmt VacuumStmt VariableSetStmt VariableShowStmt ViewStmt MergeIntoStmt 
     174             :                                 CheckPointStmt LoginStmt LogoutStmt EncryptStmt DecryptStmt CreateEncryptStmt DropEncryptStmt 
     175             :                                 StartEncryptdb data_file AlterspacStmt opt_serial ftidx_opt CreateDirStmt 
     176             :                                 ShowDirStmt select_no_parens select_with_parens select_clause simple_select alter_column_item grantee 
     177             :                                 ident Param AnonyProcedure del_targ_tab opt_win_range row_range window_extent CreateContextStmt DropContextStmt filter_where_clause/* ++bysdc@20201003 */
     178             :                                 
     179             : %type <node>      TableConstraint update_target_el ColConstraint ColConstraintElem ConstraintAttr 
     180             :                                 full_index_opts opt_partitioning_clause opt_subpartitioning_clause opt_phyical_props 
     181             :                                 opt_store_props store_props constraint_prop which_constraint group_item 
     182             :                                 MemberVarDecl PackDecl pl_sql_stmt CreProcedureStmt StmtBlock VarDef TypeDefStmt 
     183             :                                 pl_stmt pl_stmt_line VarAssign IfElseStmt LoopStmt ForStmt CaseStmt GotoStmt BreakStmt 
     184             :                                 ContinueStmt ReturnStmt When_item CallPrepareStmt ExecuteStmt ElsIfItem Exception_Item 
     185             :                                 RParam PackSpecItem ProcDecl ProcDef ThrowStmt ForallStmt 
     186             :                                 member_decl MemberFuncDef MemberFuncDecl CursorDef ExceptionDef PackBody 
     187             :                                 ClassBodyDefStmt ClassDeclStmt BackupStmt ImportStmt CheckTabStmt 
     188             :                                 CreateLinkStmt DropLinkStmt CreateSynonymStmt DropSynonymStmt CreateMViewStmt 
     189             :                                 DropMViewStmt TextPattern DropSessionStmt AbortSessionStmt TraceStmt DisassembleStmt 
     190             :                                 sys_privilege opt_top CommentStmt LoadVocableStmt 
     191             :                                 CompileVocableStmt GetLobStmt
     192             : %type <node>      TypeName STypename STypename1 ConstTypename ConstTypename1 GenericType Numeric 
     193             :                                 Character ConstDatetime ConstDatetime1 Bit CreatPolicyStmt AlterPolicyStmt DropPolicyStmt 
     194             :                                 AlterUserPolicyStmt AlterCluStmt AlterTabPolicyStmt PolicyMember PolicyMemOfCre AuditStmt LocalAuditItems 
     195             :                                 ShutdownStmt PrepareStmt OpenCursorStmt DeallocateStmt DropPackStmt DropTypeStmt 
     196             :                                 store_prop oci_parameter OptTrggParamAlias TriggerEvents TriggerOneEvent dml_stmt1 
     197             :                                 opt_missing_field_value RecompileStmt EnableStmt AssistantStmt CreateDomainStmt AlterDomainStmt 
     198             :                                 DropDomainStmt domain_constraint user_quota range_parti_item list_parti_item select_limit opt_select_limit opt_until_time /*why 2016-04-11 add add <opt_until_time>  by sdc@20170527*/
     199             : %type <node>    ConnectPolicyStmt  //why 2016-07-28 add           
     200             : %type <node>    FlashBackStmt        //why 2019-03-25 add
     201             : /*xugu hint support ++bysdc@20200411*/
     202             : %type <node>      CreateProfileStmt ProfileItem
     203             : %type <list>      ProfileList
     204             : %token <str>      PROFILE SESSION_PER_USER CPU_PER_SESSION CPU_PER_CALL MAX_CONNECT_TIME MAX_IDLE_TIME READS_PER_SESSION 
     205             :                                 READS_PER_CALL TOTAL_RESOURCE_LIMIT PRIVATE_SGA MAX_STORE_NUM CONNECT_NODES STORE_NODES TEMPSPACE_QUOTA 
     206             :                                 CURSOR_QUOTA FAILED_LOGIN_ATTEMPTS PASSWORD_LIFE_PERIOD PASSWORD_LOCK_TIME              
     207             : %type <ival>      ProfileValue    
     208             : %type <bval>      opt_varying opt_with_timez opt_force opt_fast opt_unique opt_verbose opt_analyze opt_global
     209             :                                 opt_all opt_table opt_chain opt_with_grant opt_rebuild_idx opt_auto_update
     210             : %type <bval>      enable_disable opt_validate cascade_opt keep_drop_opt keep_index_opt constraints_set_mode 
     211             :                                 password_expire_clause opt_constant opt_distinct opt_online opt_not_null opt_hide 
     212             :                                 opt_with_context opt_keep_tab opt_bulk opt_return opt_reindex opt_increment opt_cascade /*why 2016-10-27 add[opt_cascade]mergebysdc@20180907 add <opt_increment>  by sdc@20170527*/
     213             :                                 opt_if_exists opt_if_not_exists
     214             : %type <ival>    opt_nulls_order // update lwb@20210224
     215             : %type <ival>    TriggerActionTime operation_commalist operation alter_behavior opt_lock /*lock_t */privileges 
     216             :                                 account_lock_clause OptTemp TriggerForSpec op_append_mode opt_column join_type sub_type on_commit_del /* on_commit_del move from bval wsy@20200105 bug3864*/
     217             : %type <ival>      key_actions key_delete key_update key_reference size_unit ena_trans_opt optSpaceType
     218             : %type <ival>      parallel_opt parallel_opt2 in_out Cre_Rep integer opt_build_mode opt_rewrite opt_exist_tab opt_priority
     219             : %type <ival>      ConstraintAttributeSpec ConstraintDeferrabilitySpec opt_wait ConstraintTimeSpec view_opt
     220             : %type <ival>      opt_numeric opt_decimal refresh_mode period opt_interval opt_limit opt_preci dml_opt 
     221             :                                 GlobalAuditItem ObjAuditItems ObjAuditItem optAuditCond GlobalAuditItems  
     222             :                                 sys_operation obj_type opt_sub_label opt_sub_label2 opt_class_flags 
     223             :                                 class_flags class_flag opt_proc_flags opt_match_type opt_authid 
     224             :                                 opt_parti_interval opt_on_node opt_import_mode dt_unit opt_compress opt_char
     225             : 
     226             : %type <str>               user_passwd_clause user_valid_clause /*OptConstrTabNodele */
     227             :                                 space_name database_name index_type_opt index_name name func_name 
     228             :                                 file_name ROp opt_name opt_name_space OptUseOp GeomROp opt_level 
     229             :                                 opt_encoding multi_sconst character 
     230             : %type <str>               exceptions_opt name_space opt_charset opt_collate 
     231             :                                 opt_float Sconst opt_comment UserId opt_boolean var_value zone_value opt_trust_ip
     232             : %type <str>               ColId ColLabel TokenId opt_fk_name opt_alias Keywords TextItem reserved_keyword unreserved_keyword collabel_keyword
     233             : %type <str>               key_match start_time terminated_chars opt_file_type 
     234             :                                 opt_default_dir opt_badfile opt_discordfile opt_logfile
     235             : %type <str>     opt_conn_policy opt_encryptor  //why 2016-07-28 add add <opt_encryptor>  by sdc@20170527
     236             : %type <str>     opt_encrypt /*why 2016-10-27 add mergebysdc@20180907*/
     237             : %type <str>               opt_hint //++bysdc@20200411
     238             : %type <list>      OptCreateAs CreateAsList when_clause_list data_files stmtblock stmtmulti 
     239             :                                 relation_name_list table_elements group_items opt_column_list columnList columnList2
     240             :                                 opt_va_list va_list sort_clause sortby_list index_params name_list opt_from_clause 
     241             :                                 from_list expr_list expr_vector vector_values insert_values target_list update_target_list 
     242             :                                 opt_group_clause /*TriggerFuncArgs select_limit opt_select_limit */for_update_clause 
     243             :                                 opt_for_update_clause update_list position_list substr_list trim_list user_list 
     244             :                                 user_role_clause OptSeqList ColQualList base_table_refs constraints_set_list 
     245             :                                 constraints_set_namelist range_parti_items list_parti_items 
     246             :                                 parti_values opt_constraint_props constraint_props func_args func_args_list 
     247             :                                 pl_stmt_list VarDefList When_list Else_list Exceptions OptExceptionStmt func_params 
     248             :                                 member_decls PackSpecs optVarDefList alt_columns watch_list opt_trig_var_def 
     249             :                                 PolicyMembers PolicyMemsOfCre optAuditUser sys_privileges PackMemberProcs col_defs 
     250             :                                 decode_list opt_pack_inits MemberFuncDefs pragmas oci_parameters grantee_list 
     251             :                                 opt_using opt_into_list opt_returning ident_list opt_domain_constraints domain_constraints 
     252             :                                 opt_corresponding opt_user_quotas user_quotas opt_win_parti opt_win_order add_columns 
     253             :                                 alter_columns drop_columns multi_group_item with_clauses
     254             : 
     255             : %type <list>      insert_when_clause_list insert_into_list insert_else_clause
     256             : %type <node>      insert_when_clause insert_into_clause
     257             : %type <ival>      insert_multi_tab_type
     258             :                                 
     259             : %type <vptr>    full_index_opt_item opt_analyze_for opt_connect_by connect_by opt_trans_range opt_path /*add <opt_path>  by sdc@20170527*/
     260             : 
     261             : /* Keywords (in SQL92 reserved words) */
     262             : %token <str> _ABSOLUTE ACTION ADD ALL ALTER AND ANY AS _ASC AT 
     263             :                 _BEGIN BETWEEN BOTH BY MODIFY ROLLUP CUBE GROUPING SETS 
     264             :                 CASCADE CASE CAST CHARACTER CHECK CLOSE COALESCE COLLATE 
     265             :                 COLUMN COLUMNS COMMIT CONSTRAINT CONSTRAINTS CREATE CROSS CURSOR 
     266             :                 _DAY DEC _DECIMAL DECLARE DEFAULT _DELETE DESC DISTINCT _DOUBLE 
     267             :                 DROP ELSE _END ESCAPE EXCEPT EXECUTE _CALL EXISTS _FALSE FETCH _FLOAT FOR 
     268             :                 FOREIGN FROM FULL MINUS GLOBAL GRANT _GROUP HAVING _HOUR CORRESPONDING  
     269             :                 _IN _INNER INSENSITIVE INSERT INTERSECT INTO IS ISOLATION JOIN 
     270             :                 KEY LANGUAGE LEADING LEFT LEVEL LIKE LOCAL MATCH _MINUTE _MONTH NAMES 
     271             :                 NATIONAL NATURAL NCHAR NEXT NO NOT NULLIF _NULL _NUMERIC NUMBER OF 
     272             :                 ON ONLY OPTION OR ORDER _OUTER OVERLAPS PARTIAL PRECISION 
     273             :                 PRIMARY PRIOR PRIVILEGES PROCEDURE PUBLIC READ WRITE REFERENCES _RELATIVE 
     274             :                 REVOKE RIGHT ROLLBACK SCHEMA SCROLL _SECOND SELECT SESSION SET SOME 
     275             :                 TABLE TEMPORARY THEN _DATE DATETIME INTERVAL TIME TIMESTAMP TO 
     276             :                 TRAILING TRANSACTION TRAN TRIM _TRUE UNION UNIQUE UPDATE USER USING VALUES 
     277             :                 VARYING VIEW FINALLY WHEN WHERE WITH WORK _YEAR ZONE 
     278             :                 REF DECODE DBA SSO AUDITOR RESOURCE ENCRYPT ENCRYPTOR IDENTIFIED DECRYPT 
     279             :                 ACCOUNT UNLOCK EXPIRE ROLE RECORD _REPEATABLE AUTO SAVEPOINT  CURRENT NODE 
     280             :                 ONLINE OFFLINE SPATIAL BOUND EXPORT IMPORT APPEND VOCABLE _TRY _CATCH WHILE 
     281             :                 _O_JOIN OPEN INDICES TOP _DOMAIN_ EXTERNAL BADFILE DISCORDFILE MISSING ARE 
     282             :                 RECORDS FIELDS FIELD NEWLINE DELIMITED TERMINATED MATERIALIZED _ROWID BUILD 
     283             :                 PREBUILT REDUCED REWRITE DEMAND QUERY MAXVALUES OTHERVALUES SLOW FOUND NOFOUND 
     284             :                 NOTFOUND ISOPEN ROWCOUNT NULLS EXTRACT FLASHBACK /*why 2019-03-25 add flashback*/ LOGON LOGOFF
     285             :                 
     286             : /* Keywords (in SQL3 reserved words) */
     287             : %token <str>      CHAIN CHARACTERISTICS 
     288             :                 DEFERRABLE DEFERRED 
     289             :                 IMMEDIATE INITIALLY INOUT 
     290             :                 OFF _OUT 
     291             :                 RESTRICT 
     292             :         TRIGGER 
     293             :                 WITHOUT 
     294             :                 FILTER 
     295             :                 LEXER 
     296             :                 FIRST 
     297             :                 LAST
     298             : 
     299             : /* Keywords (in SQL92 non-reserved words) */
     300             : %token <str> COMMITTED SERIALIZABLE
     301             : 
     302             : /* Keywords for  support (not in SQL92 reserved words)
     303             :  *
     304             :  * The CREATEDB and CREATEUSER tokens should go away
     305             :  * when some sort of pg_privileges relation is introduced.
     306             :  * - Todd A. Brandys 1998-01-01?
     307             :  */
     308             : %token <str> _ABORT ACCESS AFTER AGGREGATE ANALYZE BACKWARD 
     309             :                 BEFORE BINARY BIT CHECKPOINT CLUSTER 
     310             :                 COMMENT COPY CREATEDB CREATEUSER CYCLE DATABASE 
     311             :                 DELIMITERS DO EACH ENCODING EXCLUSIVE EXPLAIN EXTEND 
     312             :                 FORCE NOFORCE FORWARD FUNCTION HANDLER ILIKE INCREMENT 
     313             :                 INDEX INHERITS INSTEAD ISNULL LIMIT LISTEN PRIORITY 
     314             :                 LOAD LOCATION _LOCK _MAX MAXVALUE MINVALUE MODE NOCREATEDB 
     315             :                 NOCREATEUSER NONE NOTHING NOTIFY NOTNULL OFFSET OIDS OPERATOR 
     316             :                 OWNER PASSWORD PROCEDURAL REINDEX RENAME ROW RULE 
     317             :                 SEQUENCE SETOF SHARE SHOW START STATEMENT TEMP TEMPLATE 
     318             :                 TRUNCATE TRUSTED UNLISTEN UNTIL VACUUM VALID VERBOSE VERSION 
     319             :                 INIT BLOCK K M G _SIZE_ TABLESPACE LOGIN LOGOUT CONSTANT REBUILD 
     320             :                 MERGE SPLIT IDENTITY RECOMPILE IDENT FCONST SCONST BITCONST 
     321             :                 AUTHORIZATION DATAFILE ARCHIVELOG NOARCHIVELOG STANDBY PROTECTED 
     322             :                 UNPROTECTED LOGFILE MAXSIZE UNLIMITED UNIFORM UNDO BLOCKS MATCHED
     323             :                 
     324             : %token <str> WITHIN CONTAINS EQUALS DISJOINT TOUCHES CROSSES INTERSECTS 
     325             :                 BCONTAINS BWITHIN BINTERSECTS ABOVE     UNDER LEFTOF RIGHTOF 
     326             :                 LOVERLAPS ROVERLAPS AOVERLAPS BOVERLAPS UOVERLAPS  
     327             : 
     328             : %token <str> LEVELS OBJECT IDENTIFIER SYSTEM GENERATED OIDINDEX ROWS 
     329             :                 PRESERVE ORGANIZATION HEAP ELEMENT TYPE NESTED STORE RETURN LOCATOR 
     330             :                 VALUE VARRAY ARRAY LOB ENABLE STORAGE DISABLE CACHE NOCACHE 
     331             :                 READS LOGGING NOLOGGING XML MOVEMENT PCTFREE PCTUSED PARTITION RANGE 
     332             :                 LESS THAN LIST SUBPARTITION HASH SUBPARTITIONS PARTITIONS NOPARALLEL 
     333             :                 PARALLEL VALIDATE NOVALIDATE EXCEPTIONS KEEP _DIR THROW KEYSET DRIVEN
     334             : %token <str> PACKAGE REPLACE EXCEPTION LOOP GOTO EXIT CONTINUE REVERSE IF ELSIF 
     335             :                 MEMBER BODY BACKUP RESTORE CONNECT SNAPSHOT EVERY LINK SYNONYM REFRESH 
     336             :                 INCLUDE TRACE STEP BREAK RUN STOP GET REPLICATION PERIOD HOTSPOT 
     337             :                 FAST COMPLETE RAISE ENDIF ENDFOR ENDLOOP ENDCASE JOB SEGMENT TWO_DOT 
     338             :                 CATEGORY POLICY LABEL HIDE AUDIT NOAUDIT WHENEVER SUCCESSFUL USE 
     339             :                 SHUTDOWN RESTART PREPARE LEAVE ASSIGN ROWTYPE DEALLOCATE NVL NVL2
     340             : %token <str> CHUNK MINEXTENTS MAXEXTENTS PCTINCREASE FREELISTS FREELIST GROUPS 
     341             :                 BUFFER_POOL RECYCLE PCTVERSION INITIAL NOCOMPRESS COMPRESS INITRANS MAXTRANS
     342             : %token <str> VARCHAR NVARCHAR VARCHAR2 NVARCHAR2 COMPUTE STATISTICS SUBTYPE CONSTRUCTOR STATIC 
     343             :                 FINAL INSTANTIABLE AUTHID SELF RESULT DETERMINISTIC BULK COLLECT FORALL _RAW_ 
     344             :                 INDEXTYPE PRAGMA NAME PARAMETERS LIBRARY _CONTXT INDICATOR LENGTH RETURNING 
     345             :                 NOORDER NOCYCLE REFERENCING NEW OLD LEAST GREATEST WAIT NOWAIT DESCRIBE STREAM 
     346             :                 QUOTA IO MEMORY DISASSEMBLE OVER PRECEDING FOLLOWING UNBOUNDED SIBLINGS EXIST EXCEPTION_INIT
     347             : 
     348             : %token <str>    UNIONJOIN Op LE GE NE
     349             : /*xugu hint support ++bysdc@20200411*/
     350             : %token <str> HINT _HINT_TEXT ALL_ROWS FIRST_ROWS NOINDEX CHOOSE RESULT_CACHE INDEX_JOIN INDEX_ASC INDEX_DESC 
     351             :                          INDEX_FSS USE_HASH NOAPPEND ORDERD _IGNORE
     352             : %token <ival>     ICONST
     353             : 
     354             : 
     355             : /* precedence: lowest to highest */
     356             : %left           UNION EXCEPT MINUS
     357             : %left           INTERSECT
     358             : %left           JOIN UNIONJOIN CROSS LEFT FULL RIGHT _INNER NATURAL
     359             : %left           OR
     360             : %left           AND
     361             : %right          NOT
     362             : %right          '='
     363             : %nonassoc       '<' '>'
     364             : %nonassoc       LIKE ILIKE
     365             : %nonassoc       ESCAPE
     366             : %nonassoc       OVERLAPS
     367             : %nonassoc       BETWEEN
     368             : %nonassoc       _IN
     369             : 
     370             : %left   WITHIN CONTAINS EQUALS DISJOINT TOUCHES CROSSES INTERSECTS
     371       44805 :                 BCONTAINS BWITHIN BINTERSECTS ABOVE UNDER LEFTOF RIGHTOF 
     372       44805 :                 LOVERLAPS ROVERLAPS AOVERLAPS  BOVERLAPS
     373             : 
     374             : %nonassoc       NOTNULL
     375             : %nonassoc       ISNULL
     376       18981 : %nonassoc       IS _NULL _TRUE _FALSE   
     377         132 : %left           '+' '-'
     378             : //why 2015-12-17 modify old: %left              Op      '*' '/' '%' '~'
     379       18849 : %left           Op
     380             : %left           '*' '/' '%' '~'
     381       18981 : //end
     382             : 
     383           0 : /*Unary Operators*/
     384           0 : %left           AT ZONE                 
     385             : %right          UMINUS
     386           0 : %left           '.'
     387       44805 : %left           '[' ']'
     388       44805 : %left           '(' ')'
     389             : %left           TYPECAST
     390           0 : %left           '^' '&' ',' '|'
     391             : %%
     392       44805 : 
     393             : 
     394             : stmtblock:  stmtmulti
     395             :         {*((List**)parsetree) = $1; }
     396             :         ;
     397             : 
     398             : /* the thrashing around here is to discard "empty" statements... */
     399             : stmtmulti:  stmtmulti ';' stmt 
     400             :         { if ($3 != (Node *)NULL)
     401             :                 $$ = lappend($1, $3);
     402             :                 else
     403             :                 $$ = $1;
     404             :         }
     405             :         | stmtmulti ';' error ';'
     406             :         {
     407             :                 $$ = $1;
     408             :                 yyerrok;
     409             :         }
     410             :         | stmt 
     411             :         { if ($1 != (Node *)NULL)
     412             :                 $$ = makeList1($1);
     413             :                 else
     414             :                 $$ = NIL;
     415             :         }
     416             :         ;
     417             : 
     418             : stmt:
     419             :           LoginStmt
     420             :         | LogoutStmt
     421             :         | EncryptStmt
     422             :         | DecryptStmt
     423             :         | CreateEncryptStmt
     424             :         | DropEncryptStmt
     425             :         | StartEncryptdb
     426             :         | NotifyStmt
     427             :         | ListenStmt
     428             :         | UnlistenStmt
     429             :         | TraceStmt
     430             :         | DisassembleStmt
     431       18849 :         | CreatPolicyStmt
     432             :         | AlterPolicyStmt
     433       18849 :         | DropPolicyStmt
     434             :         | AlterUserPolicyStmt
     435             :         | AlterTabPolicyStmt
     436             :         | AuditStmt
     437             :         | AlterCluStmt
     438             :         | ShutdownStmt
     439             :         | pl_sql_stmt
     440             :         | PrepareStmt
     441             :         | DeallocateStmt
     442             :         | RecompileStmt
     443             :         | EnableStmt
     444             :         | DropSessionStmt
     445             :         | AbortSessionStmt
     446             :         | LoadVocableStmt
     447             :         | CompileVocableStmt
     448             :         | GetLobStmt
     449             :         | AssistantStmt
     450             :         | ConnectPolicyStmt //why 2016-07-28 add
     451             :         | CreateContextStmt //++bysdc@20201003
     452             :         | DropContextStmt //++bysdc@20201003
     453             :         | /*empty*/
     454             :         {
     455             :                 $$ = (Node *)NULL;
     456             :         }
     457             :         ;
     458             :         
     459             : pl_sql_stmt:    
     460             :       CreProcedureStmt
     461             :         | PackDecl
     462             :         | PackBody
     463             :         | ClassDeclStmt
     464             :         | ClassBodyDefStmt      
     465             :         | AnonyProcedure
     466             :         | sql_stmt
     467             :         ;
     468             :         
     469             : sql_stmt: AlterSchemaStmt
     470             :         | BackupStmt
     471             :         | ImportStmt
     472             :         | CheckTabStmt
     473             :         | AlterTableStmt
     474             :         | AlterIndexStmt
     475             :         | AlterRoleStmt
     476             :         | AlterUserStmt
     477             :         | AlterspacStmt
     478             :         | OpenCursorStmt
     479             :         | CloseCursorStmt
     480             :         | CreateTabStmt
     481             :         | CreateAsStmt
     482             :         | CreateSchemaStmt
     483             :         | CreateRoleStmt
     484             :         | CreateSeqStmt
     485             :         | AlterSeqStmt
     486             :         | CreateTrigStmt
     487             :         | CreateUserStmt
     488             :         | ClusterStmt
     489             :         | AnalyzeStmt
     490             :         | DropTabStmt
     491             :         | DropViewStmt
     492             :         | DropSeqStmt
     493             :         | DropIdxStmt                   
     494             :         | DropSchemaStmt
     495             :         | DropspacStmt
     496             :         | DropProcedureStmt
     497             :         | DropPackStmt
     498             :         | DropTypeStmt
     499             :         | TruncateStmt
     500             :         | DropRoleStmt
     501             :         | DropTrigStmt
     502             :         | DropUserStmt
     503             :         | ExtendStmt
     504             :         | ExplainStmt
     505             :         | FetchStmt
     506             :         | GrantStmt
     507             :         | IndexStmt
     508             :         | LockStmt
     509             :         | ReindexStmt
     510             :         | RenameStmt
     511             :         | RevokeStmt
     512             :         | dml_stmt
     513             :         | CursorStmt
     514             :         | TransactionStmt
     515             :         | ViewStmt
     516             :         | LoadStmt
     517             :         | CreatedbStmt
     518             :         | CreatespacStmt
     519             :         | DropdbStmt
     520             :         | VacuumStmt
     521             :         | CreateLinkStmt
     522             :         | DropLinkStmt
     523             :         | CreateSynonymStmt
     524             :         | DropSynonymStmt
     525             :         | CreateMViewStmt
     526             :         | DropMViewStmt
     527             :         | CreateDirStmt
     528             :         | ShowDirStmt   
     529             :         | ConstraintsSetStmt
     530             :         | CheckPointStmt
     531             :         | VariableSetStmt       
     532             :         | VariableShowStmt      
     533             :         | CallPrepareStmt
     534           4 :         | ExecuteStmt
     535           4 :         | CreateDomainStmt
     536             :         | AlterDomainStmt
     537           4 :         | DropDomainStmt
     538             :         | CommentStmt
     539           0 :         | FlashBackStmt /*why 2019-03-25 add*/
     540           0 :         | CreateProfileStmt//++bysdc@20200415
     541             :         | filter_where_clause//++bysdc@20201003
     542           0 :         ;
     543             : 
     544         177 : pl_stmt:        
     545         177 :           VarAssign
     546             :         | IfElseStmt 
     547         177 :         | LoopStmt  
     548             :         | ForStmt
     549             :         | ForallStmt
     550           1 :         | ThrowStmt     
     551             :         | CaseStmt  
     552           1 :         | GotoStmt
     553             :         | BreakStmt
     554           0 :         | ContinueStmt
     555           0 :         | ReturnStmt
     556           0 :         | _NULL ';'
     557             :         {
     558           0 :                 $$ = (Node*)makeNode(NullStmt);
     559             :                 SetNodePos($$);
     560             :         }
     561             :         | ProcDef ';'/*why 2020-08-26 add*/
     562             :         {
     563         932 :             $$ = $1;
     564             :                 SetNodePos($$); 
     565         932 :         }
     566             :         | sql_stmt ';'
     567           0 :         {
     568             :                 $$ = $1;
     569           0 :                 SetNodePos($$);
     570             :         }
     571           0 :         | StmtBlock
     572             :         | StmtBlock ';'
     573           0 :         {
     574             :                 $$ = $1;
     575         131 :         }
     576             :         | error ';'
     577         131 :         {
     578             :                 $$ = (Node*)makeNode(NullStmt);
     579           0 :                 SetNodePos($$);
     580             :                 yyerrok;
     581           0 :         }
     582             :         ;
     583           0 : 
     584             :  /* define or redefine package or procedure or function */
     585           0 :  Cre_Rep: CREATE
     586             :          {
     587             :                 $$ = 0;
     588         378 :          }
     589           2 :          | CREATE NOFORCE
     590             :          {
     591             :                 $$ = 0;
     592             :          }
     593             :          | CREATE FORCE
     594           0 :          {
     595           0 :                 $$ = 2;
     596           0 :          }
     597           0 :          | CREATE OR REPLACE
     598           0 :          {
     599           0 :                 $$ = 1;
     600             :          }
     601           0 :          | CREATE OR REPLACE NOFORCE
     602             :          {
     603           0 :                 $$ = 1;
     604           0 :          }
     605           0 :          | CREATE OR REPLACE FORCE
     606           0 :          {
     607           0 :                 $$ = 3;
     608           0 :          }
     609             :          ;
     610           0 :          
     611             :          Is_As: IS{}
     612           0 :          | AS{}
     613           0 :          ;
     614           0 : 
     615           0 : /* maintenace node online an offline */
     616           0 : AlterCluStmt: ALTER CLUSTER ADD NODE ICONST DESCRIBE Sconst
     617             :         {
     618           0 :                 AlterCluStmt *p_stmt = makeNode(AlterCluStmt);
     619             :                 p_stmt->action = 1;
     620           0 :                 p_stmt->node_id = $5;
     621           0 :                 p_stmt->describe = $7;
     622           0 :                 $$ = (Node*)p_stmt;
     623           0 :                 SetNodePos($$);
     624           0 :         }
     625             :         | ALTER CLUSTER ADD NODE ICONST DESCRIBE IDENT
     626           0 :         {
     627             :                 AlterCluStmt *p_stmt = makeNode(AlterCluStmt);
     628             :                 p_stmt->action = 1;
     629             :                 p_stmt->node_id = $5;
     630             :                 p_stmt->describe = $7;
     631           2 :                 $$ = (Node*)p_stmt;
     632           2 :                 SetNodePos($$);
     633             :         }
     634           2 :         | ALTER CLUSTER SET NODE ICONST OFFLINE
     635             :         {
     636           0 :                 AlterCluStmt *p_stmt = makeNode(AlterCluStmt);
     637           0 :                 p_stmt->action = 2;
     638           0 :                 p_stmt->node_id = $5;
     639             :                 $$ = (Node*)p_stmt;
     640           0 :                 SetNodePos($$);
     641             :         }
     642           0 :         | ALTER CLUSTER DROP NODE ICONST
     643           0 :         {
     644           0 :                 AlterCluStmt *p_stmt = makeNode(AlterCluStmt);
     645             :                 p_stmt->action = 3;
     646           0 :                 p_stmt->node_id = $5;
     647             :                 $$ = (Node*)p_stmt;
     648           0 :                 SetNodePos($$);
     649           0 :         }
     650           0 :         ;
     651           0 : 
     652             : /* shutdown database */
     653           0 : ShutdownStmt: SHUTDOWN 
     654             :          {
     655             :                 ShutdownStmt *p_stmt = makeNode(ShutdownStmt);
     656             :                 $$ = (Node*)p_stmt;
     657           0 :          }
     658           0 :          | SHUTDOWN RESTART
     659           0 :          {
     660           0 :                 ShutdownStmt *p_stmt = makeNode(ShutdownStmt);
     661           0 :                 p_stmt->b_restart = true;
     662           0 :                 $$ = (Node*)p_stmt;
     663           0 :          }
     664           0 :          | SHUTDOWN IMMEDIATE
     665             :          {
     666           0 :                 ShutdownStmt *p_stmt = makeNode(ShutdownStmt);
     667             :                 p_stmt->b_immediate = true;
     668             :                 $$ = (Node*)p_stmt;
     669           0 :          }
     670           0 :          | SHUTDOWN RESTART IMMEDIATE
     671           0 :          {
     672           0 :                 ShutdownStmt *p_stmt = makeNode(ShutdownStmt);
     673           0 :                 p_stmt->b_restart = true;
     674             :                 p_stmt->b_immediate = true;
     675           0 :                 $$ = (Node*)p_stmt;
     676             :          }
     677             :          ;
     678             : /* ++bysdc@20201003 */
     679             : CreateContextStmt: Cre_Rep _CONTXT name_space USING name_space
     680             :         {
     681             :                 CreateContextStmt *p_stmt = makeNode(CreateContextStmt);
     682             :                 p_stmt->cre_mode = $1;
     683             :                 p_stmt->ctx_name = $3;
     684           0 :                 p_stmt->pack_name = $5;
     685           0 :                 p_stmt->inited_mode = 0;
     686           0 :                 p_stmt->accessed_mode = 0;
     687           0 :                 $$ = (Node*)p_stmt;
     688           0 :                 SetNodePos($$);
     689           0 :         }
     690           0 :         ;
     691           0 : DropContextStmt: DROP _CONTXT name_space
     692             :         {
     693           0 :                 DropStmt *p_stmt = makeNode(DropStmt);
     694             :                 p_stmt->obj_name = $3;
     695          28 :                 p_stmt->drop_type = DROP_CONTEXT;
     696          28 :                 $$ = (Node*)p_stmt;
     697          28 :                 SetNodePos($$);
     698          28 :         }
     699          28 :         ;
     700          28 : //end
     701          28 : /*******************************************************************************
     702          28 : *
     703             : *  Package declare 
     704          28 : *
     705             : *********************************************************************************/
     706             : PackDecl: Cre_Rep PACKAGE name_space opt_authid opt_comment Is_As PackSpecs _END
     707             :          {
     708          28 :                 PackDecl *p_stmt = makeNode(PackDecl);
     709             :                 p_stmt->cre_mode = $1;
     710          28 :                 p_stmt->pack_name = $3;
     711             :                 p_stmt->def_list = $7;
     712         624 :                 p_stmt->auth_type = $4;
     713         624 :                 p_stmt->comments = $5;
     714             :                 $$ = (Node*)p_stmt;
     715           0 :                 SetNodePos($$);
     716             :          }
     717         624 :          | Cre_Rep PACKAGE name_space opt_authid  opt_comment Is_As PackSpecs _END name_space
     718             :          {
     719             :                 PackDecl *p_stmt = makeNode(PackDecl);
     720             :                 p_stmt->cre_mode = $1;
     721             :                 p_stmt->pack_name = $3;
     722         468 :                 p_stmt->def_list = $7;
     723             :                 p_stmt->auth_type = $4;
     724         468 :                 p_stmt->comments = $5;
     725             :                 $$ = (Node*)p_stmt;
     726             :                 SetNodePos($$);
     727           0 :          }
     728             :          ;
     729           0 : 
     730             : PackSpecs: PackSpecItem
     731           0 :         {
     732             :                 $$ = makeList1($1);
     733           0 :         }
     734             :         | PackSpecs PackSpecItem
     735             :         {
     736             :                 if($2)
     737             :                         $$ = lappend($1,$2);
     738        5870 :                 else
     739             :                         $$ = $1;
     740        5870 :         }
     741             :         ;
     742           4 : 
     743             : PackSpecItem: VarDef ';'
     744           4 :         | ProcDecl ';'
     745             :         {
     746             :                 $$ = $1;
     747             :         }
     748           0 :         ;
     749           0 :         pragmas: TokenId
     750           0 :         {
     751           0 :                 $$ = makeList1($1);
     752           0 :         }
     753           0 :         | pragmas ',' TokenId
     754             :         {
     755           0 :                 $$ = lappend($1,$3);
     756             :         }
     757             :         ;
     758             : 
     759             : 
     760             : opt_comment:    /*empty*/
     761             :         {
     762             :                 $$ = NULL;
     763             :         }
     764             :         |       COMMENT SCONST
     765             :         {
     766             :                 $$ = $2;
     767             :         }
     768             :         ;
     769          14 : 
     770          14 : DropPackStmt: DROP PACKAGE name_space alter_behavior
     771          14 :  {
     772          14 :         DropStmt *p_stmt = makeNode(DropStmt);
     773          14 :         p_stmt->obj_name = $3;
     774          14 :         p_stmt->drop_type = DROP_PACKAGE;
     775          14 :         p_stmt->behavior = ($4==CASCADE? OP_CASCADE : OP_RESTRICT);
     776             :         $$ = (Node*)p_stmt;
     777          14 :         SetNodePos($$);
     778             :   }
     779           0 :   ;
     780           0 :         
     781             : /************************************************************************
     782          14 : *
     783          14 : *       Package boby 
     784             : *
     785          14 : *************************************************************************/
     786             : PackBody: Cre_Rep PACKAGE BODY name_space 
     787             :                         Is_As optVarDefList 
     788             :                         PackMemberProcs 
     789          13 :                         opt_pack_inits 
     790             :                         OptExceptionStmt 
     791          13 :                         _END opt_name_space
     792             :         {
     793           1 :                 PackBody *p_stmt = makeNode(PackBody);
     794             :                 p_stmt->cre_mode = $1;
     795           1 :                 p_stmt->name = $4;
     796             :                 p_stmt->member_var_list = $6;
     797             :                 p_stmt->member_proc_list = $7;
     798             :                 p_stmt->init_stmt_list = $8;
     799          14 :                 p_stmt->exception_list = $9;
     800             : 
     801          14 :                 if($11!=NULL && (astrlen($4)<astrlen($11) || astricmp($4 + astrlen($4)-astrlen($11),$11)))
     802             :                 {
     803         324 :                         SetParsePos();
     804             :                         add_parse_error(575,$4,$11);
     805         324 :                 }
     806             :                 $$ = (Node*)p_stmt;     
     807             :                 SetNodePos($$);
     808             :         }
     809         130 :         ;
     810             :  
     811         130 :  opt_pack_inits:/*empty*/
     812             :          {
     813          14 :                 $$ = NIL;
     814             :          }
     815          14 :          | _BEGIN pl_stmt_list
     816             :          {
     817             :                 $$ = $2;
     818             :          }
     819             :         ;
     820             :   
     821             :  PackMemberProcs: ProcDef ';'
     822             :          {
     823             :                 $$ = makeList1($1);
     824             :          }
     825           0 :          | PackMemberProcs ProcDef ';'
     826           0 :          {
     827           0 :                 $$ = lappend($1,$2);
     828           0 :          }
     829           0 :          ;                
     830           0 :  
     831           0 :   opt_name_space: /*empty*/
     832           0 :           {
     833           0 :                 $$ = NULL;
     834           0 :           }
     835             :           | name_space
     836           0 :           {
     837             :                 $$ = $1;
     838             :           }
     839           0 :           ;
     840           0 :           
     841           0 : /**********************************************************************
     842           0 : *
     843           0 : *       User define data type
     844           0 : *
     845           0 : ************************************************************************/
     846           0 : ClassDeclStmt: Cre_Rep TYPE name_space  opt_authid Is_As OBJECT '(' member_decls ')'  
     847           0 :                                 opt_class_flags opt_comment
     848           0 :         {
     849           0 :                 UdtDecl *p_stmt = makeNode(UdtDecl);
     850             :                 p_stmt->cre_mode = $1;
     851           0 :                 p_stmt->udt_type = TYPE_OBJECT;
     852             :                 p_stmt->udt_name = $3;
     853           0 :                 p_stmt->def_list = $8;
     854           0 :                 p_stmt->flags = $10;
     855           0 :                 p_stmt->auth_type = $4;
     856           0 :                 p_stmt->comments = $11;
     857           0 :                 $$ = (Node*)p_stmt;
     858           0 :                 SetNodePos($$);
     859           0 :         }
     860           0 :         |  Cre_Rep TYPE name_space  opt_authid  UNDER name_space  '(' member_decls ')' 
     861           0 :            opt_class_flags opt_comment
     862           0 :         {
     863             :                 UdtDecl *p_stmt = makeNode(UdtDecl);
     864           0 :                 p_stmt->cre_mode = $1;
     865             :                 p_stmt->udt_type = TYPE_OBJECT;
     866           0 :                 p_stmt->udt_name = $3;
     867           0 :                 p_stmt->super_name = $6;
     868           0 :                 p_stmt->def_list = $8;
     869           0 :                 p_stmt->flags = $10;
     870           0 :                 p_stmt->auth_type = $4;
     871           0 :                 p_stmt->comments = $11;
     872           0 :                 $$ = (Node*)p_stmt;
     873           0 :                 SetNodePos($$);
     874           0 :         }
     875             :         |  Cre_Rep TYPE name_space  opt_authid Is_As VARRAY '(' ICONST ')' OF TypeName opt_comment
     876           0 :         {
     877             :                 UdtDecl *p_stmt = makeNode(UdtDecl);
     878             :                 p_stmt->cre_mode = $1;
     879             :                 p_stmt->udt_type = TYPE_VARRAY;
     880         828 :                 p_stmt->udt_name = $3;
     881             :                 p_stmt->varray_num = $8;
     882         828 :                 p_stmt->base_type= $11; 
     883             :                 p_stmt->auth_type = $4;
     884           0 :                 p_stmt->comments = $12;
     885             :                 $$ = (Node*)p_stmt;
     886           0 :                 SetNodePos($$);
     887             :         }
     888           6 :         |   Cre_Rep TYPE name_space  opt_authid Is_As TABLE OF TypeName opt_comment
     889           6 :         {
     890           0 :                 UdtDecl *p_stmt = makeNode(UdtDecl);
     891           0 :                 p_stmt->cre_mode = $1;
     892             :                 p_stmt->udt_type = TYPE_TABLE;
     893           0 :                 p_stmt->udt_name = $3;
     894             :                 p_stmt->base_type = $8; 
     895           6 :                 p_stmt->auth_type = $4;
     896             :                 p_stmt->comments = $9;
     897           0 :                 $$ = (Node*)p_stmt;
     898             :                 SetNodePos($$);
     899           0 :         }
     900             :         ;
     901             : 
     902             : opt_authid:     /**/
     903           0 :         {
     904             :                 $$ = 0;
     905           0 :         }
     906             :         | AUTHID DEFAULT
     907           0 :         {
     908             :                 $$ = 0;
     909           0 :         }
     910             :         | AUTHID ColId
     911             :         {
     912             :                 if(!astricmp($2,"CURRENT_USER"))
     913           0 :                         $$ = 2;
     914             :                 else if(!astricmp($2,"DEFINER"))
     915           0 :                         $$ = 1;
     916             :                 else
     917           0 :                         add_parse_error(987);
     918             :         }
     919           0 :         | AUTHID USER
     920             :         {
     921             :                 $$ = 2;
     922             :         }
     923          52 :         ;
     924          52 :         
     925          52 : member_decls: member_decl
     926          52 :         {
     927          52 :                 $$ = makeList1($1);
     928          52 :         }
     929          52 :         | member_decls ',' member_decl
     930             :         {
     931          52 :                 $$ = lappend($1,$3);
     932             :         }
     933           0 :         ;
     934           0 : 
     935           0 : member_decl:  MemberVarDecl
     936           0 :         {
     937           0 :                 $$ = $1;
     938           0 :         }
     939           0 :         | MemberFuncDecl
     940           0 :         {
     941             :                 $$ = $1;
     942           0 :         }
     943             :         ;
     944           0 :          
     945           0 : MemberVarDecl:  ColId opt_constant TypeName opt_not_null 
     946           0 :          {
     947           0 :                 VarDef *p_item = makeNode(VarDef);
     948           0 :                 p_item->var_name = $1;
     949           0 :                 p_item->is_constant = $2;
     950           0 :                 p_item->type_nam = (Typenam*)$3;
     951           0 :                 p_item->not_null = $4;
     952             :                 $$ = (Node*)p_item;
     953           0 :                 SetNodePos($$);
     954             :          }
     955             :          | ColId opt_constant TypeName opt_not_null DEFAULT b_expr 
     956             :          {
     957           0 :                 VarDef *p_item = makeNode(VarDef);
     958           0 :                 p_item->var_name = $1;
     959           0 :                 p_item->is_constant = $2;
     960             :                 p_item->type_nam = (Typenam*)$3;
     961           0 :                 p_item->not_null = $4;
     962             :                 p_item->def_val = $6;
     963           0 :                 $$ = (Node*)p_item;
     964           0 :                 SetNodePos($$);
     965           0 :          }
     966             :          | ColId opt_constant TypeName opt_not_null ASSIGN b_expr 
     967           0 :          {
     968             :                 VarDef *p_item = makeNode(VarDef);
     969           0 :                 p_item->var_name = $1;
     970           0 :                 p_item->is_constant = $2;
     971           0 :                 p_item->type_nam = (Typenam*)$3;
     972             :                 p_item->not_null = $4;
     973           0 :                 p_item->def_val = $6;
     974             :                 $$ = (Node*)p_item;
     975             :                 SetNodePos($$);
     976             :          }
     977           0 :          ;
     978             :   
     979           0 : MemberFuncDecl:  CONSTRUCTOR  ProcDecl
     980             :         {
     981           0 :                 ((ProcDecl*)$2)->scope = 1;
     982             :                 $$ = $2;                
     983           0 :                 SetNodePos($$);
     984             :         }
     985             :         | STATIC ProcDecl
     986           0 :         {
     987             :                 ((ProcDecl*)$2)->scope = 2;
     988           0 :                 $$ = $2;                
     989             :                 SetNodePos($$);
     990           0 :         }
     991             :         | MEMBER ProcDecl 
     992           0 :         {
     993             :                 ((ProcDecl*)$2)->scope = 4;
     994             :                 $$ = $2;                
     995           0 :                 SetNodePos($$);
     996             :         }
     997           0 :         ;
     998             : 
     999           0 : opt_class_flags: /**/
    1000             :         {
    1001           0 :                 $$ = 0;
    1002             :         } 
    1003           0 :         | class_flags
    1004             :         {
    1005           0 :                 $$ = $1;
    1006             :         } 
    1007           0 :         ;
    1008             :         class_flags: class_flag
    1009           0 :         {
    1010             :                 $$ = $1;
    1011             :         } 
    1012             :         | class_flags class_flag
    1013             :         {
    1014             :                 $$ = $1 | $2;
    1015             :         }
    1016             :         ;
    1017             :         class_flag: FINAL
    1018             :         {
    1019           0 :                 $$ = 1;
    1020           0 :         }
    1021           0 :         | NOT FINAL
    1022           0 :         {
    1023           0 :                 $$ = 0;
    1024           0 :         }
    1025             :         | INSTANTIABLE
    1026           0 :         {
    1027             :                 $$ = 0;
    1028             :         }
    1029             :         | NOT INSTANTIABLE
    1030           0 :         {
    1031             :                 $$ = 2;
    1032           0 :         }
    1033             :         ;
    1034           0 : 
    1035             : /*************************************************************************
    1036           0 : *
    1037             : *       UDT(User define Data type) body
    1038             : *
    1039             : **************************************************************************/
    1040           0 : ClassBodyDefStmt: Cre_Rep TYPE BODY name_space Is_As
    1041           0 :   MemberFuncDefs  _END opt_name_space
    1042           0 :         {
    1043             :                 UdtBody *p_stmt = makeNode(UdtBody);
    1044           0 :                 p_stmt->cre_mode = $1;
    1045             :                 p_stmt->udt_name = $4;
    1046           0 :                 p_stmt->member_procs = $6;
    1047           0 :                 $$ = (Node*)p_stmt;
    1048           0 :                 SetNodePos($$);
    1049             :         }
    1050           0 :         ;
    1051             : 
    1052           0 : MemberFuncDefs: MemberFuncDef ';'
    1053           0 :         {
    1054           0 :                 $$ = makeList1($1);
    1055             :         }
    1056           0 :         | MemberFuncDefs  MemberFuncDef ';'
    1057             :         {
    1058             :                 $$ = lappend($1,$2);
    1059             :         }
    1060           0 :         ;
    1061           0 : 
    1062           0 : MemberFuncDef: CONSTRUCTOR  ProcDef
    1063           0 :         {
    1064           0 :                 ((ProcDef*)$2)->scope = 1;
    1065           0 :                 $$ = $2;                
    1066             :                 SetNodePos($$);
    1067           0 :         }
    1068             :         | STATIC ProcDef
    1069             :         {
    1070             :                 ((ProcDef*)$2)->scope = 2;
    1071             :                 $$ = $2;                
    1072             :                 SetNodePos($$);
    1073             :         }
    1074           7 :         | MEMBER ProcDef 
    1075           7 :         {
    1076           7 :                 ((ProcDef*)$2)->scope = 4;
    1077           7 :                 $$ = $2;                
    1078           7 :                 SetNodePos($$);
    1079           7 :         }
    1080           7 :         ;
    1081           7 : 
    1082             : DropTypeStmt: DROP TYPE name_space alter_behavior
    1083           7 :  {
    1084             :         DropStmt *p_stmt = makeNode(DropStmt);
    1085             :         p_stmt->obj_name = $3;
    1086             :         p_stmt->drop_type = DROP_TYPE;
    1087           7 :         p_stmt->behavior = ($4==CASCADE? OP_CASCADE : OP_RESTRICT);
    1088             :         $$ = (Node*)p_stmt;
    1089           7 :         SetNodePos($$);
    1090             :   }
    1091           0 :   ;
    1092             :   
    1093           0 : /*******************************************************************************
    1094             : *       Create Domain...
    1095           0 : ********************************************************************************/ 
    1096             : CreateDomainStmt: CREATE opt_global _DOMAIN_ name_space  opt_as TypeName opt_domain_constraints opt_comment
    1097           0 :   {
    1098             :         CreateDomainStmt *n = makeNode(CreateDomainStmt);
    1099             :         n->is_global = $2;
    1100             :         n->domain_name = $4;
    1101           4 :         n->type_nam = (Typenam*)$6;
    1102           0 :         n->constraints = $7;
    1103             :         n->comment = $8;
    1104             :         $$ = (Node *)n;
    1105             :         SetNodePos($$);
    1106           3 :   }
    1107             :   ;
    1108           3 : 
    1109             : opt_global:     /*empty*/
    1110           4 :         {
    1111             :                 $$ = false;
    1112           4 :         }
    1113             :         | LOCAL
    1114             :         {
    1115             :                 $$ = false;
    1116           4 :         }
    1117             :         | GLOBAL
    1118           4 :         {
    1119             :                 $$ = true;
    1120           0 :         }
    1121             :         ;
    1122           0 :         
    1123             : opt_as: /*empty*/
    1124             :         | AS{}
    1125             :         | IS{}
    1126           0 :         ;
    1127           0 :         
    1128           0 : opt_domain_constraints: /*empty*/
    1129           0 :         {
    1130           0 :                 $$ = NIL;
    1131             :         }
    1132           0 :         | domain_constraints
    1133             :         {
    1134           0 :                 $$ = $1;
    1135           0 :         }
    1136           0 :         ;
    1137           0 :           
    1138           0 :   domain_constraints:  domain_constraint
    1139             :         {
    1140           0 :                 $$ = makeList1($1);
    1141             :         }
    1142           0 :         | domain_constraints domain_constraint
    1143           0 :         {
    1144           0 :                 $$ = lappend($1,$2);
    1145           0 :         }
    1146             :         ;
    1147           0 :   
    1148             :   domain_constraint: _NULL
    1149             :         {
    1150             :                 ConstraintDef *n = makeNode(ConstraintDef);
    1151           0 :                 n->contype = CONSTR_NULL;
    1152             :                 n->enable = true;
    1153           0 :                 $$ = (Node *)n;
    1154           0 :                 SetNodePos($$);
    1155           0 :         }
    1156           0 :         | NOT _NULL
    1157           0 :         {
    1158             :                 ConstraintDef *n = makeNode(ConstraintDef);
    1159           0 :                 n->contype = CONSTR_NOTNULL;
    1160             :                 n->enable = true;
    1161           4 :                 $$ = (Node *)n;
    1162           4 :                 SetNodePos($$);
    1163           4 :         }
    1164           4 :         | DEFAULT b_expr 
    1165           4 :         {
    1166           4 :                 ConstraintDef *n = makeNode(ConstraintDef);
    1167           4 :                 n->contype = CONSTR_DEFAULT;
    1168           4 :                 n->constr_name = (char*)NULL;
    1169           4 :                 if (exprIsNullConstant($2))
    1170             :                 {
    1171           4 :                         n->raw_expr = (Node*)NULL;
    1172             :                 }
    1173           0 :                 else
    1174           0 :                 {
    1175           0 :                         n->raw_expr = $2;
    1176           0 :                 }
    1177           0 :                 n->cooked_expr = (char*)NULL;
    1178           0 :                 n->keys = (List*)NULL;
    1179           0 :                 n->enable = true;
    1180           0 :                 $$ = (Node *)n;
    1181           0 :                 SetNodePos($$);
    1182             :         }
    1183           0 :         | CHECK '(' bool_expr ')'
    1184             :         {
    1185             :                  ConstraintDef *n = makeNode(ConstraintDef);
    1186             :                  n->contype = CONSTR_CHECK;
    1187             :                  n->constr_name = (char*)NULL;
    1188             :                  n->raw_expr = $3;
    1189             :                  n->cooked_expr = (char*)NULL;
    1190           0 :                  n->keys = (List*)NULL;
    1191           0 :                  n->enable = true;
    1192           0 :                  $$ = (Node *)n;
    1193           0 :                  SetNodePos($$);
    1194           0 :         }
    1195           0 :         | CONSTRAINT name CHECK '(' bool_expr ')'
    1196             :         {
    1197           0 :                  ConstraintDef *n = makeNode(ConstraintDef);
    1198             :                  n->contype = CONSTR_CHECK;
    1199           0 :                  n->constr_name = (char*)$2;
    1200           0 :                  n->raw_expr = $5;
    1201           0 :                  n->cooked_expr = (char*)NULL;
    1202           0 :                  n->keys = (List*)NULL;
    1203           0 :                  n->enable = true;
    1204             :                  $$ = (Node *)n;
    1205           0 :                  SetNodePos($$);
    1206             :         }
    1207           0 :         ; 
    1208           0 : 
    1209           0 : /*******************************************************************************
    1210           0 : *       Alter DOMAIN statement
    1211           0 : *******************************************************************************/ 
    1212             : AlterDomainStmt: ALTER _DOMAIN_ name_space  SET DEFAULT b_expr
    1213           0 :         {
    1214             :                 AlterDomainStmt *n = makeNode(AlterDomainStmt);
    1215           0 :                 n->alter_type = ADD_DOMAIN_DEF_VAL;
    1216           0 :                 n->domain_name = $3;
    1217           0 :                 n->def_val = $6;
    1218           0 :                 $$ = (Node *)n;
    1219           0 :                 SetNodePos($$);
    1220             :         }
    1221           0 :         | ALTER _DOMAIN_ name_space  DROP DEFAULT 
    1222             :         {
    1223           0 :                 AlterDomainStmt *n = makeNode(AlterDomainStmt);
    1224           0 :                 n->alter_type = DROP_DOMAIN_DEF_VAL;
    1225           0 :                 n->domain_name = $3;
    1226           0 :                 $$ = (Node *)n;
    1227           0 :                 SetNodePos($$);
    1228             :         }
    1229           0 :         | ALTER _DOMAIN_ name_space SET NOT _NULL
    1230             :         {
    1231           0 :                 AlterDomainStmt *n = makeNode(AlterDomainStmt);
    1232           0 :                 n->alter_type = SET_DOMAIN_NOTNULL;
    1233           0 :                 n->domain_name = $3;
    1234           0 :                 $$ = (Node *)n;
    1235           0 :                 SetNodePos($$);
    1236           0 :         }
    1237           0 :         | ALTER _DOMAIN_ name_space SET _NULL
    1238           0 :         {
    1239           0 :                 AlterDomainStmt *n = makeNode(AlterDomainStmt);
    1240           0 :                 n->alter_type = DROP_DOMAIN_NOTNULL;
    1241           0 :                 n->domain_name = $3;
    1242           0 :                 $$ = (Node *)n;
    1243           0 :                 SetNodePos($$);
    1244           0 :         }
    1245           0 :         | ALTER _DOMAIN_ name_space DROP NOT _NULL
    1246             :         {
    1247           0 :                 AlterDomainStmt *n = makeNode(AlterDomainStmt);
    1248             :                 n->alter_type = DROP_DOMAIN_NOTNULL;
    1249           0 :                 n->domain_name = $3;
    1250           0 :                 $$ = (Node *)n;
    1251           0 :                 SetNodePos($$);
    1252           0 :         }
    1253           0 :         | ALTER _DOMAIN_ name_space ADD CHECK '(' bool_expr ')' alter_behavior
    1254           0 :         {
    1255           0 :                  AlterDomainStmt *n = makeNode(AlterDomainStmt);
    1256           0 :                  ConstraintDef  *cons = makeNode(ConstraintDef);
    1257           0 :                  n->constraint = (Node*)cons;
    1258           0 :                  n->alter_type = ADD_DOMAIN_CONSTRAINT;
    1259           0 :                  n->domain_name = $3;
    1260           0 :                  n->constraint_name = NULL;
    1261           0 :                  n->alter_behavier = $9;
    1262           0 :                  cons->contype = CONSTR_CHECK;
    1263           0 :                  cons->constr_name = (char*)NULL;
    1264             :                  cons->raw_expr = $7;
    1265           0 :                  cons->cooked_expr = (char*)NULL;
    1266             :                  cons->keys = (List*)NULL;
    1267           0 :                  cons->enable = true;
    1268           0 :                  $$ = (Node *)n;
    1269           0 :                  SetNodePos($$);
    1270           0 :         }
    1271           0 :         | ALTER _DOMAIN_ name_space ADD CONSTRAINT name CHECK '(' bool_expr ')' alter_behavior
    1272           0 :         {
    1273           0 :                  AlterDomainStmt *n = makeNode(AlterDomainStmt);
    1274             :                  ConstraintDef  *cons = makeNode(ConstraintDef);
    1275           0 :                  n->constraint = (Node*)cons;
    1276             :                  n->alter_type = ADD_DOMAIN_CONSTRAINT;
    1277           0 :                  n->domain_name = $3;
    1278           0 :                  n->constraint_name = $6;
    1279           0 :                  n->alter_behavier = $11;
    1280           0 :                  cons->contype = CONSTR_CHECK;
    1281             :                  cons->constr_name = (char*)$6;
    1282           0 :                  cons->raw_expr = $9;
    1283             :                  cons->cooked_expr = (char*)NULL;
    1284             :                  cons->keys = (List*)NULL;
    1285             :                  cons->enable = true;
    1286             :                  $$ = (Node *)n;
    1287             :                  SetNodePos($$);
    1288             :         }
    1289             :         | ALTER _DOMAIN_ name_space DROP CONSTRAINT name alter_behavior
    1290             :         {
    1291           7 :                 AlterDomainStmt *n = makeNode(AlterDomainStmt);
    1292           7 :                 n->alter_type = DROP_DOMAIN_CONSTRAINT;
    1293           7 :                 n->domain_name = $3;
    1294           7 :                 n->constraint_name = $6;
    1295           7 :                 n->alter_behavier = $7;
    1296             :                 $$ = (Node *)n;
    1297           7 :                 SetNodePos($$);
    1298             :         }
    1299             :         | ALTER _DOMAIN_ name_space OWNER TO UserId
    1300             :         {
    1301             :                 AlterDomainStmt *n = makeNode(AlterDomainStmt);
    1302             :                 n->alter_type = SET_DOMAIN_OWNER;
    1303             :                 n->domain_name = $3;
    1304           0 :                 n->new_owner = $6;
    1305           0 :         }
    1306           0 :         ;
    1307           0 : 
    1308           0 : /*******************************************************************************
    1309           0 : *
    1310             : *       Drop DOMAIN statement
    1311           0 : *
    1312             : *******************************************************************************/        
    1313           0 : DropDomainStmt: DROP _DOMAIN_ name_space alter_behavior
    1314           0 :         {
    1315           0 :                 DropDomainStmt *n = makeNode(DropDomainStmt);
    1316           0 :                 n->domain_name = $3;
    1317           0 :                 n->drop_behavior = $4;
    1318           0 :                 $$ = (Node *)n;
    1319             :                 SetNodePos($$);
    1320           0 :         }
    1321             :         ;
    1322             :    
    1323             : /*******************************************************************************
    1324             : *       COMMENT statement
    1325             : *******************************************************************************/           
    1326             : CommentStmt: COMMENT ON obj_type name_space IS Sconst
    1327           0 :         {
    1328           0 :                 CommentStmt *n = makeNode(CommentStmt);
    1329           0 :                 n->objtype = $3;
    1330           0 :                 n->objname = $4;
    1331           0 :                 n->comment = $6;
    1332           0 :                 $$ = (Node *)n;
    1333             :                 SetNodePos($$); 
    1334           0 :         }
    1335             :         |       COMMENT ON COLUMN name_space IS Sconst
    1336           0 :         {
    1337           0 :                 CommentStmt *n = makeNode(CommentStmt);
    1338           0 :                 n->objtype = OBJ_TYPE_COL;
    1339           0 :                 n->objname = $4;
    1340           0 :                 n->comment = $6;
    1341             :                 $$ = (Node *)n;
    1342           0 :                 SetNodePos($$); 
    1343             :         }
    1344             :         ;
    1345             :    
    1346             : /*******************************************************************************
    1347             : *       Create procedure statement
    1348             : *******************************************************************************/
    1349             : CreProcedureStmt:       Cre_Rep ProcDef 
    1350             :  {
    1351         570 :         CreProcedureStmt *p_stmt = makeNode(CreProcedureStmt);
    1352         570 :         p_stmt->cre_mode = $1;
    1353         570 :         p_stmt->language = "PLSQL";
    1354         570 :         p_stmt->define = (ProcDef*)$2;
    1355         570 :         $$ = (Node*)p_stmt;
    1356         570 :         SetNodePos($$);
    1357         570 :  }
    1358             :  | ProcDef
    1359         570 :  {
    1360             :         CreProcedureStmt *p_stmt = makeNode(CreProcedureStmt);
    1361             :         p_stmt->language = "PLSQL";
    1362           0 :         p_stmt->define = (ProcDef*)$1;
    1363           0 :         $$ = (Node*)p_stmt;
    1364           0 :         SetNodePos($$);
    1365           0 :  }
    1366           0 :  ;
    1367           0 : 
    1368           0 : /*******************************************************************************
    1369           0 : *  Procedure(Function) declaration
    1370             : *******************************************************************************/
    1371           0 : 
    1372             : ProcDecl: FUNCTION name_space func_args
    1373         236 :                          RETURN TypeName opt_authid opt_proc_flags
    1374         236 :         {
    1375         236 :                 ProcDecl *p_decl =makeNode(ProcDecl);
    1376         236 :                 p_decl->func_name = $2;
    1377         236 :                 p_decl->fparam_list = $3;
    1378         236 :                 p_decl->ret_type = (Typenam*)$5;
    1379             :                 p_decl->auth_type = $6;
    1380         236 :                 $$ = (Node*)p_decl;
    1381             :                 SetNodePos($$);
    1382             :         }
    1383             :         | FUNCTION name_space func_args
    1384         793 :                                  RETURN SELF AS RESULT opt_authid opt_proc_flags
    1385             :         {
    1386         793 :                 ProcDecl *p_decl =makeNode(ProcDecl);
    1387             :                 p_decl->func_name = $2;
    1388           9 :                 p_decl->fparam_list = $3;
    1389             :                 p_decl->scope = 1;
    1390           9 :                 p_decl->ret_type = NULL;
    1391             :                 p_decl->auth_type = $8;
    1392           4 :                 $$ = (Node*)p_decl;
    1393             :                 SetNodePos($$); 
    1394           4 :         }
    1395             :         | PROCEDURE name_space func_args  opt_authid opt_proc_flags
    1396             :         {
    1397             :                 ProcDecl *p_decl =makeNode(ProcDecl);
    1398         793 :                 p_decl->func_name = $2;
    1399             :                 p_decl->fparam_list = $3;
    1400         793 :                 p_decl->auth_type = $4;
    1401             :                 $$ = (Node*)p_decl;     
    1402        1600 :                 SetNodePos($$);
    1403             :         }
    1404        1600 :         ; 
    1405             : 
    1406             : func_args:  '(' func_args_list ')'                      
    1407             :         { 
    1408         775 :                 $$ = $2; 
    1409         775 :         }
    1410         775 :         | '(' ')'                               
    1411         775 :         { 
    1412         775 :                 $$ = NIL; 
    1413         775 :         }
    1414             :         |
    1415         775 :         {
    1416             :                 $$ = NIL;
    1417        1451 :         }
    1418        1451 :         ;
    1419        1451 : 
    1420        1451 : func_args_list:  FuncArg
    1421        1451 :         {       
    1422        1451 :                 $$ = makeList1($1); 
    1423             :         }
    1424        1451 :         | func_args_list ',' FuncArg
    1425             :         {       
    1426           0 :                 $$ = lappend($1, $3); 
    1427           0 :         }
    1428           0 :         ;
    1429           0 : 
    1430           0 : FuncArg:  ColLabel in_out TypeName 
    1431           0 :         {
    1432           0 :                 FuncArg *p_arg = makeNode(FuncArg);
    1433             :                 p_arg->name = $1;
    1434           0 :                 p_arg->in_out = $2;
    1435             :                 p_arg->type_nam = (Typenam*)$3;
    1436           0 :                 $$ = (Node*)p_arg;
    1437           0 :                 SetNodePos($$);
    1438           0 :         }
    1439           0 :         | ColLabel TypeName 
    1440           0 :         {
    1441           0 :                 FuncArg *p_arg = makeNode(FuncArg);
    1442           0 :                 p_arg->name = $1;
    1443             :                 p_arg->in_out = 1;
    1444           0 :                 p_arg->type_nam = (Typenam*)$2;
    1445             :                 $$ = (Node*)p_arg;      
    1446         143 :                 SetNodePos($$);
    1447         143 :         }
    1448         143 :         | ColLabel in_out TypeName ASSIGN b_expr  
    1449         143 :         {
    1450         143 :                 FuncArg *p_arg = makeNode(FuncArg);
    1451         143 :                 p_arg->name = $1;
    1452         143 :                 p_arg->in_out = $2;
    1453             :                 p_arg->type_nam = (Typenam*)$3;
    1454         143 :                 p_arg->def_val = (A_Expr*)$5;
    1455             :                 $$ = (Node*)p_arg;
    1456          24 :                 SetNodePos($$);
    1457          24 :         }
    1458          24 :         | ColLabel TypeName ASSIGN b_expr
    1459          24 :         {
    1460          24 :                 FuncArg *p_arg = makeNode(FuncArg);
    1461          24 :                 p_arg->name = $1;
    1462          24 :                 p_arg->in_out = 1;
    1463             :                 p_arg->type_nam = (Typenam*)$2;
    1464          24 :                 p_arg->def_val = (A_Expr*)$4;
    1465             :                 $$ = (Node*)p_arg;      
    1466             :                 SetNodePos($$);
    1467             :         }
    1468         685 :         | ColLabel in_out TypeName DEFAULT b_expr  
    1469             :         {
    1470         685 :                 FuncArg *p_arg = makeNode(FuncArg);
    1471             :                 p_arg->name = $1;
    1472         204 :                 p_arg->in_out = $2;
    1473             :                 p_arg->type_nam = (Typenam*)$3;
    1474         204 :                 p_arg->def_val = (A_Expr*)$5;
    1475             :                 $$ = (Node*)p_arg;
    1476          29 :                 SetNodePos($$);
    1477             :         }
    1478          29 :         | ColLabel TypeName DEFAULT b_expr
    1479             :         {
    1480             :                 FuncArg *p_arg = makeNode(FuncArg);
    1481             :                 p_arg->name = $1;
    1482         806 :                 p_arg->in_out = 1;
    1483             :                 p_arg->type_nam = (Typenam*)$2;
    1484         806 :                 p_arg->def_val = (A_Expr*)$4;
    1485             :                 $$ = (Node*)p_arg;      
    1486           0 :                 SetNodePos($$);
    1487             :         }
    1488           0 :         ;
    1489             : 
    1490             : in_out:  _IN
    1491             :         {
    1492             :                 $$ = 1;
    1493             :         }
    1494             :         | _OUT
    1495             :         {
    1496             :                 $$ = 2;
    1497             :         }
    1498             :         | _IN _OUT
    1499             :         {
    1500             :                 $$ = 3;
    1501             :         }
    1502           0 :         ;
    1503           0 : 
    1504           0 :  opt_proc_flags: /*empty*/
    1505           0 :  {
    1506           0 :         $$ = 0;
    1507           0 :  }
    1508           0 :  | DETERMINISTIC 
    1509           0 :  {
    1510           0 :         $$ = 1;
    1511           0 :  }
    1512           0 :  ;
    1513           0 : /*******************************************************************************
    1514           0 : *
    1515             : *       procedure or function define
    1516           0 : *
    1517             : *******************************************************************************/
    1518             : ProcDef: ProcDecl  opt_comment
    1519             :           Is_As         LANGUAGE TokenId
    1520         208 :           NAME          ColId
    1521         208 :           LIBRARY       name_space
    1522         208 :           opt_with_context
    1523         208 :           PARAMETERS  '(' oci_parameters ')'
    1524         208 :                                 
    1525         208 :         {
    1526         208 :                 ProcDef *p_def = makeNode(ProcDef);
    1527         208 :                 p_def->comments = $2;
    1528         208 :                 p_def->language = $5;
    1529         208 :                 p_def->func_name = ((ProcDecl*)$1)->func_name;
    1530             :                 p_def->fparam_list = ((ProcDecl*)$1)->fparam_list;
    1531         208 :                 p_def->ret_type = ((ProcDecl*)$1)->ret_type;
    1532             :                 p_def->auth_type = ((ProcDecl*)$1)->auth_type;
    1533             :                 p_def->native_name = $7;
    1534         130 :                 p_def->library = $9;
    1535         130 :                 p_def->with_context = $10;
    1536         130 :                 p_def->oci_parameter = $13; 
    1537         130 :                 $$ = (Node*)p_def;
    1538             :                 SetNodePos($$);
    1539           0 :         }
    1540           0 :         | ProcDecl opt_comment
    1541             :                   Is_As         LANGUAGE TokenId
    1542         130 :                   NAME          ColId           
    1543         130 :         {
    1544         130 :                 ProcDef *p_def = makeNode(ProcDef);
    1545         130 :                 p_def->comments = $2;
    1546         130 :                 p_def->language = $5;
    1547         130 :                 p_def->func_name = ((ProcDecl*)$1)->func_name;
    1548         130 :                 p_def->fparam_list = ((ProcDecl*)$1)->fparam_list;
    1549         130 :                 p_def->ret_type = ((ProcDecl*)$1)->ret_type;
    1550         130 :                 p_def->auth_type = ((ProcDecl*)$1)->auth_type;
    1551         130 :                 p_def->native_name = $7;
    1552             :                 $$ = (Node*)p_def;
    1553         130 :                 SetNodePos($$);
    1554             :         }
    1555             :         | ProcDecl opt_comment Is_As optVarDefList StmtBlock opt_name_space
    1556             :         {
    1557           0 :                 ProcDef *p_def = makeNode(ProcDef);
    1558             :                 p_def->func_name = ((ProcDecl*)$1)->func_name;
    1559           0 :                 p_def->comments = $2;
    1560             :                 if( $6!=NULL && (astrlen(p_def->func_name)<astrlen($6) || astricmp(p_def->func_name+astrlen(p_def->func_name)-astrlen($6),$6)))
    1561           0 :                 {
    1562             :                         SetParsePos();
    1563           0 :                         add_parse_error(576,p_def->func_name,$6);
    1564             :                 }
    1565             :                 p_def->fparam_list = ((ProcDecl*)$1)->fparam_list;
    1566             :                 p_def->ret_type = ((ProcDecl*)$1)->ret_type;
    1567           0 :                 p_def->auth_type = ((ProcDecl*)$1)->auth_type;
    1568             :                 p_def->var_def_list = $4;
    1569           0 :                 p_def->stmt_list = ((StmtBlock*)$5)->stmt_list;
    1570             :                 p_def->sub_proc_list = ((StmtBlock*)$5)->sub_proc_list;
    1571           0 :                 p_def->exception_list = ((StmtBlock*)$5)->exception_list;
    1572             :                 ((StmtBlock*)$5)->exception_list = NIL;
    1573           0 :                 $$ = (Node*)p_def;              
    1574             :                 SetNodePos($$);
    1575             :         }
    1576             :         ;
    1577             : 
    1578           0 : opt_with_context:       /*empty*/
    1579           0 :         {
    1580           0 :                 $$ = false;
    1581           0 :         }
    1582           0 :         |  WITH _CONTXT
    1583           0 :         {
    1584             :                 $$ = true;      
    1585             :         }
    1586           0 :         ;
    1587             : 
    1588           0 : oci_parameters: oci_parameter
    1589           0 :         {
    1590           0 :                 $$ = makeList1($1);
    1591           0 :         }
    1592           0 :         | oci_parameters  ',' oci_parameter
    1593           0 :         {
    1594             :                 $$ = lappend($1,$3);
    1595           0 :         }
    1596             :         ;
    1597           0 : 
    1598           0 : oci_parameter:
    1599           0 :           _CONTXT
    1600           0 :         {
    1601           0 :                 OciArg *p_arg = makeNode(OciArg);
    1602           0 :                 p_arg->name = "CONTXT";
    1603             :                 p_arg->arg_type = OCI_CONTEXT;
    1604           0 :                 p_arg->type_nam = NULL;
    1605             :                 $$ = (Node*)p_arg;      
    1606           0 :                 SetNodePos($$);
    1607           0 : 
    1608           0 :         }   
    1609           0 :         | ColLabel TypeName 
    1610           0 :         {
    1611           0 :                 OciArg *p_arg = makeNode(OciArg);
    1612             :                 p_arg->name = $1;
    1613           0 :                 p_arg->arg_type = OCI_PARAMETER;
    1614             :                 p_arg->type_nam = (Typenam*)$2;
    1615             :                 $$ = (Node*)p_arg;      
    1616             :                 SetNodePos($$);
    1617             :         }
    1618           0 :         | ColLabel INDICATOR TypeName 
    1619           0 :         {
    1620           0 :                 OciArg *p_arg = makeNode(OciArg);
    1621           0 :                 p_arg->name = $1;
    1622           0 :                 p_arg->arg_type = OCI_INDICATOR;
    1623           0 :                 p_arg->type_nam = (Typenam*)$3;
    1624           0 :                 $$ = (Node*)p_arg;      
    1625             :                 SetNodePos($$);
    1626           0 :         }
    1627             :         | ColLabel LENGTH TypeName 
    1628           0 :         {
    1629           0 :                 OciArg *p_arg = makeNode(OciArg);
    1630           0 :                 p_arg->name = $1;
    1631           0 :                 p_arg->arg_type = OCI_LENGTH;
    1632           0 :                 p_arg->type_nam = (Typenam*)$3;
    1633           0 :                 $$ = (Node*)p_arg;      
    1634           0 :                 SetNodePos($$);
    1635             :         }
    1636           0 :         ;
    1637             : 
    1638           0 :   AnonyProcedure:
    1639           0 :    DECLARE  VarDefList  StmtBlock
    1640           0 :  {
    1641           0 :         ProcDef *p_def = makeNode(ProcDef);
    1642           0 :         p_def->var_def_list = $2;
    1643           0 :         p_def->stmt_list = ((StmtBlock *)$3)->stmt_list;
    1644             :         p_def->exception_list = ((StmtBlock *)$3)->exception_list;
    1645           0 :         ((StmtBlock *)$3)->exception_list = NIL;
    1646             :         $$ = (Node*)p_def;
    1647             :         SetNodePos($$);
    1648             :  }
    1649             :  |   DECLARE  StmtBlock
    1650             :  {
    1651             :         ProcDef *p_def = makeNode(ProcDef);
    1652             :         p_def->var_def_list = NIL;
    1653             :         p_def->stmt_list = ((StmtBlock *)$2)->stmt_list;
    1654           0 :         p_def->exception_list = ((StmtBlock *)$2)->exception_list;
    1655           0 :         ((StmtBlock *)$2)->exception_list = NIL;
    1656           0 :         $$ = (Node*)p_def;
    1657           0 :         SetNodePos($$);
    1658           0 :  }
    1659           0 :  | StmtBlock
    1660             :  {
    1661           0 :         ProcDef *p_def = makeNode(ProcDef);
    1662             :         p_def->stmt_list = ((StmtBlock *)$1)->stmt_list;
    1663           0 :         p_def->exception_list = ((StmtBlock *)$1)->exception_list;
    1664           0 :         ((StmtBlock *)$1)->exception_list = NIL;
    1665           0 :         $$ = (Node*)p_def;
    1666           0 :         SetNodePos($$);
    1667           0 :  }
    1668           0 :  ;
    1669             : 
    1670           0 : /*******************************************************************************
    1671             : *
    1672             : *       drop procedure or function
    1673             : *
    1674             : *******************************************************************************/
    1675             : DropProcedureStmt: DROP PROCEDURE name_space alter_behavior
    1676             :         {
    1677         131 :                 DropStmt *p_stmt = makeNode(DropStmt);
    1678         131 :                 p_stmt->obj_name = $3;
    1679         131 :                 p_stmt->drop_type = DROP_PROCEDURE;
    1680         131 :                 p_stmt->behavior = ($4==CASCADE? OP_CASCADE : OP_RESTRICT);
    1681         131 :                 $$ = (Node*)p_stmt;
    1682             :                 SetNodePos($$);
    1683         131 :         }
    1684             :         |  DROP FUNCTION name_space alter_behavior
    1685             :         {
    1686             :                 DropStmt *p_stmt = makeNode(DropStmt);
    1687             :                 p_stmt->obj_name = $3;
    1688         145 :                 p_stmt->drop_type = DROP_PROCEDURE;
    1689             :                 p_stmt->behavior = ($4==CASCADE? OP_CASCADE : OP_RESTRICT);
    1690         145 :                 $$ = (Node*)p_stmt;
    1691             :                 SetNodePos($$);
    1692           0 :         }
    1693             :         ;
    1694           0 : 
    1695             : /**************************************************************************************
    1696           0 : *               sql block
    1697           0 : ***************************************************************************************/
    1698           0 : StmtBlock:  _BEGIN pl_stmt_list OptExceptionStmt _END 
    1699           0 :         {
    1700             :                 StmtBlock *p_body = makeNode(StmtBlock);
    1701           0 :                 p_body->stmt_list = $2;
    1702             :                 p_body->exception_list = $3;
    1703             :                 $$ = (Node*)p_body;
    1704             :                 SetNodePos($$);
    1705           0 :         }
    1706             :         ;   
    1707           0 : 
    1708             : /* exception sql define */
    1709           0 : OptExceptionStmt: /*empty*/
    1710             :         {
    1711           0 :                 $$ = NULL;
    1712             :         }
    1713             :         | EXCEPTION Exceptions
    1714           0 :         {
    1715           0 :                 $$ = $2;
    1716           0 :         }
    1717           0 :         |       EXCEPTION  Exceptions FINALLY  pl_stmt_list 
    1718           0 :         {
    1719             :                 Exception_Item *p_item = makeNode(Exception_Item);
    1720           0 :                 p_item->err_name = NULL;
    1721             :                 p_item->stmt_list = $4;
    1722           0 :                 $$ = lappend($2,p_item);
    1723           0 :         }
    1724           0 :         ;
    1725           0 : 
    1726           0 : Exceptions: Exception_Item
    1727             :  {
    1728           0 :         $$ = makeList1($1);
    1729             :  }
    1730             :  | Exceptions Exception_Item
    1731             :  {
    1732             :         $$ = lappend($1,$2);
    1733             :  }
    1734             :  ;
    1735             : Exception_Item: WHEN ColId THEN  pl_stmt_list 
    1736             :  {
    1737          46 :         Exception_Item *p_item = makeNode(Exception_Item);
    1738             :         p_item->err_name = $2;
    1739          46 :         p_item->stmt_list = $4;
    1740             :         $$ = (Node*)p_item;
    1741           0 :         SetNodePos($$);
    1742             :  }
    1743           0 :  | WHEN ICONST THEN  pl_stmt_list 
    1744             :  {
    1745          98 :         Exception_Item *p_item = makeNode(Exception_Item);
    1746             :         p_item->err_code = $2;
    1747          98 :         p_item->stmt_list = $4;
    1748             :         $$ = (Node*)p_item;
    1749             :         SetNodePos($$);
    1750             :  }
    1751          46 :  ;
    1752          46 : 
    1753             : /*****************************************************************************
    1754           0 : *
    1755             : *       var define
    1756          46 : *
    1757             : ******************************************************************************/
    1758          47 : optVarDefList:  VarDefList 
    1759          47 :  {
    1760           0 :         $$ = $1;
    1761           0 :  }
    1762           0 :  | DECLARE VarDefList
    1763           0 :  {
    1764           0 :         $$ = $2;
    1765           0 :  }
    1766             :  | /*empty*/
    1767          47 :  {
    1768             :         $$ = NIL;
    1769             :  }
    1770             :  ;
    1771             : 
    1772           0 :  VarDefList: VarDef ';'
    1773           0 :  {
    1774           0 :         if($1)  
    1775           0 :                 $$ = makeList1($1);
    1776           0 :         else 
    1777             :                 $$ = NIL;
    1778           0 :  }
    1779             :  | VarDefList  VarDef ';' 
    1780           0 :  {
    1781           0 :     if($1 && $2)
    1782           0 :                 $$ = lappend($1,$2);
    1783           0 :         else if($1==NIL && $2==NULL)
    1784           0 :                 $$ = NIL;
    1785             :         else if($1==NIL)
    1786           0 :                 $$ = makeList1($2);
    1787             :         else if($2==NULL)
    1788             :                 $$ = $1;
    1789             :  }
    1790             :  ;
    1791          24 : 
    1792          24 : /* exception num define */
    1793          24 : ExceptionDef:  TokenId EXCEPTION 
    1794          24 :  {
    1795          24 :         ExceptionDef    *p_stmt = makeNode(ExceptionDef);
    1796          24 :         p_stmt->exception_name = $1;
    1797             :         p_stmt->exception_no = -1;   /*-1:define by compiler , used in current function*/
    1798          24 :         $$ = (Node*)p_stmt;
    1799             :         SetNodePos($$);
    1800             :  };
    1801           0 :  | TokenId EXCEPTION integer 
    1802          24 :  {
    1803             :         ExceptionDef    *p_stmt = makeNode(ExceptionDef);
    1804             :         p_stmt->exception_name = $1;
    1805             :         p_stmt->exception_no = ABS($3) ;     //bywsy@20210121 feature170
    1806          63 :         $$ = (Node*)p_stmt;
    1807          63 :         SetNodePos($$);
    1808          63 :  };
    1809          63 :  
    1810          63 :  /*define type*/
    1811          63 :  TypeDefStmt:
    1812          63 :         TYPE_SUBTYPE  ColId IS  TypeName opt_not_null
    1813             :         {
    1814          63 :                 TypeDef *p_node = makeNode(TypeDef);
    1815             :                 p_node->type_name = $2;
    1816           0 :                 p_node->base_type = (Typenam*)$4;
    1817           0 :                 p_node->not_null = $5;
    1818           0 :                 $$ = (Node*)p_node;
    1819           0 :                 SetNodePos($$);
    1820           0 :         }
    1821           0 :         ;
    1822           0 :         
    1823           0 :         TYPE_SUBTYPE: TYPE{}
    1824             :         | SUBTYPE {};
    1825           0 :         
    1826             :  /*define single var*/
    1827         190 :  VarDef:  TokenId opt_constant TypeName opt_not_null 
    1828         190 :  {
    1829         190 :         VarDef *p_item = makeNode(VarDef);
    1830         190 :         p_item->var_name = $1;
    1831         190 :         p_item->is_constant = $2;
    1832         190 :         p_item->type_nam = (Typenam*)$3;
    1833         190 :         p_item->not_null = $4;
    1834         190 :         $$ = (Node*)p_item;
    1835             :         SetNodePos($$);
    1836         190 :  }
    1837             :  | TokenId opt_constant TypeName opt_not_null DEFAULT b_expr 
    1838             :  {
    1839             :         VarDef *p_item = makeNode(VarDef);
    1840             :         p_item->var_name = $1;
    1841           0 :         p_item->is_constant = $2;
    1842           0 :         p_item->type_nam = (Typenam*)$3;
    1843           0 :         p_item->not_null = $4;
    1844           0 :         p_item->def_val = $6;
    1845             :         $$ = (Node*)p_item;
    1846           0 :         SetNodePos($$);
    1847           0 :  }
    1848           0 :  | TokenId opt_constant TypeName opt_not_null ASSIGN opt_default b_expr 
    1849           0 :  {
    1850             :         VarDef *p_item = makeNode(VarDef);
    1851           0 :         p_item->var_name = $1;
    1852             :         p_item->is_constant = $2;
    1853           0 :         p_item->type_nam = (Typenam*)$3;
    1854           0 :         p_item->not_null = $4;
    1855           0 :         p_item->def_val = $7;
    1856           0 :         $$ = (Node*)p_item;
    1857             :         SetNodePos($$);
    1858           0 :  }
    1859             :  | CursorDef 
    1860           0 :  | ExceptionDef 
    1861           0 :  | TypeDefStmt
    1862           0 :  | PRAGMA EXCEPTION_INIT '(' TokenId ',' integer ')'//bywsy@202210128 feature170 add
    1863           0 :  {
    1864           0 :         Pragma *n = makeNode(Pragma);
    1865             :         Exception_Item *p_item = makeNode(Exception_Item);
    1866           0 :         p_item->err_name = $4;
    1867             :         p_item->err_code = ABS($6);
    1868             : 
    1869             :         n->name = $2;
    1870             :         n->args = makeList1(p_item);
    1871           0 :         $$ = (Node*)n;
    1872           0 :         SetNodePos($$);
    1873           0 :  }
    1874           0 :  | PRAGMA TokenId
    1875           0 :  {
    1876           0 :         Pragma *n = makeNode(Pragma);
    1877           0 :         n->name = $2;
    1878           0 :         $$ = (Node*)n;
    1879           0 :         SetNodePos($$);
    1880             :  }
    1881           0 :  |  PRAGMA TokenId '(' pragmas ')'
    1882             :  {
    1883             :         Pragma *n = makeNode(Pragma);
    1884         287 :         n->name = $2;
    1885             :         n->args = $4;
    1886         287 :         $$ = (Node*)n;
    1887             :         SetNodePos($$);
    1888          18 :  }
    1889             :  ;
    1890          18 : 
    1891             : /*define cursor */
    1892             : CursorDef: CURSOR name func_args Is_As SelectStmt parallel_opt opt_wait
    1893             :  {
    1894         329 :         CursorDef *p_def = makeNode(CursorDef);
    1895             :         p_def->var_name = $2;
    1896         329 :         p_def->args = $3;
    1897             :         p_def->cur_type = CUR_INSENSITIVE;
    1898           0 :         ((SelectStmt*)$5)->parallel = $6;
    1899             :         ((SelectStmt*)$5)->wait_ms = $7;
    1900           0 :         p_def->define = (SelectStmt*)$5;
    1901             :         $$ = (Node*)p_def;
    1902             :         SetNodePos($$);
    1903             :  };
    1904           0 : 
    1905             : opt_constant:
    1906             :         {
    1907             :                 $$ = false;
    1908             :         } 
    1909             :         | CONSTANT
    1910             :         {
    1911             :                 $$ = true;
    1912         201 :         }
    1913             :         ;
    1914         201 : 
    1915             : opt_not_null:
    1916         288 :         {
    1917             :                 $$ = false;
    1918         288 :         } 
    1919             :         | NOT _NULL
    1920             :         {
    1921             :                 $$ = true;
    1922             :         }
    1923             :         ;
    1924             : 
    1925         489 : opt_default:
    1926             :         | DEFAULT {}
    1927         489 :         ;
    1928             : 
    1929           0 : 
    1930           0 : /**********************************************************************
    1931           0 : *  PL SQL sets
    1932           0 : **********************************************************************/
    1933           0 : pl_stmt_list: pl_stmt_line 
    1934             :         {
    1935           0 :                 $$ = makeList1($1);
    1936             :         }
    1937           0 :         | pl_stmt_list pl_stmt_line
    1938           0 :         {
    1939           0 :                 $$ = lappend($1,$2);
    1940           0 :         }
    1941           0 :         ;
    1942             : 
    1943           0 : /**********************************************************************
    1944             : *  PL SQL line
    1945             : **********************************************************************/
    1946             : pl_stmt_line: pl_stmt
    1947             :  {
    1948             :         $$ = $1;
    1949             :  }
    1950         137 :  | '<'  '<' ColId '>' '>' pl_stmt
    1951         137 :  {
    1952         137 :         LabelStmt *p_label = makeNode(LabelStmt);
    1953         137 :         p_label->label = $3;
    1954         137 :         p_label->stmt = $6; 
    1955             :         $$ = (Node*)p_label;
    1956         137 :         SetNodePos($$);
    1957             :  }
    1958           0 :  |  ColId ':' pl_stmt
    1959           0 :  {
    1960           0 :         LabelStmt *p_label = makeNode(LabelStmt);
    1961           0 :         p_label->label = $1;
    1962           0 :         p_label->stmt = $3;
    1963             :         $$ = (Node*)p_label; 
    1964           0 :         SetNodePos($$);
    1965             :  }
    1966             :  ;
    1967             :  
    1968           7 :  /**********************************************************************
    1969           7 : *  assign sql
    1970           7 : ***********************************************************************/
    1971           7 : VarAssign: ident ASSIGN b_expr ';'
    1972           7 :  {
    1973           7 :         VarAssign *p_assign = makeNode(VarAssign);
    1974           7 :         p_assign->var = (Ident*)$1;
    1975             :         p_assign->value = $3;
    1976           7 :         $$ = (Node*)p_assign;
    1977             :         SetNodePos($$);
    1978          31 :  }
    1979          31 :  | SET ident  '=' b_expr ';'
    1980          31 :  {
    1981          31 :         VarAssign *p_assign = makeNode(VarAssign);
    1982          31 :         p_assign->var = (Ident*)$2;
    1983             :         p_assign->value = $4;
    1984          31 :         $$ = (Node*)p_assign;
    1985             :         SetNodePos($$);
    1986           3 :  }
    1987           3 :  ;                      
    1988           3 : 
    1989           3 : IfElseStmt: IF bool_expr THEN pl_stmt_list ELSE pl_stmt_list EndIf ';'
    1990           3 :  {
    1991           3 :         IfElseStmt *p_if = makeNode(IfElseStmt);
    1992             :         p_if->t_cond = $2;
    1993           3 :         p_if->t_stmt_list = $4;
    1994             :         p_if->elsif_list = NIL;
    1995           1 :         p_if->f_stmt_list = $6;
    1996           1 :         $$ = (Node*)p_if;
    1997           1 :         SetNodePos($$);
    1998           1 :  }
    1999           1 :  | IF bool_expr THEN pl_stmt_list EndIf ';'
    2000           1 :  {
    2001           1 :         IfElseStmt *p_if = makeNode(IfElseStmt);
    2002             :         p_if->t_cond = $2;
    2003           1 :         p_if->t_stmt_list = $4;
    2004             :         $$ = (Node*)p_if;
    2005             :         SetNodePos($$);
    2006          32 :  }
    2007          10 :  | IF bool_expr THEN pl_stmt_list Else_list EndIf ';'
    2008           0 :  {
    2009           0 :         IfElseStmt *p_if = makeNode(IfElseStmt);
    2010             :         p_if->t_cond = $2;
    2011             :         p_if->t_stmt_list = $4;
    2012             :         p_if->elsif_list = $5;
    2013           4 :         $$ = (Node*)p_if;
    2014             :         SetNodePos($$);
    2015           4 :   }
    2016             :  | IF bool_expr THEN pl_stmt_list Else_list ELSE pl_stmt_list EndIf ';'
    2017           5 :  {
    2018             :         IfElseStmt *p_if = makeNode(IfElseStmt);
    2019           5 :         p_if->t_cond = $2;
    2020             :         p_if->t_stmt_list = $4;
    2021             :         p_if->elsif_list = $5;
    2022             :         p_if->f_stmt_list = $7;
    2023           9 :         $$ = (Node*)p_if;
    2024           9 :         SetNodePos($$);
    2025           9 :  }
    2026           9 :  ;
    2027           9 :  
    2028             : EndIf: _END IF {}
    2029           9 :         | ENDIF {}
    2030             :         |_END IF name_space {}
    2031             :         | ENDIF  name_space {}
    2032             :         ;
    2033           2 : 
    2034           2 :  Else_list: ElsIfItem
    2035           2 :  {
    2036           2 :         $$ = makeList1($1);
    2037           2 :  }
    2038             :  | Else_list ElsIfItem
    2039           2 :  {
    2040             :         $$ = lappend($1,$2);
    2041           0 :  }
    2042           0 :  ;
    2043           0 : 
    2044           0 :  ElsIfItem: ELSIF bool_expr THEN pl_stmt_list
    2045           0 :  {
    2046             :         ElsIfItem *p_item = makeNode(ElsIfItem);
    2047           0 :         p_item->cond = $2;
    2048             :         p_item->stmt_list = $4;
    2049           0 :         $$ = (Node*)p_item;
    2050           0 :         SetNodePos($$);
    2051           0 :  }
    2052           0 :  ;
    2053             :  
    2054           0 :  LoopStmt: WHILE bool_expr LOOP pl_stmt_list EndLoop ';'
    2055             :  {
    2056             :         LoopStmt *p_loop = makeNode(LoopStmt);
    2057           2 :         p_loop->cond = $2;
    2058           0 :         p_loop->stmt_list = $4;
    2059           0 :         $$ = (Node*)p_loop;
    2060           0 :         SetNodePos($$);
    2061             :  } 
    2062             :  | WHERE bool_expr LOOP pl_stmt_list EndLoop ';'
    2063             :  {
    2064           5 :         LoopStmt *p_loop = makeNode(LoopStmt);
    2065           5 :         p_loop->cond = $2;
    2066           5 :         p_loop->stmt_list = $4;
    2067           5 :         $$ = (Node*)p_loop;
    2068           5 :         SetNodePos($$);
    2069           5 :  }
    2070           5 :  | LOOP pl_stmt_list EndLoop ';'
    2071             :  {
    2072           5 :         LoopStmt *p_loop = makeNode(LoopStmt);
    2073             :         p_loop->stmt_list = $2;
    2074           0 :         $$ = (Node*)p_loop;     
    2075           0 :         SetNodePos($$);
    2076           0 :  }
    2077           0 :  ;
    2078           0 :  
    2079           0 : EndLoop:_END LOOP {}
    2080           0 :         |       ENDLOOP {}
    2081           0 :         |  ENDLOOP name_space {}
    2082             :         | _END LOOP name_space {}
    2083           0 :         ;
    2084             : 
    2085           0 : ForStmt: FOR ColId _IN b_expr TWO_DOT   b_expr LOOP pl_stmt_list EndFor ';'
    2086           0 :  {
    2087             :         ForStmt *p_for = makeNode(ForStmt);
    2088           0 :         p_for->var_name = $2;
    2089           0 :         p_for->from_val = $4;
    2090             :         p_for->to_val = $6;
    2091           0 :         p_for->stmt_list = $8;
    2092             :         $$ = (Node*)p_for;
    2093           0 :         SetNodePos($$);
    2094             :  }
    2095           0 :  | FOR ColId _IN REVERSE b_expr TWO_DOT  b_expr LOOP pl_stmt_list EndFor ';' 
    2096           0 :  {
    2097             :         ForStmt *p_for = makeNode(ForStmt);
    2098           0 :         p_for->var_name = $2;
    2099             :         p_for->from_val = $5;
    2100           0 :         p_for->to_val = $7;
    2101           0 :         p_for->b_reverse = true;
    2102           0 :         p_for->stmt_list = $9;
    2103           0 :         $$ = (Node*)p_for;
    2104             :         SetNodePos($$);
    2105           0 :  }
    2106             :  | FOR ColId _IN  ident LOOP pl_stmt_list EndFor ';'
    2107             :  { 
    2108           3 :         ForStmt *p_for = makeNode(ForStmt);
    2109           3 :         Ident   *p_ident = ((Ident*)$4);
    2110           3 :         
    2111           3 :         p_for->var_name = $2;
    2112           3 :         p_for->b_use_cursor = true;
    2113           3 : 
    2114             :         if(p_ident->child)
    2115           3 :         {
    2116             :                 if(p_ident->child->ident_t != IDENT_FUNC)
    2117           0 :                 {
    2118           0 :                         SetSrcPos(p_ident);
    2119           0 :                         add_parse_error(577);
    2120           0 :                 }
    2121             :                 p_for->cursor_paras = p_ident->child->args;
    2122           0 :         }
    2123             :         p_for->cursor_name = p_ident->name;       
    2124             :         p_for->stmt_list = $6;
    2125           8 :         $$ = (Node*)p_for;
    2126           0 :         SetNodePos($$);
    2127           0 :  }
    2128           0 :  
    2129           0 :  | FOR ColId _IN select_with_parens LOOP pl_stmt_list EndFor ';'
    2130           0 :  {
    2131           0 :         ForStmt *p_for = makeNode(ForStmt);
    2132           0 :         p_for->var_name = $2;
    2133             :         p_for->sel_stmt = (SelectStmt*)$4;
    2134             :         p_for->stmt_list = $6;
    2135             :         $$ = (Node*)p_for;
    2136           0 :         SetNodePos($$);
    2137           0 :  }
    2138           0 :  | FOR error LOOP pl_stmt_list EndFor ';'
    2139           0 :  {
    2140           0 :         ForStmt *p_for = makeNode(ForStmt);
    2141           0 :         p_for->stmt_list = $4;
    2142           0 :         $$ = (Node*)p_for;
    2143             :         SetNodePos($$);
    2144           0 :  }
    2145             :  ;
    2146             :  
    2147           0 :  EndFor: _END FOR {}
    2148           0 :  | ENDFOR {}
    2149           0 :  | _END LOOP {}
    2150           0 :  | ENDLOOP {}
    2151           0 :  | _END FOR  name_space {} 
    2152           0 :  | ENDFOR name_space {}
    2153           0 :  | _END LOOP name_space {}
    2154           0 :  | ENDLOOP name_space {}
    2155             :  ;
    2156           0 :  
    2157             :  ForallStmt: FORALL  ColId _IN b_expr TWO_DOT  b_expr dml_stmt1  ';'
    2158             :  {
    2159           0 :         ForallStmt *p_stmt = makeNode(ForallStmt);
    2160           0 :         p_stmt->var_name = $2;
    2161           0 :         p_stmt->from_val = $4;
    2162           0 :         p_stmt->to_val = $6;
    2163           0 :         p_stmt->dml_stmt = $7;
    2164           0 :         $$ = (Node*)p_stmt;
    2165             :         SetNodePos($$);
    2166           0 :  }
    2167             :  | FORALL ColId _IN INDICES OF ident
    2168           0 :    BETWEEN b_expr AND b_expr dml_stmt1 ';'
    2169           0 :  {
    2170           0 :         ForallStmt *p_stmt = makeNode(ForallStmt);
    2171           0 :         p_stmt->var_name = $2;
    2172           0 :         p_stmt->idx_ident = (Ident*)$6;
    2173           0 :         p_stmt->from_val = $8;
    2174             :         p_stmt->to_val = $10;
    2175           0 :         p_stmt->dml_stmt = $11;
    2176             :         $$ = (Node*)p_stmt;
    2177             :         SetNodePos($$);
    2178             :  }
    2179             :   | FORALL ColId _IN INDICES OF ident
    2180             :     dml_stmt1 ';'
    2181             :  {
    2182             :         ForallStmt *p_stmt = makeNode(ForallStmt);
    2183             :         p_stmt->var_name = $2;
    2184             :         p_stmt->idx_ident = (Ident*)$6;
    2185           0 :         p_stmt->dml_stmt = $7;
    2186           0 :         $$ = (Node*)p_stmt;
    2187           0 :         SetNodePos($$);
    2188           0 :  }
    2189             :  |  FORALL ColId _IN VALUES OF ident dml_stmt1 ';'
    2190           0 :  {
    2191             :         ForallStmt *p_stmt = makeNode(ForallStmt);
    2192           0 :         p_stmt->var_name = $2;
    2193           0 :         p_stmt->value_of = (Ident*)$6;
    2194           0 :         p_stmt->dml_stmt = $7;
    2195           0 :         $$ = (Node*)p_stmt;
    2196           0 :         SetNodePos($$);
    2197             :  }
    2198           0 :  ; 
    2199             : 
    2200           0 : dml_stmt1: UpdateStmt
    2201           0 :         | InsertStmt
    2202           0 :         | DeleteStmt
    2203           0 :         | ExecuteStmt
    2204             :         ;
    2205           0 : 
    2206             :  ThrowStmt:THROW EXCEPTION ColId  ';'
    2207           0 :  {
    2208           0 :         ThrowStmt *p_stmt = makeNode(ThrowStmt);
    2209           0 :         p_stmt->exception_name = $3;
    2210           0 :         $$ = (Node*)p_stmt;
    2211           0 :         SetNodePos($$);
    2212             :  }
    2213           0 :  | THROW EXCEPTION ColId  b_expr ';'
    2214             :  {
    2215           0 :         ThrowStmt *p_stmt = makeNode(ThrowStmt);
    2216           0 :         p_stmt->exception_name = $3;
    2217           0 :         p_stmt->msg_expr = $4;
    2218           0 :         $$ = (Node*)p_stmt;
    2219             :         SetNodePos($$);
    2220           0 :  }
    2221             :  | THROW ColId  ';'
    2222           0 :  {
    2223           0 :         ThrowStmt *p_stmt = makeNode(ThrowStmt);
    2224           0 :         p_stmt->exception_name= $2;
    2225           0 :         $$ = (Node*)p_stmt;
    2226           0 :         SetNodePos($$);
    2227             :  }
    2228           0 :  | THROW ColId b_expr ';'
    2229             :  {
    2230           0 :         ThrowStmt *p_stmt = makeNode(ThrowStmt);
    2231           0 :         p_stmt->exception_name= $2;
    2232           0 :         p_stmt->msg_expr = $3;
    2233           0 :         $$ = (Node*)p_stmt;
    2234             :         SetNodePos($$);
    2235           0 :  }
    2236             :  | RAISE EXCEPTION ColId  ';'
    2237           0 :  {
    2238           0 :         ThrowStmt *p_stmt = makeNode(ThrowStmt);
    2239           0 :         p_stmt->exception_name = $3;
    2240           0 :         $$ = (Node*)p_stmt;
    2241           0 :         SetNodePos($$);
    2242             :  }
    2243           0 :  |  RAISE EXCEPTION ColId b_expr ';'
    2244             :  {
    2245           0 :         ThrowStmt *p_stmt = makeNode(ThrowStmt);
    2246           0 :         p_stmt->exception_name = $3;
    2247           0 :         p_stmt->msg_expr = $4;
    2248           0 :         $$ = (Node*)p_stmt;
    2249             :         SetNodePos($$);
    2250           0 :  }
    2251             :  | RAISE ColId  ';'
    2252             :  {
    2253             :         ThrowStmt *p_stmt = makeNode(ThrowStmt);
    2254           0 :         p_stmt->exception_name= $2;
    2255           0 :         $$ = (Node*)p_stmt;
    2256           0 :         SetNodePos($$);
    2257           0 :  }
    2258           0 :  | RAISE ColId b_expr ';'
    2259             :  {
    2260           0 :         ThrowStmt *p_stmt = makeNode(ThrowStmt);
    2261             :         p_stmt->exception_name= $2;
    2262           0 :         p_stmt->msg_expr = $3;
    2263           0 :         $$ = (Node*)p_stmt;
    2264           0 :         SetNodePos($$);
    2265           0 :  }
    2266           0 :  | RAISE ';'
    2267           0 :  {
    2268             :         ThrowStmt *p_stmt = makeNode(ThrowStmt);
    2269           0 :         p_stmt->exception_name= NULL;
    2270             :         $$ = (Node*)p_stmt;
    2271             :         SetNodePos($$);
    2272           0 :  }
    2273           0 :  ;
    2274             :  
    2275             :  CaseStmt:  CASE case_arg When_list EndCase  ';'
    2276             :  {
    2277           0 :         CaseStmt *p_stmt = makeNode(CaseStmt);
    2278             :         p_stmt->case_arg = $2;
    2279           0 :         p_stmt->when_list = $3;
    2280             :         $$ = (Node*)p_stmt;
    2281           0 :         SetNodePos($$);
    2282             :  }
    2283           0 :  | CASE case_arg When_list ELSE pl_stmt_list EndCase  ';'
    2284             :  {
    2285             :         CaseStmt *p_stmt = makeNode(CaseStmt);
    2286             :         p_stmt->case_arg = $2;
    2287           0 :         p_stmt->when_list = $3;
    2288           0 :         p_stmt->def_stmt_list = $5;
    2289           0 :         $$ = (Node*)p_stmt;
    2290           0 :         SetNodePos($$);
    2291           0 :  }
    2292             :  ;      
    2293           0 : 
    2294             : EndCase:_END CASE {}
    2295             :         | ENDCASE {}
    2296             :         ;
    2297           0 :  
    2298           0 :  When_list: When_item
    2299           0 :  {
    2300           0 :         $$ = makeList1($1);
    2301             :  }
    2302           0 :  | When_list When_item
    2303             :  {
    2304             :         $$ = lappend($1,$2);
    2305           1 :  }
    2306           1 :  ;
    2307           1 :  
    2308             :  When_item: WHEN bool_expr THEN pl_stmt_list
    2309           1 :  {
    2310             :         When_item *p_item = makeNode(When_item);
    2311           0 :         p_item->cond = $2;
    2312           0 :         p_item->stmt_list = $4;
    2313           0 :         $$ = (Node*)p_item;
    2314           0 :         SetNodePos($$);
    2315             :  }
    2316           0 :  ;
    2317             :   
    2318           0 :  GotoStmt: GOTO ColId  ';'
    2319           0 :  {
    2320           0 :         GotoStmt *p_goto = makeNode(GotoStmt);
    2321           0 :         p_goto->label = $2;
    2322             :         $$ = (Node*)p_goto;
    2323           0 :         SetNodePos($$);
    2324             :  };
    2325           0 : 
    2326           0 :  BreakStmt:  EXIT  ';'
    2327           0 :  {
    2328           0 :         BreakStmt *p_stmt = makeNode(BreakStmt);
    2329           0 :         $$ = (Node*)p_stmt;
    2330             :         SetNodePos($$);
    2331           0 :  }
    2332             :  | EXIT ColId  ';'
    2333           0 :  {
    2334           0 :         BreakStmt *p_stmt = makeNode(BreakStmt);
    2335           0 :         p_stmt->label = $2;
    2336             :         $$ = (Node*)p_stmt;
    2337           0 :         SetNodePos($$);
    2338             :  }
    2339           0 :  | EXIT WHEN bool_expr  ';'
    2340           0 :  {
    2341           0 :         BreakStmt *p_stmt = makeNode(BreakStmt);
    2342           0 :         p_stmt->cond = $3;
    2343             :         $$ = (Node*)p_stmt;
    2344           0 :         SetNodePos($$);
    2345             :  }
    2346           0 :  | EXIT ColId WHEN bool_expr  ';'
    2347           0 :  {
    2348           0 :         BreakStmt *p_stmt = makeNode(BreakStmt);
    2349           0 :         p_stmt->label = $2;
    2350             :         p_stmt->cond = $4;
    2351           0 :         $$ = (Node*)p_stmt;
    2352             :         SetNodePos($$);
    2353           0 :  }
    2354           0 :  | LEAVE  ';'
    2355           0 :  {
    2356           0 :         BreakStmt *p_stmt = makeNode(BreakStmt);
    2357           0 :         $$ = (Node*)p_stmt;
    2358             :         SetNodePos($$);
    2359           0 :  }
    2360             :  | LEAVE ColId  ';'
    2361             :  {
    2362             :         BreakStmt *p_stmt = makeNode(BreakStmt);
    2363           1 :         p_stmt->label = $2;
    2364           1 :         $$ = (Node*)p_stmt;
    2365           1 :         SetNodePos($$);
    2366             :  }
    2367           1 :  | LEAVE WHEN bool_expr  ';'
    2368             :  {
    2369           0 :         BreakStmt *p_stmt = makeNode(BreakStmt);
    2370           0 :         p_stmt->cond = $3;
    2371           0 :         $$ = (Node*)p_stmt;
    2372           0 :         SetNodePos($$);
    2373             :  }
    2374           0 :  | LEAVE ColId WHEN bool_expr  ';'
    2375             :  {
    2376             :         BreakStmt *p_stmt = makeNode(BreakStmt);
    2377             :         p_stmt->label = $2;
    2378           0 :         p_stmt->cond = $4;
    2379           0 :         $$ = (Node*)p_stmt;
    2380           0 :         SetNodePos($$);
    2381             :  }
    2382           0 :  ;
    2383             : 
    2384         116 :  ContinueStmt: CONTINUE  ';'
    2385         116 :  {
    2386         116 :         ContinueStmt *p_stmt = makeNode(ContinueStmt);
    2387         116 :         $$ = (Node*)p_stmt;
    2388             :         SetNodePos($$);
    2389         116 :  }
    2390             :  | CONTINUE ColId  ';'
    2391             :  {
    2392             :         ContinueStmt *p_stmt = makeNode(ContinueStmt);
    2393       12674 :         p_stmt->label = $2;
    2394       12674 :         $$ = (Node*)p_stmt;     
    2395       12674 :         SetNodePos($$);
    2396       12674 :  };
    2397             : 
    2398       12674 :  ReturnStmt: 
    2399             :         RETURN   ';'
    2400           0 :  {
    2401           0 :         ReturnStmt *p_stmt = makeNode(ReturnStmt);
    2402           0 :         $$ = (Node*)p_stmt;
    2403           0 :         SetNodePos($$);
    2404           0 :  }
    2405             :  | RETURN  b_expr ';'   // b_expr  ';'
    2406           0 :  {
    2407             :         ReturnStmt *p_stmt = makeNode(ReturnStmt);
    2408           0 :         p_stmt->p_val = $2;
    2409           0 :         $$ = (Node*)p_stmt;
    2410           0 :         SetNodePos($$);
    2411           0 :  }
    2412           0 :  ;
    2413           0 : 
    2414             : CallPrepareStmt: '?' ColLabel 
    2415           0 :  {
    2416             :         ExePrepareStmt  *p_stmt = makeNode(ExePrepareStmt);
    2417           0 :         p_stmt->name = $2;
    2418           0 :         $$ = (Node*)p_stmt;
    2419           0 :         SetNodePos($$);
    2420           0 :  }
    2421           0 :  | '?' ColLabel '(' expr_list ')'  
    2422           0 :  {
    2423             :         ExePrepareStmt  *p_stmt = makeNode(ExePrepareStmt);
    2424           0 :         p_stmt->name = $2;
    2425             :         p_stmt->params = $4;
    2426             :         $$ = (Node*)p_stmt;
    2427             :         SetNodePos($$);
    2428         175 :  }
    2429         175 :  | '?' ColLabel AS CURSOR name RETURN ICONST
    2430         175 :  {
    2431         175 :         ExePrepareStmt  *p_stmt = makeNode(ExePrepareStmt);
    2432             :         p_stmt->name = $2;
    2433             :         p_stmt->cursor_name = $5;
    2434         175 :         p_stmt->fetch_num = $7;
    2435             :         $$ = (Node*)p_stmt;
    2436           0 :         SetNodePos($$);
    2437           0 :  }
    2438           0 :   | '?' ColLabel AS CURSOR name
    2439           0 :  {
    2440           0 :         ExePrepareStmt  *p_stmt = makeNode(ExePrepareStmt);
    2441           0 :         p_stmt->name = $2;
    2442           0 :         p_stmt->cursor_name = $5;
    2443             :         p_stmt->fetch_num = 0x7fffffff;//default=MAX(INT)
    2444           0 :         $$ = (Node*)p_stmt;
    2445             :         SetNodePos($$);
    2446           0 :  }
    2447           0 :  ;
    2448           0 :  
    2449           0 :  ExecuteStmt:  ident 
    2450           0 :  {
    2451           0 :         ExecuteStmt     *p_stmt = makeNode(ExecuteStmt);
    2452           0 :         p_stmt->p_ident = (Ident*)$1;
    2453             :         $$ = (Node*)p_stmt;
    2454           0 :         SetNodePos($$);
    2455             :    
    2456           0 :  }
    2457           0 :  | _CALL func_name
    2458           0 :  {
    2459           0 :         ExecuteStmt     *p_stmt = makeNode(ExecuteStmt);
    2460           0 :         Ident  *p_ident = makeNode(Ident);
    2461           0 :         p_ident->name = $2;
    2462           0 :         p_stmt->p_ident = p_ident;
    2463           0 :         p_stmt->limit_num = -1;
    2464           0 :         $$ = (Node*)p_stmt;
    2465           0 :         SetNodePos($$);
    2466           0 :  }
    2467             :  | EXECUTE func_name   
    2468           0 :  {
    2469             :         ExecuteStmt     *p_stmt = makeNode(ExecuteStmt);
    2470           0 :         Ident  *p_ident = makeNode(Ident);
    2471           0 :         p_ident->name = $2;
    2472           0 :         p_stmt->p_ident = p_ident;
    2473           0 :         p_stmt->limit_num = -1;
    2474           0 :         $$ = (Node*)p_stmt;
    2475           0 :         SetNodePos($$);
    2476           0 :  }
    2477           0 :  |  EXECUTE func_name '(' func_params ')'  
    2478           0 :  {
    2479           0 :         ExecuteStmt     *p_stmt = makeNode(ExecuteStmt);
    2480           0 :         Ident  *p_ident1 = makeNode(Ident);
    2481             :         Ident  *p_ident2 = makeNode(Ident);
    2482           0 :         p_ident1->name = $2;
    2483             :         p_ident2->args = $4;
    2484           1 :         p_ident2->ident_t = IDENT_FUNC;
    2485           1 :         set_ident_child(p_ident1,p_ident2);
    2486           1 :         p_stmt->p_ident = p_ident1;
    2487           1 :         p_stmt->limit_num = -1;
    2488           1 :         $$ = (Node*)p_stmt;
    2489           1 :         SetNodePos($$);
    2490           1 :  }
    2491           1 :  |  _CALL func_name '(' func_params ')'  
    2492             :  {
    2493           1 :         ExecuteStmt     *p_stmt = makeNode(ExecuteStmt);
    2494             :         Ident  *p_ident1 = makeNode(Ident);
    2495           0 :         Ident  *p_ident2 = makeNode(Ident);
    2496           0 :         p_ident1->name = $2;
    2497           0 :         p_ident2->args = $4;
    2498           0 :         p_ident2->ident_t = IDENT_FUNC;
    2499           0 :         set_ident_child(p_ident1,p_ident2);
    2500           0 :         p_stmt->p_ident = p_ident1;
    2501           0 :         p_stmt->limit_num = -1;
    2502           0 :         $$ = (Node*)p_stmt;
    2503             :         SetNodePos($$);
    2504           0 :  }
    2505             :  | EXECUTE IMMEDIATE b_expr opt_using opt_return opt_into_list opt_limit 
    2506             :  {
    2507             :         ExecuteStmt     *p_stmt = makeNode(ExecuteStmt);
    2508           1 :         p_stmt->sql_expr = $3;
    2509             :         p_stmt->param_list = $4;
    2510           1 :         p_stmt->is_bulk = $5;
    2511             :         p_stmt->into_list = $6;
    2512           0 :         p_stmt->limit_num = $7;
    2513             :         $$ = (Node*)p_stmt;
    2514           0 :         SetNodePos($$);
    2515             :  }
    2516           0 :  | _CALL IMMEDIATE b_expr opt_using opt_return opt_into_list opt_limit 
    2517             :  {
    2518           0 :         ExecuteStmt     *p_stmt = makeNode(ExecuteStmt);
    2519             :         p_stmt->sql_expr = $3;
    2520           0 :         p_stmt->param_list = $4;
    2521             :         p_stmt->is_bulk = $5;
    2522           0 :         p_stmt->into_list = $6;
    2523             :         p_stmt->limit_num = $7;
    2524             :         $$ = (Node*)p_stmt;
    2525             :         SetNodePos($$);
    2526           1 :  }
    2527             :  ;
    2528           1 :  
    2529             : opt_return: /*empty*/
    2530           0 :         {
    2531             :                 $$ = false;
    2532           0 :         }
    2533             :         | RETURNING
    2534             :         {
    2535           1 :         $$ = false;     
    2536             :         }
    2537           1 :         | BULK COLLECT
    2538             :         {
    2539           0 :                 $$ = true;
    2540             :         }
    2541           0 :         | RETURNING BULK COLLECT
    2542             :         {
    2543             :                 $$ = true;
    2544             :         }
    2545           1 :         ;
    2546             :         
    2547           1 :  opt_limit: /*empty*/
    2548             :  {
    2549           0 :         $$ = 0;
    2550             :  }
    2551           0 :  | LIMIT ICONST
    2552             :  {
    2553             :         $$ = $2;
    2554             :  }
    2555         961 :  ;
    2556             :  opt_using: /*empty*/
    2557         961 :  {
    2558             :         $$ = NIL;
    2559        1067 :  } 
    2560             :  |      USING  expr_list
    2561           0 :  {
    2562           0 :         $$ = $2;
    2563             :  }
    2564        1067 :  ;
    2565             :  
    2566        1067 :  ident_list: ident
    2567             :  {
    2568           0 :         $$ = makeList1($1);
    2569             :  }
    2570           0 :  | ident_list ',' ident
    2571             :  {
    2572             :         $$ = lappend($1,$3);
    2573             :  }
    2574        2028 :  ;
    2575             :         
    2576        2028 :  func_params: RParam
    2577             :  {
    2578           0 :         $$ = makeList1($1);
    2579           0 :  }
    2580           0 :  | func_params ',' RParam
    2581           0 :  {
    2582             :         if($1==NIL)
    2583           0 :         {
    2584             :                 SetParsePos();
    2585             :                 add_parse_error(578);
    2586             :         }
    2587             :         $$ = lappend($1,$3);
    2588           0 :  }
    2589           0 :  |/*empty*/
    2590           0 :  {
    2591             :         $$ = NIL;
    2592           0 :  }
    2593             :  ;
    2594             : 
    2595             :  RParam: b_expr
    2596             :  {
    2597           0 :         $$ = $1;
    2598           0 :  }
    2599           0 :  | name '=' '>' b_expr
    2600           0 :  {
    2601             :         RParam *p_func_para = makeNode(RParam);
    2602           0 :         p_func_para->param_name = $1;
    2603             :         p_func_para->value = $4;
    2604           0 :         $$ = (Node*)p_func_para;
    2605           0 :  }
    2606           0 :  ;
    2607             : 
    2608           0 : /*disassemble sql*/
    2609             : DisassembleStmt: DISASSEMBLE name_space 
    2610           0 :         {
    2611           0 :                 DisassembleStmt *p_stmt = makeNode(DisassembleStmt);
    2612           0 :                 p_stmt->name_space = $2;
    2613             :                 $$ = (Node*)p_stmt;
    2614           0 :         }
    2615             :         ;
    2616           0 : 
    2617           0 : /*procedure or function debug sql*/
    2618           0 : TraceStmt:  TRACE SESSION  ICONST  
    2619             :  {
    2620           0 :         TraceStmt       *p_stmt = makeNode(TraceStmt);
    2621             :         p_stmt->cmd = TRACE_BIND;
    2622           0 :         p_stmt->session_id = $3;
    2623           0 :         $$ = (Node*)p_stmt;
    2624           0 :  }
    2625             :  | TRACE STEP
    2626           0 :  {
    2627             :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2628           0 :         p_stmt->cmd = TRACE_STEP;
    2629           0 :         $$ = (Node*)p_stmt;
    2630           0 :  }
    2631             :  | TRACE NEXT
    2632           0 :  {
    2633             :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2634           0 :         p_stmt->cmd = TRACE_NEXT;
    2635           0 :         $$ = (Node*)p_stmt;
    2636           0 :  }
    2637             :  | TRACE _OUT 
    2638           0 :  {
    2639             :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2640           0 :         p_stmt->cmd = TRACE_OUT;
    2641           0 :         $$ = (Node*)p_stmt;
    2642           0 :  }
    2643           0 :  | TRACE _OUT BREAK
    2644           0 :  {
    2645             :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2646           0 :         p_stmt->cmd = TRACE_OUT_BRK;
    2647             :         $$ = (Node*)p_stmt;
    2648           0 :  }
    2649           0 :  | TRACE RUN
    2650           0 :  {
    2651           0 :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2652           0 :         p_stmt->cmd = TRACE_RUN;
    2653             :         $$ = (Node*)p_stmt;
    2654           0 :  }
    2655             :  | TRACE RUN BREAK
    2656           0 :  {
    2657           0 :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2658           0 :         p_stmt->cmd = TRACE_RUN_BRK;
    2659             :         $$ = (Node*)p_stmt;
    2660           0 :  }
    2661             :  | TRACE RUN TO ICONST OF name_space
    2662           0 :  {
    2663           0 :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2664           0 :         p_stmt->cmd = TRACE_RUN_TO;
    2665             :         p_stmt->obj_name = $6;
    2666           0 :         p_stmt->src_pos = $4<<16;
    2667             :         $$ = (Node*)p_stmt;
    2668             :  }
    2669           0 :  | TRACE RUN TO ICONST ':' ICONST OF name_space
    2670           0 :  {
    2671           0 :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2672             :         p_stmt->cmd = TRACE_RUN_TO;
    2673           0 :         p_stmt->obj_name = $8;
    2674             :         p_stmt->src_pos = ($4<<16)+$6;
    2675           0 :         $$ = (Node*)p_stmt;
    2676           0 :  }
    2677           0 :  | TRACE BREAK
    2678             :  {
    2679           0 :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2680             :         p_stmt->cmd = TRACE_BRK;
    2681           0 :         $$ = (Node*)p_stmt;
    2682           0 :  }
    2683           0 :  | TRACE CONTINUE
    2684             :  {
    2685           0 :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2686             :         p_stmt->cmd = TRACE_CONTINUE;
    2687           0 :         $$ = (Node*)p_stmt;
    2688           0 :  }
    2689           0 :  /*why 2020-10-10 add 'begin and end' branch for create or destroy tracer strucate*/
    2690           0 :  | TRACE _BEGIN
    2691           0 :  {
    2692             :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2693           0 :         p_stmt->cmd = TRACE_BEGIN;
    2694             :         $$ = (Node*)p_stmt;
    2695           0 :  }
    2696           0 :  | TRACE _END
    2697           0 :  {
    2698           0 :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2699           0 :         p_stmt->cmd = TRACE_END;
    2700             :         $$ = (Node*)p_stmt;
    2701           0 :  }//end
    2702             :  | TRACE STOP
    2703           0 :  {
    2704           0 :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2705           0 :         p_stmt->cmd = TRACE_STOP;
    2706           0 :         $$ = (Node*)p_stmt;
    2707           0 :  }
    2708             :  | TRACE ADD BREAK ICONST OF name_space
    2709           0 :  {
    2710             :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2711           0 :         p_stmt->cmd = TRACE_ADD_BRK;
    2712           0 :         p_stmt->obj_name = $6;
    2713           0 :         p_stmt->src_pos = $4<<16;
    2714           0 :         $$ = (Node*)p_stmt;
    2715           0 :  }
    2716             :  | TRACE ADD BREAK ICONST ':' ICONST OF name_space
    2717           0 :  {
    2718             :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2719           0 :         p_stmt->cmd = TRACE_ADD_BRK;
    2720           0 :         p_stmt->obj_name = $8;
    2721           0 :         p_stmt->src_pos = ($4<<16)+$6;
    2722           0 :         $$ = (Node*)p_stmt;
    2723           0 :  }
    2724             :  | TRACE DROP BREAK ICONST OF name_space
    2725           0 :  {
    2726             :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2727             :         p_stmt->cmd = TRACE_DROP_BRK;
    2728           0 :         p_stmt->obj_name = $6;
    2729           0 :         p_stmt->src_pos = $4<<16;      
    2730           0 :         $$ = (Node*)p_stmt;
    2731           0 :  }
    2732             :  | TRACE DROP BREAK ICONST ':' ICONST OF name_space
    2733           0 :  {
    2734             :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2735             :         p_stmt->cmd = TRACE_DROP_BRK;
    2736             :         p_stmt->obj_name = $8;
    2737           0 :         p_stmt->src_pos = ($4<<16)+$6;
    2738             :         $$ = (Node*)p_stmt;
    2739           0 :  }
    2740             :  | TRACE SET ident TO AexprConst
    2741           0 :  {
    2742             :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2743           0 :         p_stmt->cmd = TRACE_SET;
    2744             :         p_stmt->var = (Ident*)$3;
    2745             :         p_stmt->value = $5;  
    2746             :         $$ = (Node*)p_stmt;
    2747             :  }
    2748             :  /*get infomation of vars*/
    2749             :  | TRACE GET watch_list
    2750             :  {
    2751           0 :         TraceStmt *p_stmt = makeNode(TraceStmt);
    2752           0 :         p_stmt->cmd = TRACE_GET;
    2753           0 :         p_stmt->watch_list = $3;
    2754           0 :         $$ = (Node*)p_stmt;
    2755           0 :  }
    2756           0 :  ;
    2757           0 : /*watch var list*/
    2758           0 : watch_list: b_expr
    2759             :         {
    2760           0 :                 $$ = makeList1($1);
    2761             :         }
    2762           0 :         |watch_list ',' b_expr
    2763           0 :         {
    2764           0 :                 $$ = lappend($1,$3);
    2765           0 :         }
    2766           0 :         ;
    2767           0 :  
    2768           0 : /**********************************************************
    2769           0 : *backup database or data
    2770           0 : *add opt_encryptor bysdc@20210310 feature-backup_encrypt
    2771             : ***********************************************************/
    2772           0 : BackupStmt:  EXPORT  DATABASE  opt_trans_range opt_encryptor opt_compress parallel_opt
    2773             :         {
    2774             :                 BackupStmt *p_stmt = makeNode(BackupStmt);
    2775           0 :                 p_stmt->backup_type = EXPORT_DB;
    2776           0 :                 p_stmt->min_trans_id = ((TransRange*)$3)->min_trans_id;
    2777           0 :                 p_stmt->max_trans_id = ((TransRange*)$3)->max_trans_id;
    2778           0 :                 p_stmt->encrypt_key = $4;
    2779           0 :                 p_stmt->compress_mode = $5;
    2780             :                 p_stmt->parallel = $6;
    2781           0 :                 $$ = (Node*)p_stmt;     
    2782           0 :         }       
    2783             :         | EXPORT TABLE  name_space  opt_trans_range  opt_encryptor opt_compress parallel_opt
    2784           0 :         {
    2785           0 :                 BackupStmt *p_stmt = makeNode(BackupStmt);
    2786           0 :                 p_stmt->backup_type = EXPORT_TABLE;
    2787             :                 p_stmt->name = $3;
    2788           0 :                 p_stmt->min_trans_id = ((TransRange*)$4)->min_trans_id;
    2789           0 :                 p_stmt->max_trans_id = ((TransRange*)$4)->max_trans_id;
    2790           0 :                 p_stmt->encrypt_key = $5;
    2791             :                 p_stmt->compress_mode = $6;
    2792           0 :                 p_stmt->parallel = $7;
    2793             :                 $$ = (Node*)p_stmt;     
    2794             :         }
    2795           0 :         /* add by sdc@20170527 */
    2796           0 :         | BACKUP SYSTEM opt_increment opt_path opt_online opt_encryptor opt_compress parallel_opt
    2797           0 :         {
    2798           0 :                 BackupStmt *p_stmt = makeNode(BackupStmt);
    2799           0 :                 p_stmt->backup_type = BACKUP_SYS;
    2800           0 :                 if($3)
    2801           0 :                         p_stmt->is_increment = $3;
    2802           0 :                 if($4)
    2803           0 :                 {
    2804           0 :                         p_stmt->is_append = ((BackupPath*)$4)->is_append;
    2805             :                         p_stmt->path = ((BackupPath*)$4)->path;
    2806           0 :                 }
    2807             :                 p_stmt->online = $5;
    2808           0 :                 p_stmt->encrypt_key = $6;
    2809           0 :                 p_stmt->compress_mode = $7;
    2810           0 :                 
    2811           0 :                 if($8)
    2812           0 :                         p_stmt->parallel = $8;
    2813           0 :                 $$ = (Node*)p_stmt;
    2814           0 :         }
    2815             :         | BACKUP  DATABASE opt_increment opt_path       opt_encryptor opt_compress parallel_opt
    2816           0 :         {
    2817             :                 BackupStmt *p_stmt = makeNode(BackupStmt);
    2818           0 :                 p_stmt->backup_type = BACKUP_DB;
    2819           0 :                 if($3)
    2820           0 :                         p_stmt->is_increment = $3;
    2821           0 :                 p_stmt->is_append = ((BackupPath*)$4)->is_append;
    2822           0 :                 p_stmt->path = ((BackupPath*)$4)->path;
    2823           0 :                 p_stmt->encrypt_key = $5;
    2824           0 :                 p_stmt->compress_mode = $6;
    2825             :                 p_stmt->parallel = $7;
    2826           0 :                 $$ = (Node*)p_stmt;     
    2827             :         }
    2828           0 :         | BACKUP USER   name_space opt_path opt_encryptor opt_compress
    2829           0 :         {
    2830           0 :                 BackupStmt *p_stmt  = makeNode(BackupStmt);
    2831           0 :                 p_stmt->backup_type = BACKUP_USER;
    2832           0 :                 p_stmt->name        = $3;
    2833           0 :                 p_stmt->path        = ((BackupPath*)$4)->path;
    2834           0 :                 p_stmt->encrypt_key = $5;
    2835           0 :                 p_stmt->compress_mode = $6;
    2836             :                 $$ = (Node*)p_stmt;     
    2837           0 :         }
    2838             :         | BACKUP SCHEMA name_space opt_path opt_encryptor opt_compress 
    2839             :         {
    2840             :                 BackupStmt *p_stmt  = makeNode(BackupStmt);
    2841           0 :                 p_stmt->backup_type = BACKUP_SCHEMA;
    2842           0 :                 p_stmt->name        = $3;
    2843           0 :                 p_stmt->path        = ((BackupPath*)$4)->path;
    2844           0 :                 p_stmt->encrypt_key = $5;
    2845             :                 p_stmt->compress_mode = $6;
    2846           0 :                 $$ = (Node*)p_stmt;     
    2847             :         }
    2848           0 :         | BACKUP TABLE  name_space opt_path opt_encryptor opt_compress
    2849           0 :         {
    2850           0 :                 BackupStmt *p_stmt  = makeNode(BackupStmt);
    2851           0 :                 p_stmt->backup_type = BACKUP_TABLE;
    2852             :                 p_stmt->name        = $3;
    2853           0 :                 p_stmt->is_append   = ((BackupPath*)$4)->is_append;
    2854             :                 p_stmt->path        = ((BackupPath*)$4)->path;
    2855           0 :                 p_stmt->encrypt_key = $5;
    2856           0 :                 p_stmt->compress_mode = $6;
    2857           0 :                 $$ = (Node*)p_stmt;     
    2858           0 :         }/* end add by sdc@20170527 */
    2859             :         ;
    2860           0 :                                                 
    2861             : opt_trans_range: /*empty*/
    2862           0 :         {
    2863           0 :                 TransRange *p_range = New(TransRange);
    2864           0 :                 p_range->min_trans_id = 0;
    2865           0 :                 p_range->max_trans_id = 0xffffffffffffffffULL;
    2866             :                 $$ = p_range;   
    2867           0 :         }
    2868             :         |       TRANSACTION BETWEEN ICONST AND ICONST 
    2869           0 :         {
    2870           0 :                 TransRange *p_range = New(TransRange);
    2871           0 :                 p_range->min_trans_id = (TRANID)$3;
    2872           0 :                 p_range->max_trans_id = (TRANID)$5;          
    2873             :                 $$ = p_range;
    2874           0 :         }
    2875             :         |       TRANSACTION BETWEEN ICONST AND FCONST 
    2876             :         {
    2877             :                 TransRange *p_range = New(TransRange);
    2878           0 :                 p_range->min_trans_id = (TRANID)$3;
    2879             :                 p_range->max_trans_id = (TRANID)atoi8($5);   
    2880           0 :                 $$ = p_range;   
    2881             :         }
    2882           0 :         |       TRANSACTION BETWEEN FCONST AND ICONST 
    2883             :         {
    2884           0 :                 TransRange *p_range = New(TransRange);
    2885             :                 p_range->min_trans_id = (TRANID)atoi8($3);
    2886           0 :                 p_range->max_trans_id = (TRANID)$5;          
    2887             :                 $$ = p_range;   
    2888           0 :         }
    2889             :         |       TRANSACTION BETWEEN FCONST AND FCONST 
    2890             :         {
    2891             :                 TransRange *p_range = New(TransRange);
    2892             :                 p_range->min_trans_id = (TRANID)atoi8($3);
    2893             :                 p_range->max_trans_id = (TRANID)atoi8($5);
    2894             :                 $$ = p_range;                   
    2895             :         }
    2896             :         ;
    2897             : /* add by sdc@20170527 */
    2898             : opt_increment:  /* empty */
    2899             :         {
    2900             :                 $$ = false;
    2901           0 :         }
    2902           0 :         |       ALL
    2903           0 :         {
    2904           0 :                 $$ = false;
    2905             :         }               
    2906           0 :         |       INCREMENT       
    2907             :         {
    2908           0 :                 $$ = true;
    2909           0 :         }
    2910           0 :         ;
    2911           0 :         
    2912             : opt_path:       /* empty */
    2913           0 :         /*{
    2914             :                 BackupPath *p_path = New(BackupPath);
    2915             :                 p_path->is_append = false;
    2916             :                 p_path->path = NULL;
    2917             :                 $$ = (Node*)p_path;
    2918             :         }       
    2919             :         |*/
    2920             :         TO      Sconst  
    2921           0 :         {
    2922           0 :                 BackupPath *p_path = New(BackupPath);
    2923           0 :                 p_path->is_append = false;
    2924           0 :                 p_path->path = dbs2utf($2);
    2925           0 :                 $$ = (Node*)p_path;
    2926           0 :         }
    2927           0 :         |       APPEND TO Sconst
    2928           0 :         {
    2929             :                 BackupPath *p_path = New(BackupPath);
    2930           0 :                 p_path->is_append = true;
    2931             :                 p_path->path = dbs2utf($3);
    2932             :                 $$ = (Node*)p_path;
    2933           0 :         }
    2934           0 :         ;       
    2935           0 : /* end add by sdc@20170527 */                           
    2936           0 : /**********************************************************
    2937           0 : *restore database or data
    2938           0 : ***********************************************************/
    2939           0 : ImportStmt: 
    2940           0 :         IMPORT op_append_mode TABLE name_space opt_column_list FROM STREAM opt_reindex opt_import_mode parallel_opt
    2941           0 :         {
    2942           0 :                 ImportStmt *p_stmt = makeNode(ImportStmt);
    2943             :                 p_stmt->restore_type = IMPORT_TABLE;
    2944           0 :                 p_stmt->append_mode = $2;
    2945             :                 p_stmt->b_reindex = $8;
    2946           6 :                 p_stmt->name = $4;
    2947           6 :                 p_stmt->import_mode = $9;
    2948           6 :                 p_stmt->parallel = $10;
    2949           6 :                 $$ = (Node*)p_stmt;
    2950           6 :         }
    2951           6 :         |       IMPORT op_append_mode TABLE name_space opt_column_list FROM STREAM RECORDS DELIMITED BY 
    2952           6 :         terminated_chars FIELDS TERMINATED BY terminated_chars opt_reindex  opt_import_mode parallel_opt
    2953           6 :         {
    2954           6 :                 ImportStmt *p_stmt = makeNode(ImportStmt);
    2955           6 :                 p_stmt->restore_type = IMPORT_TABLE;
    2956             :                 p_stmt->append_mode = $2;
    2957           6 :                 p_stmt->b_reindex = $16;
    2958             :                 p_stmt->name = $4;
    2959             :                 p_stmt->row_separator = $11;
    2960           0 :                 p_stmt->field_separator = $15;
    2961           0 :                 p_stmt->import_mode = $17;
    2962           0 :                 p_stmt->parallel = $18;
    2963           0 :                 $$ = (Node*)p_stmt;
    2964           0 :         }
    2965           0 :         |   IMPORT op_append_mode TABLE name_space opt_column_list FROM SelectStmt opt_reindex  opt_import_mode parallel_opt
    2966           0 :         {
    2967           0 :                 ImportStmt *p_stmt = makeNode(ImportStmt);
    2968             :                 p_stmt->restore_type = IMPORT_TABLE;
    2969           0 :                 p_stmt->append_mode = $2;
    2970             :                 p_stmt->b_reindex = $8;
    2971           0 :                 p_stmt->name = $4;
    2972           0 :                 p_stmt->col_list = $5;
    2973           0 :                 p_stmt->selectStmt = $7;     
    2974           0 :                 p_stmt->import_mode = $9;    
    2975           0 :                 p_stmt->parallel = $10;
    2976           0 :                 $$ = (Node*)p_stmt;
    2977           0 :         }       
    2978             :         /*  add by sdc@20170527 */
    2979           0 :         |       RESTORE DATABASE name_space FROM Sconst opt_encryptor opt_reindex parallel_opt
    2980             :         {
    2981           0 :                 ImportStmt *p_stmt   = makeNode(ImportStmt);
    2982           0 :                 p_stmt->restore_type = RESTORE_DB;
    2983           0 :                 p_stmt->name         = $3;
    2984           0 :                 p_stmt->path         = dbs2utf($5);
    2985           0 :                 p_stmt->encrypt_key  = $6;
    2986           0 :                 p_stmt->b_reindex     = $7;
    2987             :                 p_stmt->parallel     = $8;
    2988           0 :                 $$ = (Node*)p_stmt;
    2989             :         }
    2990           0 :         |       RESTORE USER name_space FROM Sconst opt_encryptor parallel_opt
    2991           0 :         {
    2992           0 :                 ImportStmt *p_stmt   = makeNode(ImportStmt);
    2993           0 :                 p_stmt->restore_type = RESTORE_USER;
    2994           0 :                 p_stmt->name         = $3;
    2995           0 :                 p_stmt->path         = dbs2utf($5);
    2996           0 :                 p_stmt->encrypt_key  = $6;
    2997             :                 p_stmt->parallel     = $7;
    2998           0 :                 $$ = (Node*)p_stmt;
    2999             :         }
    3000           0 :         |       RESTORE ALL TABLE FROM Sconst opt_encryptor parallel_opt
    3001           0 :         {
    3002           0 :                 ImportStmt *p_stmt   = makeNode(ImportStmt);
    3003           0 :                 p_stmt->restore_type = RESTORE_USER;
    3004           0 :                 p_stmt->path         = dbs2utf($5);
    3005           0 :                 p_stmt->encrypt_key  = $6;
    3006           0 :                 p_stmt->parallel     = $7;
    3007           0 :                 $$ = (Node*)p_stmt;
    3008             :         }
    3009           0 :         |       RESTORE SCHEMA name_space FROM Sconst opt_encryptor parallel_opt
    3010             :         {
    3011           0 :                 ImportStmt *p_stmt   = makeNode(ImportStmt);
    3012           0 :                 p_stmt->restore_type = RESTORE_SCHEMA;
    3013           0 :                 p_stmt->name         = $3;
    3014           0 :                 p_stmt->path         = dbs2utf($5);
    3015             :                 p_stmt->encrypt_key  = $6;
    3016           0 :                 p_stmt->parallel     = $7;
    3017           0 :                 $$ = (Node*)p_stmt;
    3018           0 :         }
    3019             :         |       RESTORE SCHEMA name_space RENAME TO name_space FROM Sconst opt_encryptor parallel_opt
    3020           0 :         {
    3021             :                 ImportStmt *p_stmt   = makeNode(ImportStmt);
    3022           0 :                 p_stmt->restore_type = RESTORE_SCHEMA;
    3023           0 :                 p_stmt->name         = $3;
    3024           0 :                 p_stmt->rename       = $6;
    3025           0 :                 p_stmt->path         = dbs2utf($8);
    3026           0 :                 p_stmt->encrypt_key  = $9;
    3027             :                 p_stmt->parallel     = $10;
    3028           0 :                 $$ = (Node*)p_stmt;
    3029           0 :         }
    3030           0 :         |       RESTORE TABLE name_space FROM Sconst opt_encryptor parallel_opt
    3031             :         {
    3032           0 :                 ImportStmt *p_stmt   = makeNode(ImportStmt);
    3033             :                 p_stmt->restore_type = RESTORE_TABLE;
    3034           0 :                 p_stmt->name         = $3;
    3035           0 :                 p_stmt->path         = dbs2utf($5);
    3036           0 :                 //p_stmt->append_mode = $2;
    3037           0 :                 p_stmt->encrypt_key  = $6;
    3038           0 :                 p_stmt->parallel     = $7;
    3039           0 :                 $$ = (Node*)p_stmt;
    3040           0 :         }       
    3041             :         |       RESTORE TABLE name_space RENAME TO name_space FROM Sconst opt_encryptor parallel_opt
    3042           0 :         {
    3043             :                 ImportStmt *p_stmt   = makeNode(ImportStmt);
    3044             :                 p_stmt->restore_type = RESTORE_TABLE;
    3045           0 :                 p_stmt->name         = $3;
    3046           0 :                 p_stmt->rename       = $6;
    3047           0 :                 p_stmt->path         = dbs2utf($8);
    3048           0 :                 //p_stmt->append_mode = $2;
    3049           0 :                 p_stmt->encrypt_key  = $9;
    3050           0 :                 p_stmt->parallel     = $10;
    3051           0 :                 $$ = (Node*)p_stmt;
    3052           0 :         }
    3053             :         |       RESTORE SYSTEM FROM Sconst opt_encryptor opt_until_time parallel_opt
    3054           0 :         {
    3055             :                 ImportStmt *p_stmt   = (ImportStmt*)$6; 
    3056             :                 p_stmt->restore_type = RESTORE_SYS;
    3057           0 :                 p_stmt->name         = NULL;
    3058           0 :                 p_stmt->path         = dbs2utf($4);
    3059           0 :                 p_stmt->encrypt_key  = $5;
    3060           0 :                 p_stmt->parallel     = $7;
    3061           0 :                 $$ = (Node*)p_stmt;
    3062           0 :         }/* end add by sdc@20170527 */  
    3063           0 :         /*why 2019-01-03 add*/  
    3064           0 :         |LOAD op_append_mode TABLE name_space  FROM STREAM opt_reindex opt_import_mode parallel_opt2
    3065           0 :         {
    3066           0 :                 ImportStmt *p_stmt   = makeNode(ImportStmt);
    3067             :                 p_stmt->restore_type = LOAD_TABLE;
    3068           0 :                 p_stmt->append_mode  = $2;
    3069             :                 p_stmt->b_reindex    = $7;
    3070             :                 p_stmt->name         = $4;
    3071             :                 p_stmt->import_mode  = $8;
    3072             :                 p_stmt->parallel     = $9;
    3073           0 :                 $$ = (Node*)p_stmt;
    3074             :         }       
    3075           0 :         |LOAD op_append_mode TABLE name_space FROM STREAM RECORDS DELIMITED BY 
    3076             :         terminated_chars FIELDS TERMINATED BY terminated_chars opt_reindex  opt_import_mode parallel_opt2
    3077           0 :         {
    3078             :                 ImportStmt *p_stmt = makeNode(ImportStmt);
    3079           0 :                 p_stmt->restore_type = LOAD_TABLE;
    3080             :                 p_stmt->append_mode = $2;
    3081             :                 p_stmt->b_reindex = $15;
    3082             :                 p_stmt->name = $4;
    3083           6 :                 p_stmt->row_separator = $10;
    3084             :                 p_stmt->field_separator = $14;
    3085           6 :                 p_stmt->import_mode = $16;
    3086             :                 p_stmt->parallel = $17;
    3087           0 :                 $$ = (Node*)p_stmt;
    3088             :         }
    3089           0 :         //end                                   
    3090             :         ;               
    3091           0 : 
    3092             : terminated_chars: Sconst
    3093           0 :         {
    3094             :                 $$ = $1;
    3095             :         }
    3096             :         | BITCONST
    3097           6 :         {
    3098             :                 $$ = hex2str($1);
    3099           6 :         }
    3100             :         ;
    3101           0 :         
    3102             : op_append_mode: /*empty*/
    3103           0 :         {
    3104             :                 $$ = 1;
    3105             :         }       
    3106           6 :         | APPEND
    3107             :         {
    3108           6 :                 $$ = 1;
    3109             :         }
    3110           0 :         | REPLACE
    3111             :         {
    3112           0 :                 $$ = 2;
    3113             :         }
    3114           0 :         ;
    3115             :         
    3116           0 : opt_reindex: /*empty*/
    3117             :         {
    3118             :                 $$ = false;
    3119             :         }
    3120        1083 :         | WITH REINDEX
    3121             :         {
    3122        1083 :                 $$ = true;
    3123             :         }
    3124           0 :         ;
    3125             :  opt_import_mode: /*empty*/
    3126           0 :         {
    3127             :                 $$ = 0;
    3128             :         }
    3129           0 :         |  USE MODE ICONST
    3130             :         {
    3131           0 :                 $$ = $3;
    3132             :         }
    3133           0 :         | USE MODE AUTO
    3134             :         {
    3135           0 :                 $$ = 0;
    3136             :         };
    3137             :         
    3138             : //why 2016-10-27 add mergebysdc@20180907
    3139             : opt_encrypt:/*empty*/
    3140           0 :     {
    3141             :         $$ = 0;
    3142           0 :     }
    3143             :     | ENCRYPT  BY Sconst 
    3144           0 :     {
    3145             :         $$ = dbs2utf($3);
    3146           0 :     };
    3147             :     
    3148             :   opt_cascade:/*empty*/
    3149           0 :     {
    3150             :         $$ = false;
    3151           0 :     }
    3152             :     | CASCADE
    3153             :     {
    3154           0 :         $$ = true;
    3155           0 :     }
    3156             : 
    3157             : //end
    3158           0 : /*  add by sdc@20170527 */
    3159           0 : opt_encryptor: /* empty */
    3160             :         {
    3161             :                 $$ = NULL;
    3162             :         }
    3163           0 :         |       ENCRYPTOR IS Sconst
    3164           0 :         {
    3165           0 :                 $$ = dbs2utf($3);
    3166           0 :         }       
    3167             :         ;
    3168           0 : opt_compress: /* empty */
    3169             :         {
    3170           0 :                 $$ = 1;
    3171           0 :         }
    3172           0 :         |       NOCOMPRESS
    3173           0 :         {
    3174             :                 $$ = 0;
    3175           0 :         }       
    3176             :         |       COMPRESS
    3177             :         {
    3178           0 :                 $$ = 1;
    3179           0 :         }
    3180           0 :         ;
    3181           0 :         
    3182             : opt_until_time: /* empty */     
    3183           0 :         {
    3184             :                 ImportStmt *p_stmt = makeNode(ImportStmt);
    3185           0 :                 p_stmt->until_time = NULL;
    3186           0 :                 p_stmt->until_tranid = 0;
    3187           0 :                 $$ = (Node*)p_stmt;
    3188           0 :         }
    3189             :         |       UNTIL CURRENT TIME
    3190           0 :         {
    3191             :                 ImportStmt *p_stmt = makeNode(ImportStmt);
    3192             :                 p_stmt->until_time = "NOW";
    3193           0 :                 p_stmt->until_tranid = 0;
    3194           0 :                 $$ = (Node*)p_stmt;
    3195           0 :         }
    3196           0 :         |       UNTIL TIME Sconst
    3197             :         {
    3198           0 :                 ImportStmt *p_stmt = makeNode(ImportStmt);
    3199             :                 p_stmt->until_time = dbs2utf($3);
    3200             :                 p_stmt->until_tranid = 0;
    3201             :                 $$ = (Node*)p_stmt;
    3202             :         }
    3203             :         |       UNTIL TRANSACTION ICONST
    3204             :         {
    3205             :                 ImportStmt *p_stmt = makeNode(ImportStmt);
    3206             :                 p_stmt->until_time = NULL;
    3207           0 :                 p_stmt->until_tranid = (TRANID)$3;
    3208           0 :                 $$ = (Node*)p_stmt;
    3209           0 :         }
    3210           0 :         |   UNTIL TRANSACTION  FCONST 
    3211             :         {
    3212           0 :                 ImportStmt *p_stmt = makeNode(ImportStmt);
    3213             :                 p_stmt->until_time = NULL;
    3214             :                 p_stmt->until_tranid = (TRANID)atoi8($3);
    3215             :                 $$ = (Node*)p_stmt;
    3216             :         }
    3217             :         ;                       
    3218             :         /* end add by sdc@20170527 */           
    3219             :                           
    3220             : /**********************************************************
    3221             : *create encryptor
    3222             : ***********************************************************/
    3223             : 
    3224             : CreateEncryptStmt:      CREATE ENCRYPTOR Sconst BY Sconst
    3225             :         {
    3226             :                 CreateEncryptorStmt *p_stmt = makeNode( CreateEncryptorStmt);
    3227             :                 p_stmt->name     = dbs2utf($3);
    3228             :                 p_stmt->password = dbs2utf($5);
    3229             :                 $$ = (Node*)p_stmt;
    3230             :         }
    3231             :         ; 
    3232             :  
    3233             : /***********************************************************
    3234             : *define database or user or table encryt
    3235           0 : ************************************************************/
    3236           0 :  /* why 2016-10-27 mergebysdc@20180907 modify old:
    3237           0 :  EncryptStmt:   ENCRYPT ALL 
    3238           0 :                 {
    3239           0 :                         EncryptStmt *p_stmt = makeNode(EncryptStmt);
    3240           0 :                         p_stmt->tab_list = makeList1((Node*)NULL);
    3241           0 :                         $$ = (Node*)p_stmt;     
    3242           0 :                 }
    3243             :         |       ENCRYPT TABLE relation_name_list
    3244           0 :                 {
    3245             :                         EncryptStmt *p_stmt = makeNode(EncryptStmt);
    3246           0 :                         p_stmt->tab_list = $3;
    3247           0 :                         $$ = (Node*)p_stmt;     
    3248           0 :                 }
    3249           0 :                 ;
    3250           0 : */
    3251           0 : EncryptStmt:    
    3252           0 :      ENCRYPT DATABASE  BY ICONST opt_cascade opt_force
    3253           0 :      {
    3254           0 :          if($4<2 || $4>255)
    3255             :             add_parse_error(1170);
    3256           0 :          EncryptStmt *p_stmt = makeNode(EncryptStmt);
    3257             :                  p_stmt->mode      = 1;
    3258           0 :                  p_stmt->encry_id  = $4;
    3259           0 :                  p_stmt->cascade   = $5;
    3260           0 :                  p_stmt->b_force   = $6;
    3261           0 :                  $$ = (Node*)p_stmt;
    3262           0 :      }
    3263           0 :      | ENCRYPT USER UserId BY ICONST opt_cascade opt_force
    3264           0 :      {
    3265           0 :          if($5<2 || $5>255)
    3266             :             add_parse_error(1170);
    3267           0 :          EncryptStmt *p_stmt = makeNode(EncryptStmt);
    3268             :                  p_stmt->mode      = 2;
    3269           0 :                  p_stmt->name      = $3;
    3270           0 :                  p_stmt->encry_id  = $5;
    3271           0 :                  p_stmt->cascade   = $6;
    3272           0 :                  p_stmt->b_force   = $7;
    3273           0 :                  $$ = (Node*)p_stmt;
    3274           0 :      };
    3275             :      | ENCRYPT TABLE  name_space  BY  ICONST opt_force
    3276           0 :      {
    3277             :          if($5<2 || $5>255)
    3278           0 :             add_parse_error(1170);
    3279           0 :          EncryptStmt *p_stmt = makeNode(EncryptStmt);
    3280           0 :                  p_stmt->mode      = 3;
    3281           0 :                  p_stmt->name      = $3;
    3282           0 :                  p_stmt->encry_id  = $5;
    3283           0 :                  p_stmt->b_force   = $6;
    3284           0 :                  $$ = (Node*)p_stmt;
    3285             :      }
    3286           0 :      | ENCRYPT DATABASE  BY Sconst opt_cascade opt_force
    3287             :      {
    3288           0 :          EncryptStmt *p_stmt = makeNode(EncryptStmt);
    3289           0 :                  p_stmt->mode       = 1;
    3290           0 :                  p_stmt->encry_name = dbs2utf($4);
    3291           0 :                  p_stmt->cascade    = $5;
    3292           0 :                  p_stmt->b_force    = $6;
    3293           0 :                  $$ = (Node*)p_stmt;
    3294             :      }
    3295           0 :      | ENCRYPT USER UserId BY Sconst opt_cascade opt_force
    3296             :      {
    3297             :          EncryptStmt *p_stmt = makeNode(EncryptStmt);
    3298             :                  p_stmt->mode       = 2;
    3299             :                  p_stmt->name       = $3;
    3300             :                  p_stmt->encry_name = dbs2utf($5);
    3301             :                  p_stmt->cascade    = $6;
    3302             :                  p_stmt->b_force    = $7;
    3303           0 :                  $$ = (Node*)p_stmt;
    3304           0 :      };
    3305           0 :      | ENCRYPT TABLE  name_space  BY  Sconst opt_force
    3306             :      {
    3307           0 :          EncryptStmt *p_stmt = makeNode(EncryptStmt);
    3308             :                  p_stmt->mode       = 3;
    3309           0 :                  p_stmt->name       = $3;
    3310           0 :                  p_stmt->encry_name = dbs2utf($5);
    3311           0 :                  p_stmt->b_force    = $6;
    3312             :                  $$ = (Node*)p_stmt;
    3313           0 :      };         
    3314             : //end
    3315             : 
    3316             : /************************************************************
    3317             : *decrypt database or table
    3318             : ************************************************************/
    3319           0 :                                 
    3320             : DecryptStmt:    DECRYPT ALL
    3321           0 :                 {
    3322             :                         DecryptStmt *p_stmt = makeNode(DecryptStmt);
    3323             :                         p_stmt->tab_list = makeList1((Node*)NULL);
    3324             :                         $$ = (Node*)p_stmt;     
    3325             :                 }
    3326           0 :         |       DECRYPT TABLE relation_name_list
    3327           0 :                 {
    3328           0 :                         DecryptStmt *p_stmt = makeNode(DecryptStmt);
    3329             :                         p_stmt->tab_list = $3;
    3330           0 :                         $$ = (Node*)p_stmt;     
    3331             :                 };
    3332             : 
    3333             : /***********************************************************
    3334             : *alter encyptor
    3335             : ***********************************************************/
    3336             : DropEncryptStmt : DROP ENCRYPTOR 
    3337             :         {
    3338             :                 $$ = (Node*)makeNode(DropEncryptorStmt);
    3339             :         };
    3340             : /***********************************************************
    3341          15 : *enable encrypt database
    3342          15 : ***********************************************************/
    3343          15 : StartEncryptdb :START  DATABASE WITH PASSWORD Sconst
    3344          15 :         {
    3345          15 :                 StartEncryptdbStmt *p_stmt = makeNode(StartEncryptdbStmt);
    3346          15 :                 p_stmt->password = dbs2utf($5);
    3347          15 :                 $$ = (Node*)p_stmt;     
    3348          15 :         }
    3349          15 :         ;
    3350          15 : 
    3351          15 : /*****************************************************************************
    3352          15 :  *
    3353          15 :  * Create a new  DBMS user
    3354             :  *
    3355          15 :  *****************************************************************************/
    3356             : CreateUserStmt:   CREATE USER UserId opt_alias opt_priority user_passwd_clause 
    3357             :                                   user_role_clause user_valid_clause account_lock_clause 
    3358             :                                   password_expire_clause opt_trust_ip opt_user_quotas opt_encrypt
    3359          15 :        {
    3360             :                         CreateUserStmt *n = makeNode(CreateUserStmt);
    3361          15 :                         n->user = $3;
    3362             :                         n->alias = $4;
    3363           0 :                         n->priority = $5;
    3364             :                         n->password = $6;
    3365           0 :                         n->roleElts = $7;
    3366             :                         n->validUntil = $8;
    3367             :                         n->lock_action = $9;
    3368             :                         n->expire = $10;
    3369          15 :                         n->trust_ip = $11;
    3370             :                         n->user_quotas = $12;
    3371          15 :                         n->encry_name  = $13;
    3372             :                         $$ = (Node *)n;
    3373           0 :        }
    3374             :        ;
    3375           0 : 
    3376             : opt_alias: /*empty*/
    3377             :                 {
    3378             :                         $$ = NULL;
    3379           0 :                 }
    3380             :         |       LOGIN UserId
    3381           0 :                 {
    3382             :                         $$ = $2;
    3383           0 :                 }       
    3384             :                 ;
    3385           0 :                                 
    3386             : opt_priority: /*empty*/
    3387          15 :         {
    3388             :                 $$ = 0;
    3389          15 :         }
    3390             :         | PRIORITY ICONST
    3391             :         {
    3392             :                 $$ = $2;
    3393             :         }
    3394           0 :         ;                               
    3395             : /*lock account*/
    3396           0 : account_lock_clause:    ACCOUNT _LOCK
    3397             :                 {
    3398          15 :                         $$ = 1;
    3399             :                 }
    3400          15 :         |       ACCOUNT UNLOCK
    3401             :                 {
    3402             :                         $$ = -1;
    3403             :                 }
    3404             :         |       /* empty*/
    3405             :                 {
    3406             :                         $$ = 0;
    3407             :                 }
    3408             :                 ;
    3409             : 
    3410           0 : /*define password expire */
    3411           0 : password_expire_clause: PASSWORD EXPIRE
    3412           0 :                 {
    3413           0 :                         $$ = true;
    3414           0 :                 }
    3415           0 :         |       /*empty*/
    3416           0 :                 {
    3417           0 :                         $$ = false;
    3418           0 :                 }
    3419           0 :                 ;
    3420           0 : 
    3421             : /*****************************************************************************
    3422           0 :  *
    3423             :  * Alter a  DBMS user
    3424           0 :  *
    3425           0 :  *****************************************************************************/
    3426           0 : AlterUserStmt:  ALTER USER UserId opt_alias opt_priority user_passwd_clause user_valid_clause 
    3427           0 :                                 account_lock_clause password_expire_clause opt_trust_ip opt_user_quotas
    3428             :        {
    3429           0 :                         AlterUserStmt *n = makeNode(AlterUserStmt);
    3430             :                         n->user = $3;
    3431           0 :                         n->alias = $4;
    3432           0 :                         n->priority = $5;
    3433           0 :                         n->password = $6;
    3434           0 :                         n->validUntil = $7;
    3435             :                         n->lock_action = $8;
    3436           0 :                         n->expire = $9;
    3437             :                         n->trust_ip = $10;
    3438             :                         n->user_quotas = $11;
    3439          15 :                         $$ = (Node *)n;
    3440          15 :        } 
    3441           0 :     |  ALTER USER UserId RENAME TO UserId
    3442           0 :           {
    3443           0 :                         AlterUserStmt *n = makeNode(AlterUserStmt);
    3444           0 :                         n->user = $3;
    3445             :                         n->new_name = $6;
    3446             :                         $$ = (Node *)n;
    3447             :           } 
    3448           0 :          | ALTER USER UserId SET LOGIN UserId
    3449             :           {
    3450           0 :                         AlterUserStmt *n = makeNode(AlterUserStmt);
    3451             :                         n->user = $3;
    3452           0 :                         n->alias = $6;
    3453             :                         $$ = (Node *)n;
    3454           0 :           }                             
    3455             :         ;
    3456             : 
    3457           0 : user_passwd_clause:  
    3458           0 :                   IDENTIFIED BY Sconst              { $$ = dbs2utf($3); }
    3459          15 :                 | IDENTIFIED BY ColId               { $$ = $3; }        
    3460          15 :                 | /*EMPTY*/                             { $$ = (char*)NULL; }
    3461             :                 ;
    3462             : 
    3463           0 : user_list:  
    3464           0 :                   user_list ',' UserId              { $$ = lappend($1, $3); }
    3465          15 :                 | UserId                            { $$ = makeList1($1); }
    3466          15 :                 ;
    3467             : 
    3468             : user_role_clause:   
    3469          15 :                   DEFAULT ROLE user_list                        { $$ = $3; }
    3470             :                 | /*EMPTY*/                                                     { $$ = NIL; }
    3471          15 :                 ;
    3472             : 
    3473           0 : user_valid_clause:  
    3474             :                   VALID UNTIL SCONST                        { $$ = $3; }
    3475           0 :                 | /*EMPTY*/                                                 { $$ = (char*)NULL; }
    3476             :                 ;
    3477             : opt_trust_ip: 
    3478          15 :                   /*empty*/                         { $$ = NULL; }
    3479          15 :                 | SCONST                            { $$ = $1; }
    3480             :                 ;
    3481           0 :                                 
    3482             : opt_user_quotas:
    3483           0 :                   /*empty*/                         { $$ = NIL;}
    3484             :                 | user_quotas                       { $$ = $1; }
    3485             :                 ;
    3486             : 
    3487           0 : user_quotas: 
    3488             :                   user_quota                        { $$ = makeList1($1); }
    3489           0 :                 | user_quotas user_quota            { $$ = lappend($1,$2); }
    3490             :                 ;
    3491           0 :                         
    3492             : user_quota: QUOTA ICONST size_unit ON MEMORY
    3493           0 :                 {
    3494             :                         UserQuota *n = makeNode(UserQuota);
    3495             :                         n->quota_type = "MEMORY";
    3496             :                         n->quota = $2*($3/1024);
    3497           0 :                         $$ = (Node*)n;
    3498           0 :                 }
    3499           0 :         |   QUOTA UNLIMITED ON MEMORY
    3500           0 :                 {
    3501             :                         UserQuota *n = makeNode(UserQuota);
    3502           0 :                         n->quota_type = "MEMORY";
    3503             :                         n->quota = -1;
    3504           0 :                         $$ = (Node*)n;                  
    3505           0 :                 }       
    3506           0 :         |       QUOTA ICONST size_unit ON TEMP TABLESPACE
    3507           0 :                 {
    3508             :                         UserQuota *n = makeNode(UserQuota);
    3509           0 :                         n->quota_type = "TEMP_SPACE";
    3510             :                         n->quota = $2*($3/1024);
    3511           0 :                         $$ = (Node*)n;
    3512           0 :                 }
    3513           0 :         |   QUOTA UNLIMITED ON TEMP TABLESPACE
    3514           0 :                 {
    3515             :                         UserQuota *n = makeNode(UserQuota);
    3516           0 :                         n->quota_type = "TEMP_SPACE";
    3517             :                         n->quota = -1;
    3518           0 :                         $$ = (Node*)n;
    3519           0 :                 }
    3520           0 :         |       QUOTA ICONST size_unit ON UNDO TABLESPACE
    3521           0 :                 {
    3522             :                         UserQuota *n = makeNode(UserQuota);
    3523           0 :                         n->quota_type = "UNDO_SPACE";
    3524             :                         n->quota = $2*($3/1024);
    3525           0 :                         $$ = (Node*)n;
    3526           0 :                 }
    3527           0 :         |   QUOTA UNLIMITED ON UNDO TABLESPACE
    3528           0 :                 {
    3529             :                         UserQuota *n = makeNode(UserQuota);
    3530           0 :                         n->quota_type = "UNDO_SPACE";
    3531             :                         n->quota = -1;
    3532           0 :                         $$ = (Node*)n;
    3533           0 :                 }       
    3534           0 :         |       QUOTA ICONST ON CURSOR
    3535           0 :                 {
    3536             :                         UserQuota *n = makeNode(UserQuota);
    3537           0 :                         n->quota_type = "CURSOR";
    3538             :                         n->quota = $2;
    3539           0 :                         $$ = (Node*)n;
    3540           0 :                 }
    3541           0 :         |   QUOTA UNLIMITED ON CURSOR
    3542           0 :                 {
    3543             :                         UserQuota *n = makeNode(UserQuota);
    3544           0 :                         n->quota_type = "CURSOR";
    3545             :                         n->quota = -1;
    3546           0 :                         $$ = (Node*)n;
    3547           0 :                 }               
    3548           0 :         |   QUOTA ICONST ON SESSION
    3549           0 :                 {
    3550             :                         UserQuota *n = makeNode(UserQuota);
    3551           0 :                         n->quota_type = "SESSION";
    3552             :                         n->quota = $2;
    3553           0 :                         $$ = (Node*)n;
    3554           0 :                 }
    3555           0 :         |   QUOTA UNLIMITED ON  SESSION 
    3556           0 :                 {
    3557             :                         UserQuota *n = makeNode(UserQuota);
    3558           0 :                         n->quota_type = "SESSION";
    3559             :                         n->quota = -1;
    3560           0 :                         $$ = (Node*)n;
    3561           0 :                 }                               
    3562           0 :         |   QUOTA ICONST ON IO
    3563           0 :                 {
    3564             :                         UserQuota *n = makeNode(UserQuota);
    3565           0 :                         n->quota_type = "IO";
    3566             :                         n->quota = $2;
    3567           0 :                         $$ = (Node*)n;
    3568           0 :                 }
    3569           0 :         |   QUOTA UNLIMITED ON IO
    3570           0 :                 {
    3571             :                         UserQuota *n = makeNode(UserQuota);
    3572           0 :                         n->quota_type = "IO";
    3573             :                         n->quota = -1;
    3574           0 :                         $$ = (Node*)n;
    3575           0 :                 }                                       
    3576           0 :         |   QUOTA ICONST ON PROCEDURE
    3577           0 :                 {
    3578             :                         UserQuota *n = makeNode(UserQuota);
    3579           0 :                         n->quota_type = "PROC";
    3580             :                         n->quota = $2;
    3581           0 :                         $$ = (Node*)n;
    3582           0 :                 }
    3583           0 :         |   QUOTA UNLIMITED ON PROCEDURE
    3584           0 :                 {
    3585             :                         UserQuota *n = makeNode(UserQuota);
    3586           0 :                         n->quota_type = "PROC";
    3587             :                         n->quota = -1;
    3588           0 :                         $$ = (Node*)n;
    3589           0 :                 }                                       
    3590           0 :         |       QUOTA ICONST size_unit ON TABLESPACE 
    3591           0 :                 {
    3592             :                         UserQuota *n = makeNode(UserQuota);
    3593           0 :                         n->quota_type = "SPACE";
    3594             :                         n->quota = $2*($3/1024);
    3595           0 :                         $$ = (Node*)n;
    3596           0 :                 }
    3597           0 :         |   QUOTA UNLIMITED ON TABLESPACE 
    3598           0 :                 {
    3599             :                         UserQuota *n = makeNode(UserQuota);
    3600           0 :                         n->quota_type = "SPACE";
    3601             :                         n->quota = -1;
    3602           0 :                         $$ = (Node*)n;
    3603           0 :                 }                                       
    3604           0 :                 ;       
    3605           0 : 
    3606             : /*****************************************************************************
    3607           0 :  *
    3608             :  * Drop a  DBMS user
    3609             :  *
    3610             :  *
    3611             :  *****************************************************************************/
    3612             : 
    3613             : DropUserStmt:  DROP USER UserId  alter_behavior /*opt_keep_obj bysdc@20220322 forbug5141 not surpport*/
    3614             :                 {
    3615             :                         DropStmt *n = makeNode(DropStmt);
    3616             :                         n->obj_name = $3;
    3617             :                         n->drop_type = DROP_USER;
    3618           0 :                         n->behavior = ($4==CASCADE? OP_CASCADE : OP_RESTRICT);
    3619           0 :                         //n->keep_objs = $5;
    3620           0 :                         $$ = (Node *)n;
    3621           0 :                         SetNodePos($$);
    3622             :                 }
    3623           0 :                 ;
    3624           0 : /*
    3625             : opt_keep_obj:
    3626           0 :                 {
    3627             :                         $$ = false;
    3628             :                 }
    3629             :         |       KEEP OBJECT
    3630             :                 {
    3631             :                         $$ = true;
    3632             :                 }
    3633             :                 ;               
    3634             : */
    3635             : /*****************************************************************************
    3636             :  *
    3637             :  * Create a  group
    3638             :  *
    3639             :  *
    3640             :  *****************************************************************************/
    3641             : 
    3642             : CreateRoleStmt:  CREATE ROLE UserId 
    3643             :                         {
    3644             :                                 CreateRoleStmt *n = makeNode(CreateRoleStmt);
    3645             :                                 n->name = $3;
    3646             :                                 n->initUsers = NIL;
    3647           0 :                                 $$ = (Node *)n;
    3648           0 :                         }
    3649           0 :                 | CREATE ROLE UserId INIT USER user_list
    3650           0 :                         {
    3651             :                                 CreateRoleStmt *n = makeNode(CreateRoleStmt);
    3652           0 :                                 n->name = $3;
    3653             :                                 n->initUsers = $6;
    3654           0 :                                 $$ = (Node *)n;
    3655           0 :                         }
    3656           0 :                 |CREATE ROLE UserId INITIALLY USER user_list
    3657           0 :                         {
    3658             :                                 CreateRoleStmt *n = makeNode(CreateRoleStmt);
    3659           0 :                                 n->name = $3;
    3660             :                                 n->initUsers = $6;
    3661           0 :                                 $$ = (Node *)n;
    3662           0 :                         }
    3663           0 :         ;
    3664           0 : 
    3665             : /*****************************************************************************
    3666           0 : *
    3667             : * Alter role
    3668             : *
    3669             : *
    3670             : *****************************************************************************/
    3671             : 
    3672             : AlterRoleStmt:  GRANT ROLE UserId TO user_list  
    3673             :                 {
    3674             :                         AlterRoleStmt *n = makeNode(AlterRoleStmt);
    3675             :                         n->name = $3;
    3676             :                         n->action = +1;
    3677           0 :                         n->listUsers = $5;
    3678           0 :                         $$ = (Node *)n;
    3679           0 :                 }
    3680           0 :         |       REVOKE ROLE UserId FROM user_list 
    3681           0 :                 {
    3682             :                         AlterRoleStmt *n = makeNode(AlterRoleStmt);
    3683           0 :                         n->name = $3;
    3684             :                         n->action = -1;
    3685           0 :                         n->listUsers = $5;
    3686           0 :                         $$ = (Node *)n;
    3687           0 :                 }
    3688           0 :                 ;
    3689           0 : 
    3690             : /*****************************************************************************
    3691           0 :  *
    3692             :  * Drop Role
    3693             :  *
    3694             :  *****************************************************************************/
    3695             : 
    3696             : DropRoleStmt: DROP ROLE UserId
    3697             :                 {
    3698             :                         DropStmt *n = makeNode(DropStmt);
    3699             :                         n->obj_name = $3;
    3700             :                         n->drop_type = DROP_ROLE;
    3701           0 :                         $$ = (Node *)n;
    3702           0 :                         SetNodePos($$);
    3703           0 :                 }
    3704           0 :                 ;
    3705           0 : 
    3706             : /*****************************************************************************
    3707           0 :  *
    3708             :  * Manipulate a schema
    3709             :  *
    3710             :  *
    3711             :  *****************************************************************************/
    3712             : 
    3713             : CreateSchemaStmt:  CREATE SCHEMA ColId  AUTHORIZATION UserId 
    3714             :                 {
    3715             :                         CreateSchemaStmt *n = makeNode(CreateSchemaStmt);
    3716             :                         n->schema_name = $3;
    3717             :                         n->owner = $5;
    3718           5 :                         $$ = (Node *)n;
    3719           5 :                 }
    3720           5 :         |       CREATE SCHEMA ColId
    3721           5 :                 {
    3722             :                         CreateSchemaStmt *n = makeNode(CreateSchemaStmt);
    3723           5 :                         n->schema_name = $3;
    3724             :                         $$ = (Node *)n;
    3725           0 :                 }
    3726           0 :                 ;
    3727           0 : 
    3728             : AlterSchemaStmt:  ALTER SCHEMA name_space RENAME TO name 
    3729           0 :                 {
    3730             :                         AlterSchemaStmt *n = makeNode(AlterSchemaStmt);
    3731             :                         n->schema_name = $3;
    3732             :                         n->new_name = $6;
    3733           0 :                         $$ = (Node*)n;
    3734           0 :                 }
    3735           0 :         |       ALTER SCHEMA ColId OWNER TO ColId
    3736           0 :                 {
    3737             :                         AlterSchemaStmt *stmt = makeNode(AlterSchemaStmt );
    3738           0 :                         stmt->schema_name = $3;
    3739             :                         stmt->new_owner = $6;
    3740           0 :                         $$ = (Node*)stmt;
    3741           0 :                 }
    3742           0 :                 ;
    3743           0 : 
    3744             : DropSchemaStmt:  DROP SCHEMA ColId alter_behavior
    3745           0 :                 {
    3746             :                         DropStmt *n = makeNode(DropStmt);
    3747             :                         n->obj_name = $3;
    3748             :                         n->drop_type = DROP_SCHEMA;
    3749           0 :                         n->behavior = ($4==CASCADE? OP_CASCADE : OP_RESTRICT);
    3750           0 :                         $$ = (Node *)n;
    3751           0 :                         SetNodePos($$);
    3752           0 :                 }
    3753           0 :                 ;
    3754           0 : 
    3755             : /*****************************************************************************
    3756           0 :  *
    3757             :  * Set  internal variable
    3758             :  *        SET name TO 'var_value'
    3759             :  * Include SQL92 syntax (thomas 1997-10-22):
    3760             :  *    SET TIME ZONE 'var_value'
    3761             :  *
    3762             :  *****************************************************************************/
    3763             : 
    3764             : VariableSetStmt:  SET ColId TO var_value
    3765             :                 {
    3766             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3767             :                         n->name  = $2;
    3768             :                         n->value = dbs2utf($4);
    3769           5 :                         $$ = (Node *) n;
    3770           5 :                 }
    3771           5 :                 | SET ColId TO ColId
    3772           5 :                 {
    3773             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3774           5 :                         n->name  = $2;
    3775             :                         n->value = $4;
    3776           0 :                         $$ = (Node *) n;
    3777           0 :                 }               
    3778           0 :                 | SET ColId ON
    3779           0 :                 {
    3780             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3781           0 :                         n->name  = $2;
    3782             :                         n->value = "ON";
    3783           0 :                         $$ = (Node *) n;
    3784           0 :                 }
    3785           0 :                 | SET ColId OFF
    3786           0 :                 {
    3787             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3788           0 :                         n->name  = $2;
    3789             :                         n->value = "OFF";
    3790           2 :                         $$ = (Node *) n;
    3791           2 :                 }                               
    3792           2 :                 | ALTER SESSION SET ColId '=' var_value
    3793           2 :                 {
    3794             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3795           2 :                         n->name  = $4;
    3796             :                         n->value = $6;
    3797           0 :                         $$ = (Node *) n;
    3798           0 :                 }
    3799           0 :                 | ALTER SESSION SET ColId '=' ColId
    3800           0 :                 {
    3801             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3802           0 :                         n->name  = $4;
    3803             :                         n->value = $6;
    3804           0 :                         $$ = (Node *) n;
    3805           0 :                 }               
    3806           0 :                 | SET TIME ZONE zone_value
    3807           0 :                 {
    3808             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3809           0 :                         n->name  = "TIMEZONE";
    3810             :                         n->value = $4;
    3811           0 :                         $$ = (Node *) n;
    3812           0 :                 }
    3813           0 :                 | SET TRANSACTION ISOLATION LEVEL opt_level
    3814           0 :                 {
    3815             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3816           0 :                         n->name  = "ISO_LEVEL";
    3817             :                         n->value = $5;
    3818           0 :                         $$ = (Node *) n;
    3819           0 :                 }
    3820           0 :                 | SET TRANSACTION  READ ONLY
    3821           0 :                 {
    3822             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3823           0 :                         n->name  = "TRANS_READONLY";
    3824             :                         n->value = "ON";
    3825          10 :                         $$ = (Node *) n;
    3826          10 :                 }
    3827          10 :                 | SET TRANSACTION  READ WRITE
    3828          10 :                 {
    3829             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3830          10 :                         n->name  = "TRANS_READONLY";
    3831             :                         n->value = "OFF";
    3832           5 :                         $$ = (Node *) n;
    3833           5 :                 }               
    3834           5 :                 | SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL opt_level
    3835           5 :                 {
    3836             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3837           5 :                         n->name  = "SESSION_ISO_LEVEL";
    3838             :                         n->value = $8;
    3839           0 :                         $$ = (Node *) n;
    3840           0 :                 }
    3841           0 :                 | SET SESSION TRANSACTION ISOLATION LEVEL opt_level
    3842           0 :                 {
    3843             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3844           0 :                         n->name  = "SESSION_ISO_LEVEL";
    3845             :                         n->value = $6;
    3846           0 :                         $$ = (Node *) n;
    3847           0 :                 }
    3848           0 :                 | SET SESSION AUTHORIZATION SCONST
    3849           0 :                 {
    3850             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3851           0 :                         n->name  = "SESSION_USER";
    3852             :                         n->value = $4;
    3853           4 :                         $$ = (Node *) n;
    3854           4 :                 }
    3855           4 :                 | SET SESSION AUTHORIZATION UserId
    3856           4 :                 {
    3857             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3858           4 :                         n->name  = "SESSION_USER";
    3859             :                         n->value = $4;
    3860         311 :                         $$ = (Node *) n;
    3861         311 :                 }               
    3862         311 :                 | SET NAMES opt_encoding
    3863         311 :                 {
    3864             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3865         311 :                         n->name  = "CLIENT_ENCODING";
    3866             :                         n->value = $3;
    3867           0 :                         $$ = (Node *) n;
    3868           0 :                 }
    3869           0 :                 | SET AUTO COMMIT ON
    3870           0 :                 {
    3871             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3872           0 :                         n->name  ="AUTO_COMMIT";
    3873             :                         n->value = "ON";
    3874           0 :                         $$ = (Node *) n;
    3875           0 :                 }
    3876           0 :                 | SET AUTO COMMIT OFF
    3877           0 :                 {
    3878             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3879           0 :                         n->name  ="AUTO_COMMIT";
    3880             :                         n->value = "OFF";
    3881         499 :                         $$ = (Node *) n;
    3882         499 :                 }
    3883         499 :                 | SET ROLLBACK ALL ON
    3884         499 :                 {
    3885             :                 
    3886         499 :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3887             :                         n->name  ="ROLLBACK_ALL";
    3888             :                         n->value = "ON";
    3889           0 :                         $$ = (Node *) n;
    3890           0 :                 }
    3891           0 :                 | SET ROLLBACK ALL OFF
    3892           0 :                 {
    3893             :                 
    3894           0 :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3895             :                         n->name  ="ROLLBACK_ALL";
    3896             :                         n->value = "OFF";
    3897           0 :                         $$ = (Node *) n;
    3898           0 :                 }
    3899           0 :                 | SET CURRENT SCHEMA name
    3900           0 :                 {
    3901             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3902           0 :                         n->name  ="CURRENT_SCHEMA";
    3903             :                         n->value = $4;
    3904           0 :                         $$ = (Node *) n;
    3905           0 :                 }       
    3906           0 :                 | SET CURRENT SCHEMA DEFAULT
    3907           0 :                 {
    3908             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3909           0 :                         n->name  ="CURRENT_SCHEMA";
    3910             :                         n->value = "DEFAULT";
    3911           0 :                         $$ = (Node *) n;
    3912           0 :                 }
    3913           0 :                 | SET SCHEMA name
    3914           0 :                 {
    3915             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3916           0 :                         n->name  ="CURRENT_SCHEMA";
    3917             :                         n->value = $3;
    3918          15 :                         $$ = (Node *) n;
    3919          15 :                 }       
    3920          15 :                 | SET SCHEMA DEFAULT
    3921          15 :                 {
    3922             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3923          15 :                         n->name  ="CURRENT_SCHEMA";
    3924             :                         n->value = "DEFAULT";
    3925           0 :                         $$ = (Node *) n;
    3926           0 :                 }
    3927           0 :                 | SET SCHEMA Sconst
    3928           0 :                 {
    3929             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3930           0 :                         n->name  ="CURRENT_SCHEMA";
    3931             :                         n->value = dbs2utf($3);
    3932           0 :                         $$ = (Node *) n;
    3933           0 :                 }       
    3934           0 :                 | SET AUDIT ON
    3935           0 :                 { 
    3936             :                         VariableSetStmt *n = makeNode(VariableSetStmt);
    3937           0 :                         n->name  ="$ENABLE_AUDIT";
    3938             :                         n->value = "ON"; 
    3939           0 :                         $$ = (Node *) n;                                
    3940           0 :                 }
    3941           0 :                 | SET AUDIT OFF 
    3942           0 :                 { 
    3943             :                         VariableSetStmt *n = makeNode(VariableSetStmt); 
    3944           0 :                         n->name  ="$ENABLE_AUDIT";
    3945             :                         n->value = "OFF";
    3946           0 :                         $$ = (Node *) n;
    3947           0 :                 }       
    3948           0 :                 | SET _NULL _NULL
    3949           0 :                 {
    3950             :                         VariableSetStmt *n = makeNode(VariableSetStmt); 
    3951           0 :                         n->name  ="EMPTY_STR_AS_NULL";
    3952             :                         n->value = "OFF";
    3953           0 :                         $$ = (Node *) n;
    3954           0 :                 }
    3955           0 :                 | SET _NULL SCONST
    3956           0 :                 {
    3957             :                         VariableSetStmt *n = makeNode(VariableSetStmt); 
    3958           0 :                         n->name  = "EMPTY_STR_AS_NULL";
    3959             :                         n->value = "ON";
    3960           0 :                         $$ = (Node *) n;
    3961           0 :                 }                                                                                       
    3962           0 :                 ;
    3963           0 : 
    3964             : opt_level:  READ ONLY                           { $$ = (char*)"0"; }  //{ $$ = "Read Only; }
    3965           0 :                 | READ COMMITTED                        { $$ = (char*)"1"; }  //{ $$ = "Read Committed"; }
    3966             :                 | _REPEATABLE READ                      { $$ = (char*)"2"; }  //{ $$ = "Repeatable Read";}
    3967           0 :                 | SERIALIZABLE                          { $$ = (char*)"3"; }  //{ $$ = "Serializable"; }
    3968           0 :                 ;
    3969           0 : 
    3970           0 : var_value:  opt_boolean                         { $$ = $1; }
    3971           0 :                 | SCONST                                        { $$ = $1; }
    3972             :                 | ICONST
    3973           0 :                         {
    3974           0 :                                 char    buf[64];
    3975           0 :                                 sprintf(buf, "%d", $1);
    3976             :                                 $$ = tstrdup(buf);
    3977             :                         }
    3978           5 :                 | '-' ICONST
    3979           5 :                         {
    3980             :                                 char    buf[64];
    3981           5 :                                 sprintf(buf, "%d", -($2));
    3982             :                                 $$ = tstrdup(buf);
    3983             :                         }
    3984           0 :                 | FCONST                                        { $$ = $1; }
    3985           0 :                 | '-' FCONST
    3986             :                         {
    3987           0 :                                 char * s = (char*)tmalloc(astrlen($2)+2);
    3988           0 :                                 s[0] = '-';
    3989             :                                 strcpy(s + 1, $2);
    3990           0 :                                 $$ = s;
    3991           0 :                         }
    3992           0 : 
    3993           0 :                 | DEFAULT                                       { $$ = (char*)"DEFAULT"; }
    3994             :                 ;
    3995           0 : 
    3996           0 : opt_boolean:  _TRUE                                     { $$ = (char*)"TRUE"; }
    3997           0 :                 | _FALSE                                        { $$ = (char*)"FALSE"; }
    3998             :                 | ON                                            { $$ = (char*)"ON"; }
    3999           0 :                 | OFF                                           { $$ = (char*)"OFF"; }
    4000           0 :                 ;
    4001           0 : 
    4002           0 : zone_value:  Sconst                                     { $$ = dbs2utf($1); }
    4003           0 :                 | DEFAULT                                       { $$ = (char*)NULL; }
    4004             :                 | LOCAL                                         { $$ = (char*)NULL; }
    4005           0 :                 ;
    4006           0 : 
    4007           0 : opt_encoding:  Sconst                           { $$ = dbs2utf($1); }
    4008           0 :         | DEFAULT                                       { $$ = (char*)NULL; }
    4009             :         | /*EMPTY*/                             { $$ = (char*)NULL; }
    4010           0 :         ;
    4011           0 : 
    4012           0 : VariableShowStmt:  SHOW ColId
    4013           0 :                 {
    4014             :                         VariableShowStmt *n = makeNode(VariableShowStmt);
    4015             :                         n->name  = $2;
    4016             :                         $$ = (Node *) n;
    4017           6 :                 }
    4018           6 :                 | SHOW TIME ZONE
    4019           6 :                 {
    4020             :                         VariableShowStmt *n = makeNode(VariableShowStmt);
    4021           6 :                         n->name  = "TIMEZONE";
    4022             :                         $$ = (Node *) n;
    4023           0 :                 }
    4024           0 :                 | SHOW TRANSACTION ISOLATION LEVEL
    4025           0 :                 {
    4026             :                         VariableShowStmt *n = makeNode(VariableShowStmt);
    4027           0 :                         n->name  = "ISO_LEVEL";
    4028             :                         $$ = (Node *) n;
    4029           0 :                 }
    4030           0 :                 | SHOW AUTO COMMIT
    4031           0 :                 {
    4032             :                         VariableShowStmt *n = makeNode(VariableShowStmt);
    4033           0 :                         n->name  ="AUTO_COMMIT";
    4034             :                         $$ = (Node *) n;
    4035           0 :                 }
    4036           0 :                 | SHOW ROLLBACK ALL
    4037           0 :                 {
    4038             :                         VariableShowStmt *n = makeNode(VariableShowStmt);
    4039           0 :                         n->name  ="ROLLBACK_ALL";
    4040             :                         $$ = (Node *) n;
    4041           0 :                 }
    4042           0 :                 | SHOW CURRENT  SCHEMA
    4043           0 :                 {
    4044             :                         VariableShowStmt *n = makeNode(VariableShowStmt);
    4045           0 :                         n->name  ="CURRENT_SCHEMA";
    4046             :                         $$ = (Node *) n;
    4047           0 :                 }       
    4048           0 :                 ;
    4049           0 : 
    4050             : 
    4051           0 : ConstraintsSetStmt:     SET CONSTRAINTS constraints_set_list constraints_set_mode
    4052             :                 {
    4053             :                         ConstraintsSetStmt *n = makeNode(ConstraintsSetStmt);
    4054             :                         n->constraints = $3;
    4055             :                         n->deferred    = $4;
    4056           0 :                         $$ = (Node *) n;
    4057           0 :                 }
    4058           0 :                 ;
    4059           0 : 
    4060             : 
    4061           0 : constraints_set_list:   ALL
    4062             :                                 {
    4063             :                                         $$ = NIL;
    4064             :                                 }
    4065             :                 | constraints_set_namelist
    4066           0 :                                 {
    4067             :                                         $$ = $1;
    4068           0 :                                 }
    4069             :                 ;
    4070           0 : 
    4071             : 
    4072           0 : constraints_set_namelist:       IDENT
    4073             :                 {
    4074             :                         $$ = makeList1($1);
    4075             :                 }
    4076             :         | constraints_set_namelist ',' IDENT
    4077           0 :                 {
    4078             :                         $$ = lappend($1, $3);
    4079           0 :                 }
    4080             :                 ;
    4081           0 : 
    4082             : 
    4083           0 : constraints_set_mode:   DEFERRED
    4084             :                 {
    4085             :                         $$ = true;
    4086             :                 }
    4087             :                 | IMMEDIATE
    4088           0 :                 {
    4089             :                         $$ = false;
    4090           0 :                 }
    4091             :                 ;
    4092           0 : 
    4093             : 
    4094           0 : /*
    4095             :  * Checkpoint statement
    4096             :  */
    4097             : CheckPointStmt: CHECKPOINT 
    4098             :                 {
    4099             :                         CheckPointStmt *n = makeNode(CheckPointStmt);
    4100             :                         $$ = (Node *)n;
    4101             :                 }
    4102           0 :                 ;
    4103           0 : 
    4104             : /*
    4105           0 : * recompile objects
    4106             : */
    4107             : /***********************************************************************
    4108             : *  ALTER TABLE[ PROCEDUE|PACKAGE |TRIGGER |TYPE |VIEW] RECOMPILE
    4109             : ***********************************************************************/
    4110             : RecompileStmt: ALTER TABLE name_space RECOMPILE
    4111             :         {
    4112             :                 RecompileStmt *n = makeNode(RecompileStmt );
    4113             :                 n->obj_type = OBJ_TYPE_TAB;
    4114             :                 n->obj_name = $3;
    4115           0 :                 $$ = (Node*)n;
    4116           0 :         }
    4117           0 :         | ALTER  VIEW name_space RECOMPILE
    4118           0 :         {
    4119             :                 RecompileStmt *n = makeNode(RecompileStmt );
    4120           0 :                 n->obj_type = OBJ_TYPE_VIEW;
    4121             :                 n->obj_name = $3;
    4122           0 :                 $$ = (Node*)n;
    4123           0 :         }
    4124           0 :         | ALTER PROCEDURE name_space RECOMPILE
    4125           0 :         {
    4126             :                 RecompileStmt *n = makeNode(RecompileStmt );
    4127           0 :                 n->obj_type = OBJ_TYPE_PROC;
    4128             :                 n->obj_name = $3;
    4129           0 :                 $$ = (Node*)n;
    4130           0 :         }
    4131           0 :         | ALTER PACKAGE name_space RECOMPILE
    4132           0 :         {
    4133             :                 RecompileStmt *n = makeNode(RecompileStmt );
    4134           0 :                 n->obj_type = OBJ_TYPE_PACK;
    4135             :                 n->obj_name = $3;
    4136           0 :                 $$ = (Node*)n;
    4137           0 :         }
    4138           0 :         | ALTER TYPE name_space RECOMPILE
    4139           0 :         {
    4140             :                 RecompileStmt *n = makeNode(RecompileStmt );
    4141           0 :                 n->obj_type = OBJ_TYPE_UDT;
    4142             :                 n->obj_name = $3;
    4143           0 :                 $$ = (Node*)n;
    4144           0 :         }
    4145           0 :         | ALTER TRIGGER name_space RECOMPILE
    4146           0 :         {
    4147             :                 RecompileStmt *n = makeNode(RecompileStmt );
    4148           0 :                 n->obj_type = OBJ_TYPE_TRIG;
    4149             :                 n->obj_name = $3;
    4150           0 :                 $$ = (Node*)n;
    4151           0 :         }
    4152           0 :         ;
    4153           0 : 
    4154             : /*
    4155           0 : * enable or disable an object (etc. TRIGGER)
    4156             : */
    4157             : /***********************************************************************
    4158             : *  ALTER TRIGGER  ... [ENABLE | DISABLE]
    4159             : ***********************************************************************/
    4160             : EnableStmt: ALTER TRIGGER name_space enable_disable
    4161             :         {
    4162             :                 EnableStmt *n = makeNode(EnableStmt );
    4163             :                 n->obj_type = OBJ_TYPE_TRIG;
    4164             :                 n->obj_name = $3;
    4165           0 :                 n->enable = $4;
    4166           0 :                 $$ = (Node*)n;
    4167           0 :         }
    4168           0 :         ;
    4169           0 :  
    4170             : /*****************************************************************************
    4171           0 :  *
    4172             :  *      ALTER TABLE variations
    4173             :  *
    4174             :  *****************************************************************************/
    4175             : //add opt_wait bysdc@20190508
    4176             : AlterTableStmt:
    4177             :                 ALTER TABLE name_space add_columns alter_behavior opt_wait
    4178             :                 {
    4179             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4180             :                         n->action = CHG_FIELDS;
    4181             :                         n->relname = $3;
    4182           7 :                         n->add_columns = $4;
    4183           7 :                         n->behavior = ($5==CASCADE? OP_CASCADE : OP_RESTRICT);
    4184           7 :                         n->wait_ms   = $6;//add opt_wait bysdc@20190508
    4185           7 :                         $$ = (Node *)n;
    4186           7 :                 }
    4187           7 :         |   ALTER TABLE name_space alter_columns alter_behavior opt_force opt_wait
    4188           7 :                 {
    4189             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4190           7 :                         n->action = CHG_FIELDS;
    4191             :                         n->relname = $3;
    4192           1 :                         n->alter_columns = $4;
    4193           1 :                         n->behavior = ($5==CASCADE? OP_CASCADE : OP_RESTRICT);
    4194           1 :                         n->opt_force = $6;
    4195           1 :                         n->wait_ms    = $7;//add opt_wait bysdc@20190508
    4196           1 :                         $$ = (Node *)n;
    4197           1 :                 }
    4198           1 :         |       ALTER TABLE name_space drop_columns alter_behavior opt_wait
    4199           1 :                 {
    4200             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4201           1 :                         n->action = CHG_FIELDS;
    4202             :                         n->relname = $3;
    4203           8 :                         n->drop_columns = $4;
    4204           8 :                         n->behavior = ($5==CASCADE? OP_CASCADE : OP_RESTRICT);
    4205           8 :                         n->wait_ms   = $6;//add opt_wait bysdc@20190508
    4206           8 :                         $$ = (Node *)n;
    4207           8 :                 }
    4208           8 : 
    4209           8 :         |       ALTER TABLE name_space add_columns  alter_columns alter_behavior opt_force opt_wait
    4210             :                 {
    4211           8 :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4212             :                         n->action = CHG_FIELDS;
    4213             :                         n->relname = $3;
    4214           0 :                         n->add_columns = $4;
    4215           0 :                         n->alter_columns = $5;
    4216           0 :                         n->behavior = ($6==CASCADE? OP_CASCADE : OP_RESTRICT);
    4217           0 :                         n->opt_force = $7;
    4218           0 :                         n->wait_ms    = $8;//add opt_wait bysdc@20190508
    4219           0 :                         $$ = (Node *)n;
    4220           0 :                 }
    4221           0 :         |       ALTER TABLE name_space add_columns  drop_columns alter_behavior opt_wait
    4222           0 :                 {
    4223             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4224           0 :                         n->action = CHG_FIELDS;
    4225             :                         n->relname = $3;
    4226           0 :                         n->add_columns = $4;
    4227           0 :                         n->drop_columns = $5;
    4228           0 :                         n->behavior = ($6==CASCADE? OP_CASCADE : OP_RESTRICT);
    4229           0 :                         n->wait_ms   = $7;//add opt_wait bysdc@20190508
    4230           0 :                         $$ = (Node *)n;
    4231           0 :                 }
    4232           0 :         |       ALTER TABLE name_space alter_columns  drop_columns alter_behavior opt_force opt_wait
    4233           0 :                 {
    4234             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4235           0 :                         n->action = CHG_FIELDS;
    4236             :                         n->relname = $3;
    4237           0 :                         n->alter_columns = $4;
    4238           0 :                         n->drop_columns = $5;
    4239           0 :                         n->behavior = ($6==CASCADE? OP_CASCADE : OP_RESTRICT);
    4240           0 :                         n->opt_force = $7;
    4241           0 :                         n->wait_ms    = $8;//add opt_wait bysdc@20190508
    4242           0 :                         $$ = (Node *)n;
    4243           0 :                 }
    4244           0 :         |       ALTER TABLE name_space add_columns alter_columns drop_columns alter_behavior opt_force opt_wait
    4245           0 :                 {
    4246             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4247           0 :                         n->action = CHG_FIELDS;
    4248             :                         n->relname = $3;
    4249           0 :                         n->add_columns = $4;
    4250           0 :                         n->alter_columns = $5;
    4251           0 :                         n->drop_columns = $6;
    4252           0 :                         n->behavior = ($7==CASCADE? OP_CASCADE : OP_RESTRICT);
    4253           0 :                         n->opt_force = $8;
    4254           0 :                         n->wait_ms    = $9;//add opt_wait bysdc@20190508
    4255           0 :                         $$ = (Node *)n;
    4256           0 :                 }       
    4257           0 :         | ALTER TABLE name_space  MODIFY CONSTRAINT ColId enable_disable 
    4258           0 :                         opt_validate exceptions_opt cascade_opt keep_index_opt opt_wait
    4259             :                 {
    4260           0 :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4261             :                         n->action = CHG_CONS;
    4262             :                         n->relname = $3;
    4263           0 :                         n->wait_ms = $12;//add opt_wait bysdc@20190508
    4264           0 :                         $$ = (Node*)n;  
    4265           0 :                 }       
    4266           0 :         | ALTER TABLE name_space  ENABLE CONSTRAINT name_list keep_index_opt alter_behavior opt_wait
    4267           0 :                 {
    4268             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4269           0 :                         n->action = ENABLE_CONS;
    4270             :                         n->relname = $3;
    4271           0 :                         n->cons_name_list = $6;
    4272           0 :                         n->keep_idx = $7;
    4273           0 :                         n->behavior = ($8==CASCADE? OP_CASCADE : OP_RESTRICT);
    4274           0 :                         n->wait_ms   = $9;//add opt_wait bysdc@20190508
    4275           0 :                         $$ = (Node*)n;  
    4276           0 :                 }       
    4277           0 :         | ALTER TABLE name_space  DISABLE CONSTRAINT name_list keep_index_opt alter_behavior opt_wait
    4278           0 :                 {
    4279             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4280           0 :                         n->action = DISABLE_CONS;
    4281             :                         n->relname = $3;
    4282           0 :                         n->cons_name_list = $6;
    4283           0 :                         n->keep_idx = $7;
    4284           0 :                         n->behavior = ($8==CASCADE? OP_CASCADE : OP_RESTRICT);
    4285           0 :                         n->wait_ms   = $9;//add opt_wait bysdc@20190508
    4286           0 :                         $$ = (Node*)n;  
    4287           0 :                 }       
    4288           0 :         | ALTER TABLE name_space DROP CONSTRAINT name_list keep_drop_opt alter_behavior opt_wait
    4289           0 :                 {
    4290             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4291           0 :                         n->action = DROP_CONS;
    4292             :                         n->relname = $3;
    4293           4 :                         n->cons_name_list = $6;
    4294           4 :                         n->keep_idx = $7;
    4295           4 :                         n->behavior = ($8==CASCADE? OP_CASCADE : OP_RESTRICT);
    4296           4 :                         n->wait_ms   = $9;//add opt_wait bysdc@20190508
    4297           4 :                         $$ = (Node *)n;
    4298           4 :                 }
    4299           4 :         | ALTER TABLE name_space OWNER TO UserId opt_wait
    4300           4 :                 {
    4301             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4302           4 :                         n->action = CHG_OWNER;
    4303             :                         n->relname = $3;
    4304           0 :                         n->name = $6;
    4305           0 :                         n->wait_ms   = $7;//add opt_wait bysdc@20190508
    4306           0 :                         $$ = (Node *)n;
    4307           0 :                 }
    4308           0 :         | ALTER TABLE name_space SET ONLINE opt_wait
    4309           0 :                 {
    4310             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4311           0 :                         n->action = SET_ONLINE;
    4312             :                         n->relname = $3;
    4313           0 :                         n->wait_ms   = $6;//add opt_wait bysdc@20190508
    4314           0 :                         $$ = (Node *)n; 
    4315           0 :                 }
    4316           0 :         | ALTER TABLE name_space ENABLE operation_commalist opt_wait
    4317           0 :                 {
    4318             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4319           0 :                         n->action = ENABLE_OP;
    4320             :                         n->relname = $3;
    4321           0 :                         n->acl_mask = $5;
    4322           0 :                         n->wait_ms   = $6;//add opt_wait bysdc@20190508
    4323           0 :                         $$ = (Node *)n;
    4324           0 :                 }
    4325           0 :         | ALTER TABLE name_space DISABLE operation_commalist opt_wait
    4326           0 :                 {
    4327             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4328           0 :                         n->action = DISABLE_OP;
    4329             :                         n->relname = $3;
    4330           0 :                         n->acl_mask = $5;
    4331           0 :                         n->wait_ms   = $6;//add opt_wait bysdc@20190508
    4332           0 :                         $$ = (Node *)n; 
    4333           0 :                 }
    4334           0 :         | ALTER TABLE name_space SET OFFLINE opt_wait
    4335           0 :                 {
    4336             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4337           0 :                         n->action = SET_OFFLINE;
    4338             :                         n->relname = $3;
    4339           0 :                         n->wait_ms   = $6;//add opt_wait bysdc@20190508
    4340           0 :                         $$ = (Node *)n;
    4341           0 :                 }                                                                               
    4342           0 :         | ALTER TABLE name_space SET PARTITION ColId ONLINE opt_wait
    4343           0 :                 {
    4344             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4345           0 :                         n->action = PART_ONLINE;  
    4346             :                         n->relname = $3;
    4347           0 :                         n->parti_name= $6;
    4348           0 :                         n->wait_ms   = $8;//add opt_wait bysdc@20190508
    4349           0 :                         $$ = (Node *)n;
    4350           0 :                 }
    4351           0 :         | ALTER TABLE name_space SET PARTITION ColId OFFLINE opt_wait
    4352           0 :                 {
    4353             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4354           0 :                         n->action = PART_OFFLINE; 
    4355             :                         n->relname = $3;
    4356           0 :                         n->parti_name = $6;
    4357           0 :                         n->wait_ms   = $8;//add opt_wait bysdc@20190508
    4358           0 :                         $$ = (Node *)n;
    4359           0 :                 }
    4360           0 :         | ALTER TABLE name_space DROP PARTITION ColId  opt_rebuild_idx opt_wait
    4361           0 :                 {
    4362             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4363           0 :                         n->action = DROP_PART;
    4364             :                         n->relname = $3;
    4365           0 :                         n->parti_name = $6;
    4366           0 :                         n->rebuild_idx = $7;
    4367           0 :                         n->wait_ms   = $8;//add opt_wait bysdc@20190508
    4368           0 :                         $$ = (Node *)n;
    4369           0 :                 }
    4370           0 :                 //why 2016-11-03 add opt_rebuild_idx
    4371           0 :         | ALTER TABLE name_space TRUNCATE PARTITION  ColId  opt_rebuild_idx opt_wait
    4372             :                 {
    4373           0 :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4374             :                         n->action = TRUNC_PART;
    4375             :                         n->relname = $3;
    4376           0 :                         n->parti_name = $6;
    4377           0 :                         n->rebuild_idx = $7; //why 2016-11-03 add
    4378           0 :                         n->wait_ms   = $8;//add opt_wait bysdc@20190508
    4379           0 :                         $$ = (Node *)n;
    4380           0 :                 }                       
    4381           0 :         | ALTER TABLE name_space ADD PARTITION  ColId  VALUES '(' parti_values ')' opt_wait
    4382           0 :                 {
    4383             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4384           0 :                         n->action = ADD_PART;
    4385             :                         n->relname = $3;
    4386           0 :                         n->parti_name = $6;
    4387           0 :                         n->parti_type = LIST_PARTITION;
    4388           0 :                         n->parti_vals = $9;
    4389           0 :                         n->wait_ms   = $11;//add opt_wait bysdc@20190508
    4390           0 :                         $$ = (Node *)n;
    4391           0 :                 }                                       
    4392           0 :         | ALTER TABLE name_space ADD PARTITION  ColId  VALUES LESS THAN '(' parti_values ')' opt_wait
    4393           0 :                 {
    4394             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4395           0 :                         n->action = ADD_PART;
    4396             :                         n->relname = $3;
    4397           0 :                         n->parti_name = $6;
    4398           0 :                         n->parti_type = RANGE_PARTITION;
    4399           0 :                         n->parti_vals = $11;
    4400           0 :                         n->wait_ms   = $13;//add opt_wait bysdc@20190508
    4401           0 :                         $$ = (Node *)n;
    4402           0 :                 }
    4403           0 :         | ALTER TABLE name_space REBUILD HEAP opt_wait
    4404           0 :                 {
    4405             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4406           0 :                         n->action = REBLD_HEAP;
    4407             :                         n->relname = $3;
    4408           0 :                         n->wait_ms   = $6;//add opt_wait bysdc@20190508
    4409           0 :                         $$ = (Node *)n;
    4410           0 :                 } 
    4411           0 :         | ALTER TABLE name_space SET SLOW MODIFY ON opt_wait
    4412           0 :                 {
    4413             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4414           0 :                         n->action = SET_SLOW_MODI;
    4415             :                         n->relname = $3;
    4416           0 :                         n->wait_ms   = $8;//add opt_wait bysdc@20190508
    4417           0 :                         $$ = (Node *)n;
    4418           0 :                 }
    4419           0 :         | ALTER TABLE name_space SET SLOW MODIFY OFF opt_wait
    4420           0 :                 {
    4421             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4422           0 :                         n->action = CLR_SLOW_MODI;
    4423             :                         n->relname = $3;
    4424           0 :                         n->wait_ms   = $8;//add opt_wait bysdc@20190508
    4425           0 :                         $$ = (Node *)n;
    4426           0 :                 }
    4427           0 :         /* ++bysdc@20201116 */
    4428           0 :         | ALTER TABLE name_space SET CACHE BY '(' name_list ')' opt_wait
    4429             :                 {
    4430           0 :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4431             :                         n->action = SET_CACHE_ON;
    4432             :                         n->relname = $3;
    4433           0 :                         n->cache_keys = $8;
    4434           0 :                         n->wait_ms   = $10;
    4435           0 :                         $$ = (Node *)n;
    4436           0 :                 }
    4437           0 :         | ALTER TABLE name_space SET CACHE OFF opt_wait
    4438           0 :                 {
    4439             :                         AlterTableStmt *n = makeNode(AlterTableStmt);
    4440           0 :                         n->action = SET_CACHE_OFF;
    4441             :                         n->relname = $3;
    4442           0 :                         n->wait_ms   = $7;
    4443           0 :                         $$ = (Node *)n;
    4444           0 :                 }
    4445           0 :                 ;
    4446           0 : 
    4447             : add_columns:
    4448           0 :                 ADD opt_column table_elements 
    4449             :                 {
    4450             :                         $$ = $3;
    4451             :                 }       
    4452             :         | ADD opt_column '(' table_elements ')'
    4453           6 :                 {
    4454             :                         $$ = $4;
    4455           6 :                 }       
    4456             :                 ;
    4457           1 :                 
    4458             : alter_columns: 
    4459           1 :                 ALTER opt_column alt_columns
    4460             :                 {
    4461             :                         $$ = $3;
    4462             :                 }               
    4463             :         | ALTER opt_column '(' alt_columns ')'
    4464           1 :                 {
    4465             :                         $$ = $4;
    4466           1 :                 }       
    4467             :                 ;
    4468           0 :                 
    4469             : drop_columns:
    4470           0 :                  DROP COLUMN name_list
    4471             :                 {
    4472             :                         $$ = $3;
    4473             :                 }               
    4474             :                 ;
    4475           8 :                 
    4476             : enable_disable:
    4477           8 :                 {
    4478             :                         $$ = true;
    4479             :                 }
    4480             :         |  ENABLE
    4481        1171 :                 {
    4482             :                         $$ = true;
    4483        1171 :                 }
    4484             :         |       DISABLE
    4485           0 :                 {
    4486             :                         $$ = false;
    4487           0 :                 }
    4488             :         ;
    4489           0 : 
    4490             : opt_validate:
    4491           0 :                 {
    4492             :                         $$ = true;
    4493             :                 }
    4494             :         |  VALIDATE
    4495           0 :                 {
    4496             :                         $$ = true; 
    4497           0 :                 }
    4498             :         |       NOVALIDATE
    4499           0 :                 {
    4500             :                         $$ = false;
    4501           0 :                 }
    4502             :         ;
    4503           0 : 
    4504             : exceptions_opt:
    4505           0 :                 {
    4506             :                         $$ = (char*)NULL;
    4507             :                 }
    4508             :         |       EXCEPTIONS INTO name_space
    4509           0 :                 {
    4510             :                         $$ = (char*)$3;
    4511           0 :                 }
    4512             :                 ;
    4513           0 : 
    4514             : cascade_opt:
    4515           0 :                 {
    4516             :                         $$ = false;
    4517             :                 }
    4518             :         |       CASCADE
    4519           0 :                 {
    4520             :                         $$ = true;
    4521           0 :                 }
    4522             :         ;
    4523           0 : /*same as keep_drop_opt ,but default value is true*/
    4524             : keep_index_opt:
    4525           0 :                 {
    4526             :                         $$ = true;
    4527             :                 }
    4528             :         |       KEEP    INDEX
    4529           0 :                 {
    4530             :                         $$ = true;
    4531           0 :                 }
    4532             :         |       DROP    INDEX
    4533           0 :                 {
    4534             :                         $$ = false;
    4535           0 :                 }
    4536             :         ;
    4537           0 :         
    4538             : keep_drop_opt:
    4539           0 :                 {
    4540             :                         $$ = false;
    4541             :                 }
    4542             :         |       KEEP    INDEX
    4543           4 :                 {
    4544             :                         $$ = true;
    4545           4 :                 }
    4546             :         |       DROP    INDEX
    4547           0 :                 {
    4548             :                         $$ = false;
    4549           0 :                 }
    4550             :         ;
    4551           0 : 
    4552             : 
    4553           0 : opt_rebuild_idx:
    4554             :                                 {
    4555             :                                         $$ = false;
    4556             :                                 }
    4557             :                         |       REBUILD GLOBAL  INDEX
    4558           0 :                                 {
    4559             :                                         $$ = true;
    4560           0 :                                 }
    4561             :                         ;
    4562           0 : alt_columns:    alter_column_item
    4563             :                                 {
    4564           0 :                                         $$ = makeList1($1);
    4565             :                                 }
    4566             :                         |   columnDef
    4567           1 :                                 {
    4568             :                                         $$ = makeList1($1);
    4569           1 :                                 }       
    4570             :                         |       alt_columns ',' alter_column_item
    4571           0 :                                 {
    4572             :                                         $$ = lappend($1,$3);
    4573           0 :                                 }
    4574             :                         |       alt_columns ',' columnDef
    4575           0 :                                 {
    4576             :                                         $$ = lappend($1,$3);
    4577           0 :                                 }               
    4578             :                         ;       
    4579           0 :                                                         
    4580             : alter_column_item:
    4581           0 :                 ColId SET DEFAULT b_expr
    4582             :                         {
    4583             :                                 AlterColumn     *p_alt = makeNode(AlterColumn);
    4584             :                                 p_alt->col_name = $1;
    4585             :                                 /* Treat SET DEFAULT NULL the same as DROP DEFAULT */
    4586           1 :                                 if (exprIsNullConstant($4))
    4587           1 :                                         p_alt->def_val = (Node*)NULL;
    4588             :                                 else
    4589           1 :                                         p_alt->def_val = $4;
    4590           0 :                                 p_alt->alt_type = ADD_DEFAULT_VAL;
    4591             :                                 $$ = (Node*)p_alt;      
    4592           1 :                         }
    4593           1 :                 |ColId  DROP DEFAULT                            
    4594           1 :                         {
    4595             :                                 AlterColumn     *p_alt = makeNode(AlterColumn);
    4596           1 :                                 p_alt->col_name = $1;
    4597             :                                 p_alt->alt_type = DROP_DEFAULT_VAL; 
    4598           0 :                                 $$ =(Node*) p_alt; 
    4599           0 :                         }
    4600           0 :                 |ColId  SET NOT _NULL                           
    4601           0 :                         { 
    4602             :                                 AlterColumn     *p_alt = makeNode(AlterColumn);
    4603           0 :                                 p_alt->col_name = $1;
    4604             :                                 p_alt->alt_type = SET_NOT_NULL; 
    4605           0 :                                 $$ =(Node*) p_alt;
    4606           0 :                         }
    4607           0 :                 | ColId  SET NOTNULL                            
    4608           0 :                         { 
    4609             :                                 AlterColumn     *p_alt = makeNode(AlterColumn);
    4610           0 :                                 p_alt->col_name = $1;
    4611             :                                 p_alt->alt_type = SET_NOT_NULL; 
    4612           0 :                                 $$ =(Node*) p_alt;
    4613           0 :                         }       
    4614           0 :                 | ColId  SET _NULL                              
    4615           0 :                         { 
    4616             :                                 AlterColumn     *p_alt = makeNode(AlterColumn);
    4617           0 :                                 p_alt->col_name = $1;
    4618             :                                 p_alt->alt_type = CLR_NOT_NULL; 
    4619           0 :                                 $$ =(Node*) p_alt;
    4620           0 :                         }
    4621           0 :                 | ColId  DROP NOT _NULL                         
    4622           0 :                         { 
    4623             :                                 AlterColumn     *p_alt = makeNode(AlterColumn);
    4624           0 :                                 p_alt->col_name = $1;
    4625             :                                 p_alt->alt_type = CLR_NOT_NULL; 
    4626           0 :                                 $$ =(Node*) p_alt;
    4627           0 :                         }
    4628           0 :                 | ColId  DROP NOTNULL                           
    4629           0 :                         { 
    4630             :                                 AlterColumn     *p_alt = makeNode(AlterColumn);
    4631           0 :                                 p_alt->col_name = $1;
    4632             :                                 p_alt->alt_type = CLR_NOT_NULL; 
    4633           0 :                                 $$ =(Node*) p_alt;
    4634           0 :                         }
    4635           0 :         ;
    4636           0 : 
    4637             : alter_behavior: /*empty*/
    4638           0 :                                                                 { $$ = RESTRICT;} 
    4639             :                 |       CASCADE                         { $$ = CASCADE; }
    4640             :                 |       RESTRICT                        { $$ = RESTRICT;}
    4641          15 :         ;
    4642          15 : 
    4643         143 : /*****************************************************************************
    4644          10 :  *
    4645             :  *                              truncate table relname
    4646             :  *
    4647             :  *****************************************************************************/
    4648             : //add opt_wait bysdc@20190508
    4649             : TruncateStmt:  TRUNCATE opt_table name_space opt_wait
    4650             :                 {
    4651             :                         TruncateStmt *n = makeNode(TruncateStmt);
    4652             :                         n->relName = $3;
    4653             :                         n->wait_ms = $4;//add opt_wait bysdc@20190508
    4654           0 :                         $$ = (Node *)n;                 
    4655           0 :                 }
    4656           0 :                 ;
    4657           0 : 
    4658             : /*****************************************************************************
    4659           0 :  *
    4660             :  *                              drop table relname {CASCADE|RESTRICT}
    4661             :  *
    4662             :  *****************************************************************************/
    4663             :                 
    4664             : DropTabStmt:DROP TABLE opt_if_exists name_space alter_behavior
    4665             :                 {
    4666             :                         DropStmt        *p_stmt = makeNode(DropStmt);
    4667             :                         p_stmt->if_exists = $3;
    4668             :                         p_stmt->obj_name = $4;
    4669         124 :                         p_stmt->behavior = ($5==CASCADE? OP_CASCADE : OP_RESTRICT);
    4670         124 :                         p_stmt->drop_type = DROP_TABLE;
    4671         124 :                         $$ = (Node*)p_stmt;
    4672         124 :                         SetNodePos($$);
    4673         124 :                 }
    4674         124 :                 ;
    4675         124 : 
    4676             : opt_if_exists:/*empty*/
    4677         124 :                 {
    4678             :                         $$ = false;
    4679             :                 }
    4680             :                 | IF EXISTS
    4681         124 :                 {
    4682             :                         $$ = true;
    4683         124 :                 }
    4684             :                 ;
    4685           0 : 
    4686             : /*****************************************************************************
    4687           0 :  *   why 2019-03-25 add
    4688             :  *                              flashback table relname 
    4689             :  *
    4690             :  *****************************************************************************/
    4691             : FlashBackStmt:FLASHBACK TABLE name_space TO BEFORE DROP
    4692             :         {
    4693             :             FlashBackStmt * p_stmt = makeNode(FlashBackStmt);
    4694             :             p_stmt->action   = 1; 
    4695             :             p_stmt->tab_name = $3;              
    4696           0 :             $$ = (Node*)p_stmt;
    4697           0 :                         SetNodePos($$);         
    4698           0 :         }
    4699           0 :         |FLASHBACK TABLE name_space TO BEFORE DROP RENAME TO ColId
    4700           0 :         {
    4701             :             FlashBackStmt * p_stmt = makeNode(FlashBackStmt);
    4702           0 :             p_stmt->action   = 1; 
    4703             :             p_stmt->tab_name = $3;
    4704           0 :             p_stmt->new_name = $9;
    4705           0 :             $$ = (Node*)p_stmt;
    4706           0 :                         SetNodePos($$);
    4707           0 :         }
    4708           0 :         ;
    4709           0 : /*****************************************************************************
    4710             :  *   ++bysdc@20200415
    4711           0 :  *                              xugu profile support
    4712             :  *
    4713             :  *****************************************************************************/
    4714             : CreateProfileStmt:CREATE PROFILE name_space LIMIT ProfileList
    4715             :                 {
    4716             :                         CreateProfileStmt * p_stmt = makeNode(CreateProfileStmt);
    4717             :                         p_stmt->profile_lists = $5;
    4718             :                         $$ = (Node*)p_stmt;
    4719           0 :                 }
    4720           0 : ;
    4721           0 : ProfileList:ProfileItem
    4722             :  {
    4723           0 :         $$ = makeList1($1);
    4724             :  }
    4725             :  | ProfileList ProfileItem
    4726           0 :  {
    4727             :         $$ = lappend($1,$2);
    4728           0 :  }
    4729             :  ;
    4730           0 :  ProfileItem: SESSION_PER_USER ProfileValue
    4731             :  {
    4732           0 :         ProfileItem * p_stmt = makeNode(ProfileItem);
    4733             :         p_stmt->profile_type = PROF_SESSION_PER_USER;
    4734             :         p_stmt->value = $2;
    4735           0 :         $$ = (Node*)p_stmt;
    4736           0 :  }
    4737           0 :  | CPU_PER_SESSION ProfileValue
    4738           0 :  {
    4739             :         ProfileItem * p_stmt = makeNode(ProfileItem);
    4740           0 :         p_stmt->profile_type = PROF_CPU_PER_SESSION;
    4741             :         p_stmt->value = $2;
    4742           0 :         $$ = (Node*)p_stmt;
    4743           0 :  }
    4744           0 :  | CPU_PER_CALL ProfileValue
    4745           0 :  {
    4746             :         ProfileItem * p_stmt = makeNode(ProfileItem);
    4747           0 :         p_stmt->profile_type = PROF_CPU_PER_CALL;
    4748             :         p_stmt->value = $2;
    4749           0 :         $$ = (Node*)p_stmt;
    4750           0 :  }
    4751           0 :  | MAX_CONNECT_TIME ProfileValue
    4752           0 :  {
    4753             :         ProfileItem * p_stmt = makeNode(ProfileItem);
    4754           0 :         p_stmt->profile_type = PROF_MAX_CONNECT_TIME;
    4755             :         p_stmt->value = $2;
    4756           0 :         $$ = (Node*)p_stmt;
    4757           0 :  }
    4758           0 :  | MAX_IDLE_TIME ProfileValue
    4759           0 :  {
    4760             :         ProfileItem * p_stmt = makeNode(ProfileItem);
    4761           0 :         p_stmt->profile_type = PROF_MAX_IDLE_TIME;
    4762             :         p_stmt->value = $2;
    4763           0 :         $$ = (Node*)p_stmt;
    4764           0 :  }
    4765           0 :  | READS_PER_SESSION ProfileValue
    4766           0 :  {
    4767             :         ProfileItem * p_stmt = makeNode(ProfileItem);
    4768           0 :         p_stmt->profile_type = PROF_READS_PER_SESSION;
    4769             :         p_stmt->value = $2;
    4770           0 :         $$ = (Node*)p_stmt;
    4771           0 :  }
    4772           0 :  | READS_PER_CALL ProfileValue
    4773           0 :  {
    4774             :         ProfileItem * p_stmt = makeNode(ProfileItem);
    4775           0 :         p_stmt->profile_type = PROF_READS_PER_CALL;
    4776             :         p_stmt->value = $2;
    4777           0 :         $$ = (Node*)p_stmt;
    4778           0 :  }
    4779           0 :  | TOTAL_RESOURCE_LIMIT ProfileValue
    4780           0 :  {
    4781             :         ProfileItem * p_stmt = makeNode(ProfileItem);
    4782           0 :         p_stmt->profile_type = PROF_TOTAL_RESOURCE_LIMIT;
    4783             :         p_stmt->value = $2;
    4784           0 :         $$ = (Node*)p_stmt;
    4785           0 :  }
    4786           0 :  | PRIVATE_SGA ProfileValue
    4787           0 :  {
    4788             :         ProfileItem * p_stmt = makeNode(ProfileItem);
    4789           0 :         p_stmt->profile_type = PROF_PRIVATE_SGA;
    4790             :         p_stmt->value = $2;
    4791           0 :         $$ = (Node*)p_stmt;
    4792           0 :  }
    4793           0 :  | MAX_STORE_NUM ProfileValue
    4794           0 :  {
    4795             :         ProfileItem * p_stmt = makeNode(ProfileItem);
    4796           0 :         p_stmt->profile_type = PROF_MAX_STORE_NUM;
    4797             :         p_stmt->value = $2;
    4798           0 :         $$ = (Node*)p_stmt;
    4799           0 :  }
    4800           0 :  | CONNECT_NODES ProfileValue
    4801           0 :  {
    4802             :         ProfileItem * p_stmt = makeNode(ProfileItem);
    4803           0 :         p_stmt->profile_type = PROF_CONNECT_NODES;
    4804             :         p_stmt->value = $2;
    4805           0 :         $$ = (Node*)p_stmt;
    4806           0 :  }
    4807           0 :  | STORE_NODES ProfileValue
    4808           0 :  {
    4809             :         ProfileItem * p_stmt = makeNode(ProfileItem);
    4810           0 :         p_stmt->profile_type = PROF_STORE_NODES;
    4811             :         p_stmt->value = $2;
    4812           0 :         $$ = (Node*)p_stmt;
    4813           0 :  }
    4814           0 :  | TEMPSPACE_QUOTA ProfileValue
    4815           0 :  {
    4816             :         ProfileItem * p_stmt = makeNode(ProfileItem);
    4817           0 :         p_stmt->profile_type = PROF_TEMPSPACE_QUOTA;
    4818             :         p_stmt->value = $2;
    4819           0 :         $$ = (Node*)p_stmt;
    4820           0 :  }
    4821           0 :  | CURSOR_QUOTA ProfileValue
    4822           0 :  {
    4823             :         ProfileItem * p_stmt = makeNode(ProfileItem);
    4824           0 :         p_stmt->profile_type = PROF_CURSOR_QUOTA;
    4825             :         p_stmt->value = $2;
    4826           0 :         $$ = (Node*)p_stmt;
    4827           0 :  }
    4828           0 :  | FAILED_LOGIN_ATTEMPTS ProfileValue
    4829           0 :  {
    4830             :         ProfileItem * p_stmt = makeNode(ProfileItem);
    4831           0 :         p_stmt->profile_type = PROF_FAILED_LOGIN_ATTEMPTS;
    4832             :         p_stmt->value = $2;
    4833           0 :         $$ = (Node*)p_stmt;
    4834           0 :  }
    4835           0 :  | PASSWORD_LIFE_PERIOD ProfileValue
    4836           0 :  {
    4837             :         ProfileItem * p_stmt = makeNode(ProfileItem);
    4838           0 :         p_stmt->profile_type = PROF_PASSWORD_LIFE_PERIOD;
    4839             :         p_stmt->value = $2;
    4840           0 :         $$ = (Node*)p_stmt;
    4841           0 :  }
    4842           0 :  | PASSWORD_LOCK_TIME ProfileValue
    4843           0 :  {
    4844             :         ProfileItem * p_stmt = makeNode(ProfileItem);
    4845           0 :         p_stmt->profile_type = PROF_PASSWORD_LOCK_TIME;
    4846             :         p_stmt->value = $2;
    4847           0 :         $$ = (Node*)p_stmt;
    4848           0 :  }
    4849           0 :  ;
    4850           0 :  ProfileValue:  ICONST                          { $$ = $1; }
    4851             :                 | DEFAULT                                       { $$ = 0; }
    4852           0 :                 | UNLIMITED                                     { $$ = -1; }
    4853           0 :                 ;
    4854           0 : /*****************************************************************************
    4855           0 :  *
    4856           0 :  *              QUERY :
    4857             :  *                              open <optname>
    4858             :  *
    4859             :  *****************************************************************************/
    4860             : OpenCursorStmt: OPEN  ColId 
    4861             :         {
    4862             :                 OpenCursorStmt *p_stmt = makeNode(OpenCursorStmt);
    4863             :                 p_stmt->cursor_name = $2;
    4864             :                 $$ = (Node*)p_stmt;
    4865           0 :                 SetNodePos($$);
    4866           0 :         }
    4867           0 :         | OPEN  ColId '(' expr_list ')' 
    4868           0 :         {
    4869             :                 OpenCursorStmt *p_stmt = makeNode(OpenCursorStmt);
    4870           0 :                 p_stmt->cursor_name = $2;
    4871             :                 p_stmt->params = $4;
    4872           0 :                 $$ = (Node*)p_stmt;
    4873           0 :                 SetNodePos($$);
    4874           0 :         }
    4875           0 :         /*why 2015-11-18 modify (add opt_using)old:
    4876           0 :         | OPEN ColId FOR b_expr
    4877             :         {
    4878           0 :                 OpenCursorStmt *p_stmt = makeNode(OpenCursorStmt);
    4879             :                 p_stmt->cursor_name = $2;
    4880             :                 p_stmt->cursor_var = (A_Expr*)$4;
    4881             :                 $$ = (Node*)p_stmt;
    4882             :                 SetNodePos($$);
    4883             :         }
    4884             :         | OPEN ColId FOR select_no_parens
    4885             :         {
    4886             :                 OpenCursorStmt *p_stmt = makeNode(OpenCursorStmt);
    4887             :                 p_stmt->cursor_name = $2;
    4888             :                 p_stmt->select_stmt = (SelectStmt*)$4;
    4889             :                 $$ = (Node*)p_stmt;
    4890             :                 SetNodePos($$);
    4891             :         }*/
    4892             :         | OPEN ColId FOR b_expr opt_using
    4893             :         {
    4894             :                 OpenCursorStmt *p_stmt = makeNode(OpenCursorStmt);
    4895             :                 p_stmt->cursor_name = $2;
    4896             :                 p_stmt->cursor_var  = (A_Expr*)$4;
    4897           0 :                 p_stmt->params      = $5;
    4898           0 :                 $$ = (Node*)p_stmt;
    4899           0 :                 SetNodePos($$);
    4900           0 :         }
    4901           0 :         | OPEN ColId FOR select_no_parens opt_using
    4902           0 :         {
    4903             :             OpenCursorStmt *p_stmt = makeNode(OpenCursorStmt);
    4904           0 :                 p_stmt->cursor_name = $2;
    4905             :                 p_stmt->select_stmt = (SelectStmt*)$4;
    4906           0 :                 p_stmt->params      = $5;
    4907           0 :                 $$ = (Node*)p_stmt;
    4908           0 :                 SetNodePos($$);
    4909           0 :         }
    4910           0 :         ;
    4911           0 : 
    4912             : /*****************************************************************************
    4913           0 :  *
    4914             :  *              QUERY :
    4915             :  *                              close <optname>
    4916             :  *
    4917             :  *****************************************************************************/
    4918             : 
    4919             : CloseCursorStmt:  CLOSE 
    4920             :         {
    4921             :                 CloseCursorStmt *n = makeNode(CloseCursorStmt);
    4922             :                 n->cursor_name = NULL;
    4923             :                 $$ = (Node *)n;
    4924           0 :         }
    4925           0 :         | CLOSE ColId
    4926           0 :         {
    4927             :                 CloseCursorStmt *n = makeNode(CloseCursorStmt);
    4928           0 :                 n->cursor_name = $2;
    4929             :                 $$ = (Node *)n;
    4930           0 :         }
    4931           0 :         ;
    4932           0 : 
    4933             : CheckTabStmt: CHECK TABLE name_list
    4934           0 :                 {
    4935             :                         CheckTabStmt *p_stmt = makeNode(CheckTabStmt);
    4936             :                         p_stmt->names = $3;
    4937             :                         $$ = (Node*) p_stmt;    
    4938           0 :                 }
    4939           0 :                 ;               
    4940           0 : 
    4941             : /*****************************************************************************
    4942           0 :  *
    4943             :  *              QUERY :
    4944             :  *                              CREATE relname
    4945             :  *
    4946             :  *****************************************************************************/
    4947             : CreateTabStmt: 
    4948             :         CREATE OptTemp  TABLE opt_if_not_exists name_space '(' table_elements ')'
    4949             :         on_commit_del   ena_trans_opt  opt_phyical_props  
    4950             :         opt_partitioning_clause  opt_subpartitioning_clause 
    4951             :         opt_constraint_props  opt_store_props opt_comment opt_encrypt
    4952             :         {
    4953             :                 CreateTabStmt *n = makeNode(CreateTabStmt);
    4954             :                 n->temp = $2;
    4955             :                 n->if_not_exists = $4;
    4956        1068 :                 n->relname = $5;
    4957        1068 :                 n->table_eles = $7;
    4958        1068 :                 n->constraints = NIL;
    4959        1068 :                 n->on_commit_del = $9;
    4960        1068 :                 n->phy_prop = (PhysiProp*)$11;
    4961        1068 :                 n->parti_prop = (PartiProp*)$12;
    4962        1068 :                 n->subpa_prop = (PartiProp*)$13;
    4963        1068 :                 n->cons_props = (List*)$14;
    4964        1068 :                 n->store_prop = (StoreProp*)$15;
    4965        1068 :                 n->comments = $16;
    4966        1068 :                 n->parallel = 1;
    4967        1068 :                 n->encry_name         = $17;
    4968        1068 :                 $$ = (Node *)n; 
    4969        1068 :         }               
    4970        1068 :         ;       
    4971        1068 : 
    4972             : opt_if_not_exists: IF NOT EXISTS
    4973        1068 :                 {
    4974             :                         $$ = true;
    4975             :                 }
    4976             :                 |/*empty*/
    4977           0 :                 {
    4978             :                         $$ = false;
    4979           0 :                 }
    4980             :                 ;
    4981        1070 : 
    4982             : on_commit_del:
    4983        1070 :                 {
    4984             :                         $$ = -1;
    4985             :                 }
    4986             :         |       ON COMMIT _DELETE ROWS
    4987        1068 :                 {
    4988             :                         $$ = 1;
    4989        1068 :                 }
    4990             :         |       ON COMMIT PRESERVE ROWS
    4991           0 :                 {
    4992             :                         $$ = 0;
    4993           0 :                 }
    4994             :                 ;
    4995           0 : 
    4996             : opt_phyical_props:
    4997           0 :         {
    4998             :                 $$ = (Node*)makeNode(PhysiProp);
    4999             :         }
    5000             :         |       ORGANIZATION HEAP 
    5001        1068 :         {
    5002             :                 $$  = (Node*)makeNode(PhysiProp);
    5003        1068 :         }
    5004             :         /* bysdc@20220406 Does not support IOT until full implementation
    5005           0 :         |       ORGANIZATION INDEX 
    5006             :         {
    5007           0 :                 PhysiProp *p_phy = makeNode(PhysiProp);
    5008             :                 p_phy->is_iot = true;
    5009             :                 $$ = (Node*)p_phy;                      
    5010             :         }
    5011             :         |       ORGANIZATION INDEX  '(' name_list ')'
    5012             :         {
    5013             :                 PhysiProp *p_phy = makeNode(PhysiProp);
    5014             :                 p_phy->is_iot = true;
    5015             :                 p_phy->iot_idx_cols = $4;
    5016             :                 $$ = (Node*)p_phy;                      
    5017             :         }
    5018             :         */
    5019             :         |       ORGANIZATION  EXTERNAL '(' opt_file_type opt_default_dir LOCATION Sconst ')'
    5020             :                 {
    5021             :                         PhysiProp *p_phy = makeNode(PhysiProp);
    5022             :                         p_phy->file_type = $4;
    5023             :                         p_phy->default_dir = $5;
    5024           0 :                         p_phy->file_location = dbs2utf($7);
    5025           0 :                         p_phy->is_file = true;
    5026           0 :                         $$ = (Node*)p_phy;                      
    5027           0 :                 }
    5028           0 :         |       ORGANIZATION  EXTERNAL
    5029           0 :                 '(' 
    5030             :                         opt_file_type 
    5031           0 :                         opt_default_dir  
    5032             :                         ACCESS PARAMETERS 
    5033             :                         '('   
    5034             :                                 RECORDS DELIMITED BY terminated_chars
    5035             :                                 FIELDS TERMINATED BY terminated_chars 
    5036             :                                 opt_badfile 
    5037             :                                 opt_discordfile
    5038             :                                 opt_logfile
    5039             :                                 opt_missing_field_value  
    5040             :                         ')'
    5041             :                         LOCATION Sconst 
    5042             :                 ')'
    5043             :                 {
    5044             :                         PhysiProp *p_phy = makeNode(PhysiProp);
    5045             :                         p_phy->file_type = $4;
    5046             :                         p_phy->default_dir = $5;
    5047           0 :                         p_phy->row_delimiter = $12;
    5048           0 :                         p_phy->col_delimiter = $16;
    5049           0 :                         p_phy->bad_file = $17;
    5050           0 :                         p_phy->discord_file = $18;
    5051           0 :                         p_phy->log_file = $19;
    5052           0 :                         p_phy->missing_value  = $20;
    5053           0 :                         p_phy->file_location = $23;
    5054           0 :                         p_phy->is_file = true;
    5055           0 :                         $$ = (Node*)p_phy;                      
    5056           0 :                 }
    5057           0 :                 ;
    5058           0 : 
    5059             : /*enable or disable transaction support*/                               
    5060           0 : ena_trans_opt:  /*empty*/
    5061             :         {
    5062             :                 $$ = 1; /*default decide by runtime*/
    5063             :         }
    5064             :         |       DISABLE TRANSACTION
    5065        1068 :         {
    5066             :                 $$ = 0; /*unsupport transaction*/
    5067        1068 :         }
    5068             :         |       ENABLE TRANSACTION
    5069           0 :         {
    5070             :                 $$ = 2; /*support transaction*/
    5071           0 :         }
    5072             :         ;                                               
    5073           0 : 
    5074             : opt_file_type:
    5075           0 :                 {
    5076             :                         $$ = NULL;
    5077             :                 } 
    5078             :                 | TYPE ColId
    5079           0 :                 {
    5080             :                         $$ = $2;
    5081           0 :                 }
    5082             :                 ;
    5083           0 :                 
    5084             : opt_default_dir:
    5085           0 :                 {
    5086             :                         $$ = NULL;
    5087             :                 } 
    5088             :                 | DEFAULT _DIR ColId
    5089           0 :                 {
    5090             :                         $$ = $3;
    5091           0 :                 }
    5092             :                 | DEFAULT _DIR Sconst   
    5093           0 :                 {
    5094             :                         $$ = dbs2utf($3);
    5095           0 :                 }
    5096             :                 ;
    5097           0 :                 
    5098             : opt_badfile:
    5099           0 :                 {
    5100             :                         $$ = NULL;
    5101             :                 }       
    5102             :                 | BADFILE Sconst
    5103           0 :                 {
    5104             :                         $$ = dbs2utf($2);
    5105           0 :                 }
    5106             :                 ;
    5107           0 :                 
    5108             : opt_discordfile:
    5109           0 :                 {
    5110             :                         $$ = NULL;
    5111             :                 }
    5112             :                 | DISCORDFILE Sconst
    5113           0 :                 {
    5114             :                         $$ = dbs2utf($2);
    5115           0 :                 }
    5116             :                 ;
    5117           0 :                 
    5118             : opt_logfile:
    5119           0 :                 {
    5120             :                         $$ = NULL;
    5121             :                 }
    5122             :                 | LOGFILE Sconst
    5123           0 :                 {
    5124             :                         $$ = dbs2utf($2);
    5125           0 :                 }
    5126             :                 ;
    5127           0 :                 
    5128             : opt_missing_field_value:
    5129           0 :                 {
    5130             :                         $$ = NULL;
    5131             :                 }       
    5132             :                 | MISSING FIELD VALUES ARE c_expr
    5133           0 :                 {
    5134             :                         $$ = $5;
    5135           0 :                 }
    5136             :         ;
    5137           0 : 
    5138             : opt_store_props: /*empty*/
    5139           0 :         {
    5140             :                 $$ = NULL;
    5141             :         }
    5142             :         |       store_props
    5143        1068 :         {
    5144             :                 $$ = $1;
    5145        1068 :         }
    5146             :         ;       
    5147           0 :                                                                                                                                                                                 
    5148             : store_props: store_prop
    5149           0 :         {
    5150             :                 $$ = $1;
    5151             :         }
    5152             :         |       store_props  store_prop
    5153           0 :         {
    5154             :                 StoreProp *p_attr1 = (StoreProp*)$1;
    5155           0 :                 StoreProp *p_attr2 = (StoreProp*)$2;
    5156             :                 
    5157           0 :                 if(p_attr2)
    5158           0 :                 {
    5159             :                         if(p_attr2->pct_free>0)
    5160           0 :                                 p_attr1->pct_free = p_attr2->pct_free;    
    5161             :                         if(p_attr2->copy_num>0)
    5162           0 :                                 p_attr1->copy_num = p_attr2->copy_num;
    5163           0 :                         if(p_attr2->hot_num>0)
    5164           0 :                                 p_attr1->hot_num = p_attr2->hot_num;
    5165           0 :                         if(p_attr2->compress_level>0)
    5166           0 :                                 p_attr1->compress_level = p_attr2->compress_level;
    5167           0 :                         p_attr1->zone_ply = p_attr2->zone_ply;/*why 2019-06-13 add*/              
    5168           0 :                         p_attr1->flags |= p_attr2->flags;
    5169           0 :                 }
    5170           0 :                 $$ = (Node*)$1;
    5171           0 :         }
    5172             :         ;
    5173           0 : 
    5174             : store_prop:     PCTFREE ICONST
    5175           0 :                 {
    5176             :                         StoreProp *p_prop = makeNode(StoreProp);
    5177             :                         p_prop->pct_free = $2;
    5178             :                         
    5179           0 :                         if(p_prop->pct_free>99 || p_prop->pct_free<0)
    5180           0 :                         {
    5181             :                                 SetParsePos();
    5182           0 :                                 add_parse_error(60);
    5183             :                         }
    5184           0 :                         $$ = (Node*)p_prop;
    5185           0 :                 }
    5186             :         |       PCTUSED ICONST
    5187           0 :                 {
    5188             :                         StoreProp *p_prop = makeNode(StoreProp);
    5189           0 :                         p_prop->pct_free = 100 - $2;
    5190             :                         if(p_prop->pct_free>99 || p_prop->pct_free<0)
    5191           0 :                         {
    5192           0 :                                 SetParsePos();
    5193           0 :                                 add_parse_error(61);
    5194             :                         }
    5195           0 :                         $$ = (Node*)p_prop;                             
    5196           0 :                 }
    5197             :         |   HOTSPOT ICONST
    5198           0 :                 {
    5199             :                         StoreProp *p_prop = makeNode(StoreProp);
    5200           0 :                         p_prop->hot_num = $2;
    5201             :                         $$ = (Node*)p_prop;
    5202           0 :                 }
    5203           0 :         |       CACHE
    5204           0 :                 {
    5205             :                         StoreProp *p_prop = makeNode(StoreProp);
    5206           0 :                         p_prop->flags = ENABLE_CACHE;
    5207             :                         $$ = (Node*)p_prop;             
    5208           0 :                 }
    5209           0 :         |       NOCACHE
    5210           0 :                 {
    5211             :                         StoreProp *p_prop = makeNode(StoreProp);
    5212           0 :                         p_prop->flags = DISABLE_CACHE;
    5213             :                         $$ = (Node*)p_prop;     
    5214           0 :                 }
    5215           0 :         |       LOGGING
    5216           0 :                 {
    5217             :                         StoreProp *p_prop = makeNode(StoreProp);
    5218           0 :                         p_prop->flags  = ENABLE_LOGGING;
    5219             :                         $$ = (Node*)p_prop;     
    5220           0 :                 }
    5221           0 :         |       NOLOGGING
    5222           0 :                 {
    5223             :                         StoreProp *p_prop = makeNode(StoreProp);
    5224           0 :                         p_prop->flags = DISABLE_LOGGING;
    5225             :                         $$ = (Node*)p_prop;     
    5226           0 :                 }
    5227           0 :         | COMPRESS
    5228           0 :                 {
    5229             :                         StoreProp *p_prop = makeNode(StoreProp);
    5230           0 :                         p_prop->compress_level = 1;
    5231             :                         $$ = (Node*)p_prop;
    5232           0 :                 }
    5233           0 :         | NOCOMPRESS
    5234           0 :                 {
    5235             :                         StoreProp *p_prop = makeNode(StoreProp);
    5236           0 :                         p_prop->compress_level = 0;
    5237             :                         $$ = (Node*)p_prop;
    5238           0 :                 }
    5239           0 :         | INITRANS ICONST
    5240           0 :                 {
    5241             :                         $$ = NULL;
    5242           0 :                 }
    5243             :         | MAXTRANS ICONST
    5244           0 :                 {
    5245             :                         $$ = NULL;
    5246           0 :                 }
    5247             :         | COMPUTE STATISTICS
    5248           0 :                 {
    5249             :                         $$ = NULL;
    5250           0 :                 }               
    5251             :         | CACHE READS
    5252           0 :                 {
    5253             :                         StoreProp *p_prop = makeNode(StoreProp);
    5254           0 :                         p_prop->flags = CACHE_READ;
    5255             :                         $$ = (Node*)p_prop;     
    5256           0 :                 }       
    5257           0 :         | COPY NUMBER ICONST 
    5258           0 :                 {
    5259             :                         StoreProp *p_prop = makeNode(StoreProp);
    5260           0 :                         p_prop->copy_num = $3;;
    5261             :                         $$ = (Node*)p_prop;
    5262           0 :                 }
    5263           0 :         | PCTVERSION ICONST
    5264           0 :                 {
    5265             :                         $$ = NULL;      
    5266           0 :                 }
    5267             :         /*why 2019-06-13 add storage zone*/
    5268           0 :         | ZONE BY ICONST
    5269             :             {
    5270           0 :                 StoreProp *p_prop = makeNode(StoreProp);
    5271             :                         p_prop->zone_ply = $3;
    5272             :                         $$ = (Node*)p_prop;             
    5273           0 :         }
    5274           0 :     | ZONE BY LOCAL
    5275           0 :             {
    5276             :                 StoreProp *p_prop = makeNode(StoreProp);
    5277           0 :                         p_prop->zone_ply = -1;
    5278             :                         $$ = (Node*)p_prop;             
    5279           0 :         }
    5280           0 :     /*end */
    5281           0 :                 ;       
    5282             :                         
    5283           0 : 
    5284             : opt_partitioning_clause:
    5285             :         {
    5286             :                 $$ = (Node*)NULL;
    5287             :         }
    5288             :         |       PARTITION BY RANGE '(' name_list ')' opt_parti_interval PARTITIONS '(' range_parti_items ')'  
    5289        1068 :         {
    5290             :                 PartiProp *p_par = makeNode(PartiProp);
    5291        1068 :                 p_par->partition_type = RANGE_PARTITION;
    5292             :                 p_par->col_names = $5;
    5293           0 :                 p_par->interval =  $7;
    5294           0 :                 p_par->partitions = $10;
    5295           0 :                 p_par->parti_num = length($10);
    5296           0 :                 $$ = (Node *)p_par; 
    5297           0 :         }
    5298           0 :         |       PARTITION BY LIST '(' name_list ')' PARTITIONS '(' list_parti_items ')' 
    5299           0 :         {
    5300             :                 PartiProp *p_par = makeNode(PartiProp);
    5301           0 :                 p_par->partition_type = LIST_PARTITION;
    5302             :                 p_par->col_names = $5;
    5303           0 :                 p_par->partitions = $9;
    5304           0 :                 p_par->parti_num = length($9);
    5305           0 :                 $$ = (Node*)p_par;
    5306           0 :         }
    5307           0 :         |  PARTITION BY HASH '(' name_list ')' PARTITIONS ICONST 
    5308           0 :         {
    5309             :                 PartiProp *p_par = makeNode(PartiProp);
    5310           0 :                 p_par->partition_type = HASH_PARTITION;
    5311             :                 p_par->col_names = $5;
    5312           0 :                 p_par->parti_num = $8;
    5313           0 :                 $$ = (Node*)p_par;                      
    5314           0 :         }
    5315           0 :         |  PARTITION BY HASH '(' name_list ')' PARTITIONS '(' name_list ')' 
    5316           0 :         {
    5317             :                 PartiProp *p_par = makeNode(PartiProp);
    5318           0 :                 p_par->partition_type = HASH_PARTITION;
    5319             :                 p_par->col_names = $5;
    5320           0 :                 p_par->parti_num = length($9);
    5321           0 :                 p_par->parti_names = $9;
    5322           0 :                 $$ = (Node*)p_par;                      
    5323           0 :         }
    5324           0 :         ;
    5325           0 : //why 2017-02-22 modify old:
    5326             : /*      
    5327           0 : opt_parti_interval:
    5328             :         {
    5329             :                 $$ = 0;
    5330             :         }
    5331             :         | INTERVAL      ICONST _YEAR
    5332             :         {
    5333             :                 $$ = $2 | 0x10000000;
    5334             :         }
    5335             :         | INTERVAL      ICONST _MONTH
    5336             :         {
    5337             :                 $$ = $2;
    5338             :         }
    5339             :         ;
    5340             :         */
    5341             : opt_parti_interval: /*empty*/
    5342             :         {
    5343             :                 $$ = 0;
    5344             :         }
    5345             :         | INTERVAL      ICONST _YEAR
    5346           0 :         {
    5347             :                 //++bysdc@20190214 for bug2967
    5348           0 :                 if($2 >= 0x01000000 || $2 <= 0)
    5349             :                 {
    5350             :                         SetParsePos();
    5351           0 :                         add_parse_error(1208);
    5352             :                 }
    5353           0 :                 $$ = $2 | 0x01000000;
    5354           0 :         }
    5355             :         | INTERVAL      ICONST _MONTH
    5356           0 :         {
    5357             :                 //++bysdc@20190214 for bug2967
    5358           0 :                 if($2 >= 0x01000000 || $2 <= 0)
    5359             :                 {
    5360             :                         SetParsePos();
    5361           0 :                         add_parse_error(1208);
    5362             :                 }
    5363           0 :                 $$ = $2 | 0x02000000;
    5364           0 :         }
    5365             :         | INTERVAL      ICONST _DAY
    5366           0 :         {
    5367             :                 //++bysdc@20190214 for bug2967
    5368           0 :                 if($2 >= 0x01000000 || $2 <= 0)
    5369             :                 {
    5370             :                         SetParsePos();
    5371           0 :                         add_parse_error(1208);
    5372             :                 }
    5373           0 :                 $$ = $2 | 0x03000000;
    5374           0 :         }
    5375             :         | INTERVAL      ICONST _HOUR
    5376           0 :         {
    5377             :                 //++bysdc@20190214 for bug2967
    5378           0 :                 if($2 >= 0x01000000 || $2 <= 0)
    5379             :                 {
    5380             :                         SetParsePos();
    5381           0 :                         add_parse_error(1208);
    5382             :                 }
    5383           0 :                 $$ = $2 | 0x04000000;
    5384           0 :         }
    5385             :         ;
    5386           0 :         //end
    5387             :                 
    5388           0 : opt_subpartitioning_clause:
    5389             :         {
    5390             :                 $$ = NULL;      
    5391             :         }
    5392             :         | SUBPARTITION BY HASH '(' name_list ')' SUBPARTITIONS ICONST
    5393        1068 :         {
    5394             :                 PartiProp *p_par = makeNode(PartiProp);
    5395        1068 :                 p_par->partition_type = HASH_PARTITION;
    5396             :                 p_par->col_names = $5;
    5397           0 :                 p_par->parti_num = $8;
    5398           0 :                 $$ = (Node*)p_par;              
    5399           0 :         }
    5400           0 :         |  SUBPARTITION BY HASH '(' name_list ')' SUBPARTITIONS '(' name_list ')' 
    5401           0 :         {
    5402             :                 PartiProp *p_par = makeNode(PartiProp);
    5403           0 :                 p_par->partition_type = HASH_PARTITION;
    5404             :                 p_par->col_names = $5;
    5405           0 :                 p_par->parti_num = length($9);
    5406           0 :                 p_par->parti_names = $9;
    5407           0 :                 $$ = (Node*)p_par;                      
    5408           0 :         }
    5409           0 :         | SUBPARTITION BY LIST '(' name_list ')' SUBPARTITIONS '(' list_parti_items ')' 
    5410           0 :         {
    5411             :                 PartiProp *p_par = makeNode(PartiProp);
    5412           0 :                 p_par->partition_type = LIST_PARTITION;
    5413             :                 p_par->col_names = $5;
    5414           0 :                 p_par->partitions = $9;
    5415           0 :                 p_par->parti_num = length($9);
    5416           0 :                 $$ = (Node*)p_par;
    5417           0 :         }
    5418           0 :         | SUBPARTITION BY RANGE '(' name_list ')' SUBPARTITIONS '(' range_parti_items ')' 
    5419           0 :         {
    5420             :                 PartiProp *p_par = makeNode(PartiProp);
    5421           0 :                 p_par->partition_type = RANGE_PARTITION;
    5422             :                 p_par->col_names = $5;
    5423           0 :                 p_par->partitions = $9;
    5424           0 :                 p_par->parti_num = length($9);
    5425           0 :                 $$ = (Node*)p_par;
    5426           0 :         }
    5427           0 :         ;
    5428           0 : 
    5429             : range_parti_items: range_parti_item
    5430           0 :         {
    5431             :                 $$ = makeList1($1);
    5432             :         }
    5433             :         | range_parti_items ',' range_parti_item
    5434           0 :         {
    5435             :                 $$ = lappend($1,$3);
    5436           0 :         }
    5437             :         ;               
    5438           0 :                         
    5439             : range_parti_item: '(' parti_values ')'
    5440           0 :         {
    5441             :                 PartiItem *p_par = makeNode(PartiItem);
    5442             :                 p_par->values = $2;
    5443             :                 $$ = (Node*)p_par;
    5444           0 :         }
    5445           0 :         | '(' MAXVALUES ')'
    5446           0 :         {
    5447             :                 PartiItem *p_par = makeNode(PartiItem);
    5448           0 :                 $$ = (Node*)p_par;
    5449             :         }
    5450           0 :         | ColId VALUES  LESS THAN  '(' parti_values ')'
    5451           0 :         {
    5452             :                 PartiItem *p_par = makeNode(PartiItem);
    5453           0 :                 p_par->name = $1;
    5454             :                 p_par->values = $6;
    5455           0 :                 $$ = (Node*)p_par;
    5456           0 :         }
    5457           0 :         | ColId VALUES  LESS THAN '(' MAXVALUES ')'
    5458           0 :         {
    5459             :                 PartiItem *p_par = makeNode(PartiItem);
    5460           0 :                 p_par->name = $1;
    5461             :                 $$ = (Node*)p_par;
    5462           0 :         }
    5463           0 :         ; 
    5464           0 :         
    5465             : list_parti_items: list_parti_item
    5466           0 :         {
    5467             :                 $$ = makeList1($1);
    5468             :         }
    5469             :         | list_parti_items ',' list_parti_item
    5470           0 :         {
    5471             :                 $$ = lappend($1,$3);
    5472           0 :         }
    5473             :         ;               
    5474           0 :                         
    5475             : list_parti_item: '(' parti_values ')'
    5476           0 :         {
    5477             :                 PartiItem *p_par = makeNode(PartiItem);
    5478             :                 p_par->values = $2;
    5479             :                 $$ = (Node*)p_par;
    5480           0 :         }
    5481           0 :         | ColId VALUES  '(' parti_values ')'
    5482           0 :         {
    5483             :                 PartiItem *p_par = makeNode(PartiItem);
    5484           0 :                 p_par->name = $1;
    5485             :                 p_par->values = $4;
    5486           0 :                 $$ = (Node*)p_par;
    5487           0 :         }
    5488           0 :         | '(' OTHERVALUES ')'
    5489           0 :         {
    5490             :                 PartiItem *p_par = makeNode(PartiItem);
    5491           0 :                 $$ = (Node*)p_par;
    5492             :         }
    5493           0 :         | ColId VALUES  '(' OTHERVALUES ')'
    5494           0 :         {
    5495             :                 PartiItem *p_par = makeNode(PartiItem);
    5496           0 :                 p_par->name = $1;
    5497             :                 $$ = (Node*)p_par;
    5498           0 :         }
    5499           0 :         ; 
    5500           0 :                                 
    5501             : parti_values: c_expr 
    5502           0 :         {
    5503             :                 $$ = makeList1($1);
    5504             :         }
    5505             :         |       parti_values ',' c_expr
    5506           0 :         {
    5507             :                 $$ = lappend($1,$3);
    5508           0 :         }
    5509             :         ;
    5510           0 : 
    5511             : AssistantStmt:
    5512           0 :         '@'  '('  name_list ')'
    5513             :         {
    5514             :                 $$ = (Node*)$3;
    5515             :         }
    5516             :         |       LEXER   TextPattern
    5517           0 :         {
    5518             :                 $$ = $2;
    5519           0 :         }
    5520             :         //++bysdc@20200411
    5521           0 :         |       HINT ALL_ROWS
    5522             :         {
    5523           0 :                 HintNode *p_hn = makeNode(HintNode);
    5524             :                 p_hn->hint_type= HINT_ALL_ROWS;
    5525             :                 $$ = (Node*)p_hn;
    5526           0 :         }
    5527           0 :         |       HINT FIRST_ROWS
    5528           0 :         {
    5529             :                 HintNode *p_hn = makeNode(HintNode);
    5530           0 :                 p_hn->hint_type= HINT_FIRST_ROWS;
    5531             :                 $$ = (Node*)p_hn;
    5532           0 :         }
    5533           0 :         |       HINT CHOOSE
    5534           0 :         {
    5535             :                 HintNode *p_hn = makeNode(HintNode);
    5536           0 :                 p_hn->hint_type= HINT_CHOOSE;
    5537             :                 $$ = (Node*)p_hn;
    5538           0 :         }
    5539           0 :         |       HINT RULE
    5540           0 :         {
    5541             :                 HintNode *p_hn = makeNode(HintNode);
    5542           0 :                 p_hn->hint_type= HINT_RULE;
    5543             :                 $$ = (Node*)p_hn;
    5544           0 :         }
    5545           0 :         |       HINT RESULT_CACHE
    5546           0 :         {
    5547             :                 HintNode *p_hn = makeNode(HintNode);
    5548           0 :                 p_hn->hint_type= HINT_RESULT_CACHE;
    5549             :                 $$ = (Node*)p_hn;
    5550           0 :         }
    5551           0 :         |       HINT FULL '(' name_space ')'
    5552           0 :         {
    5553             :                 HintNode *p_hn  = makeNode(HintNode);
    5554           0 :                 p_hn->hint_type      = HINT_FULL;
    5555             :                 p_hn->tab_list       = makeList1($4);
    5556           0 :                 $$ = (Node*)p_hn;
    5557           0 :         }
    5558           0 :         |       HINT INDEX '(' name_space name ')'
    5559           0 :         {
    5560             :                 HintNode *p_hn = makeNode(HintNode);
    5561           0 :                 p_hn->hint_type= HINT_INDEX;
    5562             :                 p_hn->tab_list       = makeList1($4);
    5563           0 :                 p_hn->idx_list       = makeList1($5);
    5564           0 :                 $$ = (Node*)p_hn;
    5565           0 :         }
    5566           0 :         |       HINT NOINDEX '(' name_space name ')'
    5567           0 :         {
    5568             :                 HintNode *p_hn = makeNode(HintNode);
    5569           0 :                 p_hn->hint_type= HINT_NOINDEX;
    5570             :                 p_hn->tab_list       = makeList1($4);
    5571           0 :                 p_hn->idx_list       = makeList1($5);
    5572           0 :                 $$ = (Node*)p_hn;
    5573           0 :         }
    5574           0 :         |       HINT INDEX_JOIN
    5575           0 :         {
    5576             :                 HintNode *p_hn = makeNode(HintNode);
    5577           0 :                 p_hn->hint_type= HINT_INDEX_JOIN;
    5578             :                 $$ = (Node*)p_hn;
    5579           0 :         }
    5580           0 :         |       HINT INDEX_ASC
    5581           0 :         {
    5582             :                 HintNode *p_hn = makeNode(HintNode);
    5583           0 :                 p_hn->hint_type= HINT_INDEX_ASC;
    5584             :                 $$ = (Node*)p_hn;
    5585           0 :         }
    5586           0 :         |       HINT INDEX_DESC
    5587           0 :         {
    5588             :                 HintNode *p_hn = makeNode(HintNode);
    5589           0 :                 p_hn->hint_type= HINT_INDEX_DESC;
    5590             :                 $$ = (Node*)p_hn;
    5591           0 :         }
    5592           0 :         |       HINT INDEX_FSS
    5593           0 :         {
    5594             :                 HintNode *p_hn = makeNode(HintNode);
    5595           0 :                 p_hn->hint_type= HINT_INDEX_FSS;
    5596             :                 $$ = (Node*)p_hn;
    5597           0 :         }
    5598           0 :         |       HINT USE_HASH '(' name_space ',' name_space ')'
    5599           0 :         {
    5600             :                 HintNode *p_hn = makeNode(HintNode);
    5601           0 :                 p_hn->hint_type= HINT_USE_HASH;
    5602             :                 p_hn->tab_list       = makeList2($4,$6);
    5603           0 :                 $$ = (Node*)p_hn;
    5604           0 :         }
    5605           0 :         |       HINT CACHE
    5606           0 :         {
    5607             :                 HintNode *p_hn = makeNode(HintNode);
    5608           0 :                 p_hn->hint_type= HINT_CACHE;
    5609             :                 $$ = (Node*)p_hn;
    5610           0 :         }
    5611           0 :         |       HINT NOCACHE
    5612           0 :         {
    5613             :                 HintNode *p_hn = makeNode(HintNode);
    5614           0 :                 p_hn->hint_type= HINT_NOCACHE;
    5615             :                 $$ = (Node*)p_hn;
    5616           0 :         }
    5617           0 :         |       HINT PARALLEL
    5618           0 :         {
    5619             :                 HintNode *p_hn = makeNode(HintNode);
    5620           0 :                 p_hn->hint_type= HINT_PARALLEL;
    5621             :                 $$ = (Node*)p_hn;
    5622           0 :         }
    5623           0 :         |       HINT APPEND
    5624           0 :         {
    5625             :                 HintNode *p_hn = makeNode(HintNode);
    5626           0 :                 p_hn->hint_type= HINT_APPEND;
    5627             :                 $$ = (Node*)p_hn;
    5628           0 :         }
    5629           0 :         |       HINT NOAPPEND
    5630           0 :         {
    5631             :                 HintNode *p_hn = makeNode(HintNode);
    5632           0 :                 p_hn->hint_type= HINT_NOAPPEND;
    5633             :                 $$ = (Node*)p_hn;
    5634           0 :         }
    5635           0 :         |       HINT ORDERD
    5636           0 :         {
    5637             :                 HintNode *p_hn = makeNode(HintNode);
    5638           0 :                 p_hn->hint_type= HINT_ORDERD;
    5639             :                 $$ = (Node*)p_hn;
    5640           0 :         }
    5641           0 :         //end
    5642           0 :         ;       
    5643             :                                         
    5644           0 : TextPattern:    
    5645             :         TextPattern '&' TextPattern 
    5646             :         {
    5647             :                 TextPattern *p_pattern = makeNode(TextPattern);
    5648             :                 p_pattern->l_pattern = $1;
    5649             :                 p_pattern->r_pattern = $3;
    5650           0 :                 p_pattern->pattern_ch = '&';
    5651           0 :                 $$ = (Node*)p_pattern;
    5652           0 :         }
    5653           0 :         |       TextPattern ',' TextPattern     
    5654           0 :         {
    5655             :                 TextPattern *p_pattern = makeNode(TextPattern);
    5656           0 :                 p_pattern->l_pattern = $1;
    5657             :                 p_pattern->r_pattern = $3;
    5658           0 :                 p_pattern->pattern_ch = '&';
    5659           0 :                 $$ = (Node*)p_pattern;
    5660           0 :         }
    5661           0 :         |  TextPattern  '|' TextPattern
    5662           0 :         {
    5663             :                 TextPattern *p_pattern = makeNode(TextPattern);
    5664           0 :                 p_pattern->l_pattern = $1;
    5665             :                 p_pattern->r_pattern = $3;
    5666           0 :                 p_pattern->pattern_ch = '|';
    5667           0 :                 $$ = (Node*)p_pattern;
    5668           0 :         }
    5669           0 :         |       TextPattern  '^'  TextPattern
    5670           0 :         {
    5671             :                 TextPattern *p_pattern = makeNode(TextPattern);
    5672           0 :                 p_pattern->l_pattern = $1;
    5673             :                 p_pattern->r_pattern = $3;
    5674           0 :                 p_pattern->pattern_ch = '^';
    5675           0 :                 $$ = (Node*)p_pattern;                                                          
    5676           0 :         }
    5677           0 :         |       TextPattern  '-'  TextPattern
    5678           0 :         {
    5679             :                 TextPattern *p_pattern = makeNode(TextPattern);
    5680           0 :                 p_pattern->l_pattern = $1;
    5681             :                 p_pattern->r_pattern = $3;
    5682           0 :                 p_pattern->pattern_ch = '^';
    5683           0 :                 $$ = (Node*)p_pattern;                                                          
    5684           0 :         }       
    5685           0 :         |       '[' TextItem ']'
    5686           0 :         {
    5687             :                 TextPattern *p_pattern = makeNode(TextPattern);
    5688           0 :                 p_pattern->l_pattern = (Node*)$2;
    5689             :                 p_pattern->pattern_ch = '[';
    5690           0 :                 $$ = (Node*)p_pattern;          
    5691           0 :         
    5692           0 :         }
    5693           0 :         |       TextItem
    5694             :         {
    5695             :                 TextPattern *p_pattern = makeNode(TextPattern);
    5696           0 :                 p_pattern->l_pattern = (Node*)$1;
    5697             :                 p_pattern->pattern_ch = 't';
    5698           0 :                 $$ = (Node*)p_pattern;
    5699           0 :         }
    5700           0 :         |       '(' TextPattern ')'
    5701           0 :         {
    5702             :                 $$ = $2;
    5703           0 :         }
    5704             :         ;
    5705           0 :         
    5706             : TextItem: Keywords
    5707           0 :         |       IDENT
    5708             :         |       FCONST
    5709             :         |       ICONST
    5710             :                 {
    5711             :                         $$ = (char*)tmalloc(12);
    5712             :                         i4toa($1,$$);
    5713           0 :                 }
    5714           0 :                 ;                                                                                                                                       
    5715             :                          
    5716           0 : parallel_opt:
    5717             :         {
    5718             :                 $$ = 1;         /*no parallel*/
    5719             :         }
    5720       14269 :         |       NOPARALLEL
    5721             :         {
    5722       14269 :                 $$ = 1;         /*no parallel */
    5723             :         }
    5724           0 :         |       PARALLEL 
    5725             :         {
    5726           0 :                 $$ = -1;        /*use default set */
    5727             :         }
    5728           0 :         |       PARALLEL ICONST
    5729             :         {
    5730           0 :                 $$ = $2;        
    5731             :         }
    5732           0 :         ;
    5733             : parallel_opt2:
    5734           0 :         {
    5735             :                 $$ = 1;         /*no parallel*/
    5736             :         }
    5737         293 :         |       NOPARALLEL
    5738             :         {
    5739         293 :                 $$ = 1;         /*no parallel*/
    5740             :         }
    5741           0 :         |       PARALLEL 
    5742             :         {
    5743           0 :                 $$ = -1;        /*use default set */
    5744             :         }
    5745           0 :         |       PARALLEL ICONST
    5746             :         {
    5747           0 :                 $$ = $2;        
    5748             :         }
    5749           0 :         |       PARALLEL ICONST ',' ICONST
    5750             :         {
    5751           0 :                 $$ = $2 | $4<<16; 
    5752             :         }
    5753           0 :         ;
    5754             : 
    5755           0 : opt_constraint_props:   
    5756             :         {
    5757             :                 $$ = NIL;
    5758             :         }
    5759        1068 :         |       constraint_props
    5760             :         {
    5761        1068 :                 $$ = $1;
    5762             :         }
    5763           0 :         ;
    5764             : constraint_props:
    5765           0 :         constraint_prop
    5766             :         {
    5767             :                 $$ = makeList1($1);
    5768             :         }
    5769           0 :         |       constraint_props constraint_prop
    5770             :         {
    5771           0 :                 $$ = lappend($1,$2);
    5772             :         }
    5773           0 :         ;
    5774             : 
    5775           0 : constraint_prop:
    5776             :         which_constraint enable_disable opt_validate  exceptions_opt cascade_opt 
    5777             :                 {
    5778             :                         ConstProp  *p_cons_prop = makeNode(ConstProp);
    5779             :                         p_cons_prop->cons_type = ((ConstraintObj*)$1)->cons_type;
    5780           0 :                         p_cons_prop->cons_name = ((ConstraintObj*)$1)->cons_name;
    5781           0 :                         p_cons_prop->col_names = ((ConstraintObj*)$1)->col_names;
    5782           0 :                         p_cons_prop->enable = $2;
    5783           0 :                         p_cons_prop->validate = $3;
    5784           0 :                         p_cons_prop->exception_table = $4;
    5785           0 :                         p_cons_prop->cascade = $5;
    5786           0 :                         $$  = (Node*)p_cons_prop;
    5787           0 :                 }
    5788           0 :         ;
    5789             : 
    5790           0 : which_constraint:
    5791             :         UNIQUE '(' name_list ')'
    5792             :         {
    5793             :                 ConstraintObj *p_obj = New(ConstraintObj);
    5794             :                 p_obj->cons_type = CONSTR_UNIQUE;
    5795           0 :                 p_obj->col_names = $3;
    5796           0 :                 $$ = (Node*)p_obj;
    5797           0 :         }
    5798           0 :         |       PRIMARY KEY
    5799             :         {
    5800           0 :                 ConstraintObj *p_obj = New(ConstraintObj);
    5801             :                 p_obj->cons_type = CONSTR_PRIMARY;
    5802           0 :                 $$ = (Node*)p_obj;
    5803           0 :         }
    5804           0 :         |       CONSTRAINT ColId
    5805             :         {
    5806           0 :                 ConstraintObj *p_obj = New(ConstraintObj);
    5807             :                 p_obj->cons_type = CONSTR_NON;
    5808           0 :                 p_obj->cons_name = $2;
    5809           0 :                 $$ = (Node*)p_obj;                      
    5810           0 :         }
    5811           0 :         ;
    5812             :                                                                                                                                                         
    5813           0 : /*
    5814             :  * Redundancy here is needed to avoid shift/reduce conflicts,
    5815             :  * since TEMP is not a reserved word.  
    5816             :  */
    5817             : OptTemp:  TEMPORARY                                     { $$ = 1; }
    5818             :                 | TEMP                                          { $$ = 1; }
    5819           0 :                 | LOCAL TEMPORARY                       { $$ = 1; }
    5820           0 :                 | LOCAL TEMP                            { $$ = 1; }
    5821           0 :                 | GLOBAL TEMPORARY                      { $$ = 2; }
    5822           0 :                 | GLOBAL TEMP                           { $$ = 2; }
    5823           0 :                 | /*EMPTY*/                             { $$ = 0; }
    5824           0 :                 ;
    5825           0 : 
    5826        1070 : table_elements:  table_elements ',' table_element
    5827             :         {
    5828             :                 if ($3 != (Node*)NULL)
    5829             :                         $$ = lappend($1, $3);
    5830        2755 :                 else
    5831        2755 :                         $$ = $1;
    5832             :         }
    5833           0 :         | table_element
    5834             :         {
    5835        2755 :                 if ($1 != (Node*)NULL)
    5836             :                         $$ = makeList1($1);
    5837        1077 :                 else
    5838        1077 :                         $$ = NIL;
    5839             :         }
    5840           0 :         ;
    5841             : 
    5842        1077 : table_element:  columnDef               { $$ = $1; }
    5843             :                 | TableConstraint               { $$ = $1; }
    5844        3413 :                 ;
    5845        3413 : 
    5846         419 : columnDef:  ColId TypeName opt_serial ColQualList opt_collate opt_comment
    5847             :         {
    5848             :                 ColumnDef *n = makeNode(ColumnDef);
    5849             :                 n->colname = $1;
    5850        3413 :                 n->type_name = (Typenam*)$2;
    5851        3413 :                 if($3!=NULL)
    5852        3413 :                 {
    5853        3413 :                         n->is_sequence = true;
    5854             :                         n->p_serial_def = (SerialDef*)$3;
    5855           0 :                 }
    5856           0 :                 n->constraints = $4;
    5857             :                 if ($5 != (void*)NULL)
    5858        3413 :                 {
    5859        3413 :                         SetParsePos();
    5860             :                         add_parse_error(214,$4);
    5861           0 :                 }
    5862           0 :                 n->comments = $6;
    5863             :                 $$ = (Node *)n;
    5864        3413 :                 SetNodePos($$);
    5865        3413 :         }
    5866        3413 :         ;
    5867             : 
    5868        3413 : opt_serial:     /*empty*/
    5869             :                 {
    5870             :                         $$ = NULL;
    5871             :                 }
    5872        3413 :                 |       IDENTITY 
    5873             :                 {
    5874        3413 :                         SerialDef *p_def = makeNode(SerialDef);
    5875             :                         p_def->ini_val = (Value*)makeInteger(1);
    5876           0 :                         p_def->step_val =(Value*)makeInteger(1);
    5877           0 :                         $$ = (Node*)p_def;
    5878           0 :                         SetNodePos($$);
    5879           0 :                 }
    5880           0 :                 |       IDENTITY '(' IntegerOnly ',' IntegerOnly ')'
    5881             :                 {
    5882           0 :                         SerialDef *p_def = makeNode(SerialDef);
    5883             :                         p_def->ini_val = (Value*)$3;
    5884           0 :                         p_def->step_val =(Value*) $5;
    5885           0 :                         $$ = (Node*)p_def;
    5886           0 :                         SetNodePos($$);
    5887           0 :                 }
    5888           0 :                 ;
    5889             : 
    5890           0 : ColQualList:
    5891             :                   ColQualList ColConstraint                  { $$ = lappend($1, $2); }
    5892         752 :                 | /*EMPTY*/                                              { $$ = NIL; }
    5893         752 :                 ;
    5894        3413 : 
    5895             : ColConstraint: CONSTRAINT name ColConstraintElem
    5896             :         {
    5897             :                 switch (nodeTag($3))
    5898           6 :                 {
    5899             :                         case T_ConstraintDef:
    5900             :                                 {
    5901             :                                         ConstraintDef *n = (ConstraintDef *)$3;
    5902           0 :                                         n->constr_name = $2;
    5903           0 :                                 }
    5904             :                                 break;
    5905           0 :                         case T_FkConstraint:
    5906             :                                 {
    5907             :                                         FkConstraint *n = (FkConstraint *)$3;
    5908           6 :                                         n->constr_name = $2;
    5909           6 :                                 }
    5910             :                                 break;
    5911           6 :                         default:
    5912             :                                 break;
    5913           0 :                 }
    5914             :                 $$ = $3;
    5915           6 :         }
    5916             :         | ColConstraintElem
    5917           6 :         { $$ = $1; }
    5918         746 :         | ConstraintAttr
    5919         746 :         { $$ = $1; }
    5920           0 :         ;
    5921           0 : 
    5922             : /* DEFAULT NULL is already the default for .
    5923             :  * But define it here and carry it forward into the system
    5924             :  * to make it explicit.
    5925             :  * - thomas 1998-09-13
    5926             :  *
    5927             :  * WITH NULL and NULL are not SQL92-standard syntax elements,
    5928             :  * so leave them out. Use DEFAULT NULL to explicitly indicate
    5929             :  * that a column may have that value. WITH NULL leads to
    5930             :  * shift/reduce conflicts with WITH TIME ZONE anyway.
    5931             :  * - thomas 1999-01-08
    5932             :  *
    5933             :  * DEFAULT expression must be b_expr not b_expr to prevent shift/reduce
    5934             :  * conflict on NOT (since NOT might start a subsequent NOT NULL constraint,
    5935             :  * or be part of b_expr NOT LIKE or similar constructs).
    5936             :  */
    5937             : ColConstraintElem:
    5938             :         NOT _NULL enable_disable
    5939             :         {
    5940             :                 ConstraintDef *n = makeNode(ConstraintDef);
    5941         493 :                 n->contype = CONSTR_NOTNULL;
    5942         493 :                 n->constr_name = (char*)NULL;
    5943         493 :                 n->raw_expr = (Node*)NULL;
    5944         493 :                 n->cooked_expr = (char*)NULL;
    5945         493 :                 n->keys = NIL;
    5946         493 :                 n->enable = $3;
    5947         493 :                 $$ = (Node *)n;
    5948         493 :                 SetNodePos($$);
    5949         493 :         }
    5950             :         | _NULL  enable_disable
    5951         493 :         {
    5952             :                 ConstraintDef *n = makeNode(ConstraintDef);
    5953           0 :                 n->contype = CONSTR_NULL;
    5954           0 :                 n->constr_name = (char*)NULL;
    5955           0 :                 n->raw_expr = (Node*)NULL;
    5956           0 :                 n->cooked_expr = (char*)NULL;
    5957           0 :                 n->keys = (List*)NULL;
    5958           0 :                 n->enable = $2;
    5959           0 :                 $$ = (Node *)n;
    5960           0 :                 SetNodePos($$);
    5961           0 :         }
    5962             :         | UNIQUE  enable_disable
    5963           0 :         {
    5964             :                 ConstraintDef *n = makeNode(ConstraintDef);
    5965          76 :                 n->contype = CONSTR_UNIQUE;
    5966          76 :                 n->constr_name = (char*)NULL;
    5967          76 :                 n->raw_expr = (Node*)NULL;
    5968          76 :                 n->cooked_expr = (char*)NULL;
    5969          76 :                 n->keys = (List*)NULL;
    5970          76 :                 n->enable = $2;
    5971          76 :                 $$ = (Node *)n;
    5972          76 :                 SetNodePos($$);
    5973          76 :         }
    5974             :         | PRIMARY KEY  enable_disable
    5975          76 :         {
    5976             :                 ConstraintDef *n = makeNode(ConstraintDef);
    5977          35 :                 n->contype = CONSTR_PRIMARY;
    5978          35 :                 n->constr_name = (char*)NULL;
    5979          35 :                 n->raw_expr = (Node*)NULL;
    5980          35 :                 n->cooked_expr = (char*)NULL;
    5981          35 :                 n->keys = (List*)NULL;
    5982          35 :                 n->enable = $3;
    5983          35 :                 $$ = (Node *)n;
    5984          35 :                 SetNodePos($$);
    5985          35 :         }
    5986             :         | CHECK '(' bool_expr ')' enable_disable
    5987          35 :         {
    5988             :                 ConstraintDef *n = makeNode(ConstraintDef);
    5989          33 :                 n->contype = CONSTR_CHECK;
    5990          33 :                 n->constr_name = (char*)NULL;
    5991          33 :                 n->raw_expr = $3;
    5992          33 :                 n->cooked_expr = (char*)NULL;
    5993          33 :                 n->keys = (List*)NULL;
    5994          33 :                 n->enable = $5;
    5995          33 :                 $$ = (Node *)n;
    5996          33 :                 SetNodePos($$);
    5997          33 :         }
    5998             :         | DEFAULT b_expr enable_disable
    5999          33 :         {
    6000             :                 ConstraintDef *n = makeNode(ConstraintDef);
    6001          84 :                 n->contype = CONSTR_DEFAULT;
    6002          84 :                 n->constr_name = (char*)NULL;
    6003          84 :                 if (exprIsNullConstant($2))
    6004          84 :                 {
    6005             :                         /* DEFAULT NULL should be reported as empty expr */
    6006             :                         n->raw_expr = (Node*)NULL;
    6007           8 :                 }
    6008             :                 else
    6009             :                 {
    6010             :                         n->raw_expr = $2;
    6011          76 :                 }
    6012             :                 n->cooked_expr = (char*)NULL;
    6013          84 :                 n->keys = (List*)NULL;
    6014          84 :                 n->enable = $3;
    6015          84 :                 $$ = (Node *)n;
    6016          84 :                 SetNodePos($$);
    6017          84 :         }
    6018             :         | REFERENCES name_space opt_column_list key_match key_actions  enable_disable
    6019          84 :         {
    6020             :                 FkConstraint *n = makeNode(FkConstraint);
    6021          28 :                 n->constr_name       = (char*)NULL;
    6022          28 :                 n->pktable_name      = $2;
    6023          28 :                 n->fk_attrs  = NIL;
    6024          28 :                 n->pk_attrs  = $3;
    6025          28 :                 n->match_type = $4;
    6026          28 :                 n->actions   = $5;
    6027          28 :                 n->deferrable = false;
    6028          28 :                 n->initdeferred      = false;
    6029          28 :                 n->enable = $6;
    6030          28 :                 $$ = (Node *)n;
    6031          28 :                 SetNodePos($$);
    6032          28 :         }
    6033             :         | FOREIGN KEY opt_fk_name REFERENCES name_space opt_column_list key_match key_actions  enable_disable
    6034          28 :         {
    6035             :                 FkConstraint *n = makeNode(FkConstraint);
    6036           3 :                 n->constr_name       = $3;
    6037           3 :                 n->pktable_name      = $5;
    6038           3 :                 n->fk_attrs  = NIL;
    6039           3 :                 n->pk_attrs  = $6;
    6040           3 :                 n->match_type        = $7;
    6041           3 :                 n->actions   = $8;
    6042           3 :                 n->deferrable        = false;
    6043           3 :                 n->initdeferred      = false;
    6044           3 :                 n->enable = $9;
    6045           3 :                 $$ = (Node *)n;
    6046           3 :                 SetNodePos($$);
    6047           3 :         }       
    6048             :         ;
    6049           3 : 
    6050             : /*
    6051             :  * ConstraintAttr represents constraint attributes, which we parse as if
    6052             :  * they were independent constraint clauses, in order to avoid shift/reduce
    6053             :  * conflicts (since NOT might start either an independent NOT NULL clause
    6054             :  * or an attribute).  analyze.c is responsible for attaching the attribute
    6055             :  * information to the preceding "REAL" constraint node, and for complaining
    6056             :  * if attribute clauses appear in the wrong place or wrong combinations.
    6057             :  *
    6058             :  * See also ConstraintAttributeSpec, which can be used in places where
    6059             :  * there is no parsing conflict.
    6060             :  */
    6061             : ConstraintAttr: DEFERRABLE
    6062             :         {
    6063             :                 ConstraintDef *n = makeNode(ConstraintDef);
    6064           0 :                 n->contype = CONSTR_ATTR_DEFERRABLE;
    6065           0 :                 $$ = (Node *)n;
    6066           0 :         }
    6067             :         | NOT DEFERRABLE
    6068           0 :         {
    6069             :                 ConstraintDef *n = makeNode(ConstraintDef);
    6070           0 :                 n->contype = CONSTR_ATTR_NOT_DEFERRABLE;
    6071           0 :                 $$ = (Node *)n;
    6072           0 :         }
    6073             :         | INITIALLY DEFERRED
    6074           0 :         {
    6075             :                 ConstraintDef *n = makeNode(ConstraintDef);
    6076           0 :                 n->contype = CONSTR_ATTR_DEFERRED;
    6077           0 :                 $$ = (Node *)n;
    6078           0 :         }
    6079             :         | INITIALLY IMMEDIATE
    6080           0 :         {
    6081             :                 ConstraintDef *n = makeNode(ConstraintDef);
    6082           0 :                 n->contype = CONSTR_ATTR_IMMEDIATE;
    6083           0 :                 $$ = (Node *)n;
    6084           0 :         }
    6085             :         ;
    6086           0 : 
    6087             : 
    6088             : /* ConstraintElem specifies constraint syntax which is not embedded into
    6089             :  *  a column definition. ColConstraintElem specifies the embedded form.
    6090             :  * - thomas 1997-12-03
    6091             :  */
    6092             : TableConstraint:  CONSTRAINT name ConstraintElem
    6093             :         {
    6094             :                 switch (nodeTag($3))
    6095          11 :                 {
    6096             :                         case T_ConstraintDef:
    6097             :                                 {
    6098             :                                         ConstraintDef *n = (ConstraintDef *)$3;
    6099          10 :                                         n->constr_name = $2;
    6100          10 :                                 }
    6101             :                                 break;
    6102          10 :                         case T_FkConstraint:
    6103             :                                 {
    6104             :                                         FkConstraint *n = (FkConstraint *)$3;
    6105           1 :                                         n->constr_name = $2;
    6106           1 :                                 }
    6107             :                                 break;
    6108           1 :                         default:
    6109             :                                 break;
    6110           0 :                 }
    6111             :                 $$ = $3;
    6112          11 :         }
    6113             :         | ConstraintElem
    6114          11 :         { $$ = $1; }
    6115         408 :         ;
    6116         408 : 
    6117             : ConstraintElem:  CHECK '(' bool_expr ')'  enable_disable 
    6118             :         {
    6119             :                 ConstraintDef *n = makeNode(ConstraintDef);
    6120          69 :                 n->contype = CONSTR_CHECK;
    6121          69 :                 n->constr_name = (char*)NULL;
    6122          69 :                 n->raw_expr = $3;
    6123          69 :                 n->cooked_expr = (char*)NULL;
    6124          69 :                 n->enable = $5;
    6125          69 :                 $$ = (Node *)n;
    6126          69 :         }
    6127             :         | UNIQUE '(' columnList ')' enable_disable 
    6128          69 :         {
    6129             :                 ConstraintDef *n = makeNode(ConstraintDef);
    6130         141 :                 n->contype = CONSTR_UNIQUE;
    6131         141 :                 n->constr_name =(char*) NULL;
    6132         141 :                 n->raw_expr = (Node*)NULL;
    6133         141 :                 n->cooked_expr = (char*)NULL;
    6134         141 :                 n->keys = $3;
    6135         141 :                 n->enable = $5;
    6136         141 :                 $$ = (Node *)n;
    6137         141 :         }
    6138             :         | PRIMARY KEY '(' columnList ')' enable_disable
    6139         141 :         {
    6140             :                 ConstraintDef *n = makeNode(ConstraintDef);
    6141          65 :                 n->contype = CONSTR_PRIMARY;
    6142          65 :                 n->constr_name = (char*)NULL;
    6143          65 :                 n->raw_expr = (Node*)NULL;
    6144          65 :                 n->cooked_expr = (char*)NULL;
    6145          65 :                 n->keys = $4;        
    6146          65 :                 n->enable = $6;
    6147          65 :                 $$ = (Node *)n;
    6148          65 :         }
    6149             :         | FOREIGN KEY  opt_fk_name '(' columnList ')' REFERENCES name_space opt_column_list 
    6150          65 :                 key_match key_actions ConstraintAttributeSpec  enable_disable 
    6151             :         {
    6152             :                 FkConstraint *n = makeNode(FkConstraint);
    6153         144 :                 n->constr_name       = $3;
    6154         144 :                 n->pktable_name      = $8;
    6155         144 :                 n->fk_attrs          = $5;
    6156         144 :                 n->pk_attrs          = $9;
    6157         144 :                 n->match_type        = $10;
    6158         144 :                 n->actions           = $11;
    6159         144 :                 n->deferrable        = ($12 & 1) != 0;
    6160         144 :                 n->initdeferred      = ($12 & 2) != 0;
    6161         144 :                 
    6162             :                 n->enable = $13;
    6163         144 :                 $$ = (Node *)n;
    6164         144 :         }
    6165             :         ;
    6166         144 : 
    6167             : opt_fk_name:    /*empty*/
    6168             :         {
    6169             :                 $$ = NULL;
    6170         147 :         }
    6171             :         |       ColId   
    6172         147 :         {
    6173             :                 $$ = $1;
    6174           0 :         }
    6175             :         ;       
    6176           0 :                 
    6177             : key_match:  MATCH FULL
    6178             :         {
    6179             :                 $$ = (char*)"FULL";
    6180           0 :         }
    6181             :         | MATCH PARTIAL
    6182           0 :         {
    6183             :                 $$ = (char*)"PARTIAL";
    6184           0 :         }
    6185             :         | /*EMPTY*/
    6186           0 :         {
    6187             :                 $$ = (char*)"UNSPECIFIED";
    6188         175 :         }
    6189             :         ;
    6190         175 : 
    6191             : key_actions:
    6192           8 :                   key_delete                                { $$ = $1; }
    6193           8 :                 | key_update                                    { $$ = $1; }
    6194           0 :                 | key_delete key_update                 { $$ = $1 | $2; }
    6195           0 :                 | key_update key_delete                 { $$ = $1 | $2; }
    6196           0 :                 | /*EMPTY*/                                         { $$ = (FKCONSTR_ON_KEY_NOACTION<<FKCONSTR_ON_DELETE_SHIFT)|(FKCONSTR_ON_KEY_NOACTION<<FKCONSTR_ON_UPDATE_SHIFT); }
    6197         167 :                 ;
    6198             : 
    6199           8 : key_delete:  ON _DELETE key_reference   { $$ = $3 << FKCONSTR_ON_DELETE_SHIFT; }
    6200           8 :                 ;
    6201             : 
    6202           0 : key_update:  ON UPDATE key_reference    { $$ = $3 << FKCONSTR_ON_UPDATE_SHIFT; }
    6203           0 :                 ;
    6204             : 
    6205           1 : key_reference:  NO ACTION                       { $$ = FKCONSTR_ON_KEY_NOACTION; }
    6206           1 :                 | RESTRICT                                      { $$ = FKCONSTR_ON_KEY_RESTRICT; }
    6207           0 :                 | CASCADE                                       { $$ = FKCONSTR_ON_KEY_CASCADE; }
    6208           5 :                 | SET _NULL                                     { $$ = FKCONSTR_ON_KEY_SETNULL; }
    6209           1 :                 | SET DEFAULT                           { $$ = FKCONSTR_ON_KEY_SETDEFAULT; }
    6210           1 :                 ;
    6211             : //why 2016-01-27 modify support oracle\mssql\mysql\db2
    6212             : //CreateLinkStmt: Cre_Rep PUBLIC DATABASE LINK name CONNECT TO Sconst USER UserId user_passwd_clause
    6213             : //      {
    6214             : //              CreateLinkStmt *p_stmt = makeNode(CreateLinkStmt);
    6215             : //              p_stmt->is_public = true;
    6216             : //              p_stmt->name = $5;
    6217             : //              p_stmt->targ_db = dbs2utf($8);       
    6218             : //              p_stmt->user = $10;
    6219             : //              p_stmt->password = $11;
    6220             : //              $$ = (Node*)p_stmt;     
    6221             : //      }
    6222             : //      | CREATE DATABASE LINK name CONNECT TO Sconst USER UserId user_passwd_clause
    6223             : //      {
    6224             : //              CreateLinkStmt *p_stmt = makeNode(CreateLinkStmt);
    6225             : //              p_stmt->is_public = false;
    6226             : //              p_stmt->name = $4;
    6227             : //              p_stmt->targ_db = dbs2utf($7);       /*target database uri*/
    6228             : //              p_stmt->user = $9;
    6229             : //              p_stmt->password = $10;
    6230             : //              $$ = (Node*)p_stmt;     
    6231             : //      }
    6232             : //      ;
    6233             :         
    6234             : CreateLinkStmt: Cre_Rep PUBLIC DATABASE LINK name CONNECT TO Sconst USER UserId user_passwd_clause
    6235             :         {
    6236           0 :                 CreateLinkStmt *p_stmt = makeNode(CreateLinkStmt);
    6237           0 :                 p_stmt->is_public = true;
    6238           0 :                 p_stmt->name      = $5;
    6239           0 :                 p_stmt->targ_db   = dbs2utf($8);     
    6240           0 :                 p_stmt->user      = $10;
    6241           0 :                 p_stmt->password  = $11;
    6242           0 :                 $$ = (Node*)p_stmt;                     
    6243             :         }
    6244           0 :         | Cre_Rep PUBLIC DATABASE LINK name FOR Sconst CONNECT TO Sconst USER UserId user_passwd_clause 
    6245             :         {
    6246           0 :                 CreateLinkStmt *p_stmt = makeNode(CreateLinkStmt);
    6247           0 :                 p_stmt->is_public = true;
    6248           0 :                 p_stmt->name      = $5;
    6249           0 :                 p_stmt->db_type   = $7;
    6250           0 :                 p_stmt->targ_db   = dbs2utf($10);    
    6251           0 :                 p_stmt->user      = $12;
    6252           0 :                 p_stmt->password  = $13;
    6253           0 :                 $$ = (Node*)p_stmt;                     
    6254             :         }
    6255           0 :         | CREATE DATABASE LINK name CONNECT TO Sconst USER UserId user_passwd_clause
    6256             :         {
    6257           0 :                 CreateLinkStmt *p_stmt = makeNode(CreateLinkStmt);
    6258           0 :                 p_stmt->is_public = false;
    6259           0 :                 p_stmt->name      = $4;
    6260           0 :                 p_stmt->targ_db   = dbs2utf($7);     /*target database uri*/
    6261           0 :                 p_stmt->user      = $9;
    6262           0 :                 p_stmt->password  = $10;
    6263           0 :                 $$ = (Node*)p_stmt;                     
    6264             :         }
    6265           0 :         | CREATE DATABASE LINK name FOR Sconst CONNECT TO Sconst USER UserId user_passwd_clause
    6266             :         {
    6267           0 :                 CreateLinkStmt *p_stmt = makeNode(CreateLinkStmt);
    6268           0 :                 p_stmt->is_public = false;
    6269           0 :                 p_stmt->name      = $4;
    6270           0 :                 p_stmt->db_type   = $6;
    6271           0 :                 p_stmt->targ_db   = dbs2utf($9);     /*target database uri*/
    6272           0 :                 p_stmt->user      = $11;
    6273           0 :                 p_stmt->password  = $12;
    6274           0 :                 $$ = (Node*)p_stmt;                     
    6275             :         };
    6276           0 : 
    6277             : DropLinkStmt: DROP DATABASE LINK name
    6278             :         {
    6279           0 :                 DropStmt *p_stmt = makeNode(DropStmt);
    6280           0 :                 p_stmt->obj_name = $4;
    6281           0 :                 p_stmt->drop_type = DROP_DB_LINK;
    6282           0 :                 $$ = (Node*)p_stmt;
    6283           0 :                 SetNodePos($$);         
    6284             :         };
    6285           0 : 
    6286             : CreateSynonymStmt:      Cre_Rep SYNONYM name_space FOR name_space
    6287             :         {
    6288           0 :                 CreateSynonymStmt *p_stmt = makeNode(CreateSynonymStmt);
    6289           0 :                 p_stmt->cre_mode = $1;
    6290           0 :                 p_stmt->syn_name = $3;
    6291           0 :                 p_stmt->obj_name = $5;
    6292           0 :                 p_stmt->is_public = false;
    6293           0 :                 $$ = (Node*)p_stmt;
    6294             :         }
    6295           0 :         | Cre_Rep PUBLIC SYNONYM name_space FOR name_space
    6296             :         {
    6297           0 :                 CreateSynonymStmt *p_stmt = makeNode(CreateSynonymStmt);
    6298           0 :                 p_stmt->cre_mode = $1;
    6299           0 :                 p_stmt->syn_name = $4;
    6300           0 :                 p_stmt->obj_name = $6;
    6301           0 :                 p_stmt->is_public = true;
    6302           0 :                 $$ = (Node*)p_stmt;
    6303             :         }
    6304           0 :         ;
    6305             : 
    6306             : DropSynonymStmt: DROP SYNONYM name_space
    6307             :         {
    6308           0 :                 DropStmt *p_stmt = makeNode(DropStmt);
    6309           0 :                 p_stmt->obj_name = $3;
    6310           0 :                 p_stmt->drop_type = DROP_SYNONYM;
    6311           0 :                 $$ = (Node*)p_stmt;
    6312           0 :                 SetNodePos($$);         
    6313             :         }
    6314           0 :         | DROP PUBLIC SYNONYM name_space
    6315             :         {
    6316           0 :                 DropStmt *p_stmt = makeNode(DropStmt);
    6317           0 :                 p_stmt->obj_name = $4;
    6318           0 :                 p_stmt->drop_type = DROP_PUB_SYN;
    6319           0 :                 $$ = (Node*)p_stmt;
    6320           0 :                 SetNodePos($$);         
    6321             :         }
    6322           0 :         ;
    6323             : 
    6324             : CreateMViewStmt: CREATE MATERIALIZED VIEW name_space 
    6325             :                                         opt_exist_tab
    6326             :                                         opt_column_list
    6327             :                                         opt_phyical_props 
    6328             :                                         opt_build_mode
    6329             :                                         refresh_mode
    6330             :                                         start_time
    6331             :                                         period 
    6332             :                                         opt_rewrite
    6333             :                                         AS SelectStmt
    6334             :                                         opt_comment
    6335             :         {
    6336           0 :                 CreateMViewStmt *p_stmt = makeNode(CreateMViewStmt);
    6337           0 :                 p_stmt->view_name = $4;
    6338           0 :                 p_stmt->tab_exist_mode = $5; 
    6339           0 :                 p_stmt->aliases = $6;
    6340           0 :                 p_stmt->physical_props = (PhysiProp *)$7;
    6341           0 :                 p_stmt->build_mode = $8;
    6342           0 :                 p_stmt->refresh_mode = $9;
    6343           0 :                 p_stmt->start_t = $10;
    6344           0 :                 p_stmt->period = $11;
    6345           0 :                 p_stmt->rewrite_mode = $12;
    6346           0 :                 p_stmt->filter_stmt = (SelectStmt *)$14;
    6347           0 :                 p_stmt->comments = $15;
    6348           0 :                 SetNodePos($$);
    6349           0 :                 $$ = (Node*)p_stmt;     
    6350             :         }
    6351           0 :         | CREATE SNAPSHOT name_space 
    6352             :                                         opt_exist_tab
    6353             :                                         opt_column_list
    6354             :                                         opt_phyical_props 
    6355             :                                         opt_build_mode
    6356             :                                         refresh_mode
    6357             :                                         start_time
    6358             :                                         period 
    6359             :                                         opt_rewrite
    6360             :                                         AS SelectStmt
    6361             :                                         opt_comment
    6362             :         {
    6363           0 :                 CreateMViewStmt *p_stmt = makeNode(CreateMViewStmt);
    6364           0 :                 p_stmt->view_name = $3;
    6365           0 :                 p_stmt->tab_exist_mode = $4; 
    6366           0 :                 p_stmt->aliases = $5;
    6367           0 :                 p_stmt->physical_props = (PhysiProp *)$6;
    6368           0 :                 p_stmt->build_mode = $7;
    6369           0 :                 p_stmt->refresh_mode = $8;
    6370           0 :                 p_stmt->start_t = $9;
    6371           0 :                 p_stmt->period = $10;
    6372           0 :                 p_stmt->rewrite_mode = $11;
    6373           0 :                 p_stmt->filter_stmt = (SelectStmt *)$13;
    6374           0 :                 p_stmt->comments = $14;
    6375           0 :                 SetNodePos($$);
    6376           0 :                 $$ = (Node*)p_stmt;     
    6377             :         }
    6378           0 :         ;
    6379             : 
    6380             : DropMViewStmt: DROP MATERIALIZED VIEW name_space opt_keep_tab
    6381             :         {
    6382           0 :                 DropStmt *n = makeNode(DropStmt);
    6383           0 :                 n->drop_type = DROP_MVIEW;
    6384           0 :                 n->obj_name = $4;
    6385           0 :                 n->keep_objs = $5;
    6386           0 :                 $$ = (Node*)n;
    6387           0 :                 SetNodePos($$);         
    6388             :         }
    6389           0 :         | DROP SNAPSHOT name_space opt_keep_tab
    6390             :         {
    6391           0 :                 DropStmt *n = makeNode(DropStmt);
    6392           0 :                 n->drop_type = DROP_MVIEW;
    6393           0 :                 n->obj_name = $3;
    6394           0 :                 n->keep_objs = $4;
    6395           0 :                 $$ = (Node*)n;
    6396           0 :                 SetNodePos($$);         
    6397             :         }
    6398           0 :         ; 
    6399             : 
    6400             : opt_exist_tab:/*empty*/
    6401             :         {
    6402           0 :                 $$ = 0;
    6403             :         }
    6404           0 :         | ON PREBUILT TABLE
    6405             :         {
    6406           0 :                 $$ = 1;
    6407             :         }
    6408           0 :         | ON PREBUILT TABLE WITHOUT REDUCED PRECISION
    6409             :         {
    6410           0 :                 $$ = 1;
    6411             :         }
    6412           0 :         | ON PREBUILT TABLE WITH REDUCED PRECISION
    6413             :         {
    6414           0 :                 $$ = 2;
    6415             :         }
    6416           0 :         ;
    6417             : 
    6418             : opt_build_mode: /*empty*/
    6419             :         {
    6420           0 :                 $$ = 0;
    6421             :         }               
    6422           0 :         |       BUILD IMMEDIATE
    6423             :         {
    6424           0 :                 $$ = 1;
    6425             :         }
    6426           0 :         |       BUILD DEFERRED
    6427             :         {
    6428           0 :                 $$ = 0;
    6429             :         }
    6430           0 :         ;                       
    6431             : refresh_mode:   /*empty*/
    6432             :         {
    6433           0 :                 $$ = 0;
    6434             :         }
    6435           0 :         | REFRESH       FORCE
    6436             :         {
    6437           0 :                 $$ = 0;
    6438             :         }
    6439           0 :         | REFRESH       FORCE ON DEMAND
    6440             :         {
    6441           0 :                 $$ = 0;
    6442             :         }
    6443           0 :         | REFRESH       FORCE ON COMMIT
    6444             :         {
    6445           0 :                 $$ = 0x1;
    6446             :         }
    6447           0 :         | REFRESH  FAST
    6448             :         {
    6449           0 :                 $$ = 0x10;
    6450             :         }
    6451           0 :         | REFRESH       FAST ON DEMAND
    6452             :         {
    6453           0 :                 $$ = 0x10;
    6454             :         }
    6455           0 :         | REFRESH       FAST ON COMMIT
    6456             :         {
    6457           0 :                 $$ = 0x11;
    6458             :         }
    6459           0 :         | REFRESH  COMPLETE
    6460             :         {
    6461           0 :                 $$ = 0x20;
    6462             :         }
    6463           0 :         | REFRESH       FORCE WITH PRIMARY KEY
    6464             :         {
    6465           0 :                 $$ = 0;
    6466             :         }
    6467           0 :         | REFRESH       FORCE ON DEMAND WITH PRIMARY KEY
    6468             :         {
    6469           0 :                 $$ = 0;
    6470             :         }
    6471           0 :         | REFRESH       FORCE ON COMMIT WITH PRIMARY KEY
    6472             :         {
    6473           0 :                 $$ = 1;
    6474             :         }
    6475           0 :         | REFRESH  FAST WITH PRIMARY KEY
    6476             :         {
    6477           0 :                 $$ = 0x10;
    6478             :         }
    6479           0 :         | REFRESH       FAST ON DEMAND WITH PRIMARY KEY
    6480             :         {
    6481           0 :                 $$ = 0x10;
    6482             :         }
    6483           0 :         | REFRESH       FAST ON COMMIT WITH PRIMARY KEY
    6484             :         {
    6485           0 :                 $$ = 0x11;
    6486             :         }
    6487           0 :         | REFRESH  COMPLETE WITH PRIMARY KEY
    6488             :         {
    6489           0 :                 $$ = 0x20;
    6490             :         }
    6491           0 :         | REFRESH       FORCE ON DEMAND WITH _ROWID
    6492             :         {
    6493           0 :                 $$ = 0x100;
    6494             :         }
    6495           0 :         | REFRESH       FORCE ON COMMIT WITH _ROWID
    6496             :         {
    6497           0 :                 $$ = 0x101;
    6498             :         }
    6499           0 :         | REFRESH  FAST WITH _ROWID
    6500             :         {
    6501           0 :                 $$ = 0x110;
    6502             :         }
    6503           0 :         | REFRESH       FAST ON DEMAND WITH _ROWID
    6504             :         {
    6505           0 :                 $$ = 0x110;
    6506             :         }
    6507           0 :         | REFRESH       FAST ON COMMIT WITH _ROWID
    6508             :         {
    6509           0 :                 $$ = 0x111;
    6510             :         }
    6511           0 :         | REFRESH  COMPLETE WITH _ROWID
    6512             :         {
    6513           0 :                 $$ = 0x120;
    6514             :         }
    6515           0 :         ;
    6516             :         
    6517             : start_time:     /*empty*/
    6518             :         {
    6519           0 :                 $$ = (char*)"NOW";
    6520             :         }
    6521           0 :         |       START WITH Sconst
    6522             :         {
    6523           0 :                 $$ = dbs2utf($3);
    6524             :         }       
    6525           0 :         ;
    6526             :                 
    6527             : period:         /*empty*/       
    6528             :         {
    6529           0 :                 $$ = 0;
    6530             :         }
    6531           0 :         |       PERIOD ICONST dt_unit
    6532             :         {
    6533           0 :                 if($3 == DTUNIT_DAY)
    6534           0 :                         $$ = $2*3600*24;
    6535           0 :                 else if($3 == DTUNIT_HOUR)
    6536           0 :                         $$ = $2*3600;
    6537           0 :                 else if($3 == DTUNIT_MINUTE)
    6538           0 :                         $$ = $2*60;
    6539             :                 else 
    6540           0 :                         $$ = $2;
    6541             :         }
    6542           0 :         ;
    6543             : 
    6544             : opt_rewrite:    /*empty*/
    6545             :         {
    6546           0 :                 $$ = 0;
    6547             :         }
    6548           0 :         | DISABLE QUERY REWRITE
    6549             :         {
    6550           0 :                 $$ = 0;
    6551             :         }
    6552           0 :         | ENABLE QUERY REWRITE
    6553             :         {
    6554           0 :                 $$ = 1;
    6555             :         }
    6556           0 :         | ENABLE GLOBAL QUERY REWRITE
    6557             :         {
    6558           0 :                 $$ = 2;
    6559             :         }
    6560           0 :         ;
    6561             :  
    6562             : opt_keep_tab:
    6563             :           /*empty*/                       { $$ = false; }
    6564           0 :         | KEEP TABLE                      { $$ = true; }
    6565             :         ;
    6566           0 :         
    6567             : /*
    6568           0 :  * Note: CREATE TABLE ... AS SELECT ... is just another spelling for
    6569             :  * SELECT ... INTO.
    6570           0 :  */
    6571             : CreateAsStmt:  CREATE OptTemp TABLE opt_if_not_exists name_space OptCreateAs AS SelectStmt
    6572             :                 {
    6573             :                         /*
    6574             :                                 * When the SelectStmt is a set-operation tree, we must
    6575             :                                 * stuff the INTO information into the leftmost component
    6576             :                                 * Select, because that's where analyze.c will expect
    6577             :                                 * to find it.  Similarly, the output column names must
    6578             :                                 * be attached to that Select's target list.
    6579             :                                 */
    6580             :                         SelectStmt *n = findLeftmostSelect((SelectStmt *) $8);
    6581             :                         if (n->into != (char*)NULL)
    6582             :                         {
    6583             :                                 SetParsePos();
    6584             :                                 add_parse_error(215);
    6585           0 :                         }
    6586           0 :                         n->temp_type = $2;
    6587             :                         n->into = $5;
    6588           0 :                         n->aliasList = $6; //bywsy@20210302 bug3803
    6589           0 :                         /*if ($6 != NIL)
    6590             :                                 mapTargetColumns($6, n->targetList);*/
    6591           0 :                         $$ = $8;
    6592           0 :                         
    6593           0 :                 }
    6594             :                 ;
    6595             : 
    6596           0 : OptCreateAs:  
    6597             :                   '(' CreateAsList ')'      { $$ = $2; }
    6598             :                 | /*EMPTY*/                             { $$ = NIL; }
    6599           0 :                 ;
    6600             : 
    6601           0 : CreateAsList:  
    6602           0 :                   CreateAsList ',' CreateAsElement              { $$ = lappend($1, $3); }
    6603           0 :                 | CreateAsElement                               { $$ = makeList1($1); }
    6604             :                 ;
    6605           0 : 
    6606           0 : CreateAsElement:  ColId
    6607           0 :                 {
    6608             :                         ColumnDef *n = makeNode(ColumnDef);
    6609             :                         n->colname = $1;
    6610             :                         n->type_name = (Typenam*)NULL;
    6611           0 :                         n->raw_default = (Node*)NULL;
    6612           0 :                         n->cooked_default = (char*)NULL;
    6613           0 :                         n->is_not_null = false;
    6614           0 :                         n->constraints = (List*)NULL;
    6615           0 :                         $$ = (Node *)n;
    6616           0 :                 }
    6617           0 :                 ;
    6618           0 : 
    6619             : 
    6620           0 : /*****************************************************************************
    6621             :  *
    6622             :  *              QUERY :
    6623             :  *                              CREATE SEQUENCE seqname
    6624             :  *
    6625             :  *****************************************************************************/
    6626             : 
    6627             : CreateSeqStmt:  CREATE SEQUENCE name_space OptSeqList opt_comment
    6628             :         {
    6629             :                 CreateSeqStmt *n = makeNode(CreateSeqStmt);
    6630             :                 n->seqname = $3;
    6631             :                 //n->options = $4;
    6632           0 :                 foreach(l,$4)
    6633           0 :                 {
    6634             :                         SeqOpt *opt = (SeqOpt*)lptr(l);
    6635           0 :                         switch(opt->opt_type)
    6636             :                         {
    6637           0 :                                 case SEQ_OPT_INCREMENT:
    6638           0 :                                         n->step_val = opt->arg;
    6639             :                                         break;
    6640             :                                 case SEQ_OPT_MAXVALUE:
    6641           0 :                                         n->max_val = opt->arg;
    6642           0 :                                         break;
    6643             :                                 case SEQ_OPT_MINVALUE:
    6644           0 :                                         n->min_val = opt->arg;
    6645           0 :                                         break;
    6646             :                                 case SEQ_OPT_START:
    6647           0 :                                         n->init_val = opt->arg;
    6648           0 :                                         break;
    6649             :                                 case SEQ_OPT_CACHE:
    6650           0 :                                         n->cache_val = opt->arg;
    6651           0 :                                         break;
    6652             :                                 case SEQ_OPT_CYCLE:
    6653           0 :                                         n->is_cycle = true;
    6654           0 :                                         break;
    6655             :                                 case SEQ_OPT_ORDER:
    6656           0 :                                         n->is_order = true;
    6657           0 :                                         break;
    6658             :                         }
    6659           0 :                 }
    6660           0 :                 n->comments = $5;
    6661             :                 $$ = (Node *)n;
    6662             :                 
    6663           0 :         }
    6664           0 :         ;
    6665             :                 
    6666             : AlterSeqStmt:  ALTER SEQUENCE name_space OptSeqList
    6667           0 :         {
    6668             :                 AlterSeqStmt *n = makeNode(AlterSeqStmt);
    6669             :                 n->seqname = $3;
    6670             :                 //n->options = $4;
    6671           0 :                 foreach(l,$4)
    6672           0 :                 {
    6673             :                         SeqOpt *opt = (SeqOpt*)lptr(l);
    6674           0 :                         switch(opt->opt_type)
    6675             :                         {
    6676           0 :                                 case SEQ_OPT_INCREMENT:
    6677           0 :                                         n->step_val = opt->arg;
    6678             :                                         break;
    6679             :                                 case SEQ_OPT_MAXVALUE:
    6680           0 :                                         n->max_val = opt->arg;
    6681           0 :                                         break;
    6682             :                                 case SEQ_OPT_MINVALUE:
    6683           0 :                                         n->min_val = opt->arg;
    6684           0 :                                         break;
    6685             :                                 case SEQ_OPT_START:
    6686           0 :                                         n->init_val = opt->arg;
    6687           0 :                                         break;
    6688             :                                 case SEQ_OPT_CACHE:
    6689           0 :                                         n->cache_val = opt->arg;
    6690           0 :                                         break;
    6691             :                                 case SEQ_OPT_NOCACHE:
    6692           0 :                                         n->cache_val = opt->arg;
    6693           0 :                                         break;
    6694             :                                 case SEQ_OPT_CYCLE:
    6695           0 :                                         n->is_cycle = 1;
    6696           0 :                                         break;
    6697             :                                 case SEQ_OPT_NOCYCLE:
    6698           0 :                                         n->is_cycle = 2;
    6699           0 :                                         break;
    6700             :                                 case SEQ_OPT_ORDER:
    6701           0 :                                         n->is_order = 1;
    6702           0 :                                         break;
    6703             :                                 case SEQ_OPT_NOORDER:
    6704           0 :                                         n->is_order = 2;
    6705           0 :                                         break;
    6706             :                         }
    6707           0 :                 }
    6708           0 :                 $$ = (Node *)n;
    6709             :                 
    6710             :         }       
    6711           0 :         ;
    6712             :                 
    6713             : OptSeqList:  OptSeqList OptSeqElem
    6714           0 :                         { $$ = lappend($1, $2); }
    6715             :                 |       { $$ = NIL; }
    6716             :                 ;
    6717           0 : 
    6718           0 : OptSeqElem:  CACHE var_value
    6719           0 :         {
    6720             :                 SeqOpt *n = New(SeqOpt);
    6721             :                 n->opt_type = SEQ_OPT_CACHE;
    6722             :                 n->arg = $2;
    6723           0 :                 $$ = (void*)n;
    6724           0 :         }
    6725           0 :         | NOCACHE
    6726           0 :         {
    6727             :                 SeqOpt *n = New(SeqOpt);
    6728           0 :                 n->opt_type = SEQ_OPT_NOCACHE;
    6729             :                 n->arg = "1";
    6730           0 :                 $$ = (void*)n;
    6731           0 :         }  
    6732           0 :         | NOORDER
    6733           0 :         {
    6734             :                 SeqOpt *n = New(SeqOpt);
    6735           0 :                 n->opt_type = SEQ_OPT_NOORDER;
    6736             :                 $$ = (void*)n;
    6737           0 :         }  
    6738           0 :         | ORDER  
    6739           0 :         {
    6740             :                 SeqOpt *n = New(SeqOpt);
    6741           0 :                 n->opt_type = SEQ_OPT_ORDER;
    6742             :                 $$ = (void*)n;
    6743           0 :         }  
    6744           0 :         | NOCYCLE
    6745           0 :         {
    6746             :                 SeqOpt *n = New(SeqOpt);
    6747           0 :                 n->opt_type = SEQ_OPT_NOCYCLE;
    6748             :                 $$ = (void*)n;
    6749           0 :         }  
    6750           0 :         | CYCLE
    6751           0 :         {
    6752             :                 SeqOpt *n = New(SeqOpt);
    6753           0 :                 n->opt_type = SEQ_OPT_CYCLE;
    6754             :                 $$ = (void*)n;
    6755           0 :         }
    6756           0 :         | NO CYCLE
    6757           0 :         {
    6758             :                 SeqOpt *n = New(SeqOpt);
    6759           0 :                 n->opt_type = SEQ_OPT_NOCYCLE;
    6760             :                 $$ = (void*)n;
    6761           0 :         }
    6762           0 :         | INCREMENT  BY var_value
    6763           0 :         {
    6764             :                 SeqOpt *n = New(SeqOpt);
    6765           0 :                 n->opt_type = SEQ_OPT_INCREMENT;
    6766             :                 n->arg = $3;
    6767           0 :                 $$ = (void*)n;
    6768           0 :         }
    6769           0 :         | MAXVALUE var_value
    6770           0 :         {
    6771             :                 SeqOpt *n = New(SeqOpt);
    6772           0 :                 n->opt_type = SEQ_OPT_MAXVALUE;
    6773             :                 n->arg = $2;
    6774           0 :                 $$ = (void*)n;
    6775           0 :         }
    6776           0 :         | MINVALUE var_value
    6777           0 :         {
    6778             :                 SeqOpt *n = New(SeqOpt);
    6779           0 :                 n->opt_type = SEQ_OPT_MINVALUE;
    6780             :                 n->arg = $2;
    6781           0 :                 $$ = (void*)n;
    6782           0 :         }
    6783           0 :         | START WITH var_value
    6784           0 :         {
    6785             :                 SeqOpt *n = New(SeqOpt);
    6786           0 :                 n->opt_type = SEQ_OPT_START;
    6787             :                 n->arg = $3;
    6788           0 :                 $$ = (void*)n;
    6789           0 :         }
    6790           0 :         ;
    6791           0 : 
    6792             : IntegerOnly:  
    6793           0 :                 ICONST
    6794             :                 {
    6795             :                         $$ = (Node*)makeInteger($1);
    6796             :                 }
    6797           0 :                 | '-' ICONST
    6798             :                 {
    6799           0 :                         $$ = (Node*)makeInteger($2);
    6800             :                         ((Value*)$$)->val.ival = - ((Value*)$$)->val.ival;
    6801           0 :                 }
    6802           0 :                 /*support int64*/
    6803             :                 |  FCONST
    6804           0 :                 {
    6805             :                         $$ = (Node*)makeNumeric($1);
    6806             :                 }
    6807           0 :                 | '-' FCONST
    6808             :                 {
    6809           0 :                         char * s = (char*)tmalloc(astrlen($2)+4);
    6810             :                         s[0] = '-';
    6811           0 :                         strcpy(s + 1, $2);
    6812           0 :                         $$ = (Node*)makeNumeric(s);
    6813           0 :                 }                               
    6814           0 :                 ;
    6815             : 
    6816           0 : DropSeqStmt: DROP SEQUENCE name_space  alter_behavior
    6817             :                 {
    6818             :                         DropStmt        *p_stmt = makeNode(DropStmt);
    6819             :                         p_stmt->obj_name = $3;
    6820           0 :                         p_stmt->drop_type = DROP_SEQUENCE;
    6821           0 :                         p_stmt->behavior = ($4==CASCADE? OP_CASCADE : OP_RESTRICT);
    6822           0 :                         $$ = (Node*)p_stmt;
    6823           0 :                         SetNodePos($$);
    6824           0 :                 }
    6825           0 :                 ;
    6826             : 
    6827           0 : /*****************************************************************************
    6828             :  *
    6829             :  *              QUERIES :
    6830             :  *                              CREATE TRIGGER ...
    6831             :  *                              DROP TRIGGER ...
    6832             :  *
    6833             :  *****************************************************************************/
    6834             : CreateTrigStmt: Cre_Rep TRIGGER name_space TriggerActionTime TriggerEvents  ON
    6835             :                                 name_space  
    6836             :                                 OptTrggParamAlias
    6837             :                                 TriggerForSpec    
    6838             :                                 { _curr_thd->parse_rule = true; }
    6839             :                                 opt_trig_cond
    6840           0 :                                 opt_comment
    6841           0 :                                 opt_trig_var_def
    6842             :                                 StmtBlock
    6843             :                                 opt_name_space
    6844             :                 {
    6845             :                         CreateTrigStmt *n = makeNode(CreateTrigStmt);
    6846             :                         n->cre_mode  = $1;
    6847           0 :                         n->language = "PLSQL";
    6848           0 :                         n->trigname = $3;
    6849           0 :                         n->objname = $7;
    6850           0 :                         n->objtype = "TABLE_OR_VIEW";
    6851           0 :                         n->trigger_time = $4;
    6852           0 :                         n->trigger_event = ((TrigEvent*)$5)->trigger_event;
    6853           0 :                         n->field_names = ((TrigEvent*)$5)->field_names;
    6854           0 :                         n->new_alias = ((TrggParamAlias*)$8)->new_alias;
    6855           0 :                         n->old_alias = ((TrggParamAlias*)$8)->old_alias;
    6856           0 :                         n->trigger_type = $9;
    6857           0 :                         n->trigger_cond = $11;
    6858           0 :                         n->comments = $12;
    6859           0 :                         n->var_def_list = $13;
    6860           0 :                         n->stmt_list = ((StmtBlock*)$14)->stmt_list;
    6861           0 :                         n->exception_list = ((StmtBlock*)$14)->exception_list;
    6862           0 :                         ((StmtBlock*)$14)->exception_list = NIL;
    6863           0 :                         if($15!=NULL && (astrlen(n->trigname)<astrlen($15) || 
    6864           0 :                                 astricmp(n->trigname+astrlen(n->trigname)-astrlen($15),$15)))
    6865           0 :                         {
    6866           0 :                                 SetParsePos();
    6867             :                                 add_parse_error(579,n->trigname,$15);
    6868           0 :                         }
    6869           0 :                         $$ = (Node*)n;
    6870             :                         SetNodePos($$);
    6871           0 :                 }
    6872           0 :                 | Cre_Rep TRIGGER name_space AFTER LOGON  ON DATABASE  
    6873             :                         {
    6874           0 :                                 _curr_thd->parse_rule = true;
    6875             :                         }
    6876           0 :                         opt_comment
    6877           0 :                         opt_trig_var_def
    6878             :                         StmtBlock
    6879             :                         opt_name_space
    6880             :                 {
    6881             :                         CreateTrigStmt *n = makeNode(CreateTrigStmt);
    6882           0 :                         n->cre_mode  = $1;
    6883           0 :                         n->language = "PLSQL";
    6884           0 :                         n->trigname = $3;
    6885           0 :                         n->objtype = "DATABASE";
    6886           0 :                         n->trigger_time = T_AFTER;
    6887           0 :                         n->trigger_event = E_LOGON;
    6888           0 :                         n->comments = $9;
    6889           0 :                         n->var_def_list = $10;
    6890           0 :                         n->stmt_list = ((StmtBlock*)$11)->stmt_list;
    6891           0 :                         n->exception_list = ((StmtBlock*)$11)->exception_list;
    6892           0 :                         ((StmtBlock*)$11)->exception_list = NIL;
    6893           0 :                         if($12!=NULL && (astrlen(n->trigname)<astrlen($12) || 
    6894           0 :                                 astricmp(n->trigname+astrlen(n->trigname)-astrlen($12),$12)))
    6895           0 :                         {
    6896             :                                 SetParsePos();
    6897           0 :                                 add_parse_error(579,n->trigname,$12);
    6898           0 :                         }
    6899             :                         $$ = (Node*)n;
    6900           0 :                         SetNodePos($$);
    6901           0 :                 }
    6902             :                 ;
    6903           0 :         
    6904             : OptTrggParamAlias: /*empty*/
    6905             :                         {
    6906             :                                 TrggParamAlias *n = makeNode(TrggParamAlias);
    6907           0 :                                 n->new_alias = NULL;
    6908           0 :                                 n->old_alias = NULL;
    6909           0 :                                 $$ = (Node*)n;
    6910           0 :                         }
    6911             :                         |       REFERENCING NEW AS ColId
    6912           0 :                         {
    6913             :                                 TrggParamAlias *n = makeNode(TrggParamAlias);
    6914           0 :                                 n->new_alias = $4;
    6915           0 :                                 n->old_alias = NULL;
    6916           0 :                                 $$ = (Node*)n;
    6917           0 :                         }
    6918             :                         |  REFERENCING OLD AS ColId
    6919           0 :                         {
    6920             :                                 TrggParamAlias *n = makeNode(TrggParamAlias);
    6921           0 :                                 n->new_alias = NULL;
    6922           0 :                                 n->old_alias = $4;
    6923           0 :                                 $$ = (Node*)n;
    6924           0 :                         }
    6925             :                         |       REFERENCING NEW AS ColId OLD AS ColId
    6926           0 :                         {
    6927             :                                 TrggParamAlias *n = makeNode(TrggParamAlias);
    6928           0 :                                 n->new_alias = $4;
    6929           0 :                                 n->old_alias = $7;
    6930           0 :                                 $$ = (Node*)n;
    6931           0 :                         }
    6932             :                         |       REFERENCING OLD AS ColId NEW AS ColId
    6933           0 :                         {
    6934             :                                 TrggParamAlias *n = makeNode(TrggParamAlias);
    6935           0 :                                 n->new_alias = $7;
    6936           0 :                                 n->old_alias = $4;
    6937           0 :                                 $$ = (Node*)n;
    6938           0 :                         }
    6939             :                         ;
    6940           0 :                                         
    6941             : opt_trig_cond:  
    6942             :                           /*empty*/                   { $$ = NULL; }                    
    6943             :                         | WHEN  bool_expr             { $$ = $2; }      
    6944           0 :                         ;
    6945             :                         
    6946           0 : opt_trig_var_def:
    6947             :                           /*empty*/                   { $$ = NIL; }     
    6948           0 :                         | DECLARE VarDefList          { $$ = $2; }
    6949             :                         ;               
    6950           0 : 
    6951             : TriggerActionTime:  
    6952             :                           BEFORE                              { $$ = T_BEFORE; }
    6953             :                         | AFTER                                   { $$ = T_AFTER; }
    6954           0 :                         | INSTEAD OF                      { $$ = T_INSTEAD; }
    6955             :                         ;
    6956           0 : 
    6957             : TriggerEvents:  TriggerOneEvent
    6958           0 :                                 {
    6959             :                                         $$ = $1;
    6960           0 :                                 }
    6961             :                                 | TriggerEvents OR TriggerOneEvent
    6962           0 :                                 {
    6963           0 :                                         TrigEvent *trig_event1 = (TrigEvent*)$1;
    6964           0 :                                         TrigEvent *trig_event2 = (TrigEvent*)$3;
    6965           0 :                                         if((trig_event1->trigger_event & trig_event2->trigger_event) !=0)
    6966             :                                         {
    6967             :                                                 SetParsePos();
    6968             :                                                 add_parse_error(580);
    6969           0 :                                         }
    6970             :                                         trig_event1->trigger_event |= trig_event2->trigger_event;
    6971           0 :                                         if(trig_event2->field_names)
    6972             :                                                 trig_event1->field_names = lconc(trig_event1->field_names,trig_event2->field_names);
    6973           0 :                                         $$ = $1;
    6974           0 :                                 }
    6975           0 :                                 ;
    6976             : 
    6977           0 : TriggerOneEvent:  INSERT                
    6978           0 :                         { 
    6979             :                                 TrigEvent *p_trig_event = makeNode(TrigEvent);
    6980           0 :                                 p_trig_event->trigger_event = E_INSERT;
    6981           0 :                                 $$ = (Node*)p_trig_event ; 
    6982           0 :                         }
    6983           0 :                         | _DELETE
    6984             :                         { 
    6985           0 :                                 TrigEvent *p_trig_event = makeNode(TrigEvent);
    6986             :                                 p_trig_event->trigger_event = E_DELETE;
    6987             :                                 $$ = (Node*)p_trig_event ; 
    6988             :                         }                       
    6989           0 : 
    6990           0 :                         | UPDATE        
    6991           0 :                         { 
    6992             :                                 TrigEvent *p_trig_event = makeNode(TrigEvent);
    6993           0 :                                 p_trig_event->trigger_event = E_UPDATE; 
    6994             :                                 $$ = (Node*)p_trig_event ; 
    6995           0 :                         }               
    6996           0 :                         | UPDATE OF name_list
    6997           0 :                         { 
    6998             :                                 TrigEvent *p_trig_event = makeNode(TrigEvent);
    6999           0 :                                 p_trig_event->trigger_event = E_UPDATE; 
    7000             :                                 p_trig_event->field_names = $3;
    7001             :                                 $$ = (Node*)p_trig_event ; 
    7002           0 :                         }       
    7003           0 :                         | UPDATE OF '(' name_list ')'
    7004           0 :                         {
    7005             :                                 TrigEvent *p_trig_event = makeNode(TrigEvent);
    7006           0 :                                 p_trig_event->trigger_event = E_UPDATE; 
    7007             :                                 p_trig_event->field_names = $4;
    7008           0 :                                 $$ = (Node*)p_trig_event ; 
    7009           0 :                         }
    7010           0 :                         ;
    7011           0 : 
    7012             : TriggerForSpec: 
    7013           0 :                           /*empty*/             { $$ = TRIG_STATEMENT; } 
    7014             :                         | FOR EACH ROW          { $$ = TRIG_EACH_ROW;  }
    7015           0 :                         | FOR  STATEMENT        { $$ = TRIG_STATEMENT; }        
    7016           0 :                         ;
    7017           0 : 
    7018           0 : ConstraintAttributeSpec:  
    7019             :                         ConstraintDeferrabilitySpec
    7020           0 :                         { $$ = $1; }
    7021             :                         | ConstraintDeferrabilitySpec ConstraintTimeSpec
    7022             :                         {
    7023             :                                 if ($1 == 0 && $2 != 0)
    7024           0 :                                 {
    7025             :                                         SetParsePos();
    7026           0 :                                         add_parse_error(146);
    7027             :                                 }
    7028           0 :                                 $$ = $1 | $2;
    7029             :                         }
    7030           0 :                         | ConstraintTimeSpec
    7031             :                         {
    7032           0 :                                 if ($1 != 0)
    7033             :                                         $$ = 3;
    7034           0 :                                 else
    7035             :                                         $$ = 0;
    7036             :                         }
    7037           0 :                         | ConstraintTimeSpec ConstraintDeferrabilitySpec
    7038           0 :                         {
    7039             :                                 if ($2 == 0 && $1 != 0)
    7040           0 :                                 {
    7041             :                                         SetParsePos();
    7042           0 :                                         add_parse_error(146);
    7043           0 :                                 }
    7044             :                                 $$ = $1 | $2;
    7045           0 :                         }
    7046             :                         | /* Empty */
    7047           0 :                         { $$ = 0; }
    7048             :                 ;
    7049           0 : 
    7050           0 : ConstraintDeferrabilitySpec: 
    7051             :                   NOT DEFERRABLE           { $$ = 0; }
    7052           0 :                 | DEFERRABLE               { $$ = 1; }
    7053             :                 ;
    7054           0 : 
    7055             : ConstraintTimeSpec: 
    7056           0 :                   INITIALLY IMMEDIATE      { $$ = 0; }
    7057             :                 | INITIALLY DEFERRED       { $$ = 2; }
    7058           0 :                 ;
    7059           0 : 
    7060             : 
    7061           0 : DropTrigStmt:  DROP TRIGGER name_space
    7062             :         {
    7063           0 :                 DropStmt *n = makeNode(DropStmt);
    7064         144 :                 n->obj_name = $3;
    7065         144 :                 n->drop_type = DROP_TRIGGER;
    7066             :                 $$ = (Node *) n;
    7067             :                 SetNodePos($$);         
    7068           0 :         }
    7069           0 :         ;
    7070           0 :                         
    7071           0 : /*****************************************************************************
    7072             :  *
    7073             :  *              QUERY:
    7074           0 :  *                      fetch statement
    7075           0 :  *
    7076           0 :  *****************************************************************************/
    7077           0 : 
    7078             : FetchStmt:  FETCH name opt_bulk opt_into_list opt_limit
    7079             :                         { 
    7080             :                                 FetchStmt *n = makeNode(FetchStmt);
    7081             :                                 n->cursor_name = $2;
    7082           0 :                                 n->is_bulk = $3;
    7083           0 :                                 n->into_list = $4;
    7084           0 :                                 n->limit_num = $5;
    7085           0 :                                 $$ = (Node*)n;
    7086           0 :                                 SetNodePos($$);
    7087             :                         }                                       
    7088           0 :                         | FETCH integer FROM name 
    7089             :                         { 
    7090             :                                 FetchStmt *n = makeNode(FetchStmt);
    7091             :                                 n->fetch_num = $2;
    7092             :                                 n->cursor_name = $4;
    7093             :                                 $$ = (Node *)n;
    7094             :                                 SetNodePos($$);                         
    7095             :                         }
    7096             :                         ;
    7097             :                 
    7098             : integer: ICONST         {$$ = $1;}
    7099           0 :         |       '-' ICONST      {$$ = -$2;};    
    7100           0 :         
    7101           0 : /****************************************************************************
    7102           0 : *       Delete  connect by session id
    7103           0 : ****************************************************************************/
    7104           0 : DropSessionStmt:DROP SESSION ICONST 
    7105           0 :         {
    7106             :                 DropSessionStmt *n = makeNode(DropSessionStmt);
    7107           0 :                 n->session_id = $3;
    7108             :                 $$ = (Node*)n;
    7109           0 :                 SetNodePos($$);
    7110           0 :         }
    7111           0 :         | DROP SESSION ICONST IMMEDIATE
    7112           0 :         {
    7113           0 :                 DropSessionStmt *n = makeNode(DropSessionStmt);
    7114             :                 n->session_id = $3;
    7115           0 :                 n->immediate = true;
    7116             :                 $$ = (Node*)n;
    7117           0 :                 SetNodePos($$);
    7118           0 :         }
    7119           0 :         ;
    7120             : 
    7121             : /****************************************************************************
    7122             : *       Abort  transaction of session 
    7123             : ****************************************************************************/
    7124             : AbortSessionStmt:_ABORT SESSION ICONST
    7125           0 :         {
    7126           0 :                 AbortSessionStmt *n = makeNode(AbortSessionStmt);
    7127           0 :                 n->session_id = $3;
    7128           0 :                 $$ = (Node*)n;
    7129             :                 SetNodePos($$);
    7130           0 :         }
    7131             :         ;
    7132           0 :         
    7133           0 : /*****************************************************************************
    7134           0 :  *
    7135           0 :  *              QUERY:
    7136           0 :  *                              GRANT [privileges] ON [relation_name_list] TO [ROLE] grantee
    7137             :  *
    7138           0 :  *****************************************************************************/
    7139             : 
    7140             : GrantStmt:  
    7141             :                 GRANT privileges ON name_space TO grantee_list opt_with_grant
    7142             :                 {
    7143             :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7144             :                         p_acl->is_grant = true;
    7145           0 :                         p_acl->acl_mask = $2;
    7146           0 :                         p_acl->obj_type = 0;
    7147           0 :                         p_acl->obj_name = $4;
    7148           0 :                         p_acl->user_list = $6;
    7149             :                         p_acl->can_regrant = $7;
    7150           0 :                         $$ = (Node*)p_acl;
    7151             :                 }
    7152             :                 | GRANT privileges ON TABLE name_space TO grantee_list opt_with_grant
    7153             :                 {
    7154             :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7155             :                         p_acl->is_grant = true;
    7156             :                         p_acl->acl_mask = $2;
    7157             :                         p_acl->obj_type = OBJ_TYPE_TAB;
    7158             :                         p_acl->obj_name = $5;
    7159             :                         p_acl->user_list = $7;
    7160             :                         p_acl->can_regrant = $8;
    7161         286 :                         $$ = (Node*)p_acl;
    7162         286 :                 }       
    7163         286 :                 | GRANT privileges ON VIEW name_space TO grantee_list opt_with_grant
    7164         286 :                 {
    7165         286 :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7166         286 :                         p_acl->is_grant = true;
    7167         286 :                         p_acl->acl_mask = $2;
    7168         286 :                         p_acl->obj_type = OBJ_TYPE_VIEW;
    7169             :                         p_acl->obj_name = $5;
    7170         286 :                         p_acl->user_list = $7;
    7171             :                         p_acl->can_regrant = $8;
    7172           0 :                         $$ = (Node*)p_acl;
    7173           0 :                 }                       
    7174           0 :                 | GRANT privileges ON PROCEDURE name_space TO grantee_list opt_with_grant
    7175           0 :                 {
    7176           0 :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7177           0 :                         p_acl->is_grant = true;
    7178           0 :                         p_acl->acl_mask = $2;
    7179           0 :                         p_acl->obj_type = OBJ_TYPE_PROC;
    7180             :                         p_acl->obj_name = $5;
    7181           0 :                         p_acl->user_list = $7;
    7182             :                         p_acl->can_regrant = $8;
    7183           1 :                         $$ = (Node*)p_acl;
    7184           1 :                 }               
    7185           1 :                 | GRANT privileges ON SEQUENCE name_space TO grantee_list opt_with_grant
    7186           1 :                 {
    7187           1 :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7188           1 :                         p_acl->is_grant = true;
    7189           1 :                         p_acl->acl_mask = $2;
    7190           1 :                         p_acl->obj_type = OBJ_TYPE_SEQ;
    7191             :                         p_acl->obj_name = $5;
    7192           1 :                         p_acl->user_list = $7;
    7193             :                         p_acl->can_regrant = $8;
    7194           0 :                         $$ = (Node*)p_acl;
    7195           0 :                 }                               
    7196           0 :                 | GRANT sys_privileges _IN SCHEMA name TO grantee_list opt_with_grant
    7197           0 :                 {
    7198           0 :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7199           0 :                         p_acl->sys_privileges = $2;
    7200           0 :                         p_acl->is_grant = true;
    7201           0 :                         p_acl->schema_name = $5;
    7202             :                         p_acl->user_list = $7;
    7203           0 :                         p_acl->can_regrant = $8;
    7204             :                         $$ = (Node*)p_acl;
    7205           0 :                 }               
    7206           0 :                 | GRANT sys_privileges TO grantee_list opt_with_grant
    7207           0 :                 {
    7208           0 :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7209           0 :                         p_acl->sys_privileges = $2;
    7210           0 :                         p_acl->is_grant = true;
    7211           0 :                         p_acl->user_list = $4;
    7212           0 :                         p_acl->can_regrant = $5;
    7213             :                         $$ = (Node*)p_acl;
    7214           0 :                 }
    7215             :                 | GRANT operation_commalist '(' name_list ')' ON name_space TO grantee_list  opt_with_grant
    7216         920 :                 {
    7217         920 :                         ChangeAttrACLStmt *p_acl = makeNode(ChangeAttrACLStmt);
    7218         920 :                         p_acl->is_grant = true;
    7219         920 :                         p_acl->acl_mask = $2;
    7220         920 :                         p_acl->attrNames = $4;
    7221         920 :                         p_acl->tab_name = $7;
    7222         920 :                         p_acl->user_list = $9;
    7223             :                         p_acl->can_regrant = $10;
    7224         920 :                         $$ = (Node *)p_acl;
    7225             :                 }
    7226           0 :                 | GRANT operation_commalist '(' name_list ')' ON TABLE name_space TO grantee_list  opt_with_grant
    7227           0 :                 {
    7228           0 :                         ChangeAttrACLStmt *p_acl = makeNode(ChangeAttrACLStmt);
    7229           0 :                         p_acl->is_grant = true;
    7230           0 :                         p_acl->acl_mask = $2;
    7231           0 :                         p_acl->attrNames = $4;
    7232             :                         p_acl->tab_name = $8;
    7233           0 :                         p_acl->user_list = $10;
    7234             :                         p_acl->can_regrant = $11;
    7235          12 :                         $$ = (Node *)p_acl;
    7236          12 :                 }
    7237          12 :                 ;
    7238          12 : 
    7239          12 : privileges:  
    7240          12 :                   ALL PRIVILEGES                  { $$ = -1; }
    7241          12 :                 | ALL                             { $$ = -1; }
    7242          12 :                 | operation_commalist             { $$ = $1; }
    7243             :                 ;
    7244          12 : 
    7245             : operation_commalist:  operation
    7246             :                 {
    7247           1 :                                 $$ = $1;
    7248           1 :                 }
    7249           1 :                 | operation_commalist ',' operation
    7250           1 :                 {
    7251           1 :                                 $$ = ($1 | $3);
    7252           1 :                 }
    7253           1 :                 ;
    7254           1 : 
    7255             : operation:  
    7256           1 :                 SELECT
    7257             :                 {
    7258             :                                 $$ = ACL_READ;
    7259             :                 }
    7260         103 :                 | INSERT
    7261             :                 {
    7262         103 :                                 $$ = ACL_INSERT;
    7263             :                 }
    7264           0 :                 | UPDATE
    7265             :                 {
    7266           0 :                                 $$ = ACL_UPDATE;
    7267             :                 }
    7268         187 :                 | _DELETE
    7269             :                 {
    7270         187 :                                 $$ = ACL_DELETE;
    7271             :                 }
    7272             :                 | EXECUTE
    7273             :                 {
    7274         201 :                                 $$ = ACL_EXECUTE;
    7275             :                 }
    7276         201 :                 | REFERENCES
    7277             :                 {
    7278          51 :                                 $$ = ACL_REF;
    7279             :                 }
    7280          51 :                 | ALTER
    7281             :                 {
    7282             :                                 $$ = ACL_ALTER;
    7283             :                 }
    7284         111 :                 | DROP  
    7285             :                 {       
    7286         111 :                                 $$ = ACL_DROP;
    7287             :                 }       
    7288          43 :                 | INDEX
    7289             :                 {
    7290          43 :                         $$ = ACL_INDEX;
    7291             :                 }
    7292          50 :                 | TRIGGER
    7293             :                 {
    7294          50 :                         $$ = ACL_TRIG;
    7295             :                 }       
    7296          28 :                 | VACUUM
    7297             :                 {
    7298          28 :                         $$ = ACL_VACUUM;
    7299             :                 }                                       
    7300           0 :                 ;
    7301             : 
    7302           0 : sys_privileges :
    7303             :                 sys_privilege
    7304          20 :                 {
    7305             :                                 $$ = makeList1($1);
    7306          20 :                 }
    7307             :                 | sys_privileges  ',' sys_privilege
    7308           0 :                 {
    7309             :                                 $$ = lappend($1,$3);
    7310           0 :                 }
    7311             :                 ;
    7312           0 :         
    7313             : /*database level privilege*/
    7314           0 : sys_privilege:          
    7315             :                 DBA
    7316           0 :                 {
    7317             :                         SysAuth *p_auth = makeNode(SysAuth);
    7318           0 :                         p_auth->acl_mask = ACL_DBA;
    7319             :                         $$ = (Node*)p_auth;
    7320           0 :                 }
    7321             :                 | SSO
    7322           0 :                 {
    7323             :                         SysAuth *p_auth = makeNode(SysAuth);
    7324           0 :                         p_auth->acl_mask = ACL_SSO;
    7325             :                         $$ = (Node*)p_auth;                             
    7326           0 :                 }
    7327             :                 | AUDITOR
    7328             :                 {
    7329             :                         SysAuth *p_auth = makeNode(SysAuth);
    7330             :                         p_auth->acl_mask = ACL_AUDITOR;
    7331         920 :                         $$ = (Node*)p_auth;                             
    7332             :                 }
    7333         920 :                 | BACKUP DATABASE
    7334             :                 {
    7335           0 :                         SysAuth *p_auth = makeNode(SysAuth);
    7336             :                         p_auth->acl_mask = ACL_BACKUP_ANY;
    7337           0 :                         $$ = (Node*)p_auth;                                                                             
    7338             :                 }
    7339             :                 | BACKUP
    7340             :                 {
    7341             :                         SysAuth *p_auth = makeNode(SysAuth);
    7342             :                         p_auth->acl_mask = ACL_BACKUP_ANY;
    7343           0 :                         $$ = (Node*)p_auth;                                                                             
    7344           0 :                 }
    7345           0 :                 | RESTORE 
    7346             :                 {
    7347           0 :                         SysAuth *p_auth = makeNode(SysAuth);
    7348             :                         p_auth->acl_mask = ACL_RESTORE_ANY;
    7349           0 :                         $$ = (Node*)p_auth;                     
    7350           0 :                 }
    7351           0 :                 | RESTORE DATABASE 
    7352             :                 {
    7353           0 :                         SysAuth *p_auth = makeNode(SysAuth);
    7354             :                         p_auth->acl_mask = ACL_RESTORE_ANY;
    7355           0 :                         $$ = (Node*)p_auth;                     
    7356           0 :                 }       
    7357           0 :                 | TRACE
    7358             :                 {
    7359           0 :                         SysAuth *p_auth = makeNode(SysAuth);
    7360             :                         p_auth->acl_mask = ACL_TRACE;
    7361           0 :                         $$ = (Node*)p_auth;                     
    7362           0 :                 }                       
    7363           0 :                 | sys_operation  obj_type
    7364             :                 {
    7365           0 :                         SysAuth *p_auth = makeNode(SysAuth);
    7366             :                         p_auth->acl_mask = $1;
    7367           0 :                         p_auth->obj_type = $2;
    7368           0 :                         $$ = (Node*)p_auth;     
    7369           0 :                 }               
    7370             :                 ;       
    7371           0 : sys_operation:                                  
    7372             :                 CREATE
    7373           0 :                 {
    7374           0 :                         $$ = ACL_CREATE;
    7375           0 :                 }
    7376             :                 | CREATE ANY 
    7377           0 :                 {
    7378             :                         $$ = ACL_CRE_ANY;
    7379           0 :                 }
    7380           0 :                 | ALTER ANY
    7381           0 :                 {
    7382             :                         $$ = ACL_ALT_ANY;
    7383           0 :                 }
    7384             :                 | DROP ANY
    7385           0 :                 {
    7386           0 :                         $$ = ACL_DROP_ANY;
    7387           0 :                 }                       
    7388             :                 | SELECT ANY  
    7389           0 :                 {
    7390             :                         $$ = ACL_READ_ANY;
    7391         920 :                 }
    7392         920 :                 | INSERT ANY 
    7393         920 :                 {
    7394         920 :                         $$ = ACL_INSERT_ANY;
    7395             :                 }
    7396         920 :                 | UPDATE ANY 
    7397             :                 {
    7398             :                         $$ = ACL_UPDATE_ANY;
    7399             :                 }
    7400           0 :                 | _DELETE ANY
    7401             :                 {
    7402           0 :                         $$ = ACL_DELETE_ANY;
    7403             :                 }
    7404         200 :                 | EXECUTE ANY 
    7405             :                 {
    7406         200 :                         $$ = ACL_EXECUTE_ANY;
    7407             :                 }
    7408         200 :                 | REFERENCES ANY 
    7409             :                 {
    7410         200 :                         $$ = ACL_REF_ANY;
    7411             :                 }
    7412         200 :                 | VACUUM ANY
    7413             :                 {
    7414         200 :                         $$ = ACL_VACUUM_ANY;
    7415             :                 }       
    7416          60 :                 | ENCRYPT       ANY
    7417             :                 {
    7418          60 :                         $$ = ACL_ENCRYPT_ANY;
    7419             :                 }
    7420          40 :                 ;
    7421             : 
    7422          40 : obj_type: 
    7423             :                 DATABASE 
    7424          60 :                 {
    7425             :                         $$ = OBJ_TYPE_DB;
    7426          60 :                 } 
    7427             :                 | SCHEMA
    7428          40 :                 {
    7429             :                         $$ = OBJ_TYPE_SCHEMA;
    7430          40 :                 }               
    7431             :                 | TABLE
    7432          40 :                 {
    7433             :                         $$ = OBJ_TYPE_TAB;
    7434          40 :                 }
    7435             :                 | SEQUENCE
    7436          40 :                 {
    7437             :                         $$ = OBJ_TYPE_SEQ;
    7438          40 :                 }               
    7439             :                 | INDEX
    7440          20 :                 {
    7441             :                         $$ = OBJ_TYPE_INDEX;
    7442          20 :                 }               
    7443             :                 | VIEW
    7444          20 :                 {
    7445             :                         $$ = OBJ_TYPE_VIEW;
    7446          20 :                 }
    7447             :                 | PROCEDURE
    7448             :                 {
    7449             :                         $$ = OBJ_TYPE_PROC;
    7450           0 :                 }
    7451             :                 | PACKAGE
    7452           0 :                 {       
    7453             :                         $$ = OBJ_TYPE_PACK;
    7454           0 :                 }               
    7455             :                 | TRIGGER
    7456           0 :                 {
    7457             :                         $$ = OBJ_TYPE_TRIG;
    7458         200 :                 }
    7459             :                 | TABLESPACE
    7460         200 :                 {
    7461             :                         $$ = OBJ_TYPE_SPACE;
    7462         120 :                 }
    7463             :                 | UNDO SEGMENT
    7464         120 :                 {
    7465             :                         $$ = OBJ_TYPE_UNDO_SEG;
    7466          60 :                 }                                       
    7467             :                 | DATABASE LINK
    7468          60 :                 {
    7469             :                         $$ = OBJ_TYPE_DBLINK;
    7470         140 :                 }
    7471             :                 | REPLICATION
    7472         140 :                 {
    7473             :                         $$ = OBJ_TYPE_REPLI;
    7474          80 :                 }
    7475             :                 | SNAPSHOT
    7476          80 :                 {
    7477             :                         $$ = OBJ_TYPE_SNAPSHOT;
    7478          80 :                 }                               
    7479             :                 | SYNONYM
    7480          80 :                 {
    7481             :                         $$ = OBJ_TYPE_SYNONYM;
    7482          60 :                 }
    7483             :                 | USER  
    7484          60 :                 {
    7485             :                         $$ = OBJ_TYPE_USER;
    7486           0 :                 }       
    7487             :                 | ROLE
    7488           0 :                 {
    7489             :                         $$ = OBJ_TYPE_ROLE;
    7490           0 :                 }
    7491             :                 | JOB
    7492           0 :                 {
    7493             :                         $$ = OBJ_TYPE_JOB;
    7494           0 :                 }
    7495             :                 | _DIR  
    7496           0 :                 {
    7497             :                         $$ = OBJ_TYPE_DIR;
    7498           0 :                 }                                                                       
    7499             :                 | OBJECT
    7500           0 :                 {
    7501             :                         $$ = OBJ_TYPE_UDT;
    7502          60 :                 }               
    7503             :                 ;
    7504          60 : 
    7505             : grantee_list: grantee
    7506          60 :                 {
    7507             :                         $$ = makeList1($1);
    7508          60 :                 }
    7509             :                 | grantee_list ',' grantee
    7510           0 :                 {
    7511             :                         $$ = lappend($1,$3);
    7512           0 :                 }
    7513             :                 ;
    7514           0 :                                                                                                                                 
    7515             : grantee:  ROLE  UserId
    7516           0 :                 {
    7517             :                         UserNode *p_user = makeNode(UserNode);
    7518           0 :                         p_user->user_type = 'R';
    7519             :                         p_user->user_name = $2;
    7520           0 :                         $$ = (Node*)p_user;
    7521             :                 }
    7522           0 :                 | UserId
    7523             :                 {
    7524           0 :                         UserNode *p_user = makeNode(UserNode);
    7525             :                         p_user->user_type = 'U';
    7526          60 :                         p_user->user_name = $1; 
    7527             :                         $$ = (Node*)p_user; 
    7528          60 :                 }
    7529             :                 ;
    7530             : 
    7531             : opt_with_grant:  
    7532        1224 :         WITH GRANT OPTION
    7533             :         {
    7534        1224 :                 $$ = true;
    7535             :         }
    7536          33 :         | /*EMPTY*/
    7537             :         {
    7538          33 :                 $$ = false;
    7539             :         }
    7540             :         ;
    7541             : 
    7542           0 : 
    7543           0 : /*****************************************************************************
    7544           0 :  *
    7545           0 :  *              QUERY:
    7546             :  *                              REVOKE [privileges] ON [name_space] FROM [user]
    7547           0 :  *
    7548             :  *****************************************************************************/
    7549        1257 : 
    7550        1257 : RevokeStmt:  
    7551        1257 :                 REVOKE privileges ON name_space FROM grantee_list alter_behavior
    7552        1257 :                 {
    7553             :                         /*revoke table level privilege*/
    7554        1257 :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7555             :                         p_acl->is_grant = false;
    7556             :                         p_acl->obj_name = $4;
    7557             :                         p_acl->user_list = $6;
    7558          46 :                         p_acl->acl_mask = $2;
    7559             :                         p_acl->obj_type = 0;
    7560          46 :                         p_acl->is_cascade = ($7==CASCADE);
    7561             :                         $$ = (Node*)p_acl;
    7562        1174 :                 }
    7563             :                 | REVOKE GRANT OPTION FOR  privileges ON name_space FROM grantee_list alter_behavior
    7564        1174 :                 {
    7565             :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7566             :                         p_acl->is_grant = false;
    7567             :                         p_acl->obj_name = $7;
    7568             :                         p_acl->user_list = $9;
    7569             :                         p_acl->acl_mask = $5;
    7570             :                         p_acl->obj_type = 0;
    7571             :                         p_acl->can_regrant = true;
    7572             :                         p_acl->is_cascade = ($10==CASCADE);
    7573             :                         $$ = (Node*)p_acl;
    7574             :                         
    7575             :                 }       
    7576             :                 | REVOKE privileges ON TABLE name_space FROM grantee_list alter_behavior
    7577           3 :                 {
    7578           3 :                         /*revoke table level privilege*/
    7579           3 :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7580           3 :                         p_acl->is_grant = false;
    7581           3 :                         p_acl->obj_name = $5;
    7582           3 :                         p_acl->user_list = $7;
    7583           3 :                         p_acl->acl_mask = $2;
    7584           3 :                         p_acl->obj_type = OBJ_TYPE_TAB;
    7585             :                         p_acl->is_cascade = ($8==CASCADE);
    7586           3 :                         $$ = (Node*)p_acl;
    7587             :                 }
    7588           0 :                 | REVOKE privileges ON VIEW name_space FROM grantee_list alter_behavior
    7589           0 :                 {
    7590           0 :                         /*revoke table level privilege*/
    7591           0 :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7592           0 :                         p_acl->is_grant = false;
    7593           0 :                         p_acl->obj_name = $5;
    7594           0 :                         p_acl->user_list = $7;
    7595           0 :                         p_acl->acl_mask = $2;
    7596           0 :                         p_acl->obj_type = OBJ_TYPE_VIEW;
    7597             :                         p_acl->is_cascade = ($8==CASCADE);
    7598             :                         $$ = (Node*)p_acl;
    7599           0 :                 }
    7600             :                 | REVOKE privileges ON PROCEDURE name_space FROM grantee_list alter_behavior
    7601             :                 {
    7602           0 :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7603           0 :                         p_acl->is_grant = false;
    7604           0 :                         p_acl->acl_mask = $2;
    7605           0 :                         p_acl->obj_type = OBJ_TYPE_PROC;
    7606           0 :                         p_acl->obj_name = $5;
    7607           0 :                         p_acl->user_list = $7;
    7608           0 :                         p_acl->is_cascade = ($8==CASCADE);
    7609           0 :                         $$ = (Node*)p_acl;
    7610             :                 }       
    7611           0 :                 | REVOKE privileges ON PACKAGE name_space FROM grantee_list alter_behavior
    7612             :                 {
    7613             :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7614           0 :                         p_acl->is_grant = false;
    7615           0 :                         p_acl->acl_mask = $2;
    7616           0 :                         p_acl->obj_type = OBJ_TYPE_PACK;
    7617           0 :                         p_acl->obj_name = $5;
    7618           0 :                         p_acl->user_list = $7;
    7619           0 :                         p_acl->is_cascade = ($8==CASCADE);
    7620           0 :                         $$ = (Node*)p_acl;
    7621           0 :                 }               
    7622             :                 | REVOKE privileges ON SEQUENCE name_space FROM grantee_list alter_behavior
    7623           0 :                 {
    7624             :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7625           0 :                         p_acl->is_grant = false;
    7626           0 :                         p_acl->acl_mask = $2;
    7627           0 :                         p_acl->obj_type = OBJ_TYPE_SEQ;
    7628           0 :                         p_acl->obj_name = $5;
    7629           0 :                         p_acl->user_list = $7;
    7630           0 :                         p_acl->is_cascade = ($8==CASCADE);
    7631           0 :                         $$ = (Node*)p_acl;
    7632           0 :                 }                       
    7633             :                 | REVOKE GRANT OPTION FOR sys_privileges  FROM grantee_list alter_behavior
    7634           0 :                 {/*revoke database level privilege*/
    7635             :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7636           0 :                         p_acl->is_grant = false;
    7637           0 :                         p_acl->sys_privileges = $5;
    7638           0 :                         p_acl->user_list = $7;
    7639           0 :                         p_acl->can_regrant = true;
    7640           0 :                         p_acl->is_cascade = ($8==CASCADE);
    7641           0 :                         $$ = (Node*)p_acl;
    7642           0 :                 }
    7643           0 :                 | REVOKE sys_privileges  FROM grantee_list alter_behavior
    7644             :                 {/*revoke database level privilege*/
    7645           0 :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7646             :                         p_acl->is_grant = false;
    7647           0 :                         p_acl->sys_privileges = $2;
    7648           0 :                         p_acl->user_list = $4;
    7649           0 :                         p_acl->is_cascade = ($5==CASCADE);
    7650           0 :                         $$ = (Node*)p_acl;
    7651           0 :                 }
    7652           0 : 
    7653           0 :                 | REVOKE  sys_privileges _IN SCHEMA name FROM grantee_list  alter_behavior
    7654           0 :                 {
    7655             :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7656           0 :                         p_acl->sys_privileges = $2;
    7657             :                         p_acl->is_grant = false;
    7658           0 :                         p_acl->schema_name = $5;
    7659           0 :                         p_acl->user_list = $7;
    7660           0 :                         p_acl->is_cascade = ($8==CASCADE);
    7661           0 :                         $$ = (Node*)p_acl;
    7662           0 :                 }
    7663           0 :                 | REVOKE  GRANT OPTION FOR sys_privileges _IN SCHEMA name FROM grantee_list  alter_behavior
    7664           0 :                 {
    7665             :                         ChangeACLStmt *p_acl = makeNode(ChangeACLStmt);
    7666           0 :                         p_acl->sys_privileges = $5;
    7667             :                         p_acl->is_grant = false;
    7668           0 :                         p_acl->schema_name = $8;
    7669           0 :                         p_acl->user_list = $10;
    7670           0 :                         p_acl->can_regrant = true;
    7671           0 :                         p_acl->is_cascade = ($11==CASCADE);
    7672           0 :                         $$ = (Node*)p_acl;
    7673           0 :                 }                                       
    7674             :                                         
    7675           0 :                 | REVOKE operation_commalist '(' name_list ')' ON name_space FROM grantee_list alter_behavior
    7676             :                 {/*revoke columne level privilege*/
    7677             :                         ChangeAttrACLStmt *p_acl = makeNode(ChangeAttrACLStmt);
    7678           0 :                         p_acl->is_grant = false;
    7679           0 :                         p_acl->acl_mask = $2;
    7680           0 :                         p_acl->attrNames = $4;
    7681           0 :                         p_acl->tab_name = $7;
    7682           0 :                         p_acl->user_list = $9;
    7683           0 :                         p_acl->is_cascade = ($10==CASCADE);
    7684           0 :                         $$ = (Node *)p_acl;
    7685             :                 }
    7686           0 :                 | REVOKE GRANT OPTION FOR operation_commalist '(' name_list ')' ON name_space FROM grantee_list alter_behavior
    7687             :                 {/*revoke column level privilege*/
    7688           0 :                         ChangeAttrACLStmt *p_acl = makeNode(ChangeAttrACLStmt);
    7689           0 :                         p_acl->is_grant = false;
    7690           0 :                         p_acl->acl_mask = $5;
    7691           0 :                         p_acl->attrNames = $7;
    7692           0 :                         p_acl->tab_name = $10;
    7693           0 :                         p_acl->user_list = $12;
    7694           0 :                         p_acl->can_regrant = true;
    7695           0 :                         p_acl->is_cascade = ($13==CASCADE);
    7696             :                         $$ = (Node *)p_acl;
    7697           0 :                 }
    7698             :                 | REVOKE operation_commalist '(' name_list ')' ON TABLE name_space FROM grantee_list alter_behavior
    7699             :                 {/*revoke column level privilege*/
    7700           1 :                         ChangeAttrACLStmt *p_acl = makeNode(ChangeAttrACLStmt);
    7701           1 :                         p_acl->is_grant = false;
    7702           1 :                         p_acl->acl_mask = $2;
    7703           1 :                         p_acl->attrNames = $4;
    7704           1 :                         p_acl->tab_name = $8;
    7705           1 :                         p_acl->user_list = $10;
    7706           1 :                         p_acl->is_cascade = ($11==CASCADE);
    7707           1 :                         $$ = (Node *)p_acl;
    7708             :                 }       
    7709           1 :                 ;
    7710             : 
    7711           0 : /*****************************************************************************
    7712           0 :  *
    7713           0 :  *              QUERY:
    7714           0 :  *                              create index <indexname> on <relname>
    7715           0 :  *                                usings <access> "(" (<col> with <op>)+ ")" [with
    7716           0 :  *                                <target_list>]
    7717           0 :  *
    7718           0 :  *      [where <qual>] is not supported anymore
    7719           0 :  ******************************************************************************/
    7720             : //add opt_wait bysdc@20190508
    7721           0 : IndexStmt:      CREATE opt_unique INDEX index_name ON name_space '(' index_params ')'
    7722             :                         index_type_opt  ftidx_opt  opt_idx_parti  opt_online parallel_opt2 opt_wait
    7723           0 :         {
    7724           0 :                 IndexStmt *n = makeNode(IndexStmt);
    7725           0 :                 n->unique = $2;
    7726           0 :                 n->idxname = $4;
    7727           0 :                 n->relname = $6;
    7728           0 :                 n->index_elems = $8;
    7729           0 :                 n->idxtype = $10;
    7730           0 :                 if($11)
    7731             :                 {
    7732           0 :                         n->vocable_name = ((FullTxtIdxOpt*)$11)->vocable_name;
    7733             :                         n->word_len = ((FullTxtIdxOpt*)$11)->word_len;
    7734             :                         n->filter_name = ((FullTxtIdxOpt*)$11)->filter_name;
    7735             :                         n->lexer_name = ((FullTxtIdxOpt*)$11)->lexer_name;
    7736             :                 }
    7737             :                 n->opt_global = ((IdxPartiProp*)$12)->opt_global;
    7738             :                 n->parti_prop = ((IdxPartiProp*)$12)->parti_prop;
    7739             :                 n->subparti_prop = ((IdxPartiProp*)$12)->subparti_prop;           
    7740             :                 n->online = $13;
    7741             :                 n->parallel = $14&0xffff;
    7742             :                 n->scan_parallel = $14>>16;
    7743             :                 n->wait_ms = $15;//add opt_wait bysdc@20190508
    7744             :                 $$ = (Node *)n;
    7745             :         }
    7746             :         ;
    7747         293 :                                                         
    7748         293 : opt_unique:  
    7749         293 :                   /*EMPTY*/                       { $$ = false; }
    7750         293 :                 | UNIQUE                                  { $$ = true; } 
    7751         293 :                 ;
    7752         293 : 
    7753         293 : index_type_opt:
    7754             :                   /*EMPTY*/                           { $$ = (char*)"DEFAULT"; }
    7755           0 :                 | INDEXTYPE IS ColId                  { $$ = $3;}
    7756           0 :                 ;
    7757           0 : ftidx_opt:
    7758           0 :                   /*EMPTY*/                       { $$ = NULL; }
    7759             :                 | full_index_opts                 { $$ = $1; }
    7760         293 :                 ;       
    7761         293 : full_index_opts: full_index_opt_item
    7762         293 :         {
    7763         293 :                 $$ = (Node*)$1;
    7764         293 :         }
    7765         293 :         |  full_index_opts       full_index_opt_item
    7766         293 :         {
    7767         293 :                 FullTxtIdxOpt *p_opt1 = (FullTxtIdxOpt *)$1;
    7768             :                 FullTxtIdxOpt *p_opt2 = (FullTxtIdxOpt *)$2;
    7769         293 :                 
    7770             :                 if(p_opt2->vocable_name)
    7771         292 :                         p_opt1->vocable_name = p_opt2->vocable_name;
    7772         292 :                 if(p_opt2->word_len)
    7773           1 :                         p_opt1->word_len = p_opt2->word_len;
    7774             :                 if(p_opt2->filter_name)
    7775             :                         p_opt1->filter_name = p_opt2->filter_name;
    7776         293 :                 if(p_opt2->lexer_name)
    7777         293 :                         p_opt1->lexer_name = p_opt2->lexer_name;
    7778           0 :                 $$ = (Node*)p_opt1;
    7779           0 :         }
    7780             :         ;
    7781             : full_index_opt_item: 
    7782         293 :         /*specify vocable table*/
    7783             :         USING VOCABLE TABLE Sconst
    7784         293 :         {
    7785             :                 FullTxtIdxOpt *p_opt = New(FullTxtIdxOpt);
    7786           0 :                 p_opt->vocable_name = dbs2utf($4);
    7787             :                 $$ = p_opt;
    7788           0 :         }
    7789             :         /* build word by chinese or mutibytes*/
    7790             :         |       FOR EVERY ICONST VOCABLE
    7791           0 :         {
    7792             :                 FullTxtIdxOpt *p_opt = New(FullTxtIdxOpt);
    7793           0 :                 p_opt->word_len = $3;
    7794             :                 $$ = p_opt;
    7795           0 :         }
    7796           0 :         /*specify filter*/      
    7797             :         |       USING FILTER Sconst
    7798           0 :         {
    7799           0 :                 FullTxtIdxOpt *p_opt = New(FullTxtIdxOpt);
    7800           0 :                 p_opt->filter_name = dbs2utf($3);
    7801           0 :                 $$ = p_opt;
    7802           0 :         }
    7803           0 :         /*specify lexer*/
    7804           0 :         |       USING LEXER Sconst
    7805           0 :         {
    7806           0 :                 FullTxtIdxOpt *p_opt = New(FullTxtIdxOpt);
    7807             :                 p_opt->lexer_name = dbs2utf($3);
    7808           0 :                 $$ = p_opt;
    7809             :         }               
    7810             :         ;
    7811             :                 
    7812             : index_params:  index_params ',' index_elem                      
    7813           0 :         { $$ = lappend($1, $3); }
    7814           0 :         | index_elem                            
    7815           0 :         { $$ = makeList1($1); }
    7816             :         ;
    7817           0 : 
    7818             : index_elem:  ColId 
    7819             :         {
    7820           0 :                 $$ = (Node*)makeNode(IndexElem);
    7821           0 :                 ((IndexElem*)$$)->name = $1;
    7822           0 :                 ((IndexElem*)$$)->args = NIL;
    7823             :         }
    7824           0 :         | func_name '(' expr_list ')' 
    7825             :         {
    7826             :                 $$ = (Node*)makeNode(IndexElem);
    7827           0 :                 ((IndexElem*)$$)->name = $1;
    7828           0 :                 ((IndexElem*)$$)->args = $3;
    7829           0 :         }
    7830             :         | ColId  DESC
    7831           0 :         {
    7832             :                 $$ = (Node*)makeNode(IndexElem);
    7833             :                 ((IndexElem*)$$)->name = $1;
    7834           0 :                 ((IndexElem*)$$)->args = NIL;
    7835           0 :                 ((IndexElem*)$$)->order = 1; 
    7836           0 :         }
    7837             :         | func_name '(' expr_list ')' DESC
    7838           0 :         {
    7839             :                 $$ = (Node*)makeNode(IndexElem);
    7840             :                 ((IndexElem*)$$)->name = $1;
    7841         207 :                 ((IndexElem*)$$)->args = $3;
    7842         207 :                 ((IndexElem*)$$)->order = 1; 
    7843         293 :         }       
    7844         293 :         ;
    7845             :                 
    7846             : opt_online: 
    7847             :                   /*empty*/                       { $$ = false; }
    7848         500 :                 | ONLINE                          { $$ = true; }
    7849         500 :                 | OFFLINE                         { $$ = false; }
    7850         500 :         ;
    7851             : 
    7852         500 : opt_idx_parti: /*empty*/
    7853             :         {
    7854           0 :                 IdxPartiProp *p_prop = makeNode(IdxPartiProp);
    7855           0 :                 p_prop->opt_global = -1;
    7856           0 :                 $$ = (Node*)p_prop;
    7857             :         }
    7858           0 :         | LOCAL 
    7859             :         {
    7860           0 :                 IdxPartiProp *p_prop = makeNode(IdxPartiProp);
    7861           0 :                 p_prop->opt_global = 0;
    7862           0 :                 $$ = (Node*)p_prop;
    7863           0 :         }
    7864             :         | GLOBAL opt_partitioning_clause opt_subpartitioning_clause
    7865           0 :         {
    7866             :                 IdxPartiProp *p_prop = makeNode(IdxPartiProp);
    7867           0 :                 p_prop->opt_global = 1;
    7868           0 :                 p_prop->parti_prop = (PartiProp*)$2;
    7869           0 :                 p_prop->subparti_prop = (PartiProp*)$3;
    7870           0 :                 $$ = (Node*)p_prop;
    7871             :         }
    7872           0 :         ;               
    7873             : 
    7874             : LoadVocableStmt:        
    7875             :         LOAD VOCABLE TABLE SCONST
    7876         293 :         {
    7877             :                 LoadVocableStmt *p_stmt = makeNode(LoadVocableStmt);
    7878         293 :                 p_stmt->voc_tab_name = $4;
    7879             :                 $$ = (Node*)p_stmt;
    7880           0 :                 SetNodePos($$);
    7881             :         };
    7882           0 : 
    7883             : CompileVocableStmt:     RECOMPILE VOCABLE TABLE SCONST 
    7884           0 :         {
    7885             :                 CompileVocableStmt *p_stmt = makeNode(CompileVocableStmt);
    7886           0 :                 p_stmt->voc_tab_name = $4;
    7887             :                 $$ = (Node*)p_stmt;
    7888             :                 SetNodePos($$);
    7889             :         }
    7890         293 :         | RECOMPILE VOCABLE TABLE SCONST AUTO LOAD
    7891         293 :         {
    7892         293 :                 CompileVocableStmt *p_stmt = makeNode(CompileVocableStmt);
    7893             :                 p_stmt->voc_tab_name = $4;
    7894         293 :                 p_stmt->auto_load = true;
    7895             :                 $$ = (Node*)p_stmt;
    7896           0 :                 SetNodePos($$);
    7897           0 :         }       
    7898           0 :         ;       
    7899             : GetLobStmt: GET LOB Sconst OFFSET ICONST LIMIT ICONST
    7900           0 :         {
    7901             :                 GetLobStmt *p_stmt = makeNode(GetLobStmt);
    7902           0 :                 p_stmt->descriptor = $3;
    7903           0 :                 p_stmt->offset = $5;
    7904           0 :                 p_stmt->limit = $7;
    7905           0 :                 $$ = (Node*)p_stmt;
    7906           0 :                 SetNodePos($$);
    7907             :         }
    7908           0 :         ;
    7909             :         
    7910             : /**************************************************************************
    7911             : *     alter index  add partition 
    7912           0 : *bysdc@20210106 支持 slow modify opt_wait
    7913           0 : **************************************************************************/
    7914           0 : AlterIndexStmt: 
    7915           0 :         ALTER INDEX name_space ADD PARTITION ColId VALUES '(' parti_values ')' opt_wait
    7916             :         {
    7917           0 :                 AlterIndexStmt *n = makeNode(AlterIndexStmt);
    7918             :                 n->action = ADD_PART;
    7919             :                 n->idx_name = $3;
    7920           0 :                 n->parti_name = $6;
    7921           0 :                 n->parti_type = LIST_PARTITION;
    7922           0 :                 n->parti_vals = $9;
    7923           0 :                 n->wait_ms = $11;
    7924             :                 $$ = (Node *)n;
    7925           0 :         }
    7926             :         | ALTER INDEX name_space ADD PARTITION ColId VALUES LESS THAN '(' parti_values ')' opt_wait
    7927           0 :         {
    7928           0 :                 AlterIndexStmt *n = makeNode(AlterIndexStmt);
    7929           0 :                 n->action = ADD_PART;
    7930           0 :                 n->idx_name = $3;
    7931           0 :                 n->parti_name = $6;
    7932             :                 n->parti_type = RANGE_PARTITION;
    7933           0 :                 n->parti_vals = $11;
    7934             :                 n->wait_ms = $13;
    7935             :                 $$ = (Node *)n;
    7936           0 :         }
    7937           0 :         | ALTER INDEX name_space  SLOW MODIFY ON opt_wait
    7938           0 :         {
    7939           0 :                 AlterIndexStmt *n = makeNode(AlterIndexStmt);
    7940           0 :                 n->action = SET_SLOW_MODI;
    7941           0 :                 n->idx_name = $3;
    7942             :                 n->wait_ms = $7;
    7943           0 :                 $$ = (Node *)n;
    7944             :                 
    7945             :         }
    7946             :         | ALTER INDEX name_space  SLOW MODIFY OFF opt_wait
    7947             :         {
    7948             :                 AlterIndexStmt *n = makeNode(AlterIndexStmt);
    7949             :                 n->action = CLR_SLOW_MODI;
    7950             :                 n->idx_name = $3;
    7951           0 :                 n->wait_ms = $7;
    7952           0 :                 $$ = (Node *)n;
    7953           0 :                 
    7954           0 :         }
    7955           0 :         ;
    7956           0 : 
    7957           0 : DropIdxStmt: DROP INDEX name_space
    7958           0 :         {
    7959             :                 DropStmt  *p_stmt = makeNode(DropStmt);
    7960           0 :                 p_stmt->obj_name = $3;
    7961             :                 p_stmt->drop_type = DROP_INDEX;
    7962           0 :                 $$ = (Node*)p_stmt;
    7963           0 :                 SetNodePos($$);
    7964           0 :         }
    7965           0 :         ;
    7966           0 : 
    7967           0 : /*****************************************************************************
    7968           0 :  *
    7969           0 :  *              QUERY:
    7970             :  *                              extend index <indexname> [where <qual>]
    7971           0 :  *
    7972             :  *****************************************************************************/
    7973           0 : 
    7974           0 : ExtendStmt:  EXTEND INDEX index_name opt_where_clause
    7975           0 :         {
    7976           0 :                 ExtendStmt *n = makeNode(ExtendStmt);
    7977           0 :                 n->idxname = $3;
    7978             :                 n->whereClause = $4;
    7979             :                 $$ = (Node *)n;                                 
    7980           0 :         }
    7981             :         ;
    7982           0 : 
    7983           0 : /*****************************************************************************
    7984           0 :  *
    7985           0 :  *              QUERY:
    7986           0 :  *
    7987             :  *              REINDEX type <type_name> [FORCE] [ALL]
    7988             :  *
    7989           0 :  *****************************************************************************/
    7990             : //add opt_wait bysdc@20190508
    7991             : ReindexStmt:  
    7992             :         REINDEX name_space opt_force opt_fast opt_online parallel_opt2 opt_wait
    7993           0 :         {
    7994           0 :                 ReindexStmt *n = makeNode(ReindexStmt);
    7995           0 :                 n->reindexType = 1;
    7996           0 :                 n->name = $2;
    7997           0 :                 n->force = $3;
    7998             :                 n->fast = $4;
    7999           0 :                 n->online = $5;
    8000             :                 n->parallel = $6&0xffff;
    8001             :                 n->scan_parallel = $6>>16;
    8002             :                 n->wait_ms = $7;//add opt_wait bysdc@20190508
    8003             :                 $$ = (Node *)n;
    8004             :                 
    8005             :         }
    8006             :         | REINDEX name_space '.' '*' opt_force opt_fast opt_online  parallel_opt2 opt_wait
    8007             :         {
    8008             :                 ReindexStmt *n = makeNode(ReindexStmt);
    8009             :                 n->reindexType = 2;
    8010           0 :                 n->name = $2;
    8011           0 :                 n->force = $5;
    8012           0 :                 n->fast = $6;
    8013           0 :                 n->online = $7;
    8014             :                 n->parallel = $8&0xffff;
    8015           0 :                 n->scan_parallel = $8>>16;
    8016             :                 n->wait_ms = $9;//add opt_wait bysdc@20190508
    8017             :                 $$ = (Node *)n;
    8018             :                 
    8019             :         }
    8020             :         /*why 2018-01-16 add index partition rebuild*/
    8021             :         | REINDEX name_space PARTITION name_space opt_force opt_fast opt_online parallel_opt2 opt_wait
    8022             :         {
    8023             :                 ReindexStmt *n = makeNode(ReindexStmt);
    8024             :                 n->reindexType = 1;
    8025             :                 n->name    = $2;
    8026             :                 n->pname   = $4; //partition name
    8027           0 :                 n->force   = $5;
    8028           0 :                 n->fast    = $6;
    8029           0 :                 n->online  = $7;
    8030           0 :                 n->parallel = $8&0xffff;
    8031           0 :                 n->scan_parallel = $8>>16;
    8032           0 :                 n->wait_ms = $9;//add opt_wait bysdc@20190508
    8033           0 :                 $$ = (Node *)n;
    8034           0 :                 
    8035           0 :         }
    8036           0 :         ;
    8037             : 
    8038             : opt_force:      FORCE                           {  $$ = true; }
    8039           0 :                 | /* EMPTY */                   {  $$ = false; }
    8040             :                 ;
    8041           0 : opt_fast:       FAST                            {  $$ = true; }
    8042           0 :                 | /* EMPTY */                   {  $$ = false; }
    8043           0 :                 ;
    8044           0 :                                 
    8045           0 : /*****************************************************************************
    8046           0 :  *
    8047           0 :  *              QUERY:
    8048           0 :  *                              rename <attrname1> in <relname> [*] to <attrname2>
    8049           0 :  *                              rename <relname1> to <relname2>
    8050           0 :  *
    8051             :  *****************************************************************************/
    8052             : 
    8053           0 : RenameStmt:  ALTER TABLE name_space RENAME opt_column opt_name TO name alter_behavior
    8054             :                 {
    8055             :                         RenameStmt *n = makeNode(RenameStmt);
    8056             :                         n->relname = $3;
    8057           0 :                         n->column = $6;
    8058           0 :                         n->newname = $8;
    8059           0 :                         n->behavior = ($9==CASCADE? OP_CASCADE : OP_RESTRICT);
    8060           0 :                         $$ = (Node *)n;
    8061           0 :                         
    8062           0 :                 }
    8063           0 :                 ;
    8064           0 : 
    8065           0 : opt_name:  name                                         { $$ = $1; }
    8066           0 :                 | /*EMPTY*/                                 { $$ = NULL; }
    8067           0 :                 ;
    8068             : 
    8069             : opt_column:  COLUMN                                     { $$ = COLUMN; }
    8070           0 :                 | /*EMPTY*/                                 { $$ = 0; }
    8071             :                 ;
    8072           0 : 
    8073           0 : 
    8074           1 : /*****************************************************************************
    8075           0 :  *
    8076           0 :  *              QUERY:
    8077           0 :  *                              NOTIFY <name_space>       can appear both in rule bodies and
    8078             :  *                              as a query-level command
    8079             :  *
    8080             :  *****************************************************************************/
    8081             : 
    8082             : NotifyStmt:  NOTIFY name_space 
    8083             :         {
    8084             :                 NotifyStmt *n = makeNode(NotifyStmt);
    8085             :                 n->relname = $2;
    8086             :                 $$ = (Node *)n;
    8087             :                 
    8088             :         }
    8089           0 :         |       NOTIFY name_space Sconst
    8090           0 :         {
    8091           0 :                 NotifyStmt *n = makeNode(NotifyStmt);
    8092           0 :                 n->relname = $2;
    8093           0 :                 n->info = dbs2utf($3);
    8094           0 :                 $$ = (Node *)n;
    8095             :                 
    8096             :         }
    8097           0 :         ;
    8098             : 
    8099           0 : ListenStmt:  LISTEN name_space
    8100           0 :         {
    8101           0 :                 ListenStmt *n = makeNode(ListenStmt);
    8102             :                 n->relname = $2;
    8103           2 :                 $$ = (Node *)n;
    8104           2 :                 
    8105           6 :         }
    8106             :         ;
    8107             : 
    8108             : UnlistenStmt:  UNLISTEN name_space
    8109             :         {
    8110             :                 UnlistenStmt *n = makeNode(UnlistenStmt);
    8111             :                 n->relname = $2;
    8112             :                 $$ = (Node *)n;
    8113             :                 
    8114             :         }
    8115             :         | UNLISTEN '*'
    8116             :         {
    8117             :                 UnlistenStmt *n = makeNode(UnlistenStmt);
    8118           0 :                 n->relname = "*";
    8119           0 :                 $$ = (Node *)n;
    8120           0 :                                 
    8121             :         }
    8122             :         ;
    8123           0 : 
    8124             : 
    8125           0 : /*****************************************************************************
    8126           0 :  *
    8127           0 :  *              Transactions:
    8128           0 :  *
    8129             :  *      BEGIN / COMMIT / ROLLBACK
    8130             :  *      (also older versions _END / ABORT)
    8131           0 :  *
    8132             :  *****************************************************************************/
    8133             : 
    8134             : TransactionStmt: _ABORT opt_trans
    8135           0 :         {
    8136           0 :                 TransactionStmt *n = makeNode(TransactionStmt);
    8137           0 :                 n->command = OP_ROLLBACK;
    8138             :                 $$ = (Node *)n;
    8139             :                 
    8140           0 :         }
    8141             :         | _BEGIN opt_trans
    8142             :         {
    8143             :                 TransactionStmt *n = makeNode(TransactionStmt);
    8144           0 :                 n->command = OP_BEGIN;
    8145           0 :                 $$ = (Node *)n;
    8146           0 :                 
    8147             :         }
    8148             :         | COMMIT opt_trans
    8149           0 :         {
    8150             :                 TransactionStmt *n = makeNode(TransactionStmt);
    8151           0 :                 n->command = OP_COMMIT;
    8152           0 :                 $$ = (Node *)n;
    8153           0 :                 
    8154             :         }
    8155             :         | COMMIT opt_trans opt_chain
    8156           0 :         {
    8157             :                 TransactionStmt *n = makeNode(TransactionStmt);
    8158             :                 n->command = OP_COMMIT;
    8159             :                 $$ = (Node *)n;
    8160             :                 
    8161             :         }
    8162             :         | ROLLBACK opt_trans
    8163             :         {
    8164             :                 TransactionStmt *n = makeNode(TransactionStmt);
    8165             :                 n->command = OP_ROLLBACK;
    8166             :                 $$ = (Node *)n;
    8167             :                 
    8168             :         }
    8169             :         | ROLLBACK opt_trans opt_chain
    8170           0 :         {
    8171           0 :                 TransactionStmt *n = makeNode(TransactionStmt);
    8172           0 :                 n->command = OP_ROLLBACK;
    8173             :                 $$ = (Node *)n;
    8174             :                 
    8175           0 :         }
    8176             :         | ROLLBACK TO ColId
    8177           0 :         {
    8178           0 :                 TransactionStmt *n = makeNode(TransactionStmt);
    8179           0 :                 n->command = OP_ROLLBACK;
    8180             :                 n->label= $3;
    8181             :                 $$ = (Node *)n;
    8182           0 :                 
    8183             :         }
    8184         675 :         | ROLLBACK TO SAVEPOINT ColId
    8185         675 :         {
    8186         675 :                 TransactionStmt *n = makeNode(TransactionStmt);
    8187             :                 n->command = OP_ROLLBACK;
    8188             :                 n->label = $4;
    8189         675 :                 $$ = (Node *)n;
    8190             :                 
    8191           0 :         }
    8192           0 :         | SAVEPOINT ColId
    8193           0 :         {
    8194             :                 TransactionStmt *n = makeNode(TransactionStmt);
    8195             :                 n->command = OP_SAVEPOINT;
    8196           0 :                 n->label = $2;
    8197             :                 $$ = (Node *)n;
    8198         485 :                 
    8199         485 :         }
    8200         485 :         ;
    8201             : 
    8202             : opt_trans: WORK            {}
    8203         485 :                 | TRAN             {}                           
    8204             :                 | TRANSACTION      {}                           
    8205           0 :                 | /*EMPTY*/                             
    8206           0 :                 ;
    8207           0 : 
    8208             : opt_chain: AND NO CHAIN
    8209             :                 { $$ = false; }
    8210           0 :                 | AND CHAIN
    8211             :                 {
    8212           0 :                         /* SQL99 asks that conforming dbs reject AND CHAIN
    8213           0 :                          * if they don't support it. So we can't just ignore it.
    8214           0 :                          * - thomas 2000-08-06
    8215           0 :                          */
    8216             :                         SetParsePos();  
    8217             :                         add_parse_error(7);
    8218           0 :                         $$ = true;
    8219             :                 }
    8220           0 :                 ;
    8221           0 : 
    8222           0 : 
    8223           0 : /*****************************************************************************
    8224             :  *
    8225             :  *              QUERY:
    8226           0 :  *                              define view <view_name> '('target-list ')' [where <quals> ]
    8227             :  *
    8228           0 :  *****************************************************************************/
    8229           0 : ViewStmt:  Cre_Rep VIEW name_space opt_column_list AS SelectStmt view_opt opt_comment
    8230           0 :                 {
    8231           0 :                         ViewStmt *n = makeNode(ViewStmt);
    8232             :                         n->cre_mode = $1;
    8233             :                         n->view_name = $3;
    8234           0 :                         n->aliases = $4;
    8235             :                         n->filter_stmt = (SelectStmt *) $6;
    8236             :                         n->option = $7;
    8237        1046 :                         n->comments = $8;
    8238           0 :                         $$ = (Node *)n;
    8239           0 :                         SetNodePos($$);
    8240             :                 }
    8241             :                 | Cre_Rep VIEW name_space opt_column_list AS joined_table view_opt opt_comment
    8242             :                 {
    8243           0 :                         ViewStmt        *n = makeNode(ViewStmt);
    8244           0 :                         SelectStmt      *select_stmt = makeNode(SelectStmt);
    8245             :                         ResTarget       *res_targ = makeNode(ResTarget);        
    8246             :                         Attr *att = makeNode(Attr);
    8247             :                         
    8248             :                         att->relname = "*";
    8249             :                         att->fields = NULL;
    8250           0 :                         res_targ->name = NULL;
    8251           0 :                         res_targ->val = (Node *)att;
    8252           0 :                         select_stmt->fromClause = makeList1($6);
    8253             :                         select_stmt->targetList = makeList1(res_targ);
    8254           0 :                         n->cre_mode = $1;
    8255             :                         n->view_name = $3;
    8256             :                         n->aliases = $4;
    8257             :                         n->filter_stmt = select_stmt;
    8258             :                         n->option = $7;
    8259             :                         n->comments = $8;
    8260             :                         $$ = (Node *)n;
    8261             :                         SetNodePos($$);
    8262             :                 }
    8263             :                 | Cre_Rep VIEW name_space opt_column_list AS '(' joined_table ')' alias_clause view_opt opt_comment
    8264             :                 {
    8265        1019 :                         ViewStmt *n = makeNode(ViewStmt);
    8266        1019 :                         SelectStmt      *select_stmt = makeNode(SelectStmt);
    8267        1019 :                         ResTarget       *res_targ = makeNode(ResTarget);        
    8268        1019 :                         Attr *att = makeNode(Attr);
    8269        1019 :                         
    8270        1019 :                         att->relname = "*";
    8271        1019 :                         att->fields = NULL;
    8272        1019 :                         res_targ->name = NULL;
    8273        1019 :                         res_targ->val = (Node *)att;
    8274             :                         ((JoinNode*)$7)->alias = (Attr*) $9;
    8275        1019 :                         select_stmt->fromClause = makeList1($7);
    8276             :                         select_stmt->targetList = makeList1(res_targ);
    8277           1 :                 
    8278           1 :                         n->cre_mode = $1;
    8279           1 :                         n->view_name = $3;
    8280           1 :                         n->aliases = $4;
    8281             :                         n->filter_stmt = select_stmt;
    8282           1 :                         n->option = $10;
    8283           1 :                         n->comments = $11;
    8284           1 :                         $$ = (Node *)n;
    8285           1 :                         SetNodePos($$);
    8286           1 :                 }       
    8287           1 :                 ;       
    8288           1 :                                 
    8289           1 : 
    8290           1 : view_opt: /*empty*/
    8291           1 :                 {
    8292           1 :                         $$ = 0;
    8293           1 :                 }
    8294           1 :                 |   WITH READ ONLY
    8295           1 :                 {
    8296             :                         $$ = 1;
    8297           1 :                 }
    8298             :                 |       WITH CHECK OPTION       
    8299           0 :                 {
    8300           0 :                         $$ = 2;
    8301           0 :                 }
    8302           0 :                 ;               
    8303             :                 
    8304           0 : DropViewStmt:DROP VIEW name_space alter_behavior
    8305           0 :                 {
    8306           0 :                         DropStmt *p_stmt = makeNode(DropStmt);
    8307           0 :                         p_stmt->obj_name = $3;
    8308           0 :                         p_stmt->behavior = ($4==CASCADE? OP_CASCADE : OP_RESTRICT);
    8309           0 :                         p_stmt->drop_type = DROP_VIEW;
    8310           0 :                         $$ = (Node*)p_stmt;
    8311             :                         SetNodePos($$);
    8312           0 :                 }
    8313           0 :                 ;
    8314           0 : 
    8315           0 : /*****************************************************************************
    8316           0 :  *
    8317           0 :  *              QUERY:
    8318           0 :  *                              load "filename"
    8319           0 :  *
    8320             :  *****************************************************************************/
    8321           0 : 
    8322             : LoadStmt:  LOAD file_name
    8323             :                 {
    8324             :                         LoadStmt *n = makeNode(LoadStmt);
    8325             :                         n->filename = $2;
    8326         973 :                         $$ = (Node *)n;
    8327             :                         
    8328         973 :                 }
    8329             :                 ;
    8330           0 : /*****************************************************************************
    8331             : *  why 2016-07-28 add
    8332           0 : *  Connect Policy
    8333             : *  
    8334          47 : ******************************************************************************/
    8335             : opt_conn_policy:/*empty*/
    8336          47 :                 {
    8337             :                         $$ = NULL;
    8338             :                 }
    8339             :                 |TO Sconst
    8340          13 :                 { 
    8341          13 :                     $$ = dbs2utf($2);
    8342          13 :                 }
    8343          13 :                 ;
    8344          13 :                 
    8345          13 : //**bysdc@20190604 add [opt_on_node] merge[why 2019-09-05 modify]
    8346             : ConnectPolicyStmt:
    8347          13 :         ALTER CONNECT POLICY ADD ENABLE  Sconst LOGIN Sconst FROM Sconst opt_conn_policy opt_on_node
    8348             :         {
    8349             :                 ConnectPolicyStmt *n = makeNode(ConnectPolicyStmt);
    8350             :                 n->action   = 1;
    8351             :                 n->mode     = 1;
    8352             :                 n->user     = dbs2utf($6);
    8353             :                 n->db_name  = dbs2utf($8);                   
    8354             :                 n->start_ip = dbs2utf($10);
    8355             :                 n->end_ip   = $11;
    8356             :                 n->node_id   = $12;//++bysdc@20190604                        
    8357             :                 $$ = (Node*)n;
    8358           0 :         }
    8359           0 :         | ALTER CONNECT POLICY ADD DISABLE Sconst LOGIN Sconst FROM Sconst opt_conn_policy opt_on_node
    8360           0 :         {
    8361             :                 ConnectPolicyStmt *n = makeNode(ConnectPolicyStmt);
    8362             :                 n->action   = 1;
    8363           0 :                 n->mode     = 2;
    8364             :                 n->user     = dbs2utf($6);
    8365             :                 n->db_name  = dbs2utf($8);                   
    8366             :                 n->start_ip = dbs2utf($10);
    8367             :                 n->end_ip   = $11;                   
    8368             :                 n->node_id   = $12;//++bysdc@20190604                        
    8369             :                 $$ = (Node*)n;
    8370             :         }
    8371           0 :         | ALTER CONNECT POLICY DROP ENABLE  Sconst LOGIN Sconst FROM Sconst opt_conn_policy opt_on_node
    8372             :         {
    8373           0 :                 ConnectPolicyStmt *n = makeNode(ConnectPolicyStmt);
    8374             :                 n->action   = 2;
    8375           0 :                 n->mode     = 1;
    8376             :                 n->user     = dbs2utf($6);
    8377           0 :                 n->db_name  = dbs2utf($8);                   
    8378             :                 n->start_ip = dbs2utf($10);
    8379             :                 n->end_ip   = $11;                   
    8380             :                 n->node_id   = $12;//++bysdc@20190604                        
    8381             :                 $$ = (Node*)n;
    8382             :         }
    8383           0 :         | ALTER CONNECT POLICY DROP DISABLE Sconst LOGIN Sconst FROM Sconst opt_conn_policy opt_on_node
    8384           0 :         {
    8385           0 :                 ConnectPolicyStmt *n = makeNode(ConnectPolicyStmt);
    8386           0 :                 n->action   = 2;
    8387           0 :                 n->mode     = 2;
    8388           0 :                 n->user     = dbs2utf($6);
    8389           0 :                 n->db_name  = dbs2utf($8);                   
    8390           0 :                 n->start_ip = dbs2utf($10);
    8391           0 :                 n->end_ip   = $11;                   
    8392             :                 n->node_id   = $12;//++bysdc@20190604                        
    8393           0 :                 $$ = (Node*)n;
    8394             :         }
    8395           0 :         | ALTER CONNECT POLICY DROP ALL ENABLE opt_on_node
    8396           0 :         {
    8397           0 :                 ConnectPolicyStmt *n = makeNode(ConnectPolicyStmt);
    8398           0 :                 n->action   = 2;
    8399           0 :                 n->mode     = 1;
    8400           0 :                 n->all      = true;                  
    8401           0 :                 n->node_id   = $7;//++bysdc@20190604                 
    8402           0 :                 $$ = (Node*)n;
    8403           0 :         }
    8404             :         | ALTER CONNECT POLICY DROP ALL ENABLE LOGIN Sconst opt_on_node
    8405           0 :         {
    8406             :                 ConnectPolicyStmt *n = makeNode(ConnectPolicyStmt);
    8407           0 :                 n->action   = 2;
    8408           0 :                 n->mode     = 1;
    8409           0 :                 n->all      = true;  
    8410           0 :                 n->db_name  = dbs2utf($8);           
    8411           0 :                 n->node_id   = $9;//++bysdc@20190604                 
    8412           0 :                 $$ = (Node*)n;
    8413           0 :         }
    8414           0 :         | ALTER CONNECT POLICY DROP ALL ENABLE Sconst LOGIN Sconst opt_on_node
    8415           0 :         {
    8416             :                 ConnectPolicyStmt *n = makeNode(ConnectPolicyStmt);
    8417           0 :                 n->action   = 2;
    8418             :                 n->mode     = 1;
    8419           0 :                 n->all      = true;  
    8420           0 :                 n->user     = dbs2utf($7);
    8421           0 :                 n->db_name  = dbs2utf($9);           
    8422           0 :                 n->node_id   = $10;//++bysdc@20190604                        
    8423           0 :                 $$ = (Node*)n;
    8424           0 :         }
    8425           0 :         | ALTER CONNECT POLICY DROP ALL DISABLE opt_on_node
    8426           0 :         {
    8427           0 :                 ConnectPolicyStmt *n = makeNode(ConnectPolicyStmt);
    8428             :                 n->action   = 2;
    8429           0 :                 n->mode     = 2;
    8430             :                 n->all      = true;                  
    8431           0 :                 n->node_id   = $7;//++bysdc@20190604                 
    8432           0 :                 $$ = (Node*)n;
    8433           0 :         }
    8434           0 :         | ALTER CONNECT POLICY DROP ALL DISABLE LOGIN Sconst opt_on_node
    8435           0 :         {
    8436           0 :                 ConnectPolicyStmt *n = makeNode(ConnectPolicyStmt);
    8437             :                 n->action   = 2;
    8438           0 :                 n->mode     = 2;
    8439             :                 n->all      = true;  
    8440           0 :                 n->db_name     = dbs2utf($8);                
    8441           0 :                 n->node_id   = $9;//++bysdc@20190604                 
    8442           0 :                 $$ = (Node*)n;
    8443           0 :         }
    8444           0 :         | ALTER CONNECT POLICY DROP ALL DISABLE Sconst LOGIN Sconst opt_on_node
    8445           0 :         {
    8446           0 :                 ConnectPolicyStmt *n = makeNode(ConnectPolicyStmt);
    8447             :                 n->action   = 2;
    8448           0 :                 n->mode     = 2;
    8449             :                 n->all      = true;
    8450           0 :                 n->user     = dbs2utf($7);           
    8451           0 :                 n->db_name  = dbs2utf($9);           
    8452           0 :                 n->node_id   = $10;//++bysdc@20190604                        
    8453           0 :                 $$ = (Node*)n;
    8454           0 :         }
    8455           0 :         | ALTER CONNECT POLICY DROP ALL opt_on_node
    8456           0 :         {
    8457           0 :                 ConnectPolicyStmt *n = makeNode(ConnectPolicyStmt);
    8458             :                 n->action   = 2;
    8459           0 :                 n->mode     = 3;
    8460             :                 n->all      = true;                  
    8461           0 :                 n->node_id   = $6;//++bysdc@20190604                 
    8462           0 :                 $$ = (Node*)n;
    8463           0 :         }
    8464           0 :         ;
    8465           0 : 
    8466           0 : /*****************************************************************************
    8467             :  *
    8468           0 :  *              LOGIN
    8469             :  *
    8470           0 :  *
    8471           0 :  *****************************************************************************/
    8472           0 : LoginStmt:
    8473           0 :                 USE     ColId
    8474           0 :                 {
    8475           0 :                         LoginStmt *n = makeNode(LoginStmt);
    8476           0 :                         n->db_name =  $2;
    8477             :                         $$ = (Node*)n;                  
    8478           0 :                 }
    8479             :                 |   USE ColId  PASSWORD '=' Sconst
    8480           0 :                 {
    8481           0 :                         LoginStmt *n = makeNode(LoginStmt);
    8482           0 :                         n->db_name =  $2;
    8483           0 :                         n->password = dbs2utf($5);
    8484           0 :                         $$ = (Node*)n;
    8485           0 :         
    8486           0 :                 }
    8487           0 :                 |  USE ColId  USER '=' UserId  PASSWORD '=' Sconst
    8488             :                 {
    8489           0 :                         LoginStmt *n = makeNode(LoginStmt);
    8490             :                         n->db_name =  $2;
    8491           0 :                         n->user = $5;
    8492           0 :                         n->password = dbs2utf($8);
    8493           0 :                         $$ = (Node*)n;
    8494           0 :                 }
    8495           0 :                 ;
    8496           0 : 
    8497             : /*****************************************************************************
    8498           0 :  *
    8499             :  *              LOGOUT
    8500             :  *
    8501             :  *
    8502             :  *****************************************************************************/
    8503             : LogoutStmt:     LOGOUT DATABASE
    8504             :                 {
    8505             :                         $$ = (Node*)makeNode(LogoutStmt);       
    8506             :                 };
    8507             : 
    8508             : /*****************************************************************************
    8509          42 : *               CREATE DIR 
    8510          42 : *****************************************************************************/
    8511          42 : CreateDirStmt: CREATE _DIR Sconst opt_on_node
    8512             :         {
    8513          42 :                 CreateDirStmt *n = makeNode(CreateDirStmt);
    8514             :                 n->dir = dbs2utf($3);
    8515           0 :                 n->node_id = $4;
    8516           0 :                 $$ = (Node*)n;
    8517           0 :                 
    8518           0 :         };
    8519             : 
    8520             : ShowDirStmt: SHOW _DIR Sconst  opt_on_node
    8521           0 :         {
    8522             :                 ShowDirStmt *n = makeNode(ShowDirStmt);
    8523           0 :                 n->dir = dbs2utf($3);
    8524           0 :                 n->node_id = $4;
    8525           0 :                 $$ = (Node*)n;
    8526           0 :                 
    8527           0 :         };
    8528             : 
    8529           0 : 
    8530             : /*****************************************************************************
    8531             :  *              CREATE TABLESPACE
    8532             :  *****************************************************************************/
    8533             : CreatespacStmt: CREATE optSpaceType TABLESPACE space_name opt_on_node DATAFILE data_files  
    8534             :                         {
    8535             :                                 CreatespacStmt  *p_space = makeNode(CreatespacStmt);
    8536             :                                 p_space->space_type = (SpaceType)$2;
    8537             :                                 p_space->spac_name = $4;
    8538             :                                 p_space->node_id = $5;
    8539           0 :                                 p_space->data_files = $7;
    8540             :                                 $$ = (Node*)p_space;
    8541           0 :                         }
    8542             :                         ;
    8543             : optSpaceType:
    8544             :                         {
    8545             :                                 $$ = DATA_SPACE;
    8546             :                         }
    8547           0 :                         |       TEMP
    8548           0 :                         {
    8549           0 :                                 $$ = TEMP_SPACE;
    8550           0 :                         }
    8551             :                         |       TEMPORARY
    8552             :                         {
    8553           0 :                                 $$ = TEMP_SPACE;
    8554             :                         }
    8555             :                         ;
    8556           0 : /*excute node option*/
    8557           0 : opt_on_node: /* empty */
    8558           0 :                         {
    8559           0 :                                 $$ = 0;  //default current node 
    8560             :                         }
    8561             :                         |       ON ALL NODE
    8562           0 :                         {
    8563             :                                 $$ = -1; //all cluster alive nodes
    8564             :                         }
    8565             :                         |  ON NODE ICONST
    8566             :                         {
    8567             :                                 $$ = $3;
    8568             :                         }
    8569           0 :                         ;
    8570           0 :                                                         
    8571           0 : /*group files of data*/
    8572           0 : data_files:     data_file
    8573           0 :                 {
    8574           0 :                         $$ = makeList1($1);
    8575             :                 }
    8576           0 :                 |       data_files ',' data_file
    8577             :                 {
    8578             :                         $$ = lappend($1,$3);
    8579           0 :                 }
    8580             :                 ;
    8581           0 : 
    8582             : data_file:      Sconst
    8583           0 :                 {
    8584             :                         TFile *p_file = New(TFile);
    8585           0 :                         p_file->path = dbs2utf($1);
    8586             :                         p_file->max_size = -1;       
    8587           0 :                         p_file->ini_size = -1;
    8588             :                         p_file->step_size = -1;      
    8589           0 :                         $$ = (Node*)p_file;
    8590             :                 }
    8591             :                 |       Sconst  autoextend_clause
    8592             :                 {
    8593           0 :                         TFile *p_file = (TFile*)$2;
    8594             :                         p_file->path = dbs2utf($1);
    8595           0 :                         $$ = (Node*)p_file;                                     
    8596             :                 };
    8597           0 :                                 
    8598             : autoextend_clause:
    8599           0 :                 /* ++bysdc@20200122 for refactor-tablespace */
    8600             :                 AUTO EXTEND     OFF     
    8601           0 :                 {
    8602             :                         TFile *p_f = New(TFile);
    8603           0 :                         p_f->ini_size  = 0;
    8604             :                         p_f->max_size  = 0;
    8605             :                         p_f->step_size = 0;
    8606             :                         $$ = (Node*)p_f; 
    8607             :                 }
    8608           0 :                 //end
    8609             :                 |       _SIZE_  ICONST size_unit AUTO EXTEND    OFF     
    8610           0 :                 {
    8611             :                         TFile *p_f = New(TFile);
    8612           0 :                         p_f->ini_size = ((int64)$2) * $3;
    8613             :                         p_f->max_size = p_f->ini_size;
    8614           0 :                         p_f->step_size = 0;
    8615             :                         $$ = (Node*)p_f; 
    8616             :                 }
    8617             :                 |       _SIZE_  ICONST size_unit  MAXSIZE UNLIMITED
    8618           0 :                 {
    8619           0 :                         TFile *p_f = New(TFile);
    8620           0 :                         p_f->ini_size = ((int64)$2) *$3;
    8621           0 :                         p_f->max_size = -1;
    8622           0 :                         p_f->step_size = -1;
    8623           0 :                         $$ = (Node*)p_f; 
    8624             :                 }
    8625           0 :                 |       _SIZE_  ICONST size_unit  MAXSIZE ICONST size_unit
    8626             :                 {                                       
    8627           0 :                         TFile *p_f = New(TFile);
    8628           0 :                         p_f->ini_size = ((int64)$2) *$3;
    8629           0 :                         p_f->max_size = ((int64)$5) *$6;
    8630             :                         p_f->step_size = -1;
    8631           0 :                         $$ = (Node*)p_f; 
    8632             : 
    8633             :                 }
    8634             : 
    8635             :                 |       _SIZE_  ICONST size_unit  NEXT ICONST size_unit MAXSIZE UNLIMITED
    8636           0 :                 {
    8637           0 :                         TFile *p_f = New(TFile);
    8638           0 :                         p_f->ini_size = ((int64)$2)*$3;
    8639           0 :                         p_f->step_size = ((int64)$5)*$6;
    8640           0 :                         p_f->max_size = -1;
    8641             :                         $$ = (Node*)p_f; 
    8642           0 :                 }
    8643             : 
    8644             :                 |       _SIZE_  ICONST size_unit  NEXT ICONST size_unit MAXSIZE ICONST size_unit
    8645           0 :                 {
    8646           0 :                         TFile *p_f = New(TFile);
    8647           0 :                         p_f->ini_size = ((int64)$2)*$3;
    8648           0 :                         p_f->step_size = ((int64)$5)*$6;
    8649           0 :                         p_f->max_size = ((int64)$8)*$9;
    8650             :                         $$ = (Node*)p_f;
    8651           0 :                 }
    8652             :                 /* ++bysdc@20200122 for refactor-tablespace */
    8653           0 :                 |       NEXT ICONST size_unit MAXSIZE ICONST size_unit
    8654           0 :                 {
    8655           0 :                         TFile *p_f = New(TFile);
    8656           0 :                         p_f->ini_size = 0;
    8657           0 :                         p_f->step_size = ((int64)$2)*$3;
    8658             :                         p_f->max_size = ((int64)$5)*$6;
    8659           0 :                         $$ = (Node*)p_f;
    8660             :                 }
    8661           0 :                 |       MAXSIZE ICONST size_unit
    8662           0 :                 {                                       
    8663           0 :                         TFile *p_f = New(TFile);
    8664           0 :                         p_f->ini_size = 0;
    8665           0 :                         p_f->max_size = ((int64)$2) *$3;
    8666             :                         p_f->step_size = -1;
    8667             :                         $$ = (Node*)p_f; 
    8668           0 : 
    8669             :                 }
    8670             :                 |       NEXT ICONST size_unit
    8671           0 :                 {                                       
    8672           0 :                         TFile *p_f = New(TFile);
    8673           0 :                         p_f->ini_size = 0;
    8674           0 :                         p_f->max_size = 0;
    8675           0 :                         p_f->step_size = ((int64)$2)*$3;
    8676             :                         $$ = (Node*)p_f; 
    8677           0 : 
    8678             :                 }
    8679             :                 //end
    8680           0 :                 ;
    8681           0 : 
    8682           0 : size_unit:      K
    8683           0 :                         {
    8684           0 :                                 $$ = 1024;
    8685             :                         }
    8686           0 :                         |       M
    8687             :                         {
    8688             :                                 $$ = 1024*1024;
    8689           0 :                         }
    8690           0 :                         /* ++bysdc@20200122 for refactor-tablespace */
    8691           0 :                         |       G
    8692           0 :                         {
    8693           0 :                                 $$ = 1024*1024*1024;
    8694             :                         }
    8695           0 :                         //end           
    8696             :                         ;                               
    8697           0 :                                                                                 
    8698           0 : /*****************************************************************************
    8699           0 :  *
    8700           0 :  *              DROP TABLESPACE
    8701           0 :  *
    8702             :  *****************************************************************************/
    8703             : DropspacStmt:   DROP TABLESPACE space_name 
    8704           0 :                         {
    8705             :                                 DropStmt *n = makeNode(DropStmt);
    8706           0 :                                 n->obj_name = $3;
    8707           0 :                                 n->drop_type = DROP_SPACE;
    8708           0 :                                 $$ = (Node*)n;          
    8709           0 :                         };
    8710           0 : 
    8711             : 
    8712             : /*****************************************************************************
    8713           0 :  *
    8714             :  *              Alter TABLESPACE
    8715             :  *
    8716             :  *****************************************************************************/
    8717             : AlterspacStmt:
    8718           0 :                         ALTER TABLESPACE space_name  opt_on_node ADD DATAFILE data_file
    8719             :                         {
    8720           0 :                                 AlterspacStmt   *p_stmt = makeNode(AlterspacStmt);
    8721             :                                 p_stmt->spac_name = $3;      
    8722           0 :                                 p_stmt->node_id = $4;
    8723             :                                 p_stmt->alt_type = '+';              
    8724           0 :                                 p_stmt->data_file = (TFile*)$7;      
    8725             :                                 $$ = (Node *)p_stmt;
    8726             :                                 
    8727           0 :                         }               
    8728             :                         |       ALTER TABLESPACE space_name opt_on_node ALTER DATAFILE data_file
    8729           0 :                         {
    8730             :                                 AlterspacStmt   *p_stmt = makeNode(AlterspacStmt);
    8731             :                                 p_stmt->spac_name = $3;
    8732             :                                 p_stmt->node_id = $4;
    8733             :                                 p_stmt->alt_type = 'a';              
    8734             :                                 p_stmt->data_file =(TFile*)$7;       
    8735             :                                 $$ = (Node *)p_stmt;
    8736             :                         }
    8737             :                         ;
    8738             :                                                                 
    8739           0 : /*****************************************************************************
    8740           0 :  *              CREATE DATABASE
    8741           0 :  *****************************************************************************/
    8742           0 : 
    8743             : CreatedbStmt:  CREATE DATABASE database_name
    8744           0 :                 {
    8745             :                         CreatedbStmt *stmt = makeNode(CreatedbStmt);
    8746             :                         stmt->dbname = $3;
    8747             :                         $$ = (Node*)stmt;
    8748             :                 }
    8749             :                 | CreatedbStmt CHARACTER SET ColId
    8750             :                 {
    8751             :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8752             :                         stmt->cset_name = $4;
    8753             :                         $$ = (Node*)stmt;
    8754           0 :                 }
    8755           0 :                 | CreatedbStmt CHARACTER SET Sconst
    8756           0 :                 {
    8757           0 :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8758           0 :                         stmt->cset_name = dbs2utf($4);
    8759           0 :                         $$ = (Node*)stmt;
    8760             :                 }
    8761             :                 | CreatedbStmt TIME ZONE Sconst
    8762           0 :                 {
    8763             :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8764           0 :                         stmt->time_zone = dbs2utf($4);
    8765           0 :                         $$ = (Node*)stmt;
    8766           0 :                 }
    8767           0 :                 | CreatedbStmt _MAX USER ICONST
    8768           0 :                 {
    8769           0 :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8770             :                         stmt->max_user = $4;
    8771           0 :                         $$ = (Node*)stmt;
    8772             :                 }
    8773             :                 | CreatedbStmt _MAX CONNECT ICONST
    8774             :                 {
    8775             :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8776             :                         stmt->max_dbc = $4;
    8777             :                         $$ = (Node*)stmt;
    8778             :                 }
    8779           1 :                 | CreatedbStmt _MAX _SIZE_ ICONST size_unit
    8780           1 :                 {
    8781           1 :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8782             :                         stmt->max_size = ((int64)$4) *$5;
    8783           1 :                         $$ = (Node*)stmt;
    8784             :                 }
    8785           0 :                 | CreatedbStmt _MAX TABLE ICONST 
    8786           0 :                 {
    8787           0 :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8788             :                         stmt->max_tab = $4;
    8789           0 :                         $$ = (Node*)stmt;
    8790             :                 }
    8791           0 :                 | CreatedbStmt _MAX VIEW ICONST 
    8792           0 :                 {
    8793           0 :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8794             :                         stmt->max_view = $4;
    8795           0 :                         $$ = (Node*)stmt;
    8796             :                 }
    8797           0 :                 | CreatedbStmt _MAX SEQUENCE ICONST 
    8798           0 :                 {
    8799           0 :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8800             :                         stmt->max_seq = $4;
    8801           0 :                         $$ = (Node*)stmt;
    8802             :                 }
    8803           0 :                 | CreatedbStmt _MAX TRIGGER ICONST 
    8804           0 :                 {
    8805           0 :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8806             :                         stmt->max_trig = $4;
    8807           0 :                         $$ = (Node*)stmt;
    8808             :                 }
    8809           0 :                 | CreatedbStmt _MAX PROCEDURE ICONST 
    8810           0 :                 {
    8811           0 :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8812             :                         stmt->max_proc = $4;
    8813           0 :                         $$ = (Node*)stmt;
    8814             :                 }
    8815           0 :                 | CreatedbStmt _MAX PACKAGE ICONST 
    8816           0 :                 {
    8817           0 :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8818             :                         stmt->max_pack = $4;
    8819           0 :                         $$ = (Node*)stmt;
    8820             :                 }
    8821           0 :                 | CreatedbStmt _MAX TYPE ICONST 
    8822           0 :                 {
    8823           0 :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8824             :                         stmt->max_udt = $4;
    8825           0 :                         $$ = (Node*)stmt;
    8826             :                 }
    8827           0 :                 | CreatedbStmt _MAX JOB ICONST 
    8828           0 :                 {
    8829           0 :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8830             :                         stmt->max_job = $4;
    8831           0 :                         $$ = (Node*)stmt;
    8832             :                 }
    8833           0 :                 | CreatedbStmt ENABLE ENCRYPT 
    8834           0 :                 {
    8835           0 :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8836             :                         stmt->ena_encry = true;
    8837           0 :                         $$ = (Node*)stmt;
    8838             :                 }
    8839           0 :                 | CreatedbStmt DISABLE ENCRYPT 
    8840           0 :                 {
    8841           0 :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8842             :                         stmt->ena_encry = false;
    8843           0 :                         $$ = (Node*)stmt;
    8844             :                 }
    8845           0 :                 | CreatedbStmt ENABLE POLICY 
    8846           0 :                 {
    8847           0 :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8848             :                         stmt->ena_policy = true;
    8849           0 :                         $$ = (Node*)stmt;
    8850             :                 }
    8851           0 :                 | CreatedbStmt DISABLE POLICY 
    8852           0 :                 {
    8853           0 :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8854             :                         stmt->ena_policy = false;
    8855           0 :                         $$ = (Node*)stmt;
    8856             :                 }
    8857           0 :                 | CreatedbStmt ENABLE AUDIT 
    8858           0 :                 {
    8859           0 :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8860             :                         stmt->ena_audit = true;
    8861           0 :                         $$ = (Node*)stmt;
    8862             :                 }
    8863           0 :                 | CreatedbStmt DISABLE AUDIT 
    8864           0 :                 {
    8865           0 :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8866             :                         stmt->ena_audit = false;
    8867           0 :                         $$ = (Node*)stmt;
    8868             :                 }
    8869           0 :                 //why 2016-10-27 add mergebysdc@20180907
    8870           0 :                 | CreatedbStmt ENCRYPT BY Sconst 
    8871           0 :                 {
    8872             :                         CreatedbStmt *stmt = (CreatedbStmt*)$1;
    8873           0 :                         stmt->encry_name = dbs2utf($4);                      
    8874             :                         $$ = (Node*)stmt;
    8875           0 :                 }
    8876           0 :                 //end
    8877           0 :                 ;       
    8878             :                                         
    8879           0 : /*****************************************************************************
    8880             :  *
    8881           0 :  *              DROP DATABASE
    8882           0 :  *
    8883           0 :  *
    8884             :  *****************************************************************************/
    8885           0 : 
    8886             : DropdbStmt:     DROP DATABASE database_name
    8887           0 :                 {
    8888           0 :                         DropStmt *n = makeNode(DropStmt);
    8889           0 :                         n->obj_name = $3;
    8890             :                         n->drop_type = DROP_DB;
    8891           0 :                         $$ = (Node *)n;
    8892             :                         
    8893           0 :                 }
    8894           0 :                 ;
    8895           0 : 
    8896             : /*****************************************************************************
    8897           0 :  *
    8898             :  *              QUERY:  cluster <index_name> on <name_space>
    8899           0 :  *
    8900           0 :  *****************************************************************************/
    8901           0 : 
    8902             : ClusterStmt:  ALTER  TABLE  name_space CLUSTER BY name_list 
    8903           0 :                 {
    8904             :                    ClusterStmt *n = makeNode(ClusterStmt);
    8905             :                    n->relname = $3;
    8906           0 :                    n->col_names = $6;
    8907           0 :                    $$ = (Node*)n;
    8908           0 :                    SetNodePos($$);              
    8909             :                 }
    8910           0 :                 ;
    8911             : 
    8912             : AnalyzeStmt: ANALYZE TABLE name_space COMPUTE STATISTICS opt_analyze_for
    8913             :                 {
    8914             :                         AnalyzeStmt *p_stmt = makeNode(AnalyzeStmt);
    8915             :                         p_stmt->table_name = $3;
    8916             :                         AnalyzeOpt *opt = (AnalyzeOpt*)$6;
    8917             :                         p_stmt->ana_type = opt->ana_type;
    8918             :                         p_stmt->col_names = opt->col_names;
    8919             :                         $$ = (Node*)p_stmt;
    8920             :                         SetNodePos($$);
    8921             :                 };
    8922           1 : 
    8923           1 : opt_analyze_for: /*empty*/
    8924           1 :                 {
    8925           1 :                         AnalyzeOpt *opt = New(AnalyzeOpt);
    8926             :                         opt->ana_type = 1;
    8927             :                         opt->col_names = NIL;
    8928           1 :                         $$ = opt;
    8929             :                 }
    8930             :                 |       FOR ALL COLUMNS
    8931             :                 {
    8932             :                         AnalyzeOpt *opt = New(AnalyzeOpt);
    8933             :                         opt->ana_type = 1;
    8934             :                         opt->col_names = NIL;
    8935             :                         $$ = opt;
    8936             :                 }
    8937             :                 |  FOR COLUMNS '(' name_list ')'
    8938           0 :                 {
    8939           0 :                         AnalyzeOpt *opt = New(AnalyzeOpt);
    8940           0 :                         opt->ana_type = 1;
    8941           0 :                         opt->col_names = $4;
    8942           0 :                         $$ = opt;
    8943             :                 }
    8944           0 :                 ;       
    8945             : 
    8946             : /*****************************************************************************
    8947             :  *
    8948           0 :  *              QUERY:
    8949           0 :  *                              vacuum
    8950           0 :  *
    8951           0 :  *****************************************************************************/
    8952           0 : 
    8953           0 : VacuumStmt:  VACUUM opt_verbose opt_analyze
    8954           0 :                 {
    8955             :                         VacuumStmt *n = makeNode(VacuumStmt);
    8956           0 :                         n->verbose = $2;
    8957             :                         n->analyze = $3;
    8958             :                         n->tab_name = NULL;
    8959           0 :                         n->col_list = NIL;
    8960           0 :                         $$ = (Node *)n;
    8961           0 :                         SetNodePos($$);
    8962           0 :                 }
    8963             :                 | VACUUM opt_verbose opt_analyze name_space opt_va_list
    8964           0 :                 {
    8965             :                         VacuumStmt *n = makeNode(VacuumStmt);
    8966           0 :                         n->verbose = $2;
    8967           0 :                         n->analyze = $3;
    8968           0 :                         n->tab_name = $4;
    8969           0 :                         n->col_list = $5;
    8970             :                         if ( $5 != NIL && !$4 )
    8971           0 :                         {
    8972             :                                 SetParsePos();
    8973           0 :                                 add_parse_error(515);
    8974           0 :                         }
    8975           0 :                         $$ = (Node *)n;
    8976           0 :                         SetNodePos($$);
    8977             :                 }
    8978           0 :                 ;
    8979             : 
    8980             : opt_verbose:  VERBOSE                           { $$ = true; }
    8981             :                 |    /*EMPTY*/                          { $$ = false; }
    8982             :                 ;
    8983             : 
    8984             : opt_analyze:  ANALYZE                           { $$ = true; }
    8985             :                 |    /*EMPTY*/                          { $$ = false; }
    8986             :                 ;
    8987             : 
    8988             : opt_va_list:  
    8989           0 :                   '(' va_list ')'           { $$ = $2; }
    8990           0 :                 | /*EMPTY*/                 { $$ = NIL; }
    8991           0 :                 ;
    8992           0 : 
    8993           0 : va_list:  name
    8994           0 :                 { $$ = makeList1($1); }
    8995           0 :                 | va_list ',' name
    8996             :                 { $$ = lappend($1, $3); }
    8997           0 :                 ;
    8998             : 
    8999           0 : 
    9000           0 : /*****************************************************************************
    9001           0 :  *
    9002           0 :  *              QUERY:
    9003           0 :  *                              EXPLAIN query
    9004           0 :  *
    9005             :  *****************************************************************************/
    9006           0 : 
    9007           0 : ExplainStmt:  EXPLAIN opt_verbose dml_stmt
    9008             :                 {
    9009           0 :                         ExplainStmt *n = makeNode(ExplainStmt);
    9010           0 :                         n->verbose = $2;
    9011             :                         n->query = (Node*)$3;
    9012           0 :                         $$ = (Node *)n;
    9013             :                         
    9014           0 :                 }
    9015           0 :                 ;
    9016           0 : 
    9017             : 
    9018           0 : /*****************************************************************************
    9019           0 :  *                                                                                                                                                       *
    9020           0 :  *              Optimizable Stmts:                                                                                                       *
    9021             :  *                                                                                                                                                       *
    9022           0 :  *              one of the five queries processed by the planner                                         *
    9023           0 :  *                                                                                                                                                       *
    9024           0 :  *              [ultimately] produces query-trees as specified                                           *
    9025             :  *              in the query-spec document in ~postgres/ref                                                      *
    9026             :  *                                                                                                                                                       *
    9027           0 :  *****************************************************************************/
    9028           0 : 
    9029           0 : dml_stmt:  
    9030           0 :         SelectStmt  parallel_opt opt_wait dml_opt
    9031             :         {
    9032             :                 ((SelectStmt*)$1)->parallel = $2;
    9033             :                 ((SelectStmt*)$1)->wait_ms = $3;
    9034             :                 ((ParseNode*)$1)->dml_opt = $4;
    9035             :                 $$ = (Node*)$1;
    9036             :         }
    9037             :         | UpdateStmt  parallel_opt opt_wait dml_opt
    9038             :           {
    9039             :            ((UpdateStmt*)$1)->parallel = $2;
    9040             :            ((UpdateStmt*)$1)->wait_ms = $3;
    9041             :                 ((SelectStmt*)$1)->dml_opt = $4;
    9042           0 :                 ((ParseNode*)$1)->dml_opt = $4;
    9043           0 :                 $$ = (Node*)$1;
    9044           0 :           }
    9045           0 :         | InsertStmt  parallel_opt opt_wait dml_opt
    9046             :           {
    9047             :            ((InsertStmt*)$1)->parallel = $2;
    9048           0 :            ((InsertStmt*)$1)->wait_ms = $3;
    9049             :            ((ParseNode*)$1)->dml_opt |= $4;
    9050             :                 $$ = (Node*)$1;
    9051             :           }
    9052             :         | DeleteStmt  parallel_opt  opt_wait dml_opt
    9053             :         {
    9054             :                 ((DeleteStmt*)$1)->parallel = $2;
    9055             :                 ((DeleteStmt*)$1)->wait_ms = $3;
    9056             :                 ((ParseNode*)$1)->dml_opt = $4;
    9057             :                 $$ = (Node*)$1;
    9058             :         }
    9059             :         /*++bysdc@20200910 for mergeinto*/
    9060             :         | MergeIntoStmt  parallel_opt  opt_wait dml_opt
    9061             :         {
    9062             :                 ((MergeIntoStmt*)$1)->parallel = $2;
    9063             :                 ((MergeIntoStmt*)$1)->wait_ms = $3;
    9064             :                 ((ParseNode*)$1)->dml_opt = $4;
    9065        2036 :                 $$ = (Node*)$1;
    9066        2036 :         }
    9067        2036 :         ;
    9068        2036 : 
    9069             : opt_wait:
    9070        2036 :           /*empty*/                      { $$ = -2; }   
    9071             :         | NOWAIT                         { $$ = 0; }
    9072         273 :         | WAIT                           { $$ = -1; }
    9073         273 :         | WAIT ICONST                    { $$ = $2; }
    9074         273 :         ;
    9075         273 :         
    9076         273 : dml_opt:  /*empty*/
    9077             :         {
    9078         273 :                 $$ = 0;
    9079             :         }
    9080       11036 :         |  WITH NO ROLLBACK
    9081       11036 :         {
    9082       11036 :                 $$ = OPT_NO_UNDO;
    9083       11036 :         }
    9084             :         | WITH NO UNDO
    9085       11036 :         {
    9086             :                 $$ = OPT_NO_UNDO;
    9087         338 :         }
    9088         338 :         |  WITH NOT ROLLBACK
    9089         338 :         {
    9090         338 :                 $$ = OPT_NO_UNDO;
    9091             :         }
    9092         338 :         | WITH NOT UNDO
    9093             :         {
    9094             :                 $$ = OPT_NO_UNDO;
    9095           0 :         }
    9096           0 :         ;       
    9097           0 :         
    9098           0 : /*prepare sql for reuse until deallocate*/
    9099             : PrepareStmt: PREPARE ColId AS sql_stmt //** dml_stmt >> sql_stmt bysdc@20201028 for ddl prepare compatable
    9100           0 :         {
    9101             :                 PrepareStmt *p_prepare_stmt = makeNode(PrepareStmt);
    9102             :                 p_prepare_stmt->name = $2;
    9103             :                 p_prepare_stmt->p_stmt = $4;
    9104       14576 :                 p_prepare_stmt->is_dml = true;//++bysdc@20201028
    9105             :                 $$ = (Node*)p_prepare_stmt;
    9106       14576 :         }
    9107             :         ;
    9108           0 : DeallocateStmt: DEALLOCATE ColId
    9109             :         {
    9110           0 :                 DeallocateStmt *p_stmt = makeNode(DeallocateStmt);
    9111             :                 p_stmt->name = $2;
    9112           0 :                 $$ = (Node*)p_stmt;
    9113             :         }
    9114           0 :         ;
    9115             :                                 
    9116           0 : /*****************************************************************************
    9117             :  *              QUERY:
    9118           0 :  *                              INSERT STATEMENTS
    9119             :  *****************************************************************************/
    9120             : 
    9121             : /* This rule used 'opt_column_list' between 'name_space' and 'insert_rest'
    9122       13683 :  * originally. When the second rule of 'insert_rest' was changed to use the
    9123             :  * new 'SelectStmt' rule (for INTERSECT and EXCEPT) it produced a shift/reduce
    9124       13683 :  * conflict. So I just changed the rules 'InsertStmt' and 'insert_rest' to
    9125             :  * accept the same statements without any shift/reduce conflicts
    9126           0 : */
    9127             : InsertStmt:  INSERT INTO relation_expr insert_rest 
    9128           0 :                 {
    9129             :                         ((InsertStmt*)$4)->relation =(TabNode*) $3;
    9130           0 :                         $$ = (Node *) $4; 
    9131             :                 }
    9132           0 :                 |REPLACE INTO relation_expr insert_rest 
    9133             :                 {
    9134           0 :                         ((InsertStmt*)$4)->relation =(TabNode*) $3;
    9135             :                         ((InsertStmt*)$4)->dml_opt = OPT_INSERT_REPLACE;
    9136           0 :                         $$ = (Node *) $4; 
    9137             :                 }
    9138           0 :                 |INSERT _IGNORE INTO relation_expr insert_rest 
    9139             :                 {
    9140           0 :                         ((InsertStmt*)$5)->relation =(TabNode*) $4;
    9141             :                         ((InsertStmt*)$5)->dml_opt = OPT_INSERT_IGNORE;
    9142             :                         $$ = (Node *) $5; 
    9143             :                 }
    9144             :                 | INSERT INTO relation_expr insert_rest RETURNING target_list opt_bulk opt_into_list
    9145       13239 :                 {
    9146       13239 :                         ((InsertStmt*)$4)->relation =(TabNode*) $3;
    9147       13239 :                         ((InsertStmt*)$4)->return_list = $6;
    9148       13239 :                         ((InsertStmt*)$4)->is_bulk = $7;
    9149       13239 :                         ((InsertStmt*)$4)->into_list = $8;
    9150             :                         $$ = (Node *) $4; 
    9151       13239 :                 }       
    9152             :                 | INSERT insert_multi_tab_type insert_when_clause_list insert_else_clause select_no_parens
    9153             :                 {
    9154       12674 :                         InsertMultiTabStmt *multi_tab = makeNode(InsertMultiTabStmt);
    9155       12674 :                         multi_tab->type = $2;
    9156       12674 :                         multi_tab->when_lists = $3;
    9157             :                         multi_tab->def_lists = $4;
    9158       12674 :                         multi_tab->selectStmt = $5;
    9159             :                         $$ = (Node*)multi_tab;
    9160             :                 }
    9161             :                 | INSERT ALL insert_into_list select_no_parens
    9162             :                 {
    9163             :                         InsertMultiTabStmt *multi_tab = makeNode(InsertMultiTabStmt);
    9164             :                         multi_tab->type = INSERT_MULTI_TAB_ALL;
    9165             :                         MultiCaseWhen *w = makeNode(MultiCaseWhen);
    9166             :                         w->insert_list = $3;
    9167             :                         multi_tab->when_lists = makeList1(w);
    9168             :                         multi_tab->selectStmt = $4;
    9169             :                         $$ = (Node*)multi_tab;
    9170             :                 }
    9171             :                 ;
    9172             : 
    9173       11036 : insert_multi_tab_type: 
    9174       11036 :                   FIRST                        { $$ = INSERT_MULTI_TAB_FIRST; }
    9175             :                 | ALL                          { $$ = INSERT_MULTI_TAB_ALL;   }
    9176       11036 :                 | /*EMPTY*/                    { $$ = INSERT_MULTI_TAB_ALL;   }
    9177             :                 ;
    9178           0 : 
    9179           0 : insert_when_clause_list:  insert_when_clause_list insert_when_clause
    9180           0 :                 { 
    9181             :                         $$ = lappend($1, $2); 
    9182           0 :                 }
    9183             :                 | insert_when_clause
    9184           0 :                 { 
    9185           0 :                         $$ = makeList1($1); 
    9186           0 :                 }
    9187             :                 ;
    9188           0 : 
    9189             : insert_when_clause:  WHEN bool_expr THEN insert_into_list       
    9190           0 :                 {
    9191           0 :                         MultiCaseWhen *w = makeNode(MultiCaseWhen);
    9192           0 :                         w->expr = $2;
    9193           0 :                         w->insert_list = $4;
    9194           0 :                         $$ = (Node *)w;
    9195             :                         SetNodePos($$);
    9196           0 :                 }
    9197             :                 ;
    9198           0 : 
    9199           0 : insert_else_clause: ELSE insert_into_list                                               
    9200           0 :                 { 
    9201           0 :                         $$ = $2;
    9202           0 :                 }
    9203           0 :                 | /*EMPTY*/       { $$ = NULL; }
    9204             :                 ;
    9205           0 : 
    9206             : insert_into_list: insert_into_list insert_into_clause
    9207           0 :                 {
    9208           0 :                         $$ = lappend($1, $2); 
    9209           0 :                 }
    9210           0 :                 | insert_into_clause
    9211           0 :                 {
    9212           0 :                         $$ = makeList1($1); 
    9213           0 :                 }
    9214             :                 ;
    9215           0 : 
    9216             : insert_into_clause: INTO relation_expr opt_column_list VALUES '(' target_list ')'
    9217             :                 {
    9218           0 :                         InsertStmt *insert = makeNode(InsertStmt);
    9219           0 :                         insert->relation =(TabNode*) $2;
    9220           0 :                         insert->cols = $3;
    9221           0 :                         insert->values = $6;
    9222             :                         $$ = (Node*)insert;
    9223             :                         SetNodePos($$);
    9224             :                 }
    9225           0 :                 | INTO relation_expr '(' columnList ')' 
    9226             :                 {
    9227           0 :                         InsertStmt *insert = makeNode(InsertStmt);
    9228             :                         insert->relation =(TabNode*) $2;
    9229           0 :                         insert->cols = $4;
    9230             :                         $$ = (Node*)insert;
    9231           0 :                         SetNodePos($$);
    9232             :                 }
    9233             :                 | INTO relation_expr %prec UMINUS
    9234             :                 {
    9235           0 :                         InsertStmt *insert = makeNode(InsertStmt);
    9236           0 :                         insert->relation =(TabNode*) $2;
    9237           0 :                         $$ = (Node*)insert;
    9238           0 :                         SetNodePos($$);
    9239           0 :                 }
    9240             :                 ;
    9241           0 : 
    9242             : insert_rest:  VALUES insert_values 
    9243             :                 {
    9244             :                         $$ = (Node*)makeNode(InsertStmt);
    9245           0 :                         ((InsertStmt*)$$)->cols = NIL;
    9246             :                         ((InsertStmt*)$$)->values = $2;
    9247           0 :                         ((InsertStmt*)$$)->selectStmt = NULL;
    9248           0 :                 }
    9249             :                 | DEFAULT VALUES
    9250             :                 {
    9251             :                         $$ = (Node*)makeNode(InsertStmt);
    9252           0 :                         ((InsertStmt*)$$)->cols = NIL;
    9253             :                         ((InsertStmt*)$$)->selectStmt = NULL;
    9254           0 :                 }
    9255             :                 | SelectStmt
    9256           0 :                 {
    9257             :                         $$ = (Node*)makeNode(InsertStmt);
    9258           0 :                         ((InsertStmt*)$$)->cols = NIL;
    9259             :                         ((InsertStmt*)$$)->selectStmt = $1;
    9260             :                 }
    9261             :                 | '(' columnList ')' VALUES insert_values
    9262           0 :                 {
    9263           0 :                         $$ = (Node*)makeNode(InsertStmt);
    9264           0 :                         ((InsertStmt*)$$)->cols = $2;
    9265           0 :                         ((InsertStmt*)$$)->values = $5;
    9266           0 :                         ((InsertStmt*)$$)->selectStmt = NULL;
    9267           0 :                 }
    9268             :                 | '(' columnList ')' SelectStmt
    9269           0 :                 {
    9270             :                         $$ = (Node*)makeNode(InsertStmt);
    9271           0 :                         ((InsertStmt*)$$)->cols = $2;
    9272           0 :                         ((InsertStmt*)$$)->selectStmt = $4;
    9273           0 :                 }
    9274           0 : 
    9275           0 :                 ;
    9276             : /*++bysdc@20200910 for mergeinto:*/
    9277           0 : insert_merge:  VALUES insert_values 
    9278             :                 {
    9279           0 :                         $$ = (Node*)makeNode(InsertStmt);
    9280           0 :                         ((InsertStmt*)$$)->cols = NIL;
    9281           0 :                         ((InsertStmt*)$$)->values = $2;
    9282           0 :                         ((InsertStmt*)$$)->selectStmt = NULL;
    9283             :                 }
    9284           0 :                 | DEFAULT VALUES
    9285             :                 {
    9286             :                         $$ = (Node*)makeNode(InsertStmt);
    9287             :                         ((InsertStmt*)$$)->cols = NIL;
    9288       10871 :                         ((InsertStmt*)$$)->selectStmt = NULL;
    9289       10871 :                 }
    9290       10871 :                 | '(' columnList2 ')' VALUES insert_values
    9291       10871 :                 {
    9292             :                         $$ = (Node*)makeNode(InsertStmt);
    9293       10871 :                         ((InsertStmt*)$$)->cols = $2;
    9294             :                         ((InsertStmt*)$$)->values = $5;
    9295           1 :                         ((InsertStmt*)$$)->selectStmt = NULL;
    9296           1 :                 }
    9297           1 :                 ;
    9298             : 
    9299           1 : insert_values: '(' target_list ')'
    9300             :                 {
    9301          66 :                         $$ = makeList1($2);
    9302          66 :                 }
    9303          66 :                 | insert_values '(' target_list ')'
    9304             :                 {
    9305          66 :                         $$ = lappend($1,$3);
    9306             :                 }
    9307          94 :                 /*++bysdc@20210914 support comma split values*/
    9308          94 :                 | insert_values ',' '(' target_list ')'
    9309          94 :                 {
    9310          94 :                         $$ = lappend($1,$4);
    9311             :                 }
    9312          94 :                 ;
    9313             :         
    9314           4 : opt_column_list:  
    9315           4 :                   '(' columnList ')'       { $$ = $2; }
    9316           4 :                 | /*EMPTY*/                                { $$ = NIL; }
    9317             :                 ;
    9318           4 : 
    9319             : columnList:  columnList ',' ColLabel
    9320             :                 { 
    9321             :                         Ident *p_ident = makeNode(Ident);
    9322             :                         p_ident->name = $3;  
    9323           0 :                         $$ = lappend($1, p_ident); 
    9324           0 :                 }
    9325           0 :                 | ColLabel
    9326           0 :                 { 
    9327             :                         Ident *p_ident = makeNode(Ident);
    9328           0 :                         p_ident->name = $1;  
    9329             :                         $$ = makeList1(p_ident); 
    9330           0 :                 }
    9331           0 :                 ;
    9332           0 : /*++bysdc@20200910 for mergeinto*/
    9333             : columnList2:  columnList2 ',' ident
    9334           0 :                 { 
    9335             :                         $$ = lappend($1, $3); 
    9336           0 :                 }
    9337           0 :                 | ident
    9338           0 :                 { 
    9339           0 :                         $$ = makeList1($1); 
    9340             :                 }
    9341           0 :                 ;
    9342             : 
    9343             : opt_returning:  /*empty*/
    9344             :                 {
    9345       10965 :                         $$ = NIL;
    9346             :                 } 
    9347       10965 :                 |       RETURNING target_list
    9348             :                 {
    9349           0 :                         $$ = $2;
    9350             :                 }
    9351           0 :                 ;
    9352             : 
    9353             : opt_bulk:       /*empty*/
    9354           0 :                 {
    9355             :                         $$ = false;
    9356           0 :                 }
    9357             :                 |       BULK COLLECT
    9358         323 :                 {
    9359         323 :                         $$ = true;
    9360         878 :                 }
    9361             :                 ;
    9362             :                         
    9363             : opt_into_list:  INTO ident_list
    9364         886 :                  {
    9365         886 :                         $$ = $2;
    9366         886 :                  }
    9367             :                  | /*empty*/
    9368         886 :                  {
    9369             :                         $$ = NIL;
    9370         771 :                  }
    9371         771 :                  ;              
    9372         771 :                  
    9373             : /*****************************************************************************
    9374         771 :  *              QUERY:
    9375             :  *                              DELETE STATEMENTS *
    9376             :  *****************************************************************************/
    9377             : 
    9378           0 : DeleteStmt: _DELETE del_targ_tab opt_from_clause opt_where_clause opt_returning opt_bulk opt_into_list
    9379             :                 {
    9380           0 :                         DeleteStmt *n = makeNode(DeleteStmt);
    9381             :                         n->relation = (TabNode*)$2;
    9382           0 :                         n->fromClause = $3;                          
    9383             :                         n->whereClause = $4;
    9384           0 :                         n->return_list = $5;
    9385             :                         n->into_list = $7;
    9386             :                         n->is_bulk = $6;
    9387             :                         $$ = (Node *)n;
    9388         611 :                 }  
    9389             :                 |       _DELETE del_targ_tab opt_from_clause WHERE CURRENT OF name opt_returning opt_bulk opt_into_list
    9390         611 :                 {
    9391             :                         DeleteStmt *n = makeNode(DeleteStmt);
    9392           0 :                         n->relation = (TabNode*)$2;
    9393             :                         n->fromClause = $3;  
    9394           0 :                         n->whereClause = NULL;
    9395             :                         n->cursor_name = $7;
    9396             :                         n->return_list = $8;
    9397             :                         n->into_list = $10;
    9398        4338 :                         n->is_bulk = $9;
    9399             :                         $$ = (Node *)n;
    9400        4338 :                 }
    9401             :                 ;
    9402           0 : 
    9403             : del_targ_tab: base_table_ref
    9404           0 :                 {
    9405             :                         $$ = $1;
    9406             :                 }
    9407             :                 |       FROM base_table_ref
    9408           1 :                 {
    9409             :                         $$ = $2;
    9410           1 :                 }
    9411             :                 ;
    9412        4338 :                                                                                                 
    9413             : /*****************************************************************************
    9414        4338 :  *
    9415             :  *              QUERY:
    9416             :  *                              LOCK STATEMENTS
    9417             :  *
    9418             :  *****************************************************************************/
    9419             : 
    9420             : LockStmt: _LOCK opt_table relation_name_list opt_lock opt_wait
    9421             :                 {
    9422             :                         LockStmt *n = makeNode(LockStmt);
    9423         338 : 
    9424         338 :                         n->tab_name_list = $3;
    9425         338 :                         n->mode = $4;
    9426         338 :                         n->wait_ms = $5;
    9427         338 :                         $$ = (Node *)n;
    9428         338 :                         
    9429         338 :                 }
    9430         338 :                 ;
    9431             : 
    9432         338 : opt_lock: _IN SHARE MODE
    9433             :                 {
    9434           0 :                         $$ = S_LOCK;
    9435           0 :                 }
    9436           0 :                 | _IN EXCLUSIVE MODE
    9437           0 :                 {       
    9438           0 :                         $$ = X_LOCK;    
    9439           0 :                 }
    9440           0 :                 | _IN ROW SHARE MODE
    9441           0 :                 {
    9442           0 :                         $$ = IS_LOCK;
    9443             :                 }
    9444           0 :                 | _IN ROW EXCLUSIVE MODE
    9445             :                 {
    9446             :                         $$ = IX_LOCK;
    9447             :                 }
    9448           8 :                 |       /*EMPTY*/
    9449             :                 {
    9450           8 :                         $$ = X_LOCK;
    9451             :                 }
    9452         330 :                 ;
    9453             : 
    9454         330 : /*****************************************************************************
    9455             :  *              QUERY:
    9456             :  *                              UpdateStmt (UPDATE)
    9457             :  *****************************************************************************/
    9458             : UpdateStmt:  UPDATE base_table_refs SET update_target_list
    9459             :                          opt_from_clause opt_where_clause opt_returning 
    9460             :                          opt_bulk opt_into_list
    9461             :                 {
    9462             :                         UpdateStmt *n   = makeNode(UpdateStmt);
    9463             :                         n->targetTables = $2;
    9464             :                         n->targetList   = $4;
    9465           0 :                         n->fromClause   = $5;
    9466             :                         n->whereClause  = $6;
    9467           0 :                         n->return_list  = $7;
    9468           0 :                         n->is_bulk      = $8;
    9469           0 :                         n->into_list    = $9;                        
    9470           0 :                         $$ = (Node *)n; 
    9471             :                 }
    9472             :                 |       UPDATE base_table_refs SET update_target_list
    9473           0 :                         opt_from_clause WHERE CURRENT OF name opt_returning 
    9474             :                         opt_bulk opt_into_list
    9475             :                 {
    9476             :                         UpdateStmt *n   = makeNode(UpdateStmt);
    9477           0 :                         n->targetTables = $2;
    9478             :                         n->targetList   = $4;
    9479           0 :                         n->fromClause   = $5;
    9480             :                         n->cursor_name  = $9;
    9481           0 :                         n->return_list  = $10;
    9482             :                         n->is_bulk      = $11;
    9483           0 :                         n->into_list    = $12;                       
    9484             :                         $$ = (Node *)n;
    9485           0 :                 }
    9486             :                 //why 2015-11-27 add
    9487           0 :                 |   UPDATE base_table_refs SET '(' update_target_list ')'  '=' select_with_parens
    9488             :                     opt_where_clause opt_returning opt_bulk opt_into_list
    9489           0 :                 {
    9490             :                     UpdateStmt *n   = makeNode(UpdateStmt);
    9491           0 :                         n->targetTables = $2;
    9492             :                         n->targetList   = $5;
    9493           0 :                         n->selNode      = $8;
    9494             :                         n->whereClause  = $9;
    9495           0 :                         n->return_list  = $10;
    9496             :                         n->is_bulk      = $11;
    9497             :                         n->into_list    = $12;                       
    9498             :                         $$ = (Node *)n; 
    9499             :                 }
    9500             :                 ;       
    9501             : /*****************************************************************************
    9502             :  *                              MergeIntoStmt (MERGE INTO) ++bysdc@20200910 for mergeinto
    9503             :  *****************************************************************************/
    9504             : MergeIntoStmt:MERGE INTO base_table_ref 
    9505         273 :                                 USING table_ref ON '(' bool_expr ')'
    9506         273 :                                 WHEN MATCHED THEN UPDATE SET update_target_list opt_where_clause opt_delete_where_clause
    9507         273 :                                 WHEN NOT MATCHED THEN INSERT insert_merge opt_where_clause
    9508         273 :                         {
    9509         273 :                                 MergeIntoStmt *n   = makeNode(MergeIntoStmt);
    9510         273 :                                 n->mergeType = 3;
    9511         273 :                                 n->to_relation = (TabNode*) $3;
    9512         273 :                                 //build select node
    9513         273 :                                 JoinNode *jnode         = makeNode(JoinNode);
    9514             :                                 jnode->jointype              = JOIN_RIGHT;
    9515         273 :                                 jnode->isNatural     = false;
    9516             :                                 jnode->isMergeinto   = true;
    9517             :                                 
    9518             :                                 jnode->larg = $3;
    9519           0 :                                 jnode->rarg = $5;
    9520           0 :                                 jnode->quals = $8;
    9521           0 :                                 n->selectStmt = makeSelectStmt4JoinNode(jnode);
    9522           0 :                                 
    9523           0 :                                 //update clause
    9524           0 :                                 UpdateStmt *u   = makeNode(UpdateStmt);
    9525           0 :                                 u->targetTables      = makeList1($3);
    9526           0 :                                 u->targetList   = $15;
    9527           0 :                                 n->updateStmt        = u;
    9528             :                                 //insert clause
    9529           0 :                                 ((InsertStmt*)$23)->relation = (TabNode*) $3;
    9530             :                                 n->insertStmt        = $23;//
    9531             :                                 n->updateWhereClause  = $16;
    9532             :                                 n->updateDeleteClause  = $17;
    9533           0 :                                 n->insertWhereClause  = $24;
    9534           0 :                                 $$ = (Node *)n; 
    9535           0 :                         }
    9536           0 :                         | MERGE INTO base_table_ref 
    9537           0 :                                 USING table_ref ON '(' bool_expr ')'
    9538           0 :                                 WHEN NOT MATCHED THEN INSERT insert_merge opt_where_clause
    9539           0 :                                 WHEN MATCHED THEN UPDATE SET update_target_list opt_where_clause opt_delete_where_clause
    9540           0 :                         {
    9541           0 :                                 MergeIntoStmt *n   = makeNode(MergeIntoStmt);
    9542             :                                 n->mergeType = 3;
    9543           0 :                                 n->to_relation = (TabNode*) $3;
    9544             :                                 //
    9545             :                                 JoinNode *jnode         = makeNode(JoinNode);
    9546             :                                 jnode->jointype              = JOIN_RIGHT;
    9547             :                                 jnode->isNatural     = false;
    9548             :                                 jnode->isMergeinto   = true;
    9549             :                                 jnode->larg = $3;
    9550             :                                 jnode->rarg = $5;
    9551             :                                 jnode->quals = $8;
    9552           0 :                                 n->selectStmt = makeSelectStmt4JoinNode(jnode);
    9553           0 :                                 
    9554           0 :                                 //
    9555             :                                 UpdateStmt *u   = makeNode(UpdateStmt);
    9556           0 :                                 u->targetTables      = makeList1($3);
    9557           0 :                                 u->targetList   = $22;
    9558           0 :                                 n->updateStmt        = u;
    9559           0 :                                 //
    9560             :                                 ((InsertStmt*)$15)->relation = (TabNode*) $3;
    9561           0 :                                 n->insertStmt        = $15;
    9562           0 :                                 n->insertWhereClause  = $16;
    9563           0 :                                 n->updateWhereClause  = $23;
    9564           0 :                                 n->updateDeleteClause  = $24;
    9565             :                                 $$ = (Node *)n; 
    9566             :                         }
    9567           0 :                         |       MERGE INTO base_table_ref 
    9568           0 :                                 USING table_ref ON '(' bool_expr ')'
    9569           0 :                                 WHEN MATCHED THEN UPDATE SET update_target_list opt_where_clause opt_delete_where_clause
    9570           0 :                         {
    9571             :                                 MergeIntoStmt *n   = makeNode(MergeIntoStmt);
    9572           0 :                                 n->mergeType = 1;
    9573           0 :                                 n->to_relation = (TabNode*) $3;
    9574           0 :                                 
    9575           0 :                                 //
    9576           0 :                                 JoinNode *m             = makeNode(JoinNode);
    9577           0 :                                 m->jointype          = JOIN_INNER;
    9578             :                                 m->isNatural = false;
    9579           0 :                                 m->isMergeinto       = true;
    9580             :                                 m->larg = $3;
    9581             :                                 m->rarg = $5;
    9582             :                                 m->quals = $8;
    9583             :                                 n->selectStmt = makeSelectStmt4JoinNode(m);
    9584           0 :                                 
    9585           0 :                                 //
    9586           0 :                                 UpdateStmt *u   = makeNode(UpdateStmt);
    9587             :                                 u->targetTables      = makeList1($3);
    9588           0 :                                 u->targetList   = $15;
    9589           0 :                                 n->updateStmt        = u;
    9590           0 :                                 n->updateWhereClause  = $16;
    9591           0 :                                 n->updateDeleteClause  = $17;
    9592           0 :                                 $$ = (Node *)n; 
    9593           0 :                         }
    9594           0 :                         |       MERGE INTO base_table_ref 
    9595           0 :                                 USING table_ref ON '(' bool_expr ')'
    9596             :                                 WHEN NOT MATCHED THEN INSERT insert_merge opt_where_clause
    9597             :                         {
    9598           0 :                                 MergeIntoStmt *n   = makeNode(MergeIntoStmt);
    9599           0 :                                 n->mergeType = 2;
    9600           0 :                                 n->to_relation = (TabNode*) $3;
    9601           0 :                                 
    9602             :                                 //
    9603           0 :                                 JoinNode *m             = makeNode(JoinNode);
    9604           0 :                                 m->jointype          = JOIN_RIGHT;
    9605           0 :                                 m->isNatural = false;
    9606           0 :                                 m->isMergeinto       = true;
    9607           0 :                                 m->larg = $3;
    9608           0 :                                 m->rarg = $5;
    9609             :                                 m->quals = $8;
    9610           0 :                                 n->selectStmt = makeSelectStmt4JoinNode(m);
    9611             :                                 
    9612             :                                 //
    9613             :                                 ((InsertStmt*)$15)->relation = (TabNode*) $3;
    9614           0 :                                 n->insertStmt        = $15;//
    9615           0 :                                 n->insertWhereClause  = $16;
    9616           0 :                                 $$ = (Node *)n; 
    9617             :                         }
    9618             :                         ;
    9619           0 : opt_delete_where_clause:  _DELETE WHERE bool_expr                       { $$ = $3; }
    9620           0 :                 | /*EMPTY*/                                     { $$ = NULL;  /* no qualifiers */ }
    9621           0 :                 ;
    9622           0 : /*****************************************************************************
    9623           0 :  *
    9624           0 :  *              QUERY:
    9625           0 :  *                              CURSOR STATEMENTS
    9626           0 :  *
    9627             :  *****************************************************************************/
    9628             : CursorStmt: 
    9629           0 :                 DECLARE  ColId  func_args  CURSOR  FOR  SelectStmt  parallel_opt  opt_wait
    9630           0 :                 {
    9631           0 :                         CursorDef *p_def = makeNode(CursorDef);
    9632           0 :                         p_def->var_name = $2;
    9633           0 :                         p_def->args = $3;
    9634           0 :                         p_def->cur_type = CUR_INSENSITIVE;
    9635           0 :                         p_def->define = (SelectStmt*)$6;
    9636             :                         ((SelectStmt*)$6)->parallel = $7;
    9637           0 :                         ((SelectStmt*)$6)->wait_ms = $8;
    9638             :                         $$ = (Node*)p_def;
    9639             :                         SetNodePos($$);
    9640             :                 }
    9641           0 :                 | DECLARE  ColId func_args  CURSOR  FOR ColId  parallel_opt  opt_wait
    9642           0 :                 {
    9643           0 :                         CursorDef *p_def = makeNode(CursorDef);
    9644             :                         p_def->var_name = $2;
    9645             :                         p_def->cur_type = CUR_INSENSITIVE;
    9646           0 :                         p_def->stmt_name = $6;
    9647           0 :                         $$ = (Node*)p_def;
    9648           0 :                         SetNodePos($$);
    9649           0 :                 }       
    9650           0 :                 ;       
    9651           0 : 
    9652           0 : /*****************************************************************************
    9653           0 :  *
    9654             :  *              QUERY:
    9655             :  *                              SELECT STATEMENTS
    9656           0 :  *
    9657           0 :  *****************************************************************************/
    9658           0 : 
    9659           0 : /* A complete SELECT statement looks like this.
    9660             :  *
    9661           0 :  * The rule returns either a single SelectStmt node or a tree of them,
    9662           0 :  * representing a set-operation tree.
    9663           0 :  *
    9664           0 :  * There is an ambiguity when a sub-SELECT is within an b_expr and there
    9665             :  * are excess parentheses: do the parentheses belong to the sub-SELECT or
    9666             :  * to the surrounding b_expr?  We don't really care, but yacc wants to know.
    9667             :  * To resolve the ambiguity, we are careful to define the grammar so that
    9668             :  * the decision is staved off as long as possible: as long as we can keep
    9669             :  * absorbing parentheses into the sub-SELECT, we will do so, and only when
    9670             :  * it's no longer possible to do that will we decide that parens belong to
    9671             :  * the expression.  For example, in "SELECT (((SELECT 2)) + 3)" the extra
    9672             :  * parentheses are treated as part of the sub-select.  The necessity of doing
    9673             :  * it that way is shown by "SELECT (((SELECT 2)) UNION SELECT 2)".  Had we
    9674           0 :  * parsed "((SELECT 2))" as an b_expr, it'd be too late to go back to the
    9675           0 :  * SELECT viewpoint when we see the UNION.
    9676           0 :  *
    9677           0 :  * This approach is implemented by defining a nonterminal select_with_parens,
    9678           0 :  * which represents a SELECT with at least one outer layer of parentheses,
    9679           0 :  * and being careful to use select_with_parens, never '(' SelectStmt ')',
    9680           0 :  * in the expression grammar.  We will then have shift-reduce conflicts
    9681           0 :  * which we can resolve in favor of always treating '(' <select> ')' as
    9682           0 :  * a select_with_parens.  To resolve the conflicts, the productions that
    9683             :  * conflict with the select_with_parens productions are manually given
    9684           0 :  * precedences lower than the precedence of ')', thereby ensuring that we
    9685             :  * shift ')' (and then reduce to select_with_parens) rather than trying to
    9686           0 :  * reduce the inner <select> nonterminal to something else.  We use UMINUS
    9687           0 :  * precedence for this, which is a fairly arbitrary choice.
    9688           0 :  *
    9689           0 :  * To be able to define select_with_parens itself without ambiguity, we need
    9690           0 :  * a nonterminal select_no_parens that represents a SELECT structure with no
    9691           0 :  * outermost parentheses.  This is a little bit tedious, but it works.
    9692             :  *
    9693           0 :  * In non-expression contexts, we use SelectStmt which can represent a SELECT
    9694             :  * with or without outer parentheses.
    9695             : */
    9696             : 
    9697             : SelectStmt: select_no_parens                    %prec UMINUS
    9698             :                 |       select_with_parens              %prec UMINUS
    9699             :                 |   with_clauses select_no_parens
    9700             :                 {
    9701             :                         ((SelectStmt*)$2)->with_list = $1;
    9702             :                         $$ = $2; 
    9703             :                 }
    9704             :                 ;
    9705             : 
    9706             : with_clauses: WITH with_name AS select_with_parens
    9707             :                 {
    9708             :                         QryNode *n = makeNode(QryNode);
    9709             :                         ((QryNode*)n)->subquery = $4;
    9710             :                         ((QryNode*)n)->name =(Attr*) $2;
    9711             :                         $$ = makeList1(n);
    9712             :                 }
    9713             :                 | with_clauses  ',' with_name AS select_with_parens
    9714             :                 {
    9715             :                         QryNode *n = makeNode(QryNode);
    9716             :                         ((QryNode*)n)->subquery = $5;
    9717             :                         ((QryNode*)n)->name =(Attr*) $3;
    9718             :                         $$ =lappend($$,n);
    9719             :                 }
    9720             :                 /*支持with function bysdc@20210425*/
    9721             :                 | WITH ProcDef ';'
    9722             :                 {
    9723             :                         CreProcedureStmt *p_stmt = makeNode(CreProcedureStmt);
    9724             :                         p_stmt->cre_mode = 1;
    9725             :                         p_stmt->language = "PLSQL";
    9726             :                         p_stmt->define = (ProcDef*)$2;
    9727             :                         SetNodePos(p_stmt);
    9728             :                         $$ = makeList1(p_stmt);
    9729             :                 }
    9730             :                 ;
    9731             : 
    9732             : with_name:  ColId '(' name_list ')'
    9733             :                 {
    9734             :                         $$ = (Node*)makeNode(Attr);
    9735             :                         ((Attr*)$$)->relname = $1;
    9736             :                         ((Attr*)$$)->fields = $3;
    9737             :                 }
    9738             :                 | ColId
    9739             :                 {
    9740             :                         $$ = (Node*)makeNode(Attr);
    9741             :                         ((Attr*)$$)->relname = $1;
    9742             :                 };
    9743             :                                 
    9744           0 : select_with_parens: 
    9745           0 :                 '(' select_no_parens  parallel_opt opt_wait ')'
    9746             :                 {
    9747           0 :                         $$ = $2;
    9748             :                         ((SelectStmt*)$2)->parallel = $3;
    9749             :                         ((SelectStmt*)$2)->wait_ms = $4;
    9750             :                         SetNodePos($$);
    9751           0 :                 }
    9752           0 :                 | '(' select_with_parens ')'
    9753           0 :                 {
    9754           0 :                         $$ = $2;
    9755             :                         SetNodePos($$);
    9756           0 :                 }
    9757             :                 //++bywsy@20210225 bug3561
    9758           0 :                 | '(' with_clauses select_no_parens ')'
    9759           0 :                 {
    9760           0 :                         ((SelectStmt*)$3)->with_list = $2;
    9761           0 :                         $$ = $3;
    9762             :                         SetNodePos($$);
    9763           0 :                 }
    9764             :                 ;
    9765             : 
    9766           0 : select_no_parens: simple_select
    9767           0 :                         {
    9768           0 :                                 $$ = $1;
    9769           0 :                         }
    9770           0 :                         /* why 2015-12-17 modify old:
    9771           0 :                         | select_clause sort_clause opt_nulls_order opt_for_update_clause opt_select_limit
    9772             :                         {
    9773           0 :                                 insertSelectOptions((SelectStmt *)$1,$2,$4,(Node*)nth(0,$5),(Node*)nth(1,$5));
    9774             :                                 ((SelectStmt*)$1)->nulls_first = $3;
    9775             :                                 $$ = $1;
    9776             :                                 SetNodePos($$);
    9777           0 :                         }
    9778           0 :                         */
    9779           0 :                         | select_clause sort_clause opt_for_update_clause opt_select_limit
    9780             :                         {
    9781           0 :                                 //why 2016-04-11 modify old:insertSelectOptions((SelectStmt *)$1,$2,$3,(Node*)nth(0,$4),(Node*)nth(1,$4));
    9782             :                                 insertSelectOptions((SelectStmt *)$1,$2,$3,((LimitExpr*)$4)->limitOffset,((LimitExpr*)$4)->limitCount,((LimitExpr*)$4)->is_comma);
    9783           0 :                                 $$ = $1;
    9784           0 :                                 SetNodePos($$);
    9785             :                         }
    9786           0 :                         | select_clause for_update_clause opt_select_limit
    9787             :                         {
    9788             :                                 //why 2016-04-11 modify old:insertSelectOptions((SelectStmt *) $1,NIL,$2,(Node*)nth(0,$3),(Node*)nth(1,$3));
    9789         580 :                                 insertSelectOptions((SelectStmt *)$1,NIL,$2,((LimitExpr*)$3)->limitOffset,((LimitExpr*)$3)->limitCount,((LimitExpr*)$3)->is_comma);
    9790         580 :                                 $$ = $1;
    9791         580 :                                 SetNodePos($$);
    9792         580 :                                 
    9793             :                         }
    9794         580 :                         | select_clause select_limit
    9795             :                         {
    9796          25 :                                 //why 2016-04-11 modify old:insertSelectOptions((SelectStmt *)$1,NIL,NIL,(Node*)nth(0,$2),(Node*)nth(1,$2));
    9797          25 :                                 insertSelectOptions((SelectStmt *)$1,NIL,NIL,((LimitExpr*)$2)->limitOffset,((LimitExpr*)$2)->limitCount,((LimitExpr*)$2)->is_comma);
    9798             :                                 $$ = $1;
    9799          25 :                                 SetNodePos($$);
    9800             :                                 
    9801             :                         }               
    9802           0 :                         | select_clause FOR SNAPSHOT OF ICONST AFTER ICONST START AT ICONST opt_select_limit
    9803           0 :                         {
    9804           0 :                                 ((SelectStmt*)$1)->for_snapshot = true;
    9805             :                                 ((SelectStmt*)$1)->remote_db_id = $5;
    9806           0 :                                 ((SelectStmt*)$1)->last_trans_id = $7;
    9807             :                                 ((SelectStmt*)$1)->start_rowpos = $10;
    9808             :                                 //why 2016-04-11 modify old:insertSelectOptions((SelectStmt *)$1,NIL,NIL,(Node*)nth(0,$11),(Node*)nth(1, $11));
    9809             :                                 insertSelectOptions((SelectStmt *)$1,NIL,NIL,((LimitExpr*)$11)->limitOffset,((LimitExpr*)$11)->limitCount,((LimitExpr*)$11)->is_comma);
    9810        3537 :                                 $$ = $1;
    9811             :                                 SetNodePos($$);
    9812        3537 :                         }
    9813             :                         ;
    9814             : 
    9815             : select_clause: simple_select
    9816             :                 | select_with_parens
    9817             :                 ;
    9818             : 
    9819             : /*
    9820             :  * This rule parses SELECT statements that can appear within set operations,
    9821             :  * including UNION, INTERSECT and EXCEPT.  '(' and ')' can be used to specify
    9822             :  * the ordering of the set operations.  Without '(' and ')' we want the
    9823             :  * operations to be ordered per the precedence specs at the head of this file.
    9824         166 :  *
    9825         166 :  * As with select_no_parens, simple_select cannot have outer parentheses,
    9826         166 :  * but can have parenthesized subclauses.
    9827             :  *
    9828         166 :  * Note that sort clauses cannot be included at this level --- SQL92 requires
    9829             :  *              SELECT foo UNION SELECT bar ORDER BY baz
    9830             :  * to be parsed as
    9831           0 :  *              (SELECT foo UNION SELECT bar) ORDER BY baz
    9832           0 :  * not
    9833           0 :  *              SELECT foo UNION (SELECT bar ORDER BY baz)
    9834             :  * Likewise FOR UPDATE and LIMIT.  Therefore, those clauses are described
    9835             :  * as part of the select_no_parens production, not simple_select.
    9836           0 :  * This does not limit functionality, because you can reintroduce sort and
    9837             :  * limit clauses inside parentheses.
    9838             :  *
    9839           0 :  * NOTE: only the leftmost component SelectStmt should have INTO.
    9840           0 :  * However, this is not checked by the grammar; parse analysis must check it.
    9841           0 : */
    9842             : simple_select:SELECT opt_hint opt_top opt_distinct target_list opt_bulk opt_into_list
    9843             :                            opt_from_clause  opt_where_clause opt_connect_by
    9844           0 :                            opt_group_clause opt_having_clause
    9845             :                 {
    9846           0 :                         SelectStmt *n = makeNode(SelectStmt);
    9847           0 :                         n->hint_text = $2;//++bysdc@20200411
    9848           0 :                         n->limitCount = $3;
    9849           0 :                         n->is_distinct = $4;
    9850             :                         n->targetList = $5;
    9851           0 :                         n->is_bulk = $6;
    9852           0 :                         n->intoList = $7;
    9853           0 :                         n->fromClause = $8;
    9854             :                         n->whereClause = $9;
    9855           0 :                         if($10!=NIL)
    9856             :                         {
    9857             :                                 n->connect_by = ((ConnectBy*)$10)->connect_by;
    9858             :                                 n->start_with = ((ConnectBy*)$10)->start_with;
    9859             :                                 n->no_cycle = ((ConnectBy*)$10)->no_cycle;
    9860             :                                 n->keep_clause  = ((ConnectBy*)$10)->keep_clause;
    9861             :                                 n->start_with_first = ((ConnectBy*)$10)->start_with_first;//fix bug3517 add lwb@20200830
    9862             :                         }       
    9863             :                         n->groupClause = $11;
    9864             :                         n->havingClause = $12;
    9865             :                         $$ = (Node *)n;
    9866             :                         SetNodePos($$);                         
    9867             :                 }
    9868             :                 | select_clause UNION opt_all opt_corresponding select_clause
    9869             :                 {       
    9870             :                         $$ = makeSetOp(SETOP_UNION, $3, $1, $5,$4);
    9871             :                         SetNodePos($$);                         
    9872             :                 }
    9873             :                 | select_clause INTERSECT opt_all opt_corresponding select_clause
    9874             :                 {
    9875             :                         $$ = makeSetOp(SETOP_INTERSECT, $3, $1, $5,$4);
    9876             :                         SetNodePos($$);                         
    9877             :                 }
    9878             :                 | select_clause EXCEPT opt_all opt_corresponding select_clause
    9879             :                 {
    9880             :                         $$ = makeSetOp(SETOP_EXCEPT, $3, $1, $5,$4);
    9881             :                         SetNodePos($$);                         
    9882             :                 }
    9883             :                 | select_clause MINUS opt_all opt_corresponding select_clause
    9884             :                 {
    9885             :                         $$ = makeSetOp(SETOP_EXCEPT, $3, $1, $5,$4);
    9886             :                         SetNodePos($$);                         
    9887             :                 }       
    9888        3726 :                 ; 
    9889        3726 :                 
    9890        3726 : opt_connect_by: /*empty*/
    9891        3726 :                 {
    9892        3726 :                         $$ = NIL;
    9893        3726 :                 }
    9894        3726 :                 | connect_by
    9895        3726 :                 {
    9896        3726 :                         $$ = $1;
    9897        3726 :                 }
    9898             :                 ; 
    9899           0 : 
    9900           0 : connect_by:     
    9901           0 :                    CONNECT  BY  bool_expr START WITH  bool_expr  opt_keep_clause
    9902           0 :                 {
    9903           0 :                         ConnectBy *n = New(ConnectBy);
    9904             :                         n->connect_by = $3;
    9905        3726 :                         n->start_with = $6;
    9906        3726 :                         n->keep_clause = $7;
    9907        3726 :                         n->start_with_first = false;//fix bug3517 add lwb@20200830
    9908        3726 :                         $$ = (void*)n;
    9909             :                 }
    9910        3726 :                 |  CONNECT  BY  NOCYCLE bool_expr START WITH  bool_expr  opt_keep_clause
    9911             :                 {
    9912          25 :                         ConnectBy *n = New(ConnectBy);
    9913          25 :                         n->connect_by = $4;
    9914             :                         n->start_with = $7;
    9915          25 :                         n->keep_clause = $8;
    9916             :                         n->no_cycle = true;
    9917           4 :                         n->start_with_first = false;//fix bug3517 add lwb@20200830
    9918           4 :                         $$ = (void*)n;
    9919             :                 }
    9920           4 :                 |   START WITH  bool_expr  CONNECT  BY  bool_expr opt_keep_clause
    9921             :                 {
    9922           3 :                         ConnectBy *n = New(ConnectBy);
    9923           3 :                         n->connect_by = $6;
    9924             :                         n->start_with = $3;
    9925           3 :                         n->keep_clause = $7;
    9926             :                         n->start_with_first = true;//fix bug3517 add lwb@20200830
    9927           0 :                         $$ = (void*)n;  
    9928           0 :                 }
    9929             :                 |   START WITH  bool_expr  CONNECT  BY NOCYCLE bool_expr opt_keep_clause
    9930           0 :                 {
    9931             :                         ConnectBy *n = New(ConnectBy);
    9932             :                         n->connect_by = $7;
    9933             :                         n->start_with = $3;
    9934        3726 :                         n->keep_clause = $8;
    9935             :                         n->no_cycle = true;
    9936        3726 :                         n->start_with_first = true;//fix bug3517 add lwb@20200830
    9937             :                         $$ = (void*)n;  
    9938           0 :                 }
    9939             :                 |  CONNECT  BY  bool_expr opt_keep_clause
    9940           0 :                 {
    9941             :                         ConnectBy *n = New(ConnectBy);
    9942             :                         n->connect_by = $3;
    9943             :                         n->keep_clause = $4;
    9944             :                         n->start_with_first = false;//fix bug3517 add lwb@20200830
    9945           0 :                         $$ = (void*)n;  
    9946           0 :                 }
    9947           0 :                 |  CONNECT  BY  NOCYCLE bool_expr opt_keep_clause
    9948           0 :                 {
    9949           0 :                         ConnectBy *n = New(ConnectBy);
    9950           0 :                         n->connect_by = $4;
    9951             :                         n->keep_clause = $5;
    9952           0 :                         n->no_cycle = true;
    9953             :                         n->start_with_first = false;//fix bug3517 add lwb@20200830
    9954           0 :                         $$ = (void*)n;  
    9955           0 :                 }
    9956           0 :                 ;               
    9957           0 : opt_keep_clause: /*empty*/
    9958           0 :                 {
    9959           0 :                         $$ = NULL;
    9960           0 :                 }
    9961             :                 |  KEEP  bool_expr
    9962           0 :                 {
    9963             :                         $$ = $2;
    9964           0 :                 }
    9965           0 :                 ;
    9966           0 :                 
    9967           0 : opt_corresponding:
    9968           0 :                 {
    9969           0 :                         $$ = NIL;
    9970             :                 }
    9971           0 :                 | CORRESPONDING
    9972             :                 {
    9973           0 :                         $$ = makeList1(NULL);
    9974           0 :                 }
    9975           0 :                 | CORRESPONDING BY name_list
    9976           0 :                 {
    9977           0 :                         $$ = $3;
    9978           0 :                 }
    9979           0 :                 ;
    9980             : opt_top:        /*empty*/
    9981           0 :                 {
    9982             :                         $$ = NULL;
    9983           0 :                 }
    9984           0 :                 |       TOP  ICONST
    9985           0 :                 {
    9986           0 :                         $$ = (Node*)makeInteger($2);
    9987           0 :                 }
    9988             :                 ;
    9989           0 : //++bysdc@20200411
    9990             : opt_hint:       /*empty*/
    9991           0 :                 {
    9992           0 :                         $$ = NULL;
    9993           0 :                 }
    9994           0 :                 |       _HINT_TEXT
    9995           0 :                 {
    9996           0 :                         $$ = $1;
    9997             :                 }
    9998           0 :                 ;
    9999             :                 
   10000             : opt_table:  TABLE                               { $$ = true; }
   10001           0 :                 | /*EMPTY*/                             { $$ = false; }
   10002             :                 ;
   10003           0 : 
   10004             : opt_all:  ALL                                   { $$ = true; }
   10005           0 :                 | DISTINCT                              { $$ = true;}
   10006             :                 | /*EMPTY*/                             { $$ = false; }
   10007           0 :                 ;       
   10008             : 
   10009             : /* We use (NIL) as a placeholder to indicate that all target expressions
   10010             :  * should be placed in the DISTINCT list during parsetree analysis.
   10011          30 : */
   10012             : opt_distinct:  DISTINCT                 { $$ = true; }
   10013          30 :                 |          ALL                          { $$ = false; }
   10014             :                 |          /*EMPTY*/            { $$ = false; }
   10015           2 :                 ;
   10016             :  
   10017           2 : sort_clause:  ORDER BY sortby_list                      
   10018             :                 { 
   10019           0 :                         $$ = $3; 
   10020             :                 }
   10021           0 :                 | ORDER SIBLINGS BY sortby_list 
   10022             :                 { 
   10023             :                         Ident  *p_ident = makeNode(Ident);
   10024        3727 :                         p_ident->name = "CONNECT_BY_SIBLINGS";
   10025             :                         SortBy *p_sort = makeNode(SortBy);
   10026        3727 :                         p_sort->node = (Node*)p_ident;
   10027             :                         p_sort->useOp = (char*)"<"; 
   10028           0 :                         List *l1 = makeList1(p_sort);
   10029             :                         $$ = lconc(l1,$4);
   10030           0 :                 }
   10031             :                 ;
   10032             : 
   10033             : sortby_list:  sortby                            { $$ = makeList1($1); }
   10034        3727 :                 | sortby_list ',' sortby        { $$ = lappend($1, $3); }
   10035             :                 ;
   10036        3727 : 
   10037             : // why 2015-12-17 modify compatible oracle 
   10038           0 : /*
   10039             : sortby: b_expr OptUseOp
   10040           0 :                 {
   10041             :                         $$ = (Node*)makeNode(SortBy);
   10042           0 :                         ((SortBy*)$$)->node = $1;
   10043           0 :                         ((SortBy*)$$)->useOp = $2;
   10044           0 :                 }
   10045             :                 ;
   10046          10 :                 */
   10047          10 : 
   10048           0 : sortby: b_expr OptUseOp opt_nulls_order
   10049          22 :                 {
   10050             :                         $$ = (Node*)makeNode(SortBy);
   10051             :                         ((SortBy*)$$)->node = $1;
   10052             :                         ((SortBy*)$$)->useOp = $2;
   10053             :                         ((SortBy*)$$)->nulls_first = $3;
   10054          23 :                 }
   10055          23 :                 ;       
   10056           4 : 
   10057        3700 : OptUseOp:  USING ROp                            { $$ = $2; }
   10058             :                 |  _ASC                                         { $$ = (char*)"<"; }
   10059             :                 |  DESC                                         { $$ = (char*)">"; }
   10060             :                 | /*EMPTY*/                                     { $$ = (char*)"<"; }
   10061         166 :                 ;
   10062             :                 
   10063         166 : opt_nulls_order: NULLS FIRST    {$$ = NULLS_FIRST;}
   10064             :                                 | NULLS LAST    {$$ = NULLS_LAST;}
   10065           0 :                                 |/*empty*/              {$$ = NULLS_DEFAULT;}
   10066           0 :                 ;
   10067           0 : 
   10068           0 :  /*why 2016-04-11 modify old:
   10069           0 : select_limit:       
   10070           0 :                   LIMIT select_offset_value ',' select_limit_value 
   10071           0 :                         { $$ = makeList2($2, $4); }
   10072             :                 | LIMIT select_limit_value OFFSET select_offset_value  
   10073           0 :                         { $$ = makeList2($4, $2); }
   10074             :                 | LIMIT select_limit_value
   10075         166 :                         { $$ = makeList2(NULL, $2); }
   10076         166 :                 */
   10077         125 : select_limit:   
   10078             :                 LIMIT select_offset_value ',' select_limit_value 
   10079             :                 { 
   10080             :                     LimitExpr *n = makeNode(LimitExpr);
   10081             :                     n->limitCount  = $4;
   10082             :                     n->limitOffset = $2;
   10083             :                     n->is_comma    = true;
   10084             :                         $$ = (Node*)n; 
   10085             :                 }
   10086             :                 | LIMIT select_limit_value OFFSET select_offset_value  
   10087             :                 {
   10088             :                     LimitExpr *n = makeNode(LimitExpr);
   10089             :                     n->limitCount  = $2;
   10090             :                     n->limitOffset = $4;
   10091             :                     n->is_comma    = false;
   10092         291 :                         $$ = (Node*)n; 
   10093         291 :                 }
   10094         291 :                 | LIMIT select_limit_value
   10095         291 :                 {
   10096             :                     LimitExpr *n = makeNode(LimitExpr);
   10097         291 :                     n->limitCount  = $2;                
   10098             :                     n->is_comma    = false;
   10099           0 :                         $$ = (Node*)n; 
   10100           0 :                 }
   10101           8 :                 ;
   10102          27 : 
   10103         256 : opt_select_limit:       select_limit
   10104             :                 { $$ = $1; }
   10105           0 :                 | /* EMPTY */                                   
   10106           0 :                 { 
   10107           0 :                   //why 2016-04-11 modify old:$$ = makeList2(NULL,NULL);
   10108         291 :                   $$ = (Node*)makeNode(LimitExpr);
   10109             :                 }
   10110             :                 ;
   10111             : 
   10112             : select_limit_value:  ICONST
   10113             :                 {
   10114             :                         if($1 <0)
   10115             :                                 $1 = 0;
   10116             :                         $$ = (Node*)makeInteger($1);
   10117             :                 }
   10118             :                 | ALL
   10119             :                 {
   10120             :                         /* LIMIT ALL is represented as a NULL constant */
   10121             :                         $$ = (Node*)makeInteger(0);
   10122           0 :                 }
   10123           0 :                  /*why 2016-04-11 add*/
   10124           0 :                 |Param
   10125           0 :                 {
   10126           0 :                   $$ = $1;
   10127             :                 }
   10128           0 :                 | ':' ICONST
   10129             :                 {
   10130           0 :                         Ident *n = makeNode(Ident);
   10131           0 :                         n->param_no = $2;
   10132           0 :                         n->ident_t  = IDENT_PARAM;
   10133           0 :                         $$ = (Node *)n; 
   10134           0 :                         SetNodePos($$);
   10135             :                 }
   10136           0 :                 //end   
   10137             :                 ;
   10138           0 : 
   10139           0 : select_offset_value:    ICONST
   10140           0 :                 {
   10141           0 :                         if ($1 < 0)
   10142             :                                 $1 = 0;
   10143           0 :                         $$ = (Node*)makeInteger($1);
   10144             :                 }
   10145             :                 /*why 2016-04-11 add*/
   10146           0 :                 |Param
   10147           0 :                 {
   10148             :                   $$ = $1;
   10149             :                 }
   10150         166 :                 | ':' ICONST
   10151             :                 {
   10152         166 :                         Ident *n = makeNode(Ident);
   10153             :                         n->param_no = $2;
   10154             :                         n->ident_t  = IDENT_PARAM;
   10155             :                         $$ = (Node *)n; 
   10156           0 :                         SetNodePos($$);
   10157           0 :                 }
   10158           0 :                 //end   
   10159             :                 ;
   10160           0 : 
   10161             : relation_name_list:  name_space
   10162             :                 {
   10163           0 :                         $$ = makeList1($1);
   10164             :                 }
   10165           0 :                 |       relation_name_list ',' name_space
   10166             :                 {
   10167             :                         $$ = lappend($1,$3);
   10168           0 :                 }       
   10169             :                 ;
   10170           0 : 
   10171             : name_list:  name
   10172           0 :                         {       $$ = makeList1($1); }
   10173           0 :                 | name_list ',' name
   10174           0 :                         {       $$ = lappend($1, $3); }
   10175           0 :                 ;
   10176           0 : 
   10177             : opt_group_clause: _GROUP BY group_items
   10178           0 :                 {
   10179             :                         $$ = $3;
   10180             :                 }
   10181             :                 | /*EMPTY*/{ $$ = NIL; }
   10182             :                 ;
   10183           0 : 
   10184           0 : group_items: group_item
   10185           0 :                 {
   10186             :                         $$ = makeList1($1);
   10187           0 :                 }
   10188             :                 |       group_items ',' group_item
   10189             :                 {
   10190           0 :                         $$ = lappend($1,$3);
   10191             :                 }
   10192           0 :                 ;
   10193             : 
   10194           0 : group_item:     b_expr
   10195           0 :                 {
   10196           0 :                         $$ = (Node*)$1;
   10197           0 :                 }
   10198           0 :                 | ROLLUP '(' group_items ')'
   10199             :                 {
   10200           0 :                         GroupingSet *grp_item = makeNode(GroupingSet);
   10201             :                         grp_item->grp_type = 1;
   10202             :                         grp_item->members = $3;
   10203             :                         $$ = (Node*)grp_item;
   10204             :                 }
   10205           0 :                 | CUBE '(' group_items ')'
   10206             :                 {
   10207           0 :                         GroupingSet *grp_item = makeNode(GroupingSet);
   10208             :                         grp_item->grp_type = 2;
   10209           0 :                         grp_item->members = $3;
   10210             :                         $$ = (Node*)grp_item;
   10211           0 :                 }
   10212             :                 | GROUPING SETS '(' group_items ')'
   10213             :                 {
   10214          52 :                         GroupingSet *grp_item = makeNode(GroupingSet);
   10215          52 :                         grp_item->grp_type = 3;
   10216          44 :                         grp_item->members = $4;
   10217          44 :                         $$ = (Node*)grp_item;
   10218             :                 }
   10219             :                 | '(' multi_group_item ')'
   10220             :                 {
   10221          92 :                         GroupingSet *grp_item = makeNode(GroupingSet);
   10222             :                         grp_item->grp_type = 4;
   10223          92 :                         grp_item->members = $2;
   10224        3634 :                         $$ = (Node*)grp_item;
   10225             :                 }
   10226             :                 | '(' ')'
   10227             :                 {
   10228          92 :                         GroupingSet *grp_item = makeNode(GroupingSet);
   10229             :                         grp_item->grp_type = 4;
   10230          92 :                         grp_item->members = NIL;
   10231             :                         $$ = (Node*)grp_item;
   10232          52 :                 }
   10233             :                 ;               
   10234          52 : 
   10235             : multi_group_item: group_item ','  group_item
   10236             :                 {
   10237             :                         $$ = makeList2($1,$3);
   10238         144 :                 }
   10239             :                 | multi_group_item ',' group_item
   10240         144 :                 {
   10241             :                         $$ = lappend($1,$3);
   10242           0 :                 }
   10243           0 :                 ;
   10244           0 : 
   10245           0 : opt_having_clause:  HAVING bool_expr
   10246             :                 {
   10247           0 :                         $$ = $2;
   10248             :                 }
   10249           0 :                 | /*EMPTY*/                             { $$ = NULL; }
   10250           0 :                 ;
   10251           0 : 
   10252           0 : opt_for_update_clause:  for_update_clause       { $$ = $1; }
   10253             :                 | /* EMPTY */                           { $$ = NULL; }
   10254           0 :                 ;
   10255             : 
   10256           0 : for_update_clause:  FOR UPDATE OF update_list   { $$ = $4; }
   10257           0 :                 | FOR READ ONLY                                                 { $$ = NULL; }
   10258           0 :                 | FOR UPDATE                                                    { $$ = makeList1(NULL);}
   10259           0 :                 ;
   10260             : 
   10261           0 : update_list:  name_space                                { $$ = makeList1($1); }
   10262             :                 | update_list ',' name_space    { $$ = lappend($1,$3); }
   10263           0 :                 ;
   10264           0 : 
   10265           0 : /*****************************************************************************
   10266           0 :  *
   10267             :  *      clauses common to all Optimizable Stmts:
   10268           0 :  *              opt_from_clause         - allow list of both JOIN expressions and table names
   10269             :  *              opt_where_clause        - qualifications for joins or restrictions
   10270           0 :  *
   10271           0 :  *****************************************************************************/
   10272           0 : 
   10273           0 : opt_from_clause:                
   10274             :                 {
   10275           0 :                         $$ = NIL;
   10276             :                 }         
   10277             :                 | 
   10278             :                 FROM from_list          
   10279           0 :                 { 
   10280             :                         $$ = $2; 
   10281           0 :                 }
   10282             :                 ;
   10283           0 : 
   10284             : from_list:  from_list ',' table_ref                             
   10285           0 :                 { $$ = lappend($1, $3); }
   10286             :                 | table_ref                                     
   10287             :                 { $$ = makeList1($1); }
   10288             :                 ;
   10289          45 : /*
   10290             : ++bysdc@20200915
   10291          45 : query by partition
   10292        3681 : */
   10293             : opt_parti_clip_clause: /*EMPTY*/ { $$ = NULL; }
   10294           0 :                 | PARTITION '(' name_list ')'
   10295           0 :                 {
   10296         166 :                         PartiClip *n = makeNode(PartiClip);
   10297             :                         ((PartiClip*)n)->parti_level = 0;
   10298           0 :                         ((PartiClip*)n)->parti_names =(List*) $3;
   10299           0 :                         $$ = (Node *) n;
   10300           0 :                 }
   10301           0 :                 | SUBPARTITION '(' name_list ')'
   10302             :                 {
   10303           0 :                         PartiClip *n = makeNode(PartiClip);
   10304           0 :                         ((PartiClip*)n)->parti_level = 1;
   10305           0 :                         ((PartiClip*)n)->parti_names =(List*) $3;
   10306             :                         $$ = (Node *) n;
   10307             :                 }
   10308             : 
   10309             : /*
   10310             :  * table_ref is where an alias clause can be attached.  Note we cannot make
   10311             :  * alias_clause have an empty production because that causes parse conflicts
   10312             :  * between table_ref := '(' joined_table ')' alias_clause
   10313             :  * and joined_table := '(' joined_table ')'.  So, we must have the
   10314             :  * redundant-looking productions here instead.
   10315             :  */
   10316             : base_table_refs:
   10317         727 :                 base_table_ref
   10318             :                 {
   10319         727 :                         $$ = makeList1($1);
   10320             :                 } 
   10321             :         |       base_table_refs ','base_table_ref
   10322        3611 :                 {
   10323             :                         $$ = lappend($1,$3);
   10324        3611 :                 };
   10325             :  
   10326             : base_table_ref:  relation_expr
   10327         200 :                 {
   10328         200 :                         $$ = (Node *) $1;
   10329        3611 :                 }
   10330        3611 :                 | relation_expr alias_clause
   10331             :                 {
   10332             :                         ((TabNode*)$1)->name =(Attr*) $2;
   10333             :                         $$ = (Node *) $1;
   10334             :                 };
   10335       15559 :                                 
   10336       15559 : table_ref: base_table_ref       
   10337             :                 {
   10338           0 :                         $$ = $1;
   10339           0 :                 }
   10340           0 :                 | select_with_parens
   10341           0 :                 {
   10342             :                         QryNode *n = makeNode(QryNode);
   10343           0 :                         ((QryNode*)n)->subquery = $1;
   10344             :                         $$ = (Node *) n;
   10345           0 :                 }
   10346           0 :                 | select_with_parens alias_clause
   10347           0 :                 {
   10348           0 :                         QryNode *n = makeNode(QryNode);
   10349             :                         ((QryNode*)n)->subquery = $1;
   10350           0 :                         ((QryNode*)n)->name =(Attr*) $2;
   10351             :                         $$ = (Node *) n;
   10352             :                 }
   10353             :                 //why 2015-12-17 add
   10354             :                 | '(' relation_expr ')'
   10355             :                 {
   10356             :                         $$ = (Node *) $2;
   10357             :                 }
   10358             :                 | '(' relation_expr ')' alias_clause
   10359             :                 {
   10360             :                         ((TabNode*)$2)->name =(Attr*) $4;
   10361         273 :                         $$ = (Node *) $2;
   10362             :                 }
   10363         273 :                 //end
   10364             :                 | joined_table
   10365           0 :                 {
   10366             :                         $$ = (Node *) $1;
   10367           0 :                 }
   10368             :                 | '(' joined_table ')' alias_clause
   10369             :                 {
   10370        4245 :                         ((JoinNode*)$2)->alias = (Attr*) $4;
   10371             :                         $$ = (Node *) $2;
   10372        4245 :                 }
   10373             :                 | TABLE '(' c_expr ')'
   10374         274 :                 {
   10375         274 :                         $$ = (Node*)makeNode(TabNode);
   10376             :                         ((TabNode*)$$)->tab_expr = $3;
   10377         274 :                         SetNodePos($$); 
   10378             :                 }
   10379             :                 | TABLE '(' c_expr ')' alias_clause
   10380        3908 :                 {
   10381             :                         $$ = (Node*)makeNode(TabNode);
   10382        3908 :                         ((TabNode*)$$)->tab_expr = $3;
   10383             :                         ((TabNode*)$$)->name = (Attr*)$5;
   10384           0 :                         SetNodePos($$); 
   10385           0 :                 }
   10386           0 :                 ;
   10387             : 
   10388           0 : /*
   10389             :  * It may seem silly to separate joined_table from table_ref, but there is
   10390           0 :  * method in SQL92's madness: if you don't do it this way you get reduce-
   10391           0 :  * reduce conflicts, because it's not clear to the parser generator whether
   10392           0 :  * to expect alias_clause after ')' or not.  For the same reason we must
   10393           0 :  * treat 'JOIN' and 'join_type JOIN' separately, rather than allowing
   10394             :  * join_type to expand to empty; if we try it, the parser generator can't
   10395           0 :  * figure out when to reduce an empty join_type right after table_ref.
   10396             :  *
   10397             :  * Note that a CROSS JOIN is the same as an unqualified
   10398           0 :  * INNER JOIN, and an INNER JOIN/ON has the same shape
   10399             :  * but a qualification expression to limit membership.
   10400           0 :  * A NATURAL JOIN implicitly matches column names between
   10401             :  * tables and the shape is determined by which columns are
   10402           0 :  * in common. We'll collect columns during the later transformations.
   10403           0 :  */
   10404             : 
   10405           0 : joined_table:  
   10406             :         '(' joined_table ')'
   10407             :         {
   10408          97 :                 $$ = $2;
   10409             :         }
   10410          97 :         | table_ref CROSS JOIN table_ref
   10411             :         {
   10412           0 :                 /* CROSS JOIN is same as unqualified inner join */
   10413           0 :                 JoinNode *n = makeNode(JoinNode);
   10414             :                 n->jointype = JOIN_INNER;
   10415           0 :                 n->isNatural = false;
   10416             :                 n->larg = $1;
   10417           2 :                 n->rarg = $4;
   10418           2 :                 n->usings = NIL;
   10419           2 :                 n->quals = NULL;
   10420             :                 $$ = (Node*)n;
   10421           2 :         }
   10422             :         | table_ref UNIONJOIN table_ref
   10423           0 :         {
   10424           0 :                 /* UNION JOIN is made into 1 token to avoid shift/reduce
   10425           0 :                         * conflict against regular UNION keyword.
   10426           0 :                         */
   10427             :                 JoinNode *n = makeNode(JoinNode);
   10428           0 :                 n->jointype = JOIN_UNION;
   10429             :                 n->isNatural = false;
   10430             :                 n->larg = $1;
   10431             :                 n->rarg = $3;
   10432             :                 n->usings = NIL;
   10433             :                 n->quals = NULL;
   10434             :                 $$ = (Node*)n;
   10435             :         }
   10436             :         | table_ref join_type JOIN table_ref USING '(' name_list ')'
   10437             :         {
   10438             :                 JoinNode *n = makeNode(JoinNode);
   10439             :                 n->jointype = (JType)$2;
   10440             :                 n->isNatural = false;
   10441             :                 n->larg = $1;
   10442             :                 n->rarg = $4;
   10443             :                 n->usings = (List*)$7;
   10444             :                 $$ = (Node*)n;
   10445             :         }
   10446             :         | table_ref join_type JOIN table_ref ON bool_expr
   10447             :         {
   10448             :                 JoinNode *n = makeNode(JoinNode);
   10449          28 :                 n->jointype = (JType)$2;
   10450             :                 n->isNatural = false;
   10451          28 :                 n->larg = $1;
   10452             :                 n->rarg = $4;
   10453             :                 n->quals = $6;
   10454           0 :                 $$ = (Node*)n;
   10455           0 :         }
   10456           0 :         | table_ref JOIN table_ref USING '(' name_list ')'
   10457           0 :         {
   10458           0 :                 /* letting join_type reduce to empty doesn't work */
   10459           0 :                 JoinNode *n = makeNode(JoinNode);
   10460           0 :                 n->jointype = JOIN_INNER;
   10461           0 :                 n->isNatural = false;
   10462             :                 n->larg = $1;
   10463           0 :                 n->rarg = $3;
   10464             :                 n->usings = (List *)$6;      
   10465             :                 $$ = (Node*)n;
   10466             :         }
   10467             :         | table_ref JOIN table_ref ON bool_expr
   10468           0 :         {
   10469           0 :                 /* letting join_type reduce to empty doesn't work */
   10470           0 :                 JoinNode *n = makeNode(JoinNode);
   10471           0 :                 n->jointype = JOIN_INNER;
   10472           0 :                 n->isNatural = false;
   10473           0 :                 n->larg = $1;
   10474           0 :                 n->rarg = $3;
   10475           0 :                 n->quals = $5;
   10476             :                 $$ = (Node*)n;
   10477           0 :         }
   10478             :         | table_ref NATURAL join_type JOIN table_ref
   10479          22 :         {
   10480          22 :                 JoinNode *n = makeNode(JoinNode);
   10481          22 :                 n->jointype = (JType)$3;
   10482          22 :                 n->isNatural = true;
   10483          22 :                 n->larg = $1;
   10484          22 :                 n->rarg = $5;
   10485          22 :                 n->usings = NIL; /* figure out which columns later... */
   10486             :                 n->quals = NULL; /* fill later */
   10487          22 :                 $$ = (Node*)n;
   10488             :         }
   10489          41 :         | table_ref NATURAL JOIN table_ref
   10490          41 :         {
   10491          41 :                 /* letting join_type reduce to empty doesn't work */
   10492          41 :                 JoinNode *n = makeNode(JoinNode);
   10493          41 :                 n->jointype = JOIN_INNER;
   10494          41 :                 n->isNatural = true;
   10495          41 :                 n->larg = $1;
   10496             :                 n->rarg = $4;
   10497          41 :                 n->usings = NIL; /* figure out which columns later... */
   10498             :                 n->quals = NULL; /* fill later */
   10499             :                 $$ = (Node*)n;
   10500           4 :         }
   10501           4 :         ;
   10502           4 : 
   10503           4 : alias_clause:  AS ColId '(' name_list ')'
   10504           4 :         {
   10505           4 :                 $$ = (Node*)makeNode(Attr);
   10506           4 :                 ((Attr*)$$)->relname = $2;
   10507             :                 ((Attr*)$$)->fields = $4;
   10508           4 :         }
   10509             :         | AS ColId
   10510             :         {
   10511           2 :                 $$ = (Node*)makeNode(Attr);
   10512           2 :                 ((Attr*)$$)->relname = $2;
   10513           2 :         }
   10514           2 :         | ColId '(' name_list ')'
   10515           2 :         {
   10516           2 :                 $$ = (Node*)makeNode(Attr);
   10517           2 :                 ((Attr*)$$)->relname = $1;
   10518             :                 ((Attr*)$$)->fields = $3;
   10519           2 :         }
   10520             :         | ColId
   10521          20 :         {
   10522          20 :                 $$ = (Node*)makeNode(Attr);
   10523          20 :                 ((Attr*)$$)->relname = $1;
   10524          20 :         }
   10525          20 :         ;
   10526          20 : 
   10527          20 : join_type:  FULL join_outer                                     { $$ = JOIN_FULL; }
   10528          20 :                 | LEFT join_outer                               { $$ = JOIN_LEFT; }
   10529             :                 | RIGHT join_outer                              { $$ = JOIN_RIGHT; }
   10530          20 :                 | _INNER                                        { $$ = JOIN_INNER; }
   10531             :                 ;
   10532             : 
   10533           9 : /* OUTER is just noise... */
   10534           9 : join_outer:  _OUTER                                             { $$ = NULL; }
   10535           9 :                 | /*EMPTY*/                                     { $$ = NULL; }
   10536           9 :                 ;
   10537           9 : 
   10538           9 : relation_expr:  name_space opt_parti_clip_clause/* bysdc@20200915 */
   10539           9 :                 {
   10540           9 :                         /* default inheritance */
   10541             :                         $$ = (Node*)makeNode(TabNode);
   10542           9 :                         ((TabNode*)$$)->relname = $1;
   10543             :                         ((TabNode*)$$)->name = NULL;
   10544             :                         ((TabNode*)$$)->partiClip = $2;//bysdc@20200915
   10545             :                         SetNodePos($$);
   10546           0 :                 }
   10547           0 :                 | name_space '@' name
   10548           0 :                 {
   10549             :                         /* default inheritance */
   10550           0 :                         $$ = (Node*)makeNode(TabNode);
   10551             :                         ((TabNode*)$$)->relname = $1;
   10552          40 :                         ((TabNode*)$$)->name = NULL;
   10553          40 :                         ((TabNode*)$$)->link_name = $3;
   10554             :                         SetNodePos($$);
   10555          40 :                 }
   10556             :                 ;
   10557           0 : 
   10558           0 : opt_where_clause:  WHERE bool_expr                      { $$ = $2; }
   10559           0 :                 | /*EMPTY*/                                     { $$ = NULL;  /* no qualifiers */ }
   10560             :                 ;
   10561           0 : filter_where_clause:  WHERE bool_expr                   { $$ = $2; };
   10562             : 
   10563         234 : /*****************************************************************************
   10564         234 :  *
   10565             :  *      Type syntax
   10566         234 :  *              SQL92 introduces a large amount of type-specific syntax.
   10567             :  *              Define individual clauses to handle these cases, and use
   10568           1 :  *               the generic case to handle regular type-extensible  syntax.
   10569           1 :  *              - thomas 1997-10-10
   10570          29 :  *
   10571          13 :  *****************************************************************************/
   10572          40 : 
   10573             : /* data type  */
   10574             : TypeName: STypename     
   10575          12 :                 {
   10576          12 :                         $$ = $1;
   10577          31 :                         SetNodePos($$);
   10578             :                 }       
   10579             :                 | TABLE OF STypename
   10580             :                 {
   10581             :                         Typenam *p_node = (Typenam*)makeNode(Typenam);
   10582       15559 :                         p_node->type_id = TYPE_TABLE;
   10583       15559 :                         p_node->memb_type = (Typenam*)$3;
   10584       15559 :                         $$ = (Node*)p_node;
   10585       15559 :                         SetNodePos($$);
   10586       15559 :                 }
   10587             :                 
   10588       15559 :                 | TABLE OF STypename INDEX BY STypename
   10589             :                 {
   10590             :                         Typenam *p_node = (Typenam*)makeNode(Typenam);
   10591           0 :                         p_node->type_id = TYPE_ITABLE;
   10592           0 :                         p_node->memb_type = (Typenam*)$3;
   10593           0 :                         p_node->idx_type = (Typenam*)$6;
   10594           0 :                         $$ = (Node*)p_node;
   10595           0 :                         SetNodePos($$);
   10596             :                 }
   10597           0 : 
   10598             :                 | VARRAY '(' ICONST ')'  OF STypename
   10599        2626 :                 {
   10600        2626 :                         Typenam *p_node = (Typenam*)makeNode(Typenam);
   10601        1711 :                         p_node->type_id = TYPE_VARRAY;
   10602           0 :                         p_node->elem_num = $3;
   10603           0 :                         p_node->memb_type = (Typenam*)$6;
   10604             :                         $$ = (Node*)p_node;
   10605             :                         SetNodePos($$);
   10606             :                 }
   10607             : 
   10608             :                 | VARYING ARRAY '(' ICONST ')' OF STypename
   10609             :                 {
   10610             :                         Typenam *p_node = (Typenam*)makeNode(Typenam);
   10611             :                         p_node->type_id = TYPE_VARRAY;
   10612             :                         p_node->elem_num = $4;
   10613             :                         p_node->memb_type = (Typenam*)$7;
   10614             :                         $$ = (Node*)p_node;
   10615             :                         SetNodePos($$);
   10616             :                 }
   10617        6700 :                 ;
   10618        6700 :                 
   10619             : col_defs:  MemberVarDecl
   10620        6700 :                 {
   10621             :                         $$ = makeList1($1);
   10622          10 :                 }
   10623          10 :                 | col_defs ','  MemberVarDecl
   10624          10 :                 {
   10625          10 :                         $$ = lappend($1,$3);
   10626          10 :                 }
   10627             :                 ;
   10628          10 : 
   10629             : STypename:  
   10630             :                   ConstTypename
   10631           0 :                 | GenericType
   10632           0 :                 | name_space '%' ROWTYPE
   10633           0 :                 {
   10634           0 :                    Typenam * p_node = (Typenam*)makeNode(Typenam);
   10635           0 :                    p_node->type_id = TYPE_ROWTYPE;
   10636           0 :                    p_node->type_name = $1;
   10637             :                    $$ = (Node*)p_node;
   10638           0 :                    SetNodePos($$);
   10639             :                 }
   10640             :                 |  name_space '%' ROW TYPE
   10641           2 :                 {
   10642           2 :                    Typenam * p_node = (Typenam*)makeNode(Typenam);
   10643           2 :                    p_node->type_id = TYPE_ROWTYPE;
   10644           2 :                    p_node->type_name = $1;
   10645           2 :                    $$ = (Node*)p_node;
   10646           2 :                    SetNodePos($$);
   10647             :                 }
   10648           2 :                 | name_space '%' TYPE
   10649             :                 {
   10650             :                    Typenam * p_node = (Typenam*)makeNode(Typenam);
   10651           0 :                    p_node->type_id = TYPE_COLTYPE;
   10652           0 :                    p_node->type_name = $1;
   10653           0 :                    $$ = (Node*)p_node;
   10654           0 :                    SetNodePos($$);
   10655           0 :                 }
   10656           0 :                 | ROWTYPE OF name_space 
   10657             :                 {
   10658           0 :                    Typenam * p_node = (Typenam*)makeNode(Typenam);
   10659             :                    p_node->type_id = TYPE_ROWTYPE;
   10660             :                    p_node->type_name = $3;
   10661             :                    $$ = (Node*)p_node;
   10662          12 :                    SetNodePos($$);
   10663             :                 }
   10664          12 :                 | ROW TYPE OF name_space 
   10665             :                 {
   10666          40 :                    Typenam * p_node = (Typenam*)makeNode(Typenam);
   10667             :                    p_node->type_id = TYPE_ROWTYPE;
   10668          40 :                    p_node->type_name = $4;
   10669             :                    $$ = (Node*)p_node;
   10670             :                    SetNodePos($$);
   10671             :                 }
   10672             :                 | TYPE OF name_space
   10673             :                 {
   10674             :                    Typenam * p_node = (Typenam*)makeNode(Typenam);
   10675           0 :                    p_node->type_id = TYPE_COLTYPE;
   10676           0 :                    p_node->type_name = $3;
   10677           0 :                    $$ = (Node*)p_node;
   10678           0 :                    SetNodePos($$);
   10679           0 :                 }
   10680             :                 | REF CURSOR
   10681           0 :                 {
   10682             :                    Typenam * p_node = (Typenam*)makeNode(Typenam);
   10683           0 :                    p_node->type_id = TYPE_REFCUR;
   10684           0 :                    $$ = (Node*)p_node;          
   10685           0 :                    SetNodePos($$);
   10686           0 :                 }
   10687           0 :                 | RECORD '('col_defs ')' 
   10688             :                 {
   10689           0 :                    Typenam * p_node = makeNode(Typenam);
   10690             :                    p_node->type_id = TYPE_RECORD;
   10691           0 :                    p_node->col_defs = $3;
   10692           0 :                    $$ = (Node*)p_node;          
   10693           0 :                    SetNodePos($$);
   10694           0 :                 }
   10695           0 :                 ;
   10696             : STypename1:  
   10697           0 :                   ConstTypename1
   10698             :                 | GenericType
   10699           0 :                 ;       
   10700           0 :                 
   10701           0 : ConstTypename: Numeric
   10702           0 :                 | Bit
   10703           0 :                 | Character
   10704             :                 | ConstDatetime
   10705           0 :                 | _RAW_
   10706             :                 {
   10707           0 :                         $$ = (Node*)makeNode(Typenam);
   10708           0 :                         ((Typenam*)$$)->type_name = "BINARY";
   10709           0 :                         ((Typenam*)$$)->preci_scale = -1;
   10710           0 :                 }
   10711           0 :                 | _RAW_ '(' ICONST ')'
   10712             :                 {
   10713           0 :                         $$ = (Node*)makeNode(Typenam);
   10714             :                         ((Typenam*)$$)->type_name = "BINARY";
   10715           0 :                         ((Typenam*)$$)->preci_scale = $3;
   10716           0 :                 }
   10717           0 :                 | BINARY
   10718           0 :                 {
   10719           0 :                         $$ = (Node*)makeNode(Typenam);
   10720             :                         ((Typenam*)$$)->type_name = "BINARY";
   10721           0 :                         ((Typenam*)$$)->preci_scale = -1;
   10722             :                 }
   10723           0 :                 ;
   10724           0 : 
   10725           0 : ConstTypename1: 
   10726           0 :                   Numeric
   10727             :                 | Bit
   10728           0 :                 | Character
   10729             :                 | ConstDatetime1
   10730          12 :                 | BINARY
   10731          12 :                 {
   10732          12 :                         $$ = (Node*)makeNode(Typenam);
   10733          12 :                         ((Typenam*)$$)->type_name = "BINARY";
   10734          12 :                         ((Typenam*)$$)->preci_scale = -1;
   10735             :                 }
   10736          12 :                 ;               
   10737             :                 
   10738             : GenericType: name_space         
   10739             :                 {
   10740             :                         $$ = (Node*)makeNode(Typenam);
   10741             :                         if(!astricmp($1,"SYS_REFCURSOR"))
   10742             :                           ((Typenam*)$$)->type_id = TYPE_REFCUR;
   10743             :                     else
   10744             :                     {
   10745             :                           ((Typenam*)$$)->type_name = xlateSqlType($1);
   10746             :                           ((Typenam*)$$)->preci_scale = -1;
   10747             :                     }
   10748         262 :                 }               
   10749         262 :                 ;
   10750         262 : 
   10751             : /*SQL92 numeric data types
   10752         262 :  * Check _FLOAT() precision limits assuming IEEE floating types.
   10753             :  * Provide real _DECIMAL() and _NUMERIC() implementations now
   10754           0 : */
   10755           0 : Numeric:  _FLOAT opt_float
   10756           0 :                 {
   10757             :                         $$ = (Node*)makeNode(Typenam);
   10758           0 :                         ((Typenam*)$$)->type_name = "FLOAT";
   10759             :                         ((Typenam*)$$)->preci_scale = -1;
   10760          12 :                 }
   10761          12 :                 | _DOUBLE
   10762          12 :                 {
   10763             :                         $$ = (Node*)makeNode(Typenam);
   10764          12 :                         ((Typenam*)$$)->type_name = "DOUBLE";
   10765             :                         ((Typenam*)$$)->preci_scale = -1;
   10766             :                 }
   10767             :                 /* | _DOUBLE PRECISION
   10768             :                 {
   10769             :                         $$ = (Node*)makeNode(Typenam);
   10770             :                         ((Typenam*)$$)->type_name = "DOUBLE";
   10771             :                         ((Typenam*)$$)->preci_scale = -1;
   10772             :                 }*/
   10773           0 :                 | _DECIMAL opt_decimal
   10774           0 :                 {
   10775           0 :                         $$ = (Node*)makeNode(Typenam);
   10776             :                         ((Typenam*)$$)->type_name = "NUMERIC";
   10777           0 :                         ((Typenam*)$$)->preci_scale = $2;
   10778             :                 }
   10779             :                 | DEC opt_decimal
   10780             :                 {
   10781        2746 :                         $$ = (Node*)makeNode(Typenam);
   10782        2746 :                         ((Typenam*)$$)->type_name = "NUMERIC";
   10783           0 :                         ((Typenam*)$$)->preci_scale = $2;
   10784             :                 }
   10785             :                 | _NUMERIC opt_numeric
   10786        2746 :                 {
   10787        2746 :                         $$ = (Node*)makeNode(Typenam);
   10788             :                         ((Typenam*)$$)->type_name = "NUMERIC";
   10789             :                         ((Typenam*)$$)->preci_scale = $2;
   10790        2746 :                 }
   10791             :                 | NUMBER opt_decimal
   10792             :                 {
   10793             :                         $$ = (Node*)makeNode(Typenam);
   10794             :                         ((Typenam*)$$)->type_name = "NUMERIC";
   10795             :                         ((Typenam*)$$)->preci_scale = $2;
   10796             :                 }                               
   10797             :                 ;
   10798          75 : 
   10799          75 : opt_float:  '(' ICONST ')'
   10800          75 :                 {
   10801             :                         if ($2 < 1)
   10802          75 :                         {
   10803             :                                 SetParsePos();
   10804          55 :                                 add_parse_error(80);
   10805          55 :                         }
   10806          55 :                         else if ($2 <= 32)
   10807             :                                 $$ = (char*)"FLOAT";
   10808          55 :                         else if ($2 <= 128)
   10809             :                                 $$ = (char*)"DOUBLE";
   10810             :                         else
   10811             :                         {
   10812             :                                 SetParsePos();
   10813             :                                 add_parse_error(81);
   10814             :                         }
   10815             :                 }
   10816         413 :                 | /*EMPTY*/
   10817         413 :                 {
   10818         413 :                         $$ = (char*)"FLOAT";
   10819             :                 }
   10820         413 :                 ;
   10821             : 
   10822          24 : opt_numeric:  '(' ICONST ',' ICONST ')'
   10823          24 :                 {
   10824          24 :                         if ($2 < 1 || $2 > NUMERIC_MAX_PRECISION)
   10825             :                         {
   10826          24 :                                 SetParsePos();
   10827             :                                 add_parse_error(82,$2, NUMERIC_MAX_PRECISION);
   10828         310 :                         }
   10829         310 :                         if ($4 < 0 || $4 > $2)
   10830         310 :                         {
   10831             :                                 SetParsePos();
   10832         310 :                                 add_parse_error(83,
   10833             :                                                         $4,$2);
   10834          14 :                         }
   10835          14 : 
   10836          14 :                         $$ = (($2 << 16) | $4);
   10837             :                 }
   10838          14 :                 | '(' ICONST ')'
   10839             :                 {
   10840             :                         if ($2 < 1 || $2 > NUMERIC_MAX_PRECISION)
   10841             :                         {
   10842          10 :                                 SetParsePos();
   10843             :                                 add_parse_error(82,
   10844           0 :                                                         $2, NUMERIC_MAX_PRECISION);
   10845           0 :                         }
   10846             : 
   10847          10 :                         $$ = ($2 << 16);
   10848          10 :                 }
   10849           0 :                 | /*EMPTY*/
   10850           0 :                 {
   10851             :                         $$ = ((NUMERIC_DEFAULT_PRECISION<<16));
   10852             :                 }
   10853           0 :                 ;
   10854           0 : 
   10855             : opt_decimal:  '(' ICONST ',' ICONST ')'
   10856             :                 {
   10857          10 :                         if ($2 < 1 || $2 > NUMERIC_MAX_PRECISION)
   10858             :                         {
   10859          65 :                                 SetParsePos();
   10860             :                                 add_parse_error(84,
   10861          65 :                                                         $2, NUMERIC_MAX_PRECISION);
   10862             :                         }
   10863             :                         if ($4 < 0 || $4 > $2)
   10864             :                         {
   10865          75 :                                 SetParsePos();
   10866             :                                 add_parse_error(85,
   10867           0 :                                                         $4,$2);
   10868           0 :                                                                 
   10869             :                         }
   10870          75 :                         $$ = (($2 << 16) | $4);
   10871             :                 }
   10872           0 :                 | '(' ICONST ')'
   10873             :                 {
   10874           0 :                         if ($2 < 1 || $2 > NUMERIC_MAX_PRECISION)
   10875             :                         {
   10876             :                                 SetParsePos();
   10877          75 :                                 add_parse_error(84,
   10878             :                                                         $2, NUMERIC_MAX_PRECISION);
   10879          75 :                         }
   10880             : 
   10881         207 :                         $$ = ($2 << 16);
   10882             :                 }
   10883           0 :                 | '(' '*' ',' ICONST ')'
   10884             :                 {
   10885           0 :                     //zwp@fixbug5228
   10886             :                         if($4 < 0 || $4 > NUMERIC_DEFAULT_PRECISION)
   10887             :                         {
   10888         207 :                                 SetParsePos();
   10889             :                                 add_parse_error(85,
   10890         207 :                                                         $4,NUMERIC_DEFAULT_PRECISION);
   10891             :                         }
   10892          28 :                         $$ = ((NUMERIC_DEFAULT_PRECISION<<16)|$4);
   10893             :                 }
   10894          28 :                 | '(' ICONST ',' '*' ')'
   10895             :                 {
   10896             :                     //zwp@fixbug5228
   10897             :                         if($2 < 1 || $2 > NUMERIC_MAX_PRECISION)
   10898          66 :                         {
   10899             :                                 SetParsePos();
   10900           0 :                                 add_parse_error(84,
   10901             :                                                         $2, NUMERIC_MAX_PRECISION);
   10902           0 :                         }
   10903             :                         if($2 < NUMERIC_DEFAULT_SCALE)
   10904          66 :                         {
   10905             :                                 SetParsePos();
   10906           0 :                                 add_parse_error(84,
   10907             :                                                         $2, NUMERIC_DEFAULT_SCALE);
   10908           0 :                         }
   10909             :                         $$ = (($2<<16)|NUMERIC_DEFAULT_SCALE);
   10910             :                 }
   10911          66 :                 | '(' '*' ')'
   10912             :                 {
   10913          66 :                         $$ = ((NUMERIC_DEFAULT_PRECISION<<16));
   10914             :                 }
   10915         359 :                 | '(' '*' ',' '*' ')'
   10916             :                 {
   10917           0 :                         $$ = ((NUMERIC_DEFAULT_PRECISION<<16)|NUMERIC_DEFAULT_SCALE);
   10918             :                 }                                                               
   10919           0 :                 | /*EMPTY*/
   10920             :                 {
   10921             :                         $$ = ((NUMERIC_DEFAULT_PRECISION<<16));
   10922         359 :                 }
   10923             :                 ;
   10924         359 : 
   10925             : /*
   10926             :  * SQL92 bit-field data types
   10927           0 :  * The following implements BIT() and BIT VARYING().
   10928             : */
   10929           0 : Bit:  BIT  opt_varying  opt_preci
   10930             :                 {
   10931           0 :                         Typenam *p_typenam = makeNode(Typenam);
   10932             :                         p_typenam->type_name = "BIT";
   10933           0 :                         p_typenam->is_varying = $2;
   10934             :                         p_typenam->preci_scale = $3;
   10935           0 :                         $$ = (Node*)p_typenam;
   10936             :                 }
   10937             :                 ;               
   10938           0 : 
   10939             : /*
   10940           0 :  * SQL92 character data types
   10941             :  * The following implements CHAR() and VARCHAR().
   10942           0 : */
   10943             : Character:  character opt_charset opt_preci
   10944           0 :                 {
   10945             :                         $$ = (Node*)makeNode(Typenam);
   10946           0 :                         ((Typenam*)$$)->type_name = "CHAR";
   10947             :                         ((Typenam*)$$)->cset_name = $2;
   10948           0 :                         ((Typenam*)$$)->preci_scale = $3;
   10949             :                         ((Typenam*)$$)->is_varying = (astricmp($1,"CHAR")!=0);
   10950           0 :                 }
   10951             :                 ;
   10952           0 : 
   10953             : character:  
   10954           0 :                   CHARACTER opt_varying                 { $$ = $2 ? (char*)"VARCHAR": (char*)"CHAR";}
   10955             :                 | VARCHAR                                               { $$ = (char*)"VARCHAR"; }
   10956           0 :                 | NVARCHAR                                              { $$ = (char*)"VARCHAR"; }
   10957             :                 | VARCHAR2                                              { $$ = (char*)"VARCHAR"; }
   10958           0 :                 | NVARCHAR2                                             { $$ = (char*)"VARCHAR"; }    
   10959             :                 | NCHAR opt_varying                             { $$ = $2 ? (char*)"VARCHAR": (char*)"CHAR"; }
   10960           0 :                 | NATIONAL CHARACTER opt_varying{ $$ = $3 ? (char*)"VARCHAR": (char*)"CHAR"; }
   10961             :                 ;
   10962          26 : 
   10963             : opt_varying:  VARYING                                   { $$ = true; }
   10964          26 :                 | /*EMPTY*/                                     { $$ = false; }
   10965             :                 ;
   10966             : 
   10967             : opt_preci:
   10968             :                 {  $$ = -1;}
   10969             :                 | '(' ICONST opt_char ')'
   10970             :                 {
   10971             :                         if($2 < 1)
   10972           0 :                         {
   10973           0 :                                 SetParsePos();
   10974           0 :                                 add_parse_error(88);
   10975           0 :                         }
   10976           0 :                         else if($2 > MAX_ATTR_SIZE)
   10977             :                         {
   10978           0 :                                 SetParsePos();
   10979             :                                 add_parse_error(89,MAX_ATTR_SIZE);
   10980             :                         }
   10981             :                         $$ = $2;
   10982             :                 }
   10983             :                 ;
   10984             : 
   10985             : opt_char:
   10986        2478 :                 CHARACTER  { $$ = NULL; }
   10987        2478 :                 | /*EMPTY*/                                     { $$ = false; }
   10988        2478 :                 ;
   10989        2478 : 
   10990        2478 : opt_charset:  
   10991             :                    CHARACTER SET ColId          { $$ = $3; }
   10992        2478 :                 |  CHARACTER SET Sconst         { $$ = dbs2utf($3);}
   10993             :                 |  /*EMPTY*/                            { $$ = NULL; }
   10994             :                 ;
   10995        1645 : 
   10996        1645 : opt_collate:  COLLATE ColId                     { $$ = $2; }
   10997         594 :                 | /*EMPTY*/                                     { $$ = NULL; }
   10998           0 :                 ;
   10999         230 : 
   11000           3 : ConstDatetime:  
   11001           6 :                 TIMESTAMP  opt_sub_label opt_with_timez opt_auto_update
   11002           0 :                 {
   11003             :                         if($2>6)
   11004           6 :                                 add_parse_error(971,"TIMESTAMP",6);
   11005           6 :                         if($2<0)
   11006        1645 :                                 $2 = 6;
   11007             :                         $$ = (Node*)makeNode(Typenam);
   11008             :                         if($3)
   11009         803 :                                 ((Typenam*)$$)->type_name = "DATETIME WITH TIME ZONE";
   11010         803 :                         else
   11011             :                                 ((Typenam*)$$)->type_name = "DATETIME";
   11012        1675 :                         ((Typenam*)$$)->preci_scale = $2;
   11013             :                         ((Typenam*)$$)->is_timestamp = true;
   11014           0 :                         if($4)
   11015           0 :                                 ((Typenam*)$$)->timestamp_type = 'u';        /*for update*/
   11016             :                         else
   11017        1675 :                                 ((Typenam*)$$)->timestamp_type = 'i';        /*for insert*/
   11018             :                 }
   11019           0 :                 | TIME  opt_sub_label opt_with_timez
   11020           0 :                 {
   11021             :                         if($2>3)
   11022        1675 :                                 add_parse_error(971,"TIME",3);
   11023             :                         if($2<0)
   11024        1675 :                                 $2 = 3;
   11025             :                         $$ = (Node*)makeNode(Typenam);
   11026             :                         if($3)
   11027           0 :                                 ((Typenam*)$$)->type_name = "TIME WITH TIME ZONE";
   11028           0 :                         else
   11029           0 :                                 ((Typenam*)$$)->type_name = "TIME";
   11030        2478 :                         ((Typenam*)$$)->preci_scale = $2;
   11031             :                 }
   11032           0 :                 | _DATE  
   11033           0 :                 {
   11034        3413 :                         $$ = (Node*)makeNode(Typenam);
   11035             :                         ((Typenam*)$$)->type_name = "DATE";
   11036             :                         ((Typenam*)$$)->preci_scale = -1;
   11037             :                 }
   11038             :                 | DATETIME opt_sub_label opt_with_timez
   11039          27 :                 {
   11040           0 :                         if($2>6)
   11041          27 :                                 add_parse_error(971,"DATETIME",6);
   11042          27 :                         if($2<0)
   11043          27 :                                 $2 = 6;
   11044          27 :                         $$ = (Node*)makeNode(Typenam);
   11045           4 :                         if($3)
   11046             :                                 ((Typenam*)$$)->type_name = "DATETIME WITH TIME ZONE";
   11047          23 :                         else
   11048          27 :                                 ((Typenam*)$$)->type_name = "DATETIME";
   11049          27 :                         ((Typenam*)$$)->preci_scale = $2;
   11050          27 :                 }
   11051           0 :                 | INTERVAL  opt_interval                        
   11052             :                 {
   11053          27 :                         $$ = (Node*)makeNode(Typenam);
   11054             :                         ((Typenam*)$$)->type_name = interval_names[(((uint)$2)>>28)-1];
   11055          27 :                         ((Typenam*)$$)->preci_scale = ($2 & 0x0fffffff);
   11056             :                 }
   11057          62 :                 ;
   11058           0 :                                 
   11059          62 : opt_auto_update: /*empty*/
   11060          56 :                 {
   11061          62 :                         $$ = false;
   11062          62 :                 }
   11063          18 :                 | AUTO UPDATE
   11064             :                 {
   11065          44 :                         $$ = true;
   11066          62 :                 }
   11067             :                 ;
   11068          62 :                                                         
   11069             : ConstDatetime1: 
   11070          35 :                 TIMESTAMP  opt_sub_label 
   11071          35 :                 {
   11072          35 :                         if($2>6)
   11073             :                                 add_parse_error(971,"TIMESTAMP",6);
   11074          35 :                         if($2<0)
   11075             :                                 $2 = 6;
   11076          59 :                         $$ = (Node*)makeNode(Typenam);
   11077           0 :                         ((Typenam*)$$)->type_name = "DATETIME";
   11078          59 :                         
   11079          57 :                         ((Typenam*)$$)->preci_scale = $2;
   11080          59 :                         ((Typenam*)$$)->is_timestamp = true;
   11081          59 :                         ((Typenam*)$$)->timestamp_type = 'i';
   11082          12 :                 }
   11083             :                 //why 2016-05-06 modify bug:1895                        
   11084          47 :                 | TIME  opt_sub_label
   11085          59 :                 {
   11086             :                         if($2>3)
   11087          59 :                                 add_parse_error(971,"TIME",3);
   11088             :                         if($2<0)
   11089         267 :                                 $2 = 3;
   11090         267 :                         $$ = (Node*)makeNode(Typenam);
   11091         267 :                         ((Typenam*)$$)->type_name = "TIME";
   11092             :                         ((Typenam*)$$)->preci_scale = $2;
   11093         267 :                 }
   11094             :                 /*      
   11095             :                 | TIME  opt_sub_label opt_with_timez
   11096             :                 {
   11097          27 :                         if($2>3)
   11098             :                                 add_parse_error(971,"TIME",3);
   11099          27 :                         if($2<0)
   11100             :                                 $2 = 3;
   11101           0 :                         $$ = (Node*)makeNode(Typenam);
   11102             :                         if($3)
   11103           0 :                                 ((Typenam*)$$)->type_name = "TIME WITH TIME ZONE";
   11104             :                         else
   11105             :                                 ((Typenam*)$$)->type_name = "TIME";
   11106             :                         ((Typenam*)$$)->preci_scale = $2;
   11107             :                 }
   11108          17 :                 */
   11109           0 :                 | _DATE  
   11110          17 :                 {
   11111          17 :                         $$ = (Node*)makeNode(Typenam);
   11112          17 :                         ((Typenam*)$$)->type_name = "DATE";
   11113          17 :                         ((Typenam*)$$)->preci_scale = -1;
   11114             :                 }
   11115          17 :                 //why 2016-05-06 modify bug:1895        old:
   11116          17 :                 /*
   11117          17 :                 | DATETIME opt_sub_label 
   11118             :                 {
   11119          17 :                         if($2>6)
   11120             :                                 add_parse_error(971,"DATETIME",6);
   11121             :                         if($2<0)
   11122          26 :                                 $2 = 6;
   11123           0 :                         $$ = (Node*)makeNode(Typenam);
   11124          26 :                         ((Typenam*)$$)->type_name = "DATETIME";
   11125          26 :                         ((Typenam*)$$)->preci_scale = $2;
   11126          26 :                 }
   11127          26 :                 */
   11128          26 :                 | DATETIME opt_sub_label opt_with_timez
   11129             :                 {
   11130          26 :                         if($2>6)
   11131             :                                 add_parse_error(971,"DATETIME",6);
   11132             :                         if($2<0)
   11133             :                                 $2 = 6;
   11134             :                         $$ = (Node*)makeNode(Typenam);
   11135             :                         if($3)
   11136             :                                 ((Typenam*)$$)->type_name = "DATETIME WITH TIME ZONE";
   11137             :                         else
   11138             :                                 ((Typenam*)$$)->type_name = "DATETIME";
   11139             :                         ((Typenam*)$$)->preci_scale = $2;
   11140             :                 }                                               
   11141             :                 | INTERVAL  opt_interval                        
   11142             :                 {
   11143             :                         $$ = (Node*)makeNode(Typenam);                  
   11144             :                         ((Typenam*)$$)->type_name = interval_names[(((uint)$2)>>28)-1];
   11145             :                         ((Typenam*)$$)->preci_scale = ($2 & 0x0fffffff);
   11146             :                 }
   11147          18 :                 ;
   11148          18 :  
   11149          18 : dt_unit: _YEAR                                          { $$ = DTUNIT_YEAR; }
   11150             :                 | _MONTH                                        { $$ = DTUNIT_MONTH; }
   11151          18 :                 | _DAY                                          { $$ = DTUNIT_DAY; }
   11152             :                 | _HOUR                                         { $$ = DTUNIT_HOUR; }
   11153             :                 | _MINUTE                                       { $$ = DTUNIT_MINUTE; }
   11154             :                 | _SECOND                                       { $$ = DTUNIT_SECOND; }
   11155             :                 ;
   11156             : 
   11157             : opt_with_timez:  
   11158             :                   WITH TIME ZONE                        { $$ = true; }
   11159             :                 | WITHOUT TIME ZONE                     { $$ = false; }
   11160             :                 | /*EMPTY*/                                     { $$ = false; }
   11161             :                 ;
   11162             : 
   11163             : opt_interval: _YEAR     opt_sub_label                   
   11164             :                 {
   11165             :                         if($2>9)
   11166           0 :                                 add_parse_error(970,"INTERVAL YEAR",9);
   11167           0 :                         if($2<0)
   11168           0 :                                 $2 = 9;
   11169           0 :                         $$ = 0x10000000|($2<<16); 
   11170           0 :                 }
   11171           0 :                 | _MONTH opt_sub_label                  
   11172           0 :                 {
   11173             :                         if($2>9)
   11174           0 :                                 add_parse_error(970,"INTERVAL MONTH",9);
   11175           0 :                         if($2<0)
   11176             :                                 $2 = 9;
   11177           0 :                         $$ = 0x20000000|($2<<16); 
   11178             :                 }
   11179           0 :                 | _YEAR opt_sub_label  TO _MONTH                
   11180           0 :                 {
   11181           0 :                         if($2>8)
   11182             :                                 add_parse_error(970,"INTERVAL YEAR",8);
   11183           0 :                         if($2<0)
   11184             :                                 $2 = 8;
   11185           0 :                         $$ = 0x30000000|($2<<16); 
   11186           0 :                 }
   11187           0 :                 | _DAY opt_sub_label                    
   11188           0 :                 {
   11189           0 :                         if($2>9)
   11190           0 :                                 add_parse_error(970,"INTERVAL DAY",9);
   11191           0 :                         if($2<0)
   11192             :                                 $2 = 9;
   11193             :                         $$ = 0x40000000|($2<<16); 
   11194          34 :                 }
   11195          34 :                 | _HOUR opt_sub_label                           
   11196           0 :                 {
   11197         114 :                         if($2>9)
   11198             :                                 add_parse_error(970,"INTERVAL HOUR",9);
   11199             :                         if($2<0)
   11200             :                                 $2 = 9;
   11201          16 :                         $$ = 0x50000000|($2<<16); 
   11202           0 :                 }
   11203          16 :                 | _MINUTE opt_sub_label                         
   11204          16 :                 {
   11205          16 :                         if($2>9)
   11206             :                                 add_parse_error(970,"INTERVAL MINUTE",9);
   11207          16 :                         if($2<0)
   11208             :                                 $2 = 9;
   11209          25 :                         $$ = 0x60000000|($2<<16);
   11210           0 :                 }
   11211          25 :                 | _SECOND opt_sub_label2                                
   11212          23 :                 {
   11213          25 :                         if(($2>>16)>9)
   11214             :                                 add_parse_error(970,"INTERVAL SECOND",9);
   11215          25 :                         if(($2&0x0ffff)>6)
   11216             :                                 add_parse_error(971,"INTERVAL SECOND",6);     
   11217          27 :                         $$ = 0x70000000|($2);   
   11218           0 :                 }
   11219          27 :                 | _DAY  opt_sub_label TO _HOUR                  
   11220          26 :                 {
   11221          27 :                         if($2>7)
   11222             :                                 add_parse_error(970,"INTERVAL DAY TO HOUR",7);
   11223          27 :                         if($2<0)
   11224             :                                 $2 = 7;
   11225          21 :                         $$ = 0x80000000|($2<<16); 
   11226           0 :                 }
   11227          21 :                 | _DAY  opt_sub_label TO _MINUTE                        
   11228          21 :                 {
   11229          21 :                         if($2>6)
   11230             :                                 add_parse_error(970,"INTERVAL DAY TO MINUTE",6);
   11231          21 :                         if($2<0)
   11232             :                                 $2 = 6;
   11233          24 :                         $$ = 0x90000000|($2<<16); 
   11234           0 :                 }
   11235          24 :                 | _DAY  opt_sub_label TO _SECOND opt_sub_label                  
   11236          21 :                 {
   11237          24 :                         if($2>6)
   11238             :                                 add_parse_error(970,"INTERVAL DAY TO SECOND",7);
   11239          24 :                         if($2<0)
   11240             :                                 $2 = 6;
   11241          16 :                         if($5>6)
   11242           0 :                                 add_parse_error(971,"INTERVAL DAY TO SECOND",6);
   11243          16 :                         if($5<0)
   11244          16 :                                 $5 = 6;
   11245          16 :                         $$ = 0xa0000000|($2<<16)|$5;      
   11246             :                 }
   11247          16 :                 | _HOUR opt_sub_label TO _MINUTE                                
   11248             :                 {
   11249          30 :                         if($2>7)
   11250           0 :                                 add_parse_error(970,"INTERVAL HOUR TO MINUTE",7);
   11251          30 :                         if($2<0)
   11252           0 :                                 $2 = 7;
   11253          30 :                         $$ = 0xb0000000|($2<<16); 
   11254             :                 }
   11255          30 :                 | _HOUR opt_sub_label TO _SECOND opt_sub_label                  
   11256             :                 {
   11257          24 :                         if($2>7)
   11258           0 :                                 add_parse_error(970,"INTERVAL HOUR TO SECOND",7);
   11259          24 :                         if($2<0)
   11260          22 :                                 $2 = 7;
   11261          24 :                         if($5>6)
   11262             :                                 add_parse_error(971,"INTERVAL HOUR TO SECOND",6);
   11263          24 :                         if($5<0)
   11264             :                                 $5 = 6;
   11265          34 :                         $$ = 0xc0000000|($2<<16)|$5;      
   11266           0 :                 }
   11267          34 :                 | _MINUTE opt_sub_label TO _SECOND opt_sub_label                        
   11268          33 :                 {
   11269          34 :                         if($2>7)
   11270             :                                 add_parse_error(970,"INTERVAL MINUTE TO SECOND",7);
   11271          34 :                         if($2<0)
   11272             :                                 $2 = 7;
   11273          16 :                         if($5>6)
   11274           0 :                                 add_parse_error(971,"INTERVAL MINUTE TO SECOND",6);
   11275          16 :                         if($5<0)
   11276          16 :                                 $5 = 6;
   11277          16 :                         $$ = 0xd0000000|($2<<16)|$5;
   11278           0 :                 }
   11279          16 :                 ;
   11280          16 :                                                                         
   11281          16 : opt_sub_label:
   11282             :                 {
   11283          16 :                         $$ = -1;
   11284             :                 }
   11285         320 :                 | '(' ICONST ')'
   11286           0 :                 {
   11287         320 :                         if($2>10)
   11288         304 :                                 add_parse_error(961);
   11289         320 :                         $$ = $2;
   11290             :                 }
   11291         320 :                 ;       
   11292             :                 
   11293          16 : opt_sub_label2:
   11294           0 :                 {
   11295          16 :                         $$ = 0x90006;
   11296          16 :                 }
   11297          16 :                 | '(' ICONST ')'
   11298           0 :                 {
   11299          16 :                         if($2>12)
   11300          16 :                                 add_parse_error(961);   
   11301          16 :                         $$ = ($2<<16)|0x6;
   11302             :                 }
   11303          16 :                 | '(' ICONST ',' ICONST ')'
   11304             :                 {
   11305          42 :                         if($2>12 || $4>9)
   11306           0 :                                 add_parse_error(961);   
   11307          42 :                         $$ = (($2<<16)|$4);
   11308          40 :                 }
   11309          42 :                 ;       
   11310           0 :                                 
   11311          42 : sub_type: ANY                                           { $$ = ANY_SUBLINK; }
   11312          41 :                 | SOME                                          { $$ = ANY_SUBLINK; }
   11313          42 :                 | ALL                                           { $$ = ALL_SUBLINK; }
   11314             :                 ;
   11315          42 : 
   11316             : opt_match_type:
   11317             :                 {
   11318             :                         $$ = 0; 
   11319         810 :                 }
   11320             :                 |       UNIQUE 
   11321         810 :                 {
   11322             :                         $$ = 0x10000;
   11323          36 :                 }
   11324           0 :                 |       UNIQUE PARTIAL 
   11325          36 :                 {
   11326             :                         $$ = 0x10001;
   11327          36 :                 }
   11328             :                 |   UNIQUE FULL
   11329             :                 {
   11330             :                         $$ = 0x10002;
   11331          26 :                 } 
   11332             :                 |   PARTIAL
   11333          26 :                 {
   11334             :                         $$ = 1;
   11335           1 :                 } 
   11336           0 :                 |       FULL
   11337           1 :                 {
   11338             :                         $$ = 2;
   11339           1 :                 }
   11340             :                 ;
   11341           3 :                  
   11342           0 : ROp:      '<'                { $$ = (char*)"<"; }
   11343           3 :                 | '>'                { $$ = (char*)">"; }
   11344             :                 | '='           { $$ = (char*)"="; }
   11345           3 :                 | LE            { $$ = (char*)"<=";}
   11346             :                 | GE            { $$ = (char*)">=";}
   11347          29 :                 | NE            { $$ = (char*)"<>";}
   11348          29 :                 ;
   11349          16 :                 
   11350          19 : GeomROp:  CONTAINS      {$$ = (char*)"CONTAINS";}
   11351             :                 | WITHIN        { $$ = (char*)"WITHIN";}
   11352             :                 | TOUCHES       { $$ = (char*)"TOUCHS";}
   11353             :                 | DISJOINT      { $$ = (char*)"DISJOIN";}
   11354           0 :                 | OVERLAPS      { $$ = (char*)"OVERLAPS";}
   11355             :                 | CROSSES       { $$ = (char*)"CROSSES";}
   11356           0 :                 | INTERSECTS { $$ = (char*)"INTERSECTS";}
   11357             :                 | EQUALS        { $$ = (char*)"EQUALS";}
   11358           0 :                 | BCONTAINS     { $$ = (char*)"BCONTAINS";} 
   11359             :                 | BWITHIN       { $$ = (char*)"BWITHIN";} 
   11360           0 :                 | BINTERSECTS   { $$ = (char*)"BINTERSECTS";} 
   11361             :                 | BOVERLAPS     { $$ = (char*)"BOVERLAPS";} 
   11362           0 :                 | ABOVE         { $$ = (char*)"ABOVE";} 
   11363             :                 | UNDER         { $$ = (char*)"UNDER";} 
   11364           0 :                 | LEFTOF        { $$ = (char*)"LEFTOF";} 
   11365             :                 | RIGHTOF       { $$ = (char*)"RIGHTOF";} 
   11366           0 :                 | LOVERLAPS { $$ = (char*)"LOVERLAPS";} 
   11367             :                 | ROVERLAPS     { $$ = (char*)"ROVERLAPS";} 
   11368           0 :                 | AOVERLAPS { $$ = (char*)"AOVERLAPS";} 
   11369             :                 | UOVERLAPS     { $$ = (char*)"UOVERLAPS";} 
   11370           0 :                 ;
   11371             :                  
   11372           0 : bool_expr:      
   11373             :         rela_expr
   11374           0 :         {
   11375             :                 $$ = $1;                                
   11376           0 :                 SetNodePos($$);                         
   11377             :         }
   11378         169 :         | bool_expr1
   11379         169 :         {
   11380         291 :                 $$ = $1;                                
   11381        3847 :                 SetNodePos($$);
   11382          30 :         }                       
   11383          74 :         | bool_expr AND bool_expr
   11384         288 :         {       
   11385             :                 $$ = makeA_Expr(OP_AND, NULL, $1, $3); 
   11386           0 :                 SetNodePos($$);                         
   11387           0 :         }
   11388           0 :         | bool_expr OR bool_expr
   11389           0 :         {       
   11390           0 :                 $$ = makeA_Expr(OP_OR, NULL, $1, $3); 
   11391           0 :                 SetNodePos($$);                         
   11392           0 :         }
   11393           0 :         | NOT bool_expr
   11394           0 :         {       
   11395           0 :                 $$ = makeA_Expr(OP_NOT, NULL, NULL, $2); 
   11396           0 :                 SetNodePos($$);                         
   11397           0 :         }
   11398           0 :         | b_expr
   11399           0 :         {
   11400           0 :                 $$ = $1;        
   11401           0 :                 SetNodePos($$);
   11402           0 :         }                                               
   11403           0 :         ;
   11404           0 : bool_expr1:  
   11405           0 :         '(' bool_expr AND bool_expr ')'
   11406           0 :         {       
   11407             :                 $$ = makeA_Expr(OP_AND, NULL, $2, $4); 
   11408             :                 SetNodePos($$);                         
   11409             :         }
   11410             :         | '(' bool_expr OR bool_expr ')'
   11411        6500 :         {       
   11412        6500 :                 $$ = makeA_Expr(OP_OR, NULL, $2, $4); 
   11413             :                 SetNodePos($$);                         
   11414        6500 :         }
   11415             :         | '(' NOT bool_expr ')'
   11416         809 :         {       
   11417         809 :                 $$ = makeA_Expr(OP_NOT, NULL, NULL, $3); 
   11418             :                 SetNodePos($$);                         
   11419         809 :         }
   11420             :         | '(' bool_expr1 ')'
   11421        2463 :         {
   11422        2463 :                 $$ = $2;        
   11423             :                 SetNodePos($$);
   11424        2463 :         }       
   11425             :         ;                       
   11426         297 :                 
   11427         297 : rela_expr:
   11428             :         '(' rela_expr ')'
   11429         297 :         {
   11430             :                 $$ = $2;
   11431          77 :                 SetNodePos($$);
   11432          77 :         }
   11433             :         |  b_expr LIKE b_expr
   11434          77 :         {       
   11435             :                 $$ = makeA_Expr(OP, "LIKE", $1, $3); 
   11436          62 :                 SetNodePos($$);
   11437          62 :         }
   11438             :         |  b_expr _O_JOIN LIKE b_expr //why 2016-01-29 add
   11439          62 :         {       
   11440             :                 $$ = makeA_Expr(OP, "LIKE", $1, $4); 
   11441             :                 ((A_Expr*)$$)->ora_join = JOIN_RIGHT;
   11442         628 :                 SetNodePos($$);
   11443         628 :         }
   11444             :         | b_expr LIKE b_expr ESCAPE SCONST
   11445         628 :         {
   11446             :                 A_Const *n = makeNode(A_Const);
   11447         171 :                 n->val.type = T_String;
   11448         171 :                 n->val.val.str = $5;
   11449             :                 if( *(((char*)$5)+1)!=0)
   11450         171 :                         add_parse_error(962);
   11451             :                 $$ = makeA_Expr(OP, "LIKE", $1, $3);
   11452          10 :                 ((A_Expr*)$$)->tag = (Node*)n;
   11453          10 :                 SetNodePos($$);
   11454             :         }
   11455          10 :         | b_expr NOT LIKE b_expr
   11456             :         {       
   11457           0 :                 $$ = makeA_Expr(OP, "NOTLIKE", $1, $4); 
   11458           0 :                 SetNodePos($$);
   11459             :         }
   11460           0 :         | b_expr NOT LIKE b_expr ESCAPE SCONST
   11461             :         {
   11462             :                 A_Const *n = makeNode(A_Const);
   11463             :                 n->val.type = T_String;
   11464             :                 n->val.val.str = $6;
   11465         852 :                 if( *(((char*)$6)+1)!=0)
   11466         852 :                         add_parse_error(962);
   11467             :                 $$ = makeA_Expr(OP, "NOTLIKE", $1, $4);
   11468         852 :                 ((A_Expr*)$$)->tag = (Node*)n;
   11469             :                 SetNodePos($$);
   11470          34 :         }
   11471          34 :         | b_expr ILIKE b_expr
   11472             :         {       
   11473          34 :                 $$ = makeA_Expr(OP, "ILIKE", $1, $3); 
   11474             :                 SetNodePos($$);
   11475           0 :         }
   11476           0 :         | b_expr ILIKE b_expr ESCAPE SCONST
   11477           0 :         {
   11478             :                 A_Const *n = makeNode(A_Const);
   11479           0 :                 n->val.type = T_String;
   11480             :                 n->val.val.str = $5;
   11481          13 :                 if( *(((char*)$5)+1)!=0)
   11482          13 :                         add_parse_error(962);
   11483          13 :                 $$ = makeA_Expr(OP, "ILIKE", $1, $3);
   11484          13 :                 ((A_Expr*)$$)->tag = (Node*)n;
   11485           2 :                 SetNodePos($$);
   11486          13 :         }
   11487          13 :         | b_expr NOT ILIKE b_expr
   11488          13 :         {       
   11489             :                 $$ = makeA_Expr(OP, "NOTILIKE", $1, $4); 
   11490          13 :                 SetNodePos($$);
   11491             :         }
   11492          13 :         | b_expr NOT ILIKE b_expr ESCAPE SCONST
   11493          13 :         {
   11494             :                 A_Const *n = makeNode(A_Const);
   11495          13 :                 n->val.type = T_String;
   11496             :                 n->val.val.str = $6;
   11497           0 :                 if(*(((char*)$6)+1)!=0)
   11498           0 :                         add_parse_error(962);
   11499           0 :                 $$ = makeA_Expr(OP, "NOTILIKE", $1, $4);
   11500           0 :                 ((A_Expr*)$$)->tag = (Node*)n;
   11501           0 :                 SetNodePos($$);
   11502           0 :         }
   11503           0 :         | b_expr ISNULL
   11504           0 :         {       
   11505             :                 $$ = makeA_Expr(OP_ISNULL, NULL, $1, NULL); 
   11506           0 :                 SetNodePos($$);
   11507             :         }
   11508           0 :         | b_expr IS _NULL
   11509           0 :         {       
   11510             :                 $$ = makeA_Expr(OP_ISNULL, NULL, $1, NULL); 
   11511           0 :                 SetNodePos($$);
   11512             :         }
   11513           0 :         | b_expr NOTNULL
   11514           0 :         {       
   11515           0 :                 $$ = makeA_Expr(OP_NOTNULL, NULL, $1, NULL); 
   11516           0 :                 SetNodePos($$);
   11517           0 :         }
   11518           0 :         | b_expr IS NOT _NULL
   11519           0 :         {       
   11520           0 :                 $$ = makeA_Expr(OP_NOTNULL, NULL, $1, NULL); 
   11521             :                 SetNodePos($$);
   11522           0 :         }
   11523             :         | b_expr IS _TRUE
   11524           0 :         {
   11525           0 :                 A_Const *n = makeNode(A_Const);
   11526             :                 n->val.type = T_Boolean;
   11527           0 :                 n->val.val.bval = TRUE;
   11528             :                 n->type_name = "BOOLEAN";
   11529           0 :                 n->preci_scale = -1;
   11530           0 :                 $$ = makeA_Expr(OP, "=", $1,(Node *)n);
   11531           0 :                 SetNodePos($$);
   11532           0 :         }
   11533           0 :         | b_expr IS NOT _TRUE
   11534           0 :         {
   11535           0 :                 A_Const *n = makeNode(A_Const);
   11536           0 :                 n->val.type = T_Boolean;
   11537             :                 n->val.val.bval = TRUE;
   11538           0 :                 n->type_name = "BOOLEAN";
   11539             :                 n->preci_scale = -1;
   11540          44 :                 $$ = makeA_Expr(OP, "<>", $1,(Node *)n);
   11541          44 :                 SetNodePos($$);
   11542             :         }
   11543          44 :         | b_expr IS _FALSE
   11544             :         {
   11545         415 :                 A_Const *n = makeNode(A_Const);
   11546         415 :                 n->val.type = T_Boolean;
   11547             :                 n->val.val.bval = FALSE;
   11548         415 :                 n->type_name = "BOOLEAN";
   11549             :                 n->preci_scale = -1;
   11550         621 :                 $$ = makeA_Expr(OP, "=", $1,(Node *)n);
   11551         621 :                 SetNodePos($$);
   11552             :         }
   11553         621 :         | b_expr IS NOT _FALSE
   11554             :         {
   11555         279 :                 A_Const *n = makeNode(A_Const);
   11556         279 :                 n->val.type = T_Boolean;
   11557             :                 n->val.val.bval = FALSE;
   11558         279 :                 n->type_name = "BOOLEAN";
   11559             :                 n->preci_scale = -1;
   11560           0 :                 $$ = makeA_Expr(OP, "<>", $1,(Node *)n);
   11561           0 :                 SetNodePos($$);
   11562           0 :         }
   11563           0 :         /*why 2015-12-22 modify old:
   11564           0 :         | b_expr BETWEEN b_expr AND b_expr       %prec BETWEEN
   11565           0 :         {
   11566           0 :                 $$ = makeA_Expr(OP_AND, NULL,
   11567             :                         makeA_Expr(OP, ">=", $1, $3),
   11568           0 :                         makeA_Expr(OP, "<=", $1, $5));
   11569             :                 SetNodePos($$);
   11570           0 :         }
   11571           0 :         | b_expr NOT BETWEEN b_expr AND b_expr  %prec BETWEEN
   11572           0 :         {
   11573           0 :                 $$ = makeA_Expr(OP_OR, NULL,
   11574           0 :                         makeA_Expr(OP, "<", $1, $4),
   11575           0 :                         makeA_Expr(OP, ">", $1, $6));
   11576           0 :                 SetNodePos($$);
   11577             :         }
   11578           0 :         */
   11579             :         | b_expr BETWEEN b_expr AND b_expr       %prec BETWEEN
   11580           0 :         {
   11581           0 :                 BetweenExpr * n = makeNode(BetweenExpr);
   11582           0 :                 n->is_not    = false;
   11583           0 :                 n->expr      = $1;
   11584           0 :                 n->low_expr  = $3;
   11585           0 :                 n->high_expr = $5; 
   11586           0 :                 $$ = (Node *)n;         
   11587             :                 SetNodePos($$);
   11588           0 :         }
   11589             :         | b_expr NOT BETWEEN b_expr AND b_expr  %prec BETWEEN
   11590           0 :         {
   11591           0 :                 BetweenExpr * n = makeNode(BetweenExpr);
   11592           0 :                 n->is_not    = true;
   11593           0 :                 n->expr      = $1;
   11594           0 :                 n->low_expr  = $4;
   11595           0 :                 n->high_expr = $6; 
   11596           0 :                 $$ = (Node *)n;
   11597             :                 SetNodePos($$);
   11598           0 :         }
   11599             :         | b_expr _IN  select_with_parens
   11600             :         {
   11601             :                 SubLink *n = makeNode(SubLink);
   11602             :                 n->sub_select = $3;
   11603             :                 n->left_exprs = makeList1($1);
   11604             :                 n->oper = "=";
   11605             :                 n->sublk_t = ANY_SUBLINK;
   11606             :                 $$ = (Node *)n;         
   11607             :                 SetNodePos($$);
   11608             :         }
   11609             :         | b_expr _IN  '(' expr_list ')'
   11610             :         {
   11611             :                 if(length((List*)$4)<=1)
   11612             :                         $$ = makeA_Expr(OP, "=", $1, (Node*)lptr((List*)$4));
   11613             :                 else
   11614             :                 {
   11615             :                         InExpr *p_in = makeNode(InExpr);
   11616         116 :                         p_in->left_expr = $1;
   11617         116 :                         p_in->val_list = (List*)$4;
   11618         116 :                         $$ = (Node*)p_in;
   11619         116 :                 }
   11620         116 :                 SetNodePos($$);
   11621         116 :         }
   11622         116 :         | b_expr _IN  in_expr  //++bywsy@20210306 bug3597
   11623             :         {
   11624         116 :                         $$ = makeA_Expr(OP, "=", $1, $3); 
   11625             :                         SetNodePos($$);
   11626          12 :         }
   11627          12 :         | b_expr NOT _IN  select_with_parens
   11628          12 :         {
   11629          12 :                 SubLink *n = makeNode(SubLink);
   11630          12 :                 n->sub_select = $4;
   11631          12 :                 n->left_exprs = makeList1($1);
   11632          12 :                 n->oper = "<>";
   11633             :                 n->sublk_t = ALL_SUBLINK;
   11634          12 :                 $$ = (Node *)n;
   11635             :                 SetNodePos($$);
   11636          43 :         }
   11637          43 :         
   11638          43 :         | b_expr NOT _IN '(' expr_list ')'
   11639          43 :         {
   11640          43 :                 Node *n = NULL;
   11641          43 :                 if(length((List*)$5)==1)
   11642          43 :                         $$ = makeA_Expr(OP, "<>", $1, (Node*)lptr((List*)$5));
   11643             :                 else
   11644          43 :                 {
   11645             :                         InExpr *p_in = makeNode(InExpr);
   11646          38 :                         p_in->is_not_in = true;
   11647           0 :                         p_in->left_expr = $1;
   11648             :                         p_in->val_list = (List*)$5;
   11649             :                         $$ = (Node*)p_in;
   11650          38 :                 }
   11651          38 :                 SetNodePos($$);                         
   11652          38 :         }
   11653          38 :         | b_expr NOT _IN  in_expr  //++bywsy@20210306 bug3597
   11654             :         {
   11655          38 :                 $$ = makeA_Expr(OP, "<>", $1, $4); 
   11656             :                 SetNodePos($$);
   11657          38 :         }
   11658             :         | b_expr ROp sub_type select_with_parens                //%prec ROp
   11659           0 :         {
   11660           0 :                 SubLink *n = makeNode(SubLink);
   11661             :                 n->left_exprs = makeList1($1);
   11662           0 :                 n->oper = $2;
   11663             :                 n->sublk_t = (SubLkT)$3;
   11664           6 :                 n->sub_select = $4;
   11665           6 :                 $$ = (Node *)n;
   11666           6 :                 SetNodePos($$);
   11667           6 :         }
   11668           6 :         | EXISTS select_with_parens
   11669           6 :         {
   11670           6 :                 SubLink *n = makeNode(SubLink);
   11671             :                 n->left_exprs = NIL;
   11672           6 :                 n->oper = NULL;
   11673             :                 n->sublk_t = EXISTS_SUBLINK;
   11674             :                 n->sub_select = $2;
   11675          24 :                 $$ = (Node *)n;
   11676          24 :                 SetNodePos($$);
   11677           0 :         }
   11678             :         | UNIQUE select_with_parens
   11679             :         {
   11680          24 :                 SubLink *n = makeNode(SubLink);
   11681          24 :                 n->left_exprs = NIL;
   11682          24 :                 n->oper = NULL;
   11683          24 :                 n->sublk_t = UNIQUE_SUBLINK;
   11684          24 :                 n->sub_select = $2;
   11685             :                 $$ = (Node *)n;
   11686          24 :                 SetNodePos($$);
   11687             :         }
   11688          24 :         | b_expr ROp b_expr
   11689             :         {
   11690           0 :                 if(exprIsNullConstant($1) || exprIsNullConstant($3))
   11691           0 :                 {
   11692             :                         A_Const *n = makeNode(A_Const);
   11693           0 :                         n->val.type = T_Boolean;
   11694             :                         n->val.val.bval = -1;
   11695          64 :                         n->type_name = "BOOLEAN";
   11696          64 :                         n->preci_scale = -1;
   11697          64 :                         $$ = (Node*)n;
   11698          64 :                 }
   11699          64 :                 else if(!strcmp($2,">"))
   11700          64 :                 {
   11701          64 :                         if( exprIsGeoOp($1) && IsA($3,A_Const))
   11702             :                         {
   11703          64 :                                 if( getConstVal($3) > 0 )
   11704             :                                 {
   11705         140 :                                         $$ = makeA_Expr(OP_NOT,NULL,NULL,$1);
   11706         140 :                                 }
   11707         140 :                                 else
   11708         140 :                                         $$ = $1;    
   11709         140 :                         }
   11710         140 :                         else if(exprIsGeoOp($3) && IsA($1,A_Const))
   11711         140 :                         {
   11712             :                                 if(getConstVal($1)==0)
   11713         140 :                                 {
   11714             :                                         $$ = makeA_Expr ( NOT, NULL, NULL, $3 );
   11715           2 :                                 }
   11716           2 :                                 else
   11717           2 :                                         $$ = $1;    
   11718           2 :                         }
   11719           2 :                         else
   11720           2 :                                 $$ = makeA_Expr(OP, $2, $1, $3);                        
   11721           2 :                 }
   11722             :                 else if(!strcmp($2,"="))
   11723           2 :                 {                                        
   11724             :                         if ( exprIsGeoOp($1) && IsA($3,A_Const))
   11725        4635 :                         {
   11726             :                                 if ( getConstVal($3) == 0 )
   11727           0 :                                 {
   11728           0 :                                         $$ = makeA_Expr(OP_NOT,NULL,NULL,$1);
   11729           0 :                                 }
   11730           0 :                                 else
   11731           0 :                                         $$ = $1;    
   11732           0 :                         }
   11733             :                         else if(exprIsGeoOp($3) && IsA($1,A_Const))
   11734        4635 :                         {
   11735             :                                 if(getConstVal($1)==0)
   11736         286 :                                 {
   11737             :                                         $$ = makeA_Expr ( NOT, NULL, NULL, $3 );
   11738           0 :                                 }
   11739             :                                 else
   11740           0 :                                         $$ = $1;    
   11741             :                         }
   11742             :                         else
   11743           0 :                                 $$ = makeA_Expr(OP, "=", $1, $3);
   11744             :                 }
   11745         286 :                 else
   11746             :                         $$ = makeA_Expr(OP, $2, $1, $3); 
   11747           0 :                 SetNodePos($$);
   11748             :         }
   11749           0 :         | b_expr GeomROp b_expr
   11750             :         {
   11751             :                 $$ = makeA_Expr(OP, $2, $1, $3); 
   11752           0 :                 SetNodePos($$);
   11753             :         }
   11754             :         | b_expr ROp b_expr _O_JOIN
   11755         286 :         {
   11756             :                 $$ = makeA_Expr(OP,$2,$1,$3);
   11757        4349 :                 ((A_Expr*)$$)->ora_join = JOIN_LEFT;
   11758             :                 SetNodePos($$);
   11759        3828 :         }
   11760             :         | b_expr _O_JOIN ROp b_expr 
   11761           0 :         {
   11762             :                 $$ = makeA_Expr(OP,$3,$1,$4);
   11763           0 :                 ((A_Expr*)$$)->ora_join = JOIN_RIGHT;
   11764             :                 SetNodePos($$);
   11765             :         }       
   11766           0 :         | '(' expr_vector ')' _IN select_with_parens
   11767             :         {
   11768        3828 :                 SubLink *n = makeNode(SubLink);
   11769             :                 n->left_exprs = $2;
   11770           0 :                 n->oper = "=";
   11771             :                 n->sublk_t = ANY_SUBLINK;
   11772           0 :                 n->sub_select = $5;
   11773             :                 $$ = (Node *)n;
   11774             :                 SetNodePos($$);
   11775           0 :         }
   11776             :         | '(' expr_vector ')' _IN '(' vector_values ')'
   11777             :         {
   11778        3828 :                 VInExpr *n = makeNode(VInExpr);
   11779             :                 n->left_exprs = $2;
   11780             :                 n->vector_values = $6;
   11781         521 :                 $$ = (Node*)n;
   11782        4635 :                 SetNodePos($$);
   11783             :         }
   11784        4635 :         | '(' expr_vector ')' NOT _IN select_with_parens
   11785             :         {
   11786           0 :                 SubLink *n = makeNode(SubLink);
   11787           0 :                 n->left_exprs = $2;
   11788             :                 n->oper = "<>";
   11789           0 :                 n->sublk_t = ALL_SUBLINK;
   11790             :                 n->sub_select = $6;
   11791           0 :                 $$ = (Node *)n;
   11792           0 :                 SetNodePos($$);
   11793           0 :         }
   11794             :         | '(' expr_vector ')' NOT _IN '(' vector_values ')'
   11795           0 :         {
   11796             :                 VInExpr *n = makeNode(VInExpr);
   11797           0 :                 n->left_exprs = $2;
   11798           0 :                 n->is_not_in = true;
   11799           0 :                 n->vector_values = $7;
   11800             :                 $$ = (Node*)n;
   11801           0 :                 SetNodePos($$);
   11802             :         }
   11803           0 :         | '(' expr_vector ')' ROp sub_type select_with_parens
   11804           0 :         {
   11805           0 :                 SubLink *n = makeNode(SubLink);
   11806           0 :                 n->left_exprs = $2;
   11807           0 :                 n->oper = $4;
   11808           0 :                 n->sublk_t = (SubLkT)$5;
   11809           0 :                 n->sub_select = $6;
   11810             :                 $$ = (Node *)n;
   11811           0 :                 SetNodePos($$);
   11812             :         }
   11813           0 :         | '(' expr_vector ')' ROp select_with_parens
   11814           0 :         {
   11815           0 :                 SubLink *n = makeNode(SubLink);
   11816           0 :                 n->left_exprs = $2;
   11817           0 :                 n->oper = $4;
   11818             :                 n->sublk_t = MULTIEXPR_SUBLINK;
   11819           0 :                 n->sub_select = $5;
   11820             :                 $$ = (Node *)n;
   11821           0 :                 SetNodePos($$);
   11822           0 :         }
   11823           0 :         | '(' expr_vector ')' MATCH opt_match_type select_with_parens
   11824           0 :         {
   11825           0 :                 SubLink *n = makeNode(SubLink);
   11826           0 :                 n->left_exprs = $2;
   11827           0 :                 n->oper = NULL;
   11828             :                 n->sublk_t = MATCH_SUBLINK;
   11829           0 :                 n->match_type = $5;
   11830             :                 n->sub_select = $6;
   11831           0 :                 $$ = (Node *)n;
   11832           0 :                 SetNodePos($$);
   11833           0 :         }
   11834           0 :         | '(' expr_vector ')' ROp '(' expr_list ')'
   11835           0 :         {
   11836           0 :                 SetParsePos();
   11837             :                 $$ = makeRowExpr($4, $2, $6);
   11838           0 :                 SetNodePos($$);
   11839             :         }
   11840           0 :         | '(' expr_vector ')' ISNULL
   11841           0 :         {
   11842           0 :                 SetParsePos();
   11843           0 :                 $$ = makeRowIsNull($2);
   11844           0 :                 SetNodePos($$);
   11845           0 :         }       
   11846           0 :         | '(' expr_vector ')' IS _NULL
   11847             :         {
   11848           0 :                 SetParsePos();
   11849             :                 $$ = makeRowIsNull($2);
   11850           0 :                 SetNodePos($$);
   11851           0 :         }       
   11852           0 :         | '(' expr_vector ')' IS NOT _NULL
   11853           0 :         {
   11854           0 :                 SetParsePos();
   11855           0 :                 $$ = makeRowNotNull($2);
   11856           0 :                 SetNodePos($$);
   11857             :         }       
   11858           0 :         | '(' expr_vector ')' NOTNULL
   11859             :         {
   11860           0 :                 SetParsePos();
   11861           0 :                 $$ = makeRowNotNull($2);
   11862           0 :                 SetNodePos($$);
   11863           0 :         }                                                       
   11864           0 :         | '(' expr_vector ')' OVERLAPS '(' expr_vector ')'
   11865           0 :         {
   11866           0 :                 Ident *n = makeNode(Ident);
   11867           0 :                 Ident *n1 = makeNode(Ident);
   11868             :                 List *largs = $2;
   11869           0 :                 List *rargs = $6;
   11870             :                 n1->ident_t = IDENT_FUNC;
   11871           0 :                 n->name = "OVERLAPS";
   11872           0 :                 if (length(largs) == 1)
   11873           0 :                         largs = lappend(largs, $2);
   11874             :                 else if (length(largs) != 2)
   11875           0 :                 {
   11876             :                         SetParsePos();
   11877           0 :                         add_parse_error(151);
   11878           0 :                 }
   11879           0 :                 if (length(rargs) == 1)
   11880             :                         rargs = lappend(rargs, $6);
   11881           0 :                 else if (length(rargs) != 2)
   11882             :                 {
   11883           0 :                         SetParsePos();
   11884           0 :                         add_parse_error(152);
   11885           0 :                 }
   11886             :                 n1->args = lconc(largs, rargs);
   11887           0 :                 n1->agg_star = false;
   11888             :                 n1->agg_distinct = false;
   11889           0 :                 set_ident_child(n,n1);
   11890           0 :                 $$ = (Node *)n;
   11891           0 :                 SetNodePos($$);
   11892             :         }
   11893           0 :         ;
   11894             :                         
   11895           0 : expr_vector:  b_expr ',' b_expr
   11896           0 :                 {
   11897           0 :                         $$ = makeList2($1,$3);
   11898             :                 }
   11899           0 :                 |  expr_vector ',' b_expr
   11900             :                 {
   11901           1 :                         $$ = lappend($1,$3);
   11902           1 :                 }
   11903           1 :                 ;       
   11904           1 :                         
   11905           1 : vector_values: '(' expr_vector ')'
   11906           1 :                 {
   11907           1 :                         $$ = makeList1($2);
   11908           0 :                 }
   11909           1 :                 | vector_values ',' '(' expr_vector ')'
   11910             :                 {
   11911           0 :                    $$ = lappend($1,$4);
   11912           0 :                 } 
   11913             :                 ;
   11914           1 :                         
   11915           0 : b_expr:  c_expr
   11916           1 :                 {
   11917             :                         $$ = $1;
   11918           0 :                 }
   11919           0 :                 | PRIOR c_expr
   11920             :                 {
   11921           1 :                         PriorExpr *n = makeNode(PriorExpr);
   11922           1 :                         n->bexpr = (Node*)$2;
   11923           1 :                         $$ = (Node*)n;
   11924           1 :                 }
   11925           1 :             /*  mzh
   11926           1 :                 | c_expr opt_interval                   
   11927             :                 {
   11928           1 :                         if(!IsA($1,A_Expr))
   11929             :                                 add_parse_error(90);
   11930             :                         else
   11931             :                         {       
   11932           2 :                                 Typenam *p_typenam = makeNode(Typenam);
   11933             :                                 p_typenam->type_name = interval_names[(((uint)$2)>>28)-1];
   11934           2 :                                 p_typenam->preci_scale = ($2 & 0x0fffffff);
   11935             :                                 $$ = makeTypeCast($1, p_typenam); 
   11936           0 :                                 SetNodePos($$);
   11937             :                         }
   11938           0 :                 }
   11939             :             */
   11940             :                 | c_expr TYPECAST STypename1            
   11941             :                 {       
   11942           0 :                         $$ = makeTypeCast($1, (Typenam*) $3); 
   11943             :                         SetNodePos($$);
   11944           0 :                 }
   11945             :                 | b_expr AT TIME ZONE c_expr
   11946           0 :                 {
   11947             :                         Ident *n = makeNode(Ident);
   11948           0 :                         Ident *n1 = makeNode(Ident);
   11949             :                         n->name = "TIMEZONE";
   11950             :                         n1->args = makeList2($5, $1);
   11951             :                         n1->agg_star = false;
   11952       66677 :                         n1->agg_distinct = false;
   11953             :                         n1->ident_t = IDENT_FUNC;
   11954       66677 :                         set_ident_child(n,n1);
   11955             :                         $$ = (Node *)n;
   11956           0 :                         SetNodePos($$);
   11957           0 :                 }
   11958           0 :                 | b_expr '+' b_expr
   11959             :                 {       
   11960           0 :                         $$ = makeA_Expr(OP, "+", $1, $3); 
   11961             :                         SetNodePos($$);
   11962             :                 }
   11963             :                 | b_expr '-' b_expr
   11964             :                 {       
   11965             :                         $$ = makeA_Expr(OP, "-", $1, $3); 
   11966             :                         SetNodePos($$);
   11967             :                 }
   11968             :                 | b_expr '*' b_expr
   11969             :                 {       
   11970             :                         $$ = makeA_Expr(OP, "*", $1, $3); 
   11971             :                         SetNodePos($$);
   11972             :                 }
   11973             :                 | b_expr '/' b_expr
   11974             :                 {       
   11975             :                         $$ = makeA_Expr(OP, "/", $1, $3); 
   11976             :                         SetNodePos($$);
   11977          61 :                 }
   11978          61 :                 | b_expr '^' b_expr
   11979             :                 {
   11980          61 :                         $$ = makeA_Expr(OP, "^", $1, $3);
   11981             :                         SetNodePos($$);
   11982           0 :                 }
   11983           0 :                 | b_expr '|' b_expr
   11984           0 :                 {
   11985           0 :                         $$ = makeA_Expr(OP, "|", $1, $3);
   11986           0 :                         SetNodePos($$);
   11987           0 :                 }
   11988           0 :                 | b_expr Op b_expr
   11989           0 :                 {
   11990           0 :                         $$ = makeA_Expr(OP, $2, $1, $3);
   11991           0 :                         SetNodePos($$);
   11992             :                 }               
   11993           0 :                 ;
   11994             : 
   11995         383 : c_expr:  '(' b_expr ')'
   11996         383 :                 {
   11997             :                         $$ = $2;
   11998         383 :                 }
   11999             :                 | CONTAINS '(' b_expr ','b_expr  ')'
   12000          62 :                 {
   12001          62 :                         A_Expr *p_expr = (A_Expr*)makeA_Expr(OP,"CONTAINS",$3,$5);
   12002             :                         $$ = (Node*)p_expr;
   12003          62 :                         SetNodePos($$);
   12004             :                 }
   12005         115 :                 | CONTAINS '(' b_expr ','b_expr ',' AexprConst ')'
   12006         115 :                 {
   12007             :                         A_Expr *p_expr = (A_Expr*)makeA_Expr(OP,"CONTAINS",$3,$5);
   12008         115 :                         p_expr->tag = (Node*)$7;
   12009             :                         $$ = (Node*)p_expr;
   12010          88 :                         SetNodePos($$);
   12011          88 :                 }               
   12012             :                 | GeomROp  '(' b_expr ',' b_expr ')'
   12013          88 :                 {       
   12014             :                         $$ = makeA_Expr(OP,$1,$3,$5);
   12015           0 :                         SetNodePos($$);
   12016           0 :                 }
   12017             :                 | Op c_expr
   12018           0 :                 {
   12019             :                         $$ = makeA_Expr(OP, $1, NULL, $2);
   12020           0 :                         SetNodePos($$);
   12021           0 :                 }
   12022             :                 | '+' c_expr
   12023           0 :                 {
   12024             :                         $$ = $2;
   12025         190 :                         SetNodePos($$);
   12026         190 :                 }
   12027             :                 | '-' c_expr
   12028         190 :                 {
   12029             :                         $$ = makeA_Expr(OP, "-", NULL, $2);
   12030             :                         SetNodePos($$);
   12031             :                 }
   12032        1106 :                 | '~' c_expr
   12033             :                 {
   12034        1106 :                         $$ = makeA_Expr(OP, "~", NULL, $2);
   12035             :                         SetNodePos($$);
   12036           0 :                 }                                                               
   12037           0 :                 | ident  
   12038           0 :                 {       
   12039             :                         $$ = (Node *) $1;
   12040           0 :                         SetNodePos($$);  
   12041             :                 }
   12042           0 :                 | Param
   12043           0 :                 {
   12044           0 :                         $$ = (Node *) $1;
   12045           0 :                         SetNodePos($$);  
   12046             :                 }       
   12047           0 :                 | AexprConst
   12048             :                 {       $$ = $1;  }
   12049           0 :                 | CAST '(' b_expr AS STypename ')'
   12050           0 :                 {       
   12051             :                         $$ = makeTypeCast($3, (Typenam*)$5); 
   12052           0 :                         SetNodePos($$);
   12053             :                 }
   12054           0 :                 | case_expr
   12055           0 :                 {       $$ = $1; }
   12056             :                 | USER
   12057           0 :                 {
   12058             :                         Ident *n = makeNode(Ident);
   12059          10 :                         n->name = "CURRENT_USER";
   12060          10 :                         n->args = NIL;
   12061             :                         n->agg_star = false;
   12062          10 :                         n->agg_distinct = false;
   12063             :                         $$ = (Node *)n;
   12064         528 :                         SetNodePos($$);
   12065         528 :                 }                       
   12066             :                 | select_with_parens  %prec UMINUS
   12067         528 :                 {
   12068             :                         SubLink *n = makeNode(SubLink);
   12069           0 :                         n->left_exprs = NIL;
   12070           0 :                         n->oper = NULL;
   12071             :                         n->sublk_t = EXPR_SUBLINK;
   12072           0 :                         n->sub_select = $1;
   12073             :                         $$ = (Node *)n;
   12074       14620 :                         SetNodePos($$);
   12075       14620 :                 }
   12076             :                 | LEAST '(' expr_list ')'
   12077       14620 :                 {
   12078             :                         LeastExpr *n = makeNode(LeastExpr);
   12079           3 :                         n->args = $3;
   12080           3 :                         $$ = (Node*)n;
   12081             :                         SetNodePos($$);
   12082           3 :                 }
   12083       50273 :                 | GREATEST '(' expr_list ')'
   12084       50273 :                 {
   12085             :                         GreatestExpr *n = makeNode(GreatestExpr);
   12086         139 :                         n->args = $3;
   12087         139 :                         $$ = (Node*)n;
   12088             :                         SetNodePos($$);
   12089         139 :                 }               
   12090          26 :                 | error
   12091          26 :                 {
   12092             :                         Ident *n = makeNode(Ident);
   12093         268 :                         n->name = "@Error@";
   12094         268 :                         n->args = NIL;
   12095         268 :                         n->agg_star = false;
   12096         268 :                         n->agg_distinct = false;
   12097         268 :                         $$ = (Node *)n;
   12098         268 :                         SetNodePos($$);
   12099         268 :                 }       
   12100             :                 |  ident OVER '('  opt_win_parti opt_win_order opt_win_range ')'
   12101         268 :                 {
   12102             :                         WindowExpr *n = makeNode(WindowExpr);
   12103         305 :                         n->p_ident = $1;
   12104         305 :                         n->parti_list = $4;
   12105         305 :                         n->order_list = $5;
   12106         305 :                         if($6)
   12107         305 :                         {
   12108         305 :                                 WindowExpr *n1 = (WindowExpr*)$6;
   12109         305 :                                 n->range_type = n1->range_type;
   12110             :                                 n->wind_lo_off = n1->wind_lo_off;
   12111         305 :                                 n->wind_hi_off = n1->wind_hi_off;
   12112             :                                 n->wind_lo_val = n1->wind_lo_val;
   12113           0 :                                 n->wind_hi_val = n1->wind_hi_val;
   12114           0 :                         }
   12115           0 :                         $$ = (Node*)n;
   12116           0 :                         SetNodePos($$);
   12117             :                 }
   12118           0 :                 | ident '%' ROWCOUNT
   12119             :                 {
   12120           0 :                         IdentAttr *n = makeNode(IdentAttr);
   12121           0 :                         n->p_ident = (Ident*)$1;
   12122           0 :                         n->attr_name = "ROWCOUNT";
   12123           0 :                         $$ = (Node*)n;
   12124             :                         SetNodePos($$);
   12125           0 :                 }
   12126             :                 | ident '%' FOUND
   12127           0 :                 {
   12128           0 :                         IdentAttr *n = makeNode(IdentAttr);
   12129           0 :                         n->p_ident = (Ident*)$1;
   12130           0 :                         n->attr_name = "FOUND";
   12131           0 :                         $$ = (Node*)n;
   12132           0 :                         SetNodePos($$);
   12133           0 :                 }
   12134             :                 | ident '%' NOFOUND
   12135           0 :                 {
   12136             :                         IdentAttr *n = makeNode(IdentAttr);
   12137           0 :                         n->p_ident = (Ident*)$1;
   12138           0 :                         n->attr_name = "NOFOUND";
   12139           0 :                         $$ = (Node*)n;
   12140           0 :                         SetNodePos($$);
   12141           0 :                 }
   12142             :                 | ident '%' NOTFOUND
   12143           0 :                 {
   12144           0 :                         IdentAttr *n = makeNode(IdentAttr);
   12145           0 :                         n->p_ident = (Ident*)$1;
   12146           0 :                         n->attr_name = "NOFOUND";
   12147           0 :                         $$ = (Node*)n;
   12148           0 :                         SetNodePos($$);
   12149             :                 }
   12150           0 :                 | ident '%' ISOPEN
   12151           0 :                 {
   12152             :                         IdentAttr *n = makeNode(IdentAttr);
   12153           0 :                         n->p_ident = (Ident*)$1;
   12154             :                         n->attr_name = "ISOPEN";
   12155           0 :                         $$ = (Node*)n;
   12156           0 :                         SetNodePos($$);
   12157           0 :                 }               
   12158           0 :                 ;
   12159           0 :                 
   12160             : opt_win_parti: /*empty*/
   12161           0 :                 {
   12162             :                         $$ = NIL;
   12163           0 :                 }
   12164           0 :                 |       PARTITION BY expr_list 
   12165           0 :                 {
   12166           0 :                         $$ = $3;
   12167           0 :                 }
   12168             :                 ;       
   12169           0 : 
   12170             : opt_win_order: /*empty*/
   12171           0 :                 {
   12172           0 :                         $$ = NIL;
   12173           0 :                 }
   12174           0 :                 | ORDER BY sortby_list  
   12175           0 :                 {
   12176             :                         $$ = $3;
   12177           0 :                 }
   12178             :                 ;
   12179           0 : 
   12180           0 : opt_win_range: /*empty*/
   12181           0 :                 {
   12182           0 :                         $$ = NULL;
   12183           0 :                 }
   12184             :                 | ROWS window_extent
   12185           0 :                 {
   12186             :                     WindowExpr *n = (WindowExpr *)$2;
   12187           0 :                         n->range_type |= FRAMEOPTION_ROWS;
   12188           0 :                     $$ = (Node*)n;
   12189           0 :                     SetNodePos($$);
   12190           0 :                 }
   12191           0 :                 | RANGE window_extent
   12192             :                 {
   12193           0 :                         WindowExpr *n = (WindowExpr *)$2;
   12194             :                     n->range_type |= FRAMEOPTION_RANGE;
   12195             :                     $$ = (Node*)n;
   12196             :                     SetNodePos($$);
   12197           0 :                 }
   12198             :                 ;
   12199           0 : 
   12200             : window_extent:row_range
   12201           0 :                 {
   12202             :                         WindowExpr *n = (WindowExpr *)$1;
   12203           0 :                         if (n->range_type & FRAMEOPTION_START_UNBOUNDED_FOLLOWING)
   12204             :                                 add_parse_error(1232);
   12205             :                         if (n->range_type & FRAMEOPTION_START_OFFSET_FOLLOWING)
   12206             :                                 add_parse_error(1232);
   12207           0 :                         n->range_type |= FRAMEOPTION_END_CURRENT_ROW;
   12208             :                         $$ = (Node*)n;
   12209           0 :                 }
   12210             :                 | BETWEEN row_range AND row_range
   12211           0 :                 {
   12212             :                         WindowExpr *n1 = (WindowExpr *)$2;
   12213           0 :                         WindowExpr *n2 = (WindowExpr *)$4;
   12214             :                         int n1_type = n1->range_type;
   12215             :                         int n2_type = n2->range_type << 1;
   12216             :                         int n_type  = n1_type | n2_type;
   12217           0 :                         if(n_type & FRAMEOPTION_START_UNBOUNDED_FOLLOWING)
   12218             :                                 add_parse_error(1232);
   12219           0 :                         if(n_type & FRAMEOPTION_START_UNBOUNDED_FOLLOWING)
   12220             :                                 add_parse_error(1232);
   12221           0 :                         if ((n_type & FRAMEOPTION_START_CURRENT_ROW) &&
   12222           0 :                                 (n_type & FRAMEOPTION_END_OFFSET_PRECEDING))
   12223           0 :                                 add_parse_error(1232);
   12224           0 :                         if ((n_type & FRAMEOPTION_START_OFFSET_FOLLOWING) &&
   12225             :                                 (n_type & (FRAMEOPTION_END_OFFSET_PRECEDING | FRAMEOPTION_END_CURRENT_ROW | FRAMEOPTION_END_UNBOUNDED_PRECEDING)))
   12226           0 :                                 add_parse_error(1232);
   12227             :                         n1->wind_hi_off = n2->wind_lo_off;
   12228           0 :                         n1->wind_hi_val = n2->wind_lo_val;
   12229           0 :                         n1->range_type |= (n1_type | n2_type | FRAMEOPTION_BETWEEN);
   12230           0 :                         $$ = (Node*)n1;
   12231           0 :                 }
   12232             :                 ;
   12233           0 : 
   12234             : row_range:UNBOUNDED PRECEDING
   12235             :                 {
   12236             :                         WindowExpr *n = makeNode(WindowExpr);
   12237           0 :                         n->range_type= FRAMEOPTION_START_UNBOUNDED_PRECEDING;
   12238           0 :                     n->wind_lo_off = (0-0x7fffffff);
   12239           0 :                     n->wind_hi_off = 0;
   12240           0 :                         n->wind_lo_val = NULL;
   12241           0 :                     n->wind_hi_val = NULL;
   12242           0 :                         $$ = (Node*)n;
   12243           0 :                 }
   12244             :                 | UNBOUNDED FOLLOWING
   12245           0 :                 {
   12246             :                         WindowExpr *n = makeNode(WindowExpr);
   12247           0 :                         n->range_type= FRAMEOPTION_START_UNBOUNDED_FOLLOWING;
   12248           0 :                     n->wind_lo_off = 0x7fffffff;
   12249           0 :                     n->wind_hi_off = 0;
   12250           0 :                         n->wind_lo_val = NULL;
   12251           0 :                     n->wind_hi_val = NULL;
   12252           0 :                     $$ = (Node*)n;
   12253           0 :                 }
   12254           0 :                 | CURRENT ROW
   12255           0 :                 {
   12256           0 :                         WindowExpr *n = makeNode(WindowExpr);
   12257           0 :                         n->range_type= FRAMEOPTION_START_CURRENT_ROW;
   12258           0 :                     n->wind_lo_off = 0;
   12259           0 :                     n->wind_hi_off = 0;
   12260           0 :                         n->wind_lo_val = 0;
   12261           0 :                     n->wind_hi_val = 0;
   12262           0 :                         $$ = (Node*)n;
   12263           0 :                 }
   12264           0 :                 | b_expr PRECEDING
   12265           0 :                 {
   12266             :                         WindowExpr *n = makeNode(WindowExpr);
   12267           0 :                         n->range_type= FRAMEOPTION_START_OFFSET_PRECEDING;
   12268             :                     //n->wind_lo_off = ((A_Const *)$1)->val.val.ival;
   12269             :                     n->wind_hi_off = 0;
   12270             :                         n->wind_lo_val = $1;
   12271           0 :                     n->wind_hi_val = NULL;
   12272           0 :                         $$ = (Node*)n;
   12273           0 :                 }
   12274           0 :                 | b_expr FOLLOWING
   12275           0 :                 {
   12276           0 :                         WindowExpr *n = makeNode(WindowExpr);
   12277           0 :                         n->range_type= FRAMEOPTION_START_OFFSET_FOLLOWING;
   12278             :                         //n->wind_lo_off = ((A_Const *)$1)->val.val.ival;
   12279           0 :                     n->wind_hi_off = 0;
   12280             :                         n->wind_lo_val = $1;
   12281           0 :                     n->wind_hi_val = $1;
   12282           0 :                         $$ = (Node*)n;
   12283           0 :                 }
   12284           0 :                 ;
   12285           0 : 
   12286           0 : expr_list:  b_expr
   12287           0 :                 { $$ = makeList1($1); }
   12288             :                 | expr_list ',' b_expr
   12289           0 :                 { $$ = lappend($1, $3); }
   12290             :                 | expr_list USING b_expr
   12291           0 :                 { $$ = lappend($1, $3); }
   12292           0 :                 ;
   12293           0 : 
   12294           0 : /* in_expr used by b_expr _IN, NOT _IN supports without bracket ++bywsy@20210306 bug3597 */
   12295           0 : in_expr: ColId  
   12296           0 :                 {
   12297           0 :                         Ident *column = makeNode(Ident);
   12298             :                         column->name = $1;
   12299           0 :                         $$ = (Node *)column;    
   12300             :                         SetNodePos($$);
   12301           0 :                 }
   12302           0 :                 | ident '.' ColLabel
   12303             :                 {
   12304           0 :                         Ident *n = makeNode(Ident);
   12305           0 :                         n->name = $3;
   12306           0 :                         set_ident_child((Ident*)$1,n);
   12307           0 :                         $$ = (Node *)$1;        
   12308             :                         SetNodePos($$);
   12309           0 :                 }
   12310             :                 | ident '(' func_params ')'
   12311           0 :                 {
   12312           0 :                         Ident *n = makeNode(Ident);
   12313             :                         n->args = $3;
   12314           0 :                         n->agg_star = false;
   12315           0 :                         n->agg_distinct = false;
   12316           0 :                         n->ident_t = IDENT_FUNC;
   12317           0 :                         set_ident_child((Ident*)$1,n);
   12318             :                         $$ = (Node *)($1);
   12319           0 :                         SetNodePos($$);
   12320             :                 }
   12321             :                 | CAST '(' b_expr AS STypename ')'
   12322         103 :                 {       
   12323         103 :                         $$ = makeTypeCast($3, (Typenam*)$5); 
   12324          93 :                         SetNodePos($$);
   12325          93 :                 }
   12326           0 :                 | USER
   12327           0 :                 {
   12328             :                         Ident *n = makeNode(Ident);
   12329             :                         n->name = "CURRENT_USER";
   12330             :                         n->args = NIL;
   12331             :                         n->agg_star = false;
   12332           0 :                         n->agg_distinct = false;
   12333           0 :                         $$ = (Node *)(n);
   12334           0 :                         SetNodePos($$);
   12335           0 :                 }               
   12336             :                 | AexprConst
   12337           0 :                 {       $$ = $1;  }
   12338             :                 | case_expr
   12339           0 :                 {   $$ = $1;  }
   12340           0 :                 ;
   12341           0 : 
   12342           0 : /* position_list uses b_expr not b_expr to avoid conflict with general _IN */
   12343           0 : 
   12344             : position_list:  b_expr _IN b_expr
   12345           0 :                 {       $$ = makeList2($3, $1); }
   12346             :                 ;
   12347           0 : 
   12348           0 : /* SUBSTRING() arguments
   12349           0 :  * SQL9x defines a specific syntax for arguments to SUBSTRING():
   12350           0 :  * o substring(text from int for int)
   12351           0 :  * o substring(text from int) get entire string from starting point "INTEGER"
   12352           0 :  * o substring(text for int) get first "INTEGER" characters of string
   12353           0 :  * We also want to implement generic substring functions which accept
   12354           0 :  * the usual generic list of arguments. So we will accept both styles
   12355             :  * here, and convert the SQL9x style to the generic list for further
   12356           0 :  * processing. - thomas 2000-11-28
   12357             :  */
   12358           0 : substr_list:  b_expr FROM b_expr FOR b_expr
   12359           0 :                 {
   12360             :                         $$ = makeList3($1, $3, $5);
   12361           0 :                 }
   12362             :                 | b_expr FOR b_expr FROM b_expr
   12363           0 :                 {
   12364           0 :                         $$ = makeList3($1, $5, $3);
   12365           0 :                 }
   12366           0 :                 | b_expr FOR b_expr
   12367           0 :                 {
   12368           0 :                         A_Const *n = makeNode(A_Const);
   12369           0 :                         n->val.type = T_Integer;
   12370             :                         n->val.val.ival = 1;
   12371           0 :                         $$ = makeList3($1,(Node *)n, $3);
   12372           0 :                 }
   12373           0 :                 ;
   12374           0 : 
   12375           0 : trim_list:  b_expr FROM b_expr
   12376             :                 { $$ = makeList2($3, $1); }
   12377             :                 | FROM b_expr
   12378             :                 { $$ = makeList1($2); }
   12379             :                 ;
   12380           7 : 
   12381           7 : /* Case clause
   12382             :  * Define SQL92-style case clause.
   12383             :  * Allow all four forms described in the standard:
   12384             :  * - Full specification
   12385             :  *  CASE WHEN a = b THEN c ... ELSE d _END
   12386             :  * - Implicit argument
   12387             :  *  CASE a WHEN b THEN c ... ELSE d _END
   12388             :  * - Conditional NULL
   12389             :  *  NULLIF(x,y)
   12390             :  *  same as CASE WHEN x = y THEN NULL ELSE x _END
   12391             :  * - Conditional substitution from list, use first non-null argument
   12392             :  *  COALESCE(a,b,...)
   12393             :  * same as CASE WHEN a IS NOT NULL THEN a WHEN b IS NOT NULL THEN b ... _END
   12394             :  * - thomas 1998-11-09
   12395          31 :  */
   12396             : case_expr:
   12397          31 :                  DECODE '(' case_arg ',' decode_list ')'
   12398             :                 {
   12399           0 :                         CaseExpr *c = makeNode(CaseExpr);
   12400             :                         c->arg = $3;
   12401           0 :                         c->args = $5;
   12402             :                         c->defresult = NULL;
   12403           0 :                         $$ = (Node *)c;
   12404           0 :                         SetNodePos($$);
   12405           0 :                 } 
   12406           0 :                 | DECODE '(' case_arg ',' decode_list ',' b_expr')'
   12407             :                 {
   12408           0 :                         CaseExpr *c = makeNode(CaseExpr);
   12409             :                         c->arg = $3;
   12410             :                         c->args = $5;
   12411          20 :                         c->defresult = $7;
   12412          20 :                         $$ = (Node *)c;
   12413           2 :                         SetNodePos($$);
   12414           2 :                 } 
   12415             :                 | CASE case_arg when_clause_list case_default _END
   12416             :                 {
   12417             :                         CaseExpr *c = makeNode(CaseExpr);
   12418             :                         c->arg = $2;
   12419             :                         c->args = $3;
   12420             :                         c->defresult = $4;
   12421             :                         $$ = (Node *)c;
   12422             :                         SetNodePos($$);
   12423             :                 }
   12424             :                 | NVL '(' b_expr ',' b_expr ')'
   12425             :                 {
   12426             :                         NvlExpr *n = makeNode(NvlExpr); 
   12427             :                         n->expr = $3;
   12428             :                         n->null_result = $5;
   12429             :                         $$ = (Node *)n;
   12430             :                         SetNodePos($$);
   12431             :                 }
   12432             :                 | NVL2 '(' b_expr ',' b_expr ',' b_expr')'
   12433             :                 {
   12434           0 :                         NvlExpr *n = makeNode(NvlExpr); 
   12435           0 :                         n->expr = $3;
   12436           0 :                         n->null_result = $7;
   12437           0 :                         n->notnull_result = $5;
   12438           0 :                         $$ = (Node *)n;
   12439           0 :                         SetNodePos($$);
   12440             :                 }
   12441           0 :                 | NULLIF '(' b_expr ',' b_expr ')'
   12442             :                 {
   12443           2 :                         CaseExpr *c = makeNode(CaseExpr);
   12444           2 :                         CaseWhen *w = makeNode(CaseWhen);
   12445           2 : 
   12446           2 :                         A_Const *n = makeNode(A_Const);
   12447           2 :                         n->val.type = T_Null;
   12448           2 :                         w->result = (Node *)n;
   12449             : 
   12450           2 :                         w->expr = makeA_Expr(OP, "=", $3, $5);
   12451             :                         c->args = makeList1(w);
   12452          18 :                         c->defresult = $3;
   12453          18 :                         $$ = (Node *)c;
   12454          18 :                         SetNodePos($$);
   12455          18 :                 }
   12456          18 :                 | COALESCE '(' expr_list ')'
   12457          18 :                 {
   12458             :                         CaseExpr *c = makeNode(CaseExpr);
   12459          18 :                         CaseWhen *w;
   12460             :                         foreach (l,$3)
   12461           0 :                         {
   12462           0 :                                 w = makeNode(CaseWhen);
   12463           0 :                                 w->expr = makeA_Expr(OP_NOTNULL, NULL, (Node*)lptr(l), NULL);
   12464           0 :                                 w->result = (Node*)lptr(l);
   12465           0 :                                 c->args = lappend(c->args, w);
   12466             :                         }
   12467           0 :                         $$ = (Node *)c;
   12468             :                         SetNodePos($$);
   12469           0 :                 }
   12470           0 :                 ;
   12471           0 : 
   12472           0 : when_clause_list:  when_clause_list when_clause
   12473           0 :                                 { $$ = lappend($1, $2); }
   12474           0 :                 | when_clause
   12475             :                                 { $$ = makeList1($1); }
   12476           0 :                 ;
   12477             : 
   12478           1 : decode_list:  b_expr ','b_expr
   12479           1 :                 {
   12480             :                         CaseWhen *w = makeNode(CaseWhen);
   12481           1 :                         w->expr = $1;
   12482           1 :                         w->result = $3;
   12483           1 :                         $$ = makeList1(w);
   12484             :                 }
   12485           1 :                 | decode_list ',' b_expr ',' b_expr
   12486           1 :                 {
   12487           1 :                         CaseWhen *w = makeNode(CaseWhen);
   12488           1 :                         w->expr = $3;
   12489           1 :                         w->result = $5;
   12490             :                         $$ = lappend($1,w);             
   12491           1 :                 }
   12492             :                 ; 
   12493           5 : 
   12494             : when_clause:  WHEN bool_expr THEN b_expr
   12495          15 :                 {
   12496             :                         CaseWhen *w = makeNode(CaseWhen);
   12497          10 :                         w->expr = $2;
   12498          10 :                         w->result = $4;
   12499          10 :                         $$ = (Node *)w;
   12500          10 :                         SetNodePos($$);
   12501             :                 }
   12502           5 :                 ;
   12503           5 : 
   12504             : case_default:  ELSE b_expr                                              { $$ = $2; }
   12505           5 :                 | /*EMPTY*/                                                             { $$ = NULL; }
   12506             :                 ;
   12507             : 
   12508         111 : case_arg:  b_expr
   12509         111 :                                 {       $$ = $1; }
   12510          18 :                 | /*EMPTY*/
   12511          18 :                                 {       $$ = NULL; }
   12512             :                 ;
   12513             :         
   12514             : /********************************************************************************
   12515           2 : *
   12516           2 : *       ident node
   12517           2 : *
   12518           2 : ********************************************************************************/
   12519             :         
   12520           2 : ident:  ':' ColId
   12521             :                 {
   12522           2 :                         Ident *n = makeNode(Ident);
   12523           2 :                         n->name = $2;
   12524           2 :                         n->ident_t  = IDENT_PARAM;
   12525           2 :                         $$ = (Node *)n; 
   12526             :                         SetNodePos($$);
   12527           2 :                 }
   12528             :                 | ':' ICONST
   12529             :                 {
   12530             :                         Ident *n = makeNode(Ident);
   12531         129 :                         n->param_no = $2;
   12532         129 :                         n->ident_t  = IDENT_PARAM;
   12533         129 :                         $$ = (Node *)n; 
   12534         129 :                         SetNodePos($$);
   12535         129 :                 }
   12536             :                 | ColId 
   12537         129 :                 {
   12538             :                         Ident *n = makeNode(Ident);
   12539           3 :                         n->name = $1;
   12540           3 :                         $$ = (Node *)n; 
   12541          15 :                         SetNodePos($$);
   12542             :                 }
   12543             :                 | COLUMN
   12544           4 :                 {
   12545           4 :                         Ident *n = makeNode(Ident);
   12546          16 :                         n->name = "COLUMN";
   12547          16 :                         $$ = (Node *)n; 
   12548             :                         SetNodePos($$);
   12549             :                 }
   12550             :                 | SELF
   12551             :                 {
   12552             :                         Ident *n = makeNode(Ident);
   12553             :                         n->name = "SELF";
   12554             :                         $$ = (Node *)n; 
   12555             :                         SetNodePos($$);
   12556             :                 }
   12557           0 :                 | ISNULL
   12558           0 :                 {
   12559           0 :                         Ident *n = makeNode(Ident);
   12560           0 :                         n->name = "ISNULL";
   12561           0 :                         $$ = (Node *)n; 
   12562             :                         SetNodePos($$);
   12563           0 :                 }
   12564             :                 | NOTNULL
   12565           3 :                 {
   12566           3 :                         Ident *n = makeNode(Ident);
   12567           3 :                         n->name = "NOTNULL";
   12568           3 :                         $$ = (Node *)n; 
   12569           3 :                         SetNodePos($$);
   12570             :                 }
   12571           3 :                 | ident '.' ColLabel
   12572             :                 {
   12573       15483 :                         Ident *n = makeNode(Ident);
   12574       15483 :                         n->name = $3;
   12575       15483 :                         set_ident_child((Ident*)$1,n);
   12576       15483 :                         $$ = (Node *)$1;        
   12577             :                         SetNodePos($$);
   12578       15483 :                 }
   12579             :                 | ident '(' func_params ')'
   12580           0 :                 {
   12581           0 :                         Ident *n = makeNode(Ident);
   12582           0 :                         n->args = $3;
   12583           0 :                         n->agg_star = false;
   12584             :                         n->agg_distinct = false;
   12585           0 :                         n->ident_t = IDENT_FUNC;
   12586             :                         set_ident_child((Ident*)$1,n);
   12587           0 :                         $$ = (Node *)$1;        
   12588           0 :                         SetNodePos($$);
   12589           0 :                 }
   12590           0 :                 | OVERLAPS '(' func_params ')'
   12591             :                 {
   12592           0 :                         Ident *n = makeNode(Ident);
   12593             :                         n->name = "OVERLAPS";
   12594           0 :                         Ident *n1 = makeNode(Ident);
   12595           0 :                         n1->args = $3;
   12596           0 :                         n1->agg_star = false;
   12597           0 :                         n1->agg_distinct = false;
   12598             :                         n1->ident_t = IDENT_FUNC;
   12599           0 :                         set_ident_child(n,n1);
   12600             :                         $$ = (Node *)n; 
   12601           0 :                         SetNodePos($$);
   12602           0 :                 }
   12603           0 :                 | ident '(' ALL expr_list ')'
   12604           0 :                 {
   12605             :                         Ident *n = makeNode(Ident);
   12606           0 :                         n->args = $4;
   12607             :                         n->agg_star = false;
   12608        2212 :                         n->agg_distinct = false;
   12609        2212 :                         n->ident_t = IDENT_FUNC;
   12610        2212 :                         set_ident_child((Ident*)$1,n);
   12611        2212 :                         $$ = (Node *)$1;        
   12612        2212 :                         SetNodePos($$);
   12613             :                 }
   12614        2212 :                 | ident '(' DISTINCT expr_list ')'
   12615             :                 {
   12616         961 :                         Ident *n = makeNode(Ident);
   12617         961 :                         n->args = $4;
   12618         961 :                         n->agg_star = false;
   12619         961 :                         n->agg_distinct = true;
   12620         961 :                         n->ident_t = IDENT_FUNC;
   12621         961 :                         set_ident_child((Ident*)$1,n);
   12622         961 :                         $$ = (Node *)$1;        
   12623         961 :                         SetNodePos($$);
   12624             :                 }
   12625         961 :                 | ident '(' '*' ')'
   12626             :                 {
   12627           0 :                         A_Const *star;  
   12628           0 :                         Ident *n = makeNode(Ident);
   12629           0 :                         star = makeNode(A_Const);
   12630           0 :                         star->val.type = T_Integer;
   12631           0 :                         star->val.val.ival = 1;
   12632           0 :                         n->args = makeList1(star);
   12633           0 :                         n->agg_star = true;
   12634           0 :                         n->agg_distinct = false;
   12635           0 :                         n->ident_t = IDENT_FUNC;
   12636           0 :                         set_ident_child((Ident*)$1,n);
   12637             :                         $$ = (Node *)$1;        
   12638           0 :                         SetNodePos($$);
   12639             :                 }
   12640           2 :                 | EXTRACT '(' _YEAR FROM b_expr ')'
   12641           2 :                 {
   12642           2 :                         Ident *n = makeNode(Ident);
   12643           2 :                         Ident *n1 = makeNode(Ident);
   12644           2 :                         n->name = "EXTRACT_YEAR";
   12645           2 :                         n1->args = makeList1($5);
   12646           2 :                         n1->agg_star = false;
   12647           2 :                         n1->agg_distinct = false;
   12648             :                         n1->ident_t = IDENT_FUNC;
   12649           2 :                         set_ident_child(n,n1);
   12650             :                         $$ = (Node *)n;
   12651          34 :                         SetNodePos($$);
   12652          34 :                 }       
   12653          34 :                 | EXTRACT '(' _MONTH FROM b_expr ')'
   12654          34 :                 {
   12655          34 :                         Ident *n = makeNode(Ident);
   12656          34 :                         Ident *n1 = makeNode(Ident);
   12657          34 :                         n->name = "EXTRACT_MONTH";
   12658          34 :                         n1->args = makeList1($5);
   12659             :                         n1->agg_star = false;
   12660          34 :                         n1->agg_distinct = false;
   12661             :                         n1->ident_t = IDENT_FUNC;
   12662             :                         set_ident_child(n,n1);
   12663         877 :                         $$ = (Node *)n;
   12664         877 :                         SetNodePos($$);
   12665         877 :                 }       
   12666         877 :                 | EXTRACT '(' _DAY FROM b_expr ')'
   12667         877 :                 {
   12668         877 :                         Ident *n = makeNode(Ident);
   12669         877 :                         Ident *n1 = makeNode(Ident);
   12670         877 :                         n->name = "EXTRACT_DAY";
   12671         877 :                         n1->args = makeList1($5);
   12672         877 :                         n1->agg_star = false;
   12673         877 :                         n1->agg_distinct = false;
   12674             :                         n1->ident_t = IDENT_FUNC;
   12675         877 :                         set_ident_child(n,n1);
   12676             :                         $$ = (Node *)n;
   12677           9 :                         SetNodePos($$);
   12678           9 :                 }
   12679           9 :                 | EXTRACT '(' _HOUR FROM b_expr ')'
   12680           9 :                 {
   12681           9 :                         Ident *n = makeNode(Ident);
   12682           9 :                         Ident *n1 = makeNode(Ident);
   12683           9 :                         n->name = "EXTRACT_HOUR";
   12684           9 :                         n1->args = makeList1($5);
   12685           9 :                         n1->agg_star = false;
   12686           9 :                         n1->agg_distinct = false;
   12687             :                         n1->ident_t = IDENT_FUNC;
   12688           9 :                         set_ident_child(n,n1);
   12689             :                         $$ = (Node *)n;
   12690           3 :                         SetNodePos($$);
   12691           3 :                 }                                               
   12692           3 :                 | EXTRACT '(' _MINUTE FROM b_expr ')'
   12693           3 :                 {
   12694           3 :                         Ident *n = makeNode(Ident);
   12695           3 :                         Ident *n1 = makeNode(Ident);
   12696           3 :                         n->name = "EXTRACT_MINUTE";
   12697           3 :                         n1->args = makeList1($5);
   12698           3 :                         n1->agg_star = false;
   12699           3 :                         n1->agg_distinct = false;
   12700             :                         n1->ident_t = IDENT_FUNC;
   12701           3 :                         set_ident_child(n,n1);
   12702             :                         $$ = (Node *)n;
   12703           6 :                         SetNodePos($$);
   12704           6 :                 }       
   12705           6 :                 | EXTRACT '(' _SECOND FROM b_expr ')'
   12706           6 :                 {
   12707           6 :                         Ident *n = makeNode(Ident);
   12708           6 :                         Ident *n1 = makeNode(Ident);
   12709           6 :                         n->name = "EXTRACT_SECOND";
   12710           6 :                         n1->args = makeList1($5);
   12711           6 :                         n1->agg_star = false;
   12712           6 :                         n1->agg_distinct = false;
   12713             :                         n1->ident_t = IDENT_FUNC;
   12714           6 :                         set_ident_child(n,n1);
   12715             :                         $$ = (Node *)n;
   12716          14 :                         SetNodePos($$);
   12717          14 :                 }               
   12718          14 :                 | ident '(' position_list ')'
   12719          14 :                 {
   12720          14 :                         Ident *n = (Ident*)$1;
   12721          14 :                         if(namecmp(n->name,"POSITION"))
   12722          14 :                         {
   12723          14 :                                 SetParsePos();
   12724          14 :                                 add_parse_error(90);
   12725          14 :                         }
   12726             :                         Ident *n1 = makeNode(Ident);
   12727          14 :                         n->name = "POSITION";
   12728             :                         n1->args = $3;
   12729           9 :                         n1->agg_star = false;
   12730           9 :                         n1->agg_distinct = false;
   12731           9 :                         n1->ident_t = IDENT_FUNC;
   12732           9 :                         set_ident_child(n,n1);
   12733           9 :                         $$ = (Node *)n;
   12734           9 :                         SetNodePos($$);
   12735           9 :                 }
   12736           9 :                 | ident '(' substr_list ')'
   12737           9 :                 {
   12738           9 :                         /* substring(A from B for C) is converted to
   12739             :                          * substring(A, B, C) - thomas 2000-11-28
   12740           9 :                          */
   12741             :                          Ident *n = (Ident*)$1;
   12742           7 :                         if(namecmp(n->name,"SUBSTRING") 
   12743           7 :                            &&namecmp(n->name,"SUBSTR"))
   12744           7 :                         {
   12745           7 :                                 SetParsePos();
   12746           7 :                                 add_parse_error(90);
   12747           7 :                         }
   12748           7 :                         Ident *n1 = makeNode(Ident);
   12749           7 :                         n->name = "SUBSTR";
   12750           7 :                         n1->args = $3;
   12751           7 :                         n1->agg_star = false;
   12752             :                         n1->agg_distinct = false;
   12753           7 :                         n1->ident_t = IDENT_FUNC;
   12754             :                         set_ident_child(n,n1);
   12755           7 :                         $$ = (Node *)n;
   12756           7 :                         SetNodePos($$);
   12757             :                 }
   12758           0 :                 | ident '(' BOTH trim_list ')'
   12759           0 :                 {
   12760             :                         Ident *n = (Ident*)$1;
   12761           7 :                         if(namecmp(n->name,"TRIM"))
   12762           7 :                         {
   12763           7 :                                 SetParsePos();
   12764           7 :                                 add_parse_error(90);
   12765           7 :                         }
   12766           7 :                         Ident *n1 = makeNode(Ident);
   12767           7 :                         n->name = "TRIM";
   12768           7 :                         n1->args = $4;
   12769           7 :                         n1->agg_star = false;
   12770             :                         n1->agg_distinct = false;
   12771           7 :                         n1->ident_t = IDENT_FUNC;
   12772             :                         set_ident_child(n,n1);
   12773             :                         $$ = (Node *)n;
   12774             :                         SetNodePos($$);
   12775             :                 }
   12776          31 :                 | ident '(' LEADING trim_list ')'
   12777          93 :                 {
   12778          62 :                         Ident *n = (Ident*)$1;
   12779             :                         if(namecmp(n->name,"TRIM"))
   12780           0 :                         {
   12781           0 :                                 SetParsePos();
   12782             :                                 add_parse_error(90);
   12783          31 :                         }
   12784          31 :                         Ident *n1 = makeNode(Ident);
   12785          31 :                         n->name = "LTRIM";
   12786          31 :                         n1->args = $4;
   12787          31 :                         n1->agg_star = false;
   12788          31 :                         n1->agg_distinct = false;
   12789          31 :                         n1->ident_t = IDENT_FUNC;
   12790          31 :                         set_ident_child(n,n1);
   12791          31 :                         $$ = (Node *)n;
   12792             :                         SetNodePos($$);
   12793          31 :                 }
   12794             :                 | ident '(' TRAILING trim_list ')'
   12795           2 :                 {
   12796           2 :                         Ident *n = (Ident*)$1;
   12797             :                         if(namecmp(n->name,"TRIM"))
   12798           0 :                         {
   12799           0 :                                 SetParsePos();
   12800             :                                 add_parse_error(90);
   12801           2 :                         }
   12802           2 :                         Ident *n1 = makeNode(Ident);
   12803           2 :                         n->name = "RTRIM";
   12804           2 :                         n1->args = $4;
   12805           2 :                         n1->agg_star = false;
   12806           2 :                         n1->agg_distinct = false;
   12807           2 :                         n1->ident_t = IDENT_FUNC;
   12808           2 :                         set_ident_child(n,n1);
   12809           2 :                         $$ = (Node *)n;
   12810             :                         SetNodePos($$);
   12811           2 :                 }
   12812             :                 | ident '(' trim_list ')'
   12813           6 :                 {
   12814           6 :                         Ident *n = (Ident*)$1;
   12815             :                         if(namecmp(n->name,"TRIM"))
   12816           0 :                         {
   12817           0 :                                 SetParsePos();
   12818             :                                 add_parse_error(90);
   12819           6 :                         }
   12820           6 :                         Ident *n1 = makeNode(Ident);
   12821           6 :                         n->name = "TRIM";
   12822           6 :                         n1->args = $3;
   12823           6 :                         n1->agg_star = false;
   12824           6 :                         n1->agg_distinct = false;
   12825           6 :                         n1->ident_t = IDENT_FUNC;
   12826           6 :                         set_ident_child(n,n1);
   12827           6 :                         $$ = (Node *)n;
   12828             :                         SetNodePos($$);
   12829           6 :                 }       
   12830             :                 ;       
   12831           3 : 
   12832           3 : 
   12833             : /*****************************************************************************
   12834           0 :  *
   12835           0 :  *      target lists
   12836             :  *
   12837           3 :  *****************************************************************************/
   12838           3 : 
   12839           3 : /* Target lists as found in SELECT ... and INSERT VALUES ( ... ) */
   12840           3 : 
   12841           3 : target_list:  target_list ',' target_el
   12842           3 :                 {       $$ = lappend($1, $3);  }
   12843           3 :                 | target_el
   12844           3 :                 {       $$ = makeList1($1);  }
   12845           3 :                 ;
   12846             : 
   12847           3 : /* AS is not optional because shift/red conflict with unary ops */
   12848             : target_el:  b_expr AS ColLabel
   12849          11 :                 {
   12850          11 :                         $$ = (Node*)makeNode(ResTarget);
   12851             :                         ((ResTarget*)$$)->name = $3;
   12852           3 :                         ((ResTarget*)$$)->val = (Node *)$1;
   12853           3 :                         SetNodePos($$);
   12854             :                 }
   12855          11 :                 | b_expr  ColId
   12856          11 :                 {
   12857          11 :                         $$ = (Node*)makeNode(ResTarget);
   12858          11 :                         ((ResTarget*)$$)->name = $2;
   12859          11 :                         ((ResTarget*)$$)->val = (Node *)$1;
   12860          11 :                         SetNodePos($$);
   12861          11 :                 }
   12862          11 :                 | DEFAULT
   12863          11 :                 {
   12864             :                         $$ = (Node*)makeNode(ResTarget);
   12865          11 :                         ((ResTarget*)$$)->name = NULL;
   12866             :                         ((ResTarget*)$$)->val = NULL;
   12867             :                         SetNodePos($$);
   12868             :                 }
   12869             :                 | b_expr
   12870             :                 {
   12871             :                         $$ = (Node*)makeNode(ResTarget);
   12872             :                         ((ResTarget*)$$)->name = NULL;
   12873             :                         ((ResTarget*)$$)->val = (Node *)$1;
   12874             :                         SetNodePos($$);
   12875             :                 }
   12876             :                 | ident  '.' '*'                
   12877       35202 :                 {
   12878       35202 :                         Attr *att = makeNode(Attr);
   12879       14696 :                         att->relname = ident2names((Ident*)$1);
   12880       14696 :                         if(!att->relname)
   12881             :                         {
   12882             :                                 SetParsePos();
   12883             :                                 add_parse_error(581);
   12884             :                         }
   12885         821 :                         att->fields = makeList1((char*)"*");
   12886         821 :                         $$ = (Node*)makeNode(ResTarget);
   12887         821 :                         ((ResTarget*)$$)->name = NULL;
   12888         821 :                         ((ResTarget*)$$)->val = (Node *)att;
   12889             :                         SetNodePos($$);
   12890         821 :                 }
   12891             :                 | '*'
   12892           2 :                 {
   12893           2 :                         Attr *att = makeNode(Attr);
   12894           2 :                         att->relname = "*";
   12895           2 :                         att->fields = NULL;
   12896             :                         $$ = (Node*)makeNode(ResTarget);
   12897           2 :                         ((ResTarget*)$$)->name = NULL;
   12898             :                         ((ResTarget*)$$)->val = (Node *)att;
   12899          11 :                         SetNodePos($$);
   12900          11 :                 }
   12901          11 :                 ;
   12902          11 : 
   12903             : /* Target list as found in UPDATE table SET ... */
   12904          11 : update_target_list: update_target_el
   12905             :                 {       $$ = makeList1($1);  } 
   12906       48175 :                 | update_target_list ',' update_target_el
   12907       48175 :                 {       $$ = lappend($1,$3);  }
   12908       48175 :                 ;
   12909       48175 : 
   12910             : update_target_el:  ident '=' b_expr
   12911       48175 :                 {
   12912             :                         UpdateTarget *n = makeNode(UpdateTarget);
   12913          30 :                         n->targ_var = $1;
   12914          30 :                         n->val = (Node *)$3;
   12915          30 :                         $$ = (Node*)n;
   12916             :                         SetNodePos($$);
   12917           0 :                 }
   12918           0 :                 |       ident '=' DEFAULT
   12919             :                 {
   12920          30 :                         UpdateTarget *n = makeNode(UpdateTarget);
   12921          30 :                         n->targ_var = $1;
   12922          30 :                         n->val = NULL;
   12923          30 :                         $$ = (Node*)n;
   12924          30 :                         SetNodePos($$);
   12925             :                 }
   12926          30 :                 //why 2015-11-27 add
   12927             :                 |       ident
   12928         859 :                 {
   12929         859 :                         UpdateTarget *n = makeNode(UpdateTarget);
   12930         859 :                         n->targ_var = $1;
   12931         859 :                         n->val = NULL;
   12932         859 :                         $$ = (Node*)n;
   12933         859 :                         SetNodePos($$);
   12934         859 :                 }
   12935             :                 ;
   12936         859 : 
   12937             : func_name:
   12938             :                   name_space                            { $$ = $1; }
   12939             :                 | BETWEEN                                       { $$ = (char*)"BETWEEN"; }
   12940         273 :                 | ILIKE                                         { $$ = (char*)"ILIKE"; }
   12941         273 :                 | _IN                                           { $$ = (char*)"IN"; }
   12942         298 :                 | IS                                            { $$ = (char*)"IS"; }
   12943         298 :                 | ISNULL                                        { $$ = (char*)"ISNULL"; }
   12944             :                 | LIKE                                          { $$ = (char*)"LIKE"; }
   12945             :                 | NOTNULL                                       { $$ = (char*)"NOTNULL"; }
   12946             :                 ;
   12947         570 : 
   12948         570 : file_name:              Sconst                  { $$ = dbs2utf($1); };
   12949         570 : name:                   
   12950         570 :                   ColId                             { $$ = $1; }
   12951         570 :                 | ARRAY                         { $$ = $1; }
   12952             :                 | BOTH                                          { $$ = $1; }
   12953         570 :                 | CASE                                          { $$ = $1; }
   12954             :                 | CLUSTER                                       { $$ = $1; }
   12955           1 :                 | CONSTRUCTOR               { $$ = $1; }
   12956           1 :                 | DECLARE                       { $$ = $1; }
   12957           1 :                 | _FALSE                        { $$ = $1; }
   12958           1 :                 | FETCH                         { $$ = $1; }
   12959           1 :                 | FUNCTION                                      { $$ = $1; }
   12960             :                 | LIMIT                         { $$ = $1; }
   12961           1 :                 | MEMBER                    { $$ = $1; }
   12962             :                 | INITIALLY                 { $$ = $1; }
   12963             :                 | PRAGMA                        { $$ = $1; }
   12964           0 :                 | PRIMARY                       { $$ = $1; }
   12965           0 :                 | PROCEDURE                 { $$ = $1; }
   12966           0 :                 | RENAME                        { $$ = $1; }
   12967           0 :                 | STATIC                        { $$ = $1; }
   12968           0 :                 | TRAILING                  { $$ = $1; }
   12969             :                 | UNBOUNDED                     { $$ = $1; }
   12970           0 :                 | WHERE                         { $$ = $1; }
   12971             :                 ;
   12972             :                 
   12973           0 : database_name:  TokenId                 { $$ = $1; };
   12974           0 : space_name:             TokenId                 { $$ = $1; };
   12975           0 : index_name:             TokenId                 { $$ = $1; };
   12976           0 : 
   12977           0 : name_space: name        
   12978           0 :                 {
   12979           0 :                         $$ = $1;
   12980           0 :                         //_curr_thd->parse_as_ident = false;
   12981           0 :                 }       
   12982             :                 |   SELF '.' name //update ColId to name
   12983           0 :                 {
   12984           0 :                         char    *p_str = (char*)tmalloc(astrlen($3)+8);
   12985        1048 :                         strcpy(p_str,"SELF.");
   12986           2 :                         strcat(p_str,$3);
   12987           0 :                         //_curr_thd->parse_as_ident = false;
   12988         293 :                         $$ = p_str;
   12989             :                 }
   12990             :                 |       name_space '.' name //update ColId to name
   12991       22234 :                 {
   12992             :                         char    *p_str;
   12993             :                         SizeT   name_len = astrlen($1)+astrlen($3)+4;           
   12994       22234 :                         if(name_len>MAX_NAME_LEN*3) 
   12995             :                                 add_parse_error(305,MAX_NAME_LEN*3);
   12996           0 :                         p_str = (char*)tmalloc(name_len);
   12997           0 :                         strcpy(p_str,$1);
   12998           0 :                         strcat(p_str,".");
   12999             :                         strcat(p_str,$3);
   13000           0 :                         //_curr_thd->parse_as_ident = false;
   13001             :                         $$ = p_str;
   13002           0 :                 }
   13003             :                 ;
   13004             :                         
   13005       11265 : AexprConst:  ICONST
   13006       11265 :                 {
   13007           0 :                         A_Const *n = makeNode(A_Const);
   13008       11265 :                         n->val.type = T_Integer;
   13009       11265 :                         n->val.val.ival = $1;
   13010       11265 :                         $$ = (Node *)n;
   13011       11265 :                         SetNodePos($$);
   13012             :                 }
   13013       11265 :                 | FCONST
   13014             :                 {
   13015       11265 :                         A_Const *n = makeNode(A_Const);
   13016             :                         n->val.type = T_Numeric;
   13017             :                         n->val.val.str = $1;
   13018             :                         $$ = (Node *)n;
   13019       24452 :                         SetNodePos($$);
   13020       24452 :                 }
   13021       24452 :                 | multi_sconst
   13022       24452 :                 {
   13023       24452 :                         A_Const *n = makeNode(A_Const);
   13024             :                         n->val.type = T_String;
   13025       24452 :                         n->val.val.str = $1;
   13026             :                         $$ = (Node *)n;
   13027       19867 :                         SetNodePos($$);
   13028       19867 :                 }
   13029       19867 :                 | BITCONST
   13030       19867 :                 {
   13031       19867 :                         A_Const *n = makeNode(A_Const);
   13032             :                         n->val.type = T_BitString;
   13033       19867 :                         n->val.val.str = $1;
   13034             :                         $$ = (Node *)n;
   13035        5216 :                         SetNodePos($$);
   13036        5216 :                 }
   13037        5216 :                 | INTERVAL      Sconst  opt_interval
   13038        5216 :                 {
   13039        5216 :                         A_Const *n = makeNode(A_Const);
   13040             :                         n->val.type = T_String;
   13041        5216 :                         n->val.val.str = $2;
   13042             :                         n->type_name = interval_names[(((uint)$3)>>28)-1];
   13043           0 :                         n->preci_scale = ($3 & 0x0fffffff);
   13044           0 :                         $$ = (Node*)n;
   13045           0 :                         SetNodePos($$);
   13046           0 :                 }
   13047           0 :                 | INTERVAL  '+' Sconst  opt_interval
   13048             :                 {
   13049           0 :                         A_Const *n = makeNode(A_Const);
   13050             :                         n->val.type = T_String;
   13051         322 :                         n->val.val.str = $3;
   13052         322 :                         n->type_name = interval_names[(((uint)$4)>>28)-1];
   13053         322 :                         n->preci_scale = ($4 & 0x0fffffff);
   13054         322 :                         $$ = (Node*)n;
   13055         322 :                         SetNodePos($$);
   13056         322 :                 }       
   13057         322 :                 | INTERVAL '-' Sconst opt_interval
   13058             :                 {
   13059         322 :                         A_Const *n = makeNode(A_Const);
   13060             :                         char    *val_str = (char*)tmalloc((SizeT)strlen($3)+4);
   13061           1 :                         char    *p_str = $3;
   13062           1 :                         
   13063           1 :                         while(*p_str==' ') p_str++;
   13064           1 :                         if(*p_str=='+')
   13065           1 :                         {
   13066           1 :                                 *p_str = '-';
   13067           1 :                                 n->val.type = T_String;
   13068             :                                 n->val.val.str = $3;
   13069           1 :                         }
   13070             :                         else if(*p_str=='-')
   13071          21 :                         {
   13072          21 :                                 *p_str = ' ';
   13073          21 :                                 n->val.type = T_String;
   13074             :                                 n->val.val.str = $3;
   13075          21 :                         }       
   13076          21 :                         else
   13077             :                         {
   13078           0 :                                 val_str[0]='-';
   13079           0 :                                 strcpy(val_str+1,$3);
   13080           0 :                                 n->val.type = T_String;
   13081             :                                 n->val.val.str = val_str;
   13082          21 :                         }
   13083             :                         n->type_name = interval_names[(((uint)$4)>>28)-1];
   13084           1 :                         n->preci_scale = ($4 & 0x0fffffff);
   13085           1 :                         $$ = (Node*)n;
   13086           1 :                         SetNodePos($$);                         
   13087             :                 }
   13088             :                 | _TRUE
   13089             :                 {
   13090          20 :                         A_Const *n = makeNode(A_Const);
   13091          20 :                         n->val.type = T_Boolean;
   13092          20 :                         n->val.val.bval = true;
   13093          20 :                         n->type_name = "BOOLEAN";
   13094             :                         n->preci_scale = -1;
   13095          21 :                         $$ = (Node *)n;
   13096          21 :                         SetNodePos($$);
   13097          21 :                 }
   13098          21 :                 | _FALSE
   13099             :                 {
   13100          21 :                         A_Const *n = makeNode(A_Const);
   13101             :                         n->val.type = T_Boolean;
   13102          32 :                         n->val.val.bval = false;
   13103          32 :                         n->type_name = "BOOLEAN";
   13104          32 :                         n->preci_scale = -1;
   13105          32 :                         $$ = (Node *)n;
   13106          32 :                         SetNodePos($$);
   13107          32 :                 }
   13108          32 :                 | _NULL
   13109             :                 {
   13110          32 :                         A_Const *n = makeNode(A_Const);
   13111             :                         n->val.type = T_Null;
   13112          22 :                         $$ = (Node *)n;
   13113          22 :                         SetNodePos($$);
   13114          22 :                 }
   13115          22 :                 ;
   13116          22 :                 
   13117          22 : Param:  '?'
   13118          22 :                 {
   13119             :                         Param *n = makeNode(Param);
   13120          22 :                         n->paramkind=0;              
   13121             :                         n->paramid=0;        
   13122         340 :                         n->paramname = NULL; 
   13123         340 :                         $$ = (Node *)n;
   13124         340 :                         SetNodePos($$);
   13125         340 :                 }
   13126             :                 ;                       
   13127         340 : 
   13128             : multi_sconst: Sconst
   13129             :                 {
   13130             :                         $$ = $1;
   13131           3 :                 }
   13132           3 :                 |       multi_sconst Sconst
   13133           3 :                 {
   13134           3 :                         int len1,len2;
   13135           3 :                         char *mstr;
   13136           3 :                         len1 = astrlen($1);
   13137             :                         len2 = astrlen($2);
   13138           3 :                         mstr = (char*)tmalloc(len1+len2+2);
   13139             :                         MemCpy(mstr,$1,len1);
   13140             :                         MemCpy(mstr+len1,$2,len2);
   13141             :                         mstr[len1+len2]=0x0;
   13142        5216 :                         $$ = mstr;
   13143             :                 }
   13144        5216 :                 ;               
   13145             : 
   13146             : /*****************************************************************************
   13147             : *                            policies maintenance
   13148          60 : *******************************************************************************/                
   13149          60 :                 
   13150          60 : CreatPolicyStmt: CREATE POLICY  name 
   13151          60 :                 {
   13152          60 :                         CreatePolicyStmt *p_stmt = makeNode(CreatePolicyStmt);
   13153          60 :                         p_stmt->name = $3;
   13154          60 :                         $$ = (Node*)p_stmt;
   13155             :                 }
   13156          60 :                 |       CREATE POLICY   name PolicyMemsOfCre 
   13157             :                 {
   13158             :                         CreatePolicyStmt *p_stmt = makeNode(CreatePolicyStmt);
   13159             :                         p_stmt->name = $3;
   13160             :                         p_stmt->members = $4;
   13161             :                         $$ = (Node*)p_stmt;
   13162             :                 }
   13163             :                 ;
   13164           0 :                 
   13165           0 : AlterPolicyStmt:ALTER POLICY name  PolicyMembers
   13166           0 :                 {
   13167             :                         AlterPolicyStmt *p_stmt = makeNode(AlterPolicyStmt);
   13168           0 :                         p_stmt->name = $3;
   13169             :                         p_stmt->members = $4;
   13170           0 :                         $$ = (Node*)p_stmt;
   13171           0 :                 }
   13172           0 :                 ;
   13173           0 : 
   13174             : PolicyMembers: PolicyMember
   13175           0 :                 {
   13176             :                         $$ = makeList1($1);
   13177             :                 }
   13178             :                 | PolicyMembers ',' PolicyMember
   13179           0 :                 {
   13180           0 :                         $$ = lappend($1,$3);
   13181           0 :                 }
   13182           0 :                 ;
   13183             : 
   13184           0 : PolicyMemsOfCre: PolicyMemOfCre
   13185             :                 {
   13186             :                         $$ = makeList1($1);
   13187             :                 }
   13188           0 :                 | PolicyMemsOfCre ',' PolicyMemOfCre
   13189             :                 {
   13190           0 :                         $$ = lappend($1,$3);
   13191             :                 }
   13192           0 :                 ;
   13193             : 
   13194           0 : PolicyMemOfCre: ADD LEVEL name AS ICONST
   13195             :                 {
   13196             :                         PolicyMember *n = makeNode(PolicyMember);
   13197             :                         n->action = 2;
   13198           0 :                         n->level_name = $3;
   13199             :                         n->level_val = $5;
   13200           0 :                         $$ = (Node*)n;                  
   13201             :                 }
   13202           0 :                 |       ADD CATEGORY name
   13203             :                 {
   13204           0 :                         PolicyMember *n = makeNode(PolicyMember);
   13205             :                         n->action = 4;
   13206             :                         n->cate_name = $3;
   13207             :                         $$ = (Node*)n;
   13208           0 :                 }
   13209           0 :                 ;
   13210           0 :                 
   13211           0 : PolicyMember:   RENAME TO name
   13212           0 :                 {
   13213             :                         PolicyMember *n = makeNode(PolicyMember);
   13214           0 :                         n->action = 1;
   13215             :                         n->new_name = $3;
   13216           0 :                         $$ = (Node*)n;
   13217           0 :                 }
   13218           0 :                 |       ADD LEVEL name AS ICONST
   13219           0 :                 {
   13220             :                         PolicyMember *n = makeNode(PolicyMember);
   13221           0 :                         n->action = 2;
   13222             :                         n->level_name = $3;
   13223             :                         n->level_val = $5;
   13224             :                         $$ = (Node*)n;                  
   13225           0 :                 }
   13226           0 :                 |       ALTER LEVEL name RENAME TO name
   13227           0 :                 {
   13228           0 :                         PolicyMember *n = makeNode(PolicyMember);
   13229             :                         n->action = 3;
   13230           0 :                         n->level_name = $3;
   13231             :                         n->new_level_name = $6;
   13232           0 :                         $$ = (Node*)n;
   13233           0 :                 }
   13234           0 :                 |       ADD CATEGORY name
   13235           0 :                 {
   13236           0 :                         PolicyMember *n = makeNode(PolicyMember);
   13237             :                         n->action = 4;
   13238           0 :                         n->cate_name = $3;
   13239             :                         $$ = (Node*)n;
   13240           0 :                 }
   13241           0 :                 |       ALTER CATEGORY name RENAME TO name
   13242           0 :                 {
   13243           0 :                         PolicyMember *n = makeNode(PolicyMember);
   13244           0 :                         n->action = 5;
   13245             :                         n->cate_name = $3;
   13246           0 :                         n->new_cate_name = $6;
   13247             :                         $$ = (Node*)n;
   13248           0 :                 }
   13249           0 :                 |       DROP CATEGORY name
   13250           0 :                 {
   13251           0 :                         PolicyMember *n = makeNode(PolicyMember);
   13252             :                         n->action = 6;
   13253           0 :                         n->cate_name = $3;
   13254             :                         $$ = (Node*)n;          
   13255           0 :                 }
   13256           0 :                 |       DROP LEVEL name
   13257           0 :                 {
   13258           0 :                         PolicyMember *n = makeNode(PolicyMember);
   13259           0 :                         n->action = 7;
   13260             :                         n->level_name = $3;
   13261           0 :                         $$ = (Node*)n;          
   13262             :                 }
   13263           0 :                 ;
   13264           0 : DropPolicyStmt: DROP POLICY name 
   13265           0 :                 {
   13266           0 :                         DropStmt *p_stmt = makeNode(DropStmt);
   13267             :                         p_stmt->obj_name = $3;
   13268           0 :                         p_stmt->drop_type = DROP_POLICY;
   13269             :                         $$ = (Node*)p_stmt;
   13270           0 :                 }
   13271           0 :                 ;
   13272           0 :         
   13273           0 : AlterUserPolicyStmt: ALTER USER POLICY name ADD name LEVEL name
   13274             :                 {
   13275           0 :                         AlterUserPolicyStmt *p_stmt = makeNode(AlterUserPolicyStmt);
   13276             :                         p_stmt->action = 1;
   13277             :                         p_stmt->user_name = $4;
   13278           0 :                         p_stmt->policy_name = $6;
   13279           0 :                         p_stmt->level_name = $8;
   13280           0 :                         $$ = (Node*)p_stmt;
   13281           0 :                 }
   13282             :                 |        ALTER USER POLICY name  ADD name LEVEL name CATEGORY name_list
   13283           0 :                 {
   13284             :                         AlterUserPolicyStmt *p_stmt = makeNode(AlterUserPolicyStmt);
   13285             :                         p_stmt->action = 1;
   13286             :                         p_stmt->user_name = $4;
   13287           0 :                         p_stmt->policy_name = $6;
   13288           0 :                         p_stmt->level_name = $8;
   13289           0 :                         p_stmt->categories = $10;
   13290           0 :                         $$ = (Node*)p_stmt;             
   13291           0 :                 }
   13292           0 :                 |        ALTER USER POLICY name  ALTER name LEVEL name
   13293             :                 {
   13294           0 :                         AlterUserPolicyStmt *p_stmt = makeNode(AlterUserPolicyStmt);
   13295             :                         p_stmt->action = 2;
   13296           0 :                         p_stmt->user_name = $4;
   13297           0 :                         p_stmt->policy_name = $6;
   13298           0 :                         p_stmt->level_name = $8;
   13299           0 :                         $$ = (Node*)p_stmt;             
   13300           0 :                 }
   13301           0 :                 |        ALTER USER POLICY name  ALTER name CATEGORY name_list
   13302           0 :                 {
   13303             :                         AlterUserPolicyStmt *p_stmt = makeNode(AlterUserPolicyStmt);
   13304           0 :                         p_stmt->action = 3;
   13305             :                         p_stmt->user_name = $4;
   13306           0 :                         p_stmt->policy_name = $6;
   13307           0 :                         p_stmt->categories= $8;
   13308           0 :                         $$ = (Node*)p_stmt;             
   13309           0 :                 }
   13310           0 :                 |        ALTER USER POLICY name  DROP name 
   13311           0 :                 {
   13312             :                         AlterUserPolicyStmt *p_stmt = makeNode(AlterUserPolicyStmt);
   13313           0 :                         p_stmt->action = 4;
   13314             :                         p_stmt->user_name = $4;
   13315           0 :                         p_stmt->policy_name = $6;
   13316           0 :                         $$ = (Node*)p_stmt;             
   13317           0 :                 }
   13318           0 :                 ;
   13319           0 :                                 
   13320           0 : AlterTabPolicyStmt:     ALTER TABLE POLICY name_space ADD  name  COLUMN  ColId opt_hide LABEL Sconst
   13321             :                 {
   13322           0 :                         AlterTabPolicyStmt      *p_stmt = makeNode(AlterTabPolicyStmt);
   13323             :                         p_stmt->action = 1;
   13324           0 :                         p_stmt->tab_name = $4;
   13325           0 :                         p_stmt->policy_name = $6;
   13326           0 :                         p_stmt->col_name = $8;
   13327           0 :                         p_stmt->is_hide = $9;
   13328           0 :                         p_stmt->label = dbs2utf($11);
   13329             :                         $$ = (Node*)p_stmt;
   13330           0 :                 }
   13331             :                 |       ALTER TABLE POLICY name_space ALTER ColId opt_hide
   13332             :                 {
   13333             :                         AlterTabPolicyStmt      *p_stmt = makeNode(AlterTabPolicyStmt);
   13334           0 :                         p_stmt->action = 2;
   13335           0 :                         p_stmt->tab_name = $4;
   13336           0 :                         p_stmt->policy_name = $6;
   13337           0 :                         p_stmt->is_hide = $7;
   13338           0 :                         $$ = (Node*)p_stmt;
   13339           0 :                 } 
   13340           0 :                 |       ALTER TABLE POLICY name_space DROP name 
   13341           0 :                 {
   13342             :                         AlterTabPolicyStmt      *p_stmt = makeNode(AlterTabPolicyStmt);
   13343           0 :                         p_stmt->action = 3;
   13344             :                         p_stmt->tab_name = $4;
   13345           0 :                         p_stmt->policy_name = $6;
   13346           0 :                         $$ = (Node*)p_stmt;
   13347           0 :                 }
   13348           0 :                 ;
   13349           0 :                 
   13350           0 : opt_hide:       /*empty*/
   13351             :                 {
   13352           0 :                         $$ = false;
   13353             :                 }       
   13354           0 :                 |       HIDE
   13355           0 :                 {
   13356           0 :                         $$ = true;
   13357           0 :                 }
   13358           0 :                 |       NOT HIDE
   13359             :                 {
   13360           0 :                         $$ = false;
   13361             :                 }
   13362             :                 ;               
   13363             : 
   13364           0 : /*enable or disable audit*/
   13365             : AuditStmt: AUDIT  GlobalAuditItems  optAuditUser optAuditCond 
   13366           0 :                 {
   13367             :                         AuditStmt *p_stmt = makeNode(AuditStmt);
   13368           0 :                         p_stmt->audit_type = 1;
   13369             :                         p_stmt->action = 1;
   13370           0 :                         p_stmt->audits = $2;
   13371             :                         p_stmt->users = $3;
   13372           0 :                         p_stmt->audit_cond = $4;
   13373             :                         $$ = (Node*)p_stmt;
   13374           0 :                 }
   13375             :                 |       AUDIT   LocalAuditItems  optAuditUser optAuditCond  
   13376             :                 {
   13377             :                         AuditStmt *p_stmt =(AuditStmt*) $2;
   13378             :                         p_stmt->audit_type = 2;
   13379           0 :                         p_stmt->action = 1;
   13380           0 :                         p_stmt->users = $3;
   13381           0 :                         p_stmt->audit_cond = $4;
   13382           0 :                         $$ = (Node*)p_stmt;
   13383           0 :                 }
   13384           0 :                 |       NOAUDIT  GlobalAuditItems  optAuditUser optAuditCond 
   13385           0 :                 {
   13386             :                         AuditStmt *p_stmt = makeNode(AuditStmt);
   13387           0 :                         p_stmt->audit_type = 1;
   13388             :                         p_stmt->action = 2;
   13389           0 :                         p_stmt->audits = $2;
   13390           0 :                         p_stmt->users = $3;
   13391           0 :                         p_stmt->audit_cond = $4;
   13392           0 :                         $$ = (Node*)p_stmt;
   13393           0 :                 }
   13394           0 :                 |       NOAUDIT  LocalAuditItems  optAuditUser optAuditCond  
   13395             :                 {
   13396           0 :                         AuditStmt *p_stmt =(AuditStmt*) $2;
   13397             :                         p_stmt->audit_type = 2;
   13398           0 :                         p_stmt->action = 2;
   13399           0 :                         p_stmt->users = $3;
   13400           0 :                         p_stmt->audit_cond = $4;
   13401           0 :                         $$ = (Node*)p_stmt;
   13402           0 :                 }
   13403           0 :                 ;
   13404           0 :                 
   13405             : GlobalAuditItems: GlobalAuditItem
   13406           0 :                 {
   13407             :                         $$ = $1;
   13408           0 :                 }
   13409           0 :                 |       GlobalAuditItems ','    GlobalAuditItem
   13410           0 :                 {
   13411           0 :                         $$ = ($1) | ($3);
   13412           0 :                 }
   13413           0 :                 ;
   13414             :                 
   13415           0 : GlobalAuditItem:        DATABASE
   13416             :                 {
   13417             :                         $$ = 0x1<<AUDIT_DATABASE;
   13418             :                 }
   13419           0 :                 |       LOGIN
   13420             :                 {
   13421           0 :                         $$ = 0x1<<AUDIT_CONNECT;
   13422             :                 }
   13423           0 :                 |       CONNECT
   13424             :                 {
   13425           0 :                         $$ = 0x1<<AUDIT_CONNECT;
   13426             :                 }
   13427             :                 |   USER        
   13428             :                 {
   13429           0 :                         $$ = 0x1<<AUDIT_USER;
   13430             :                 }
   13431           0 :                 |       ROLE
   13432             :                 {
   13433           0 :                         $$ = 0x1<<AUDIT_ROLE;
   13434             :                 }
   13435           0 :                 |       GRANT
   13436             :                 {
   13437           0 :                         $$ = 0x1<<AUDIT_GRANT;
   13438             :                 } 
   13439           0 :                 |       REVOKE
   13440             :                 {
   13441           0 :                         $$ = 0x1<<AUDIT_REVOKE;
   13442             :                 }  
   13443           0 :                 |       AUDIT
   13444             :                 {
   13445           0 :                         $$ = 0x1<<AUDIT_AUDIT;
   13446             :                 }  
   13447           0 :                 |       NOAUDIT
   13448             :                 {
   13449           0 :                         $$ = 0x1<<AUDIT_NOAUDIT;
   13450             :                 }
   13451           0 :                 |       SCHEMA
   13452             :                 {
   13453           0 :                         $$ = 0x1<<AUDIT_SCHEMA;
   13454             :                 }
   13455           0 :                 |       TABLE
   13456             :                 {
   13457           0 :                         $$ = 0x1<<AUDIT_TABLE;
   13458             :                 }
   13459           0 :                 |       VIEW
   13460             :                 {
   13461           0 :                         $$ = 0x1<<AUDIT_VIEW;
   13462             :                 }
   13463           0 :                 |       INDEX 
   13464             :                 {
   13465           0 :                         $$ = 0x1<<AUDIT_INDEX;
   13466             :                 }       
   13467           0 :                 |       PROCEDURE
   13468             :                 {
   13469           0 :                         $$ = 0x1<<AUDIT_PROCEDURE;
   13470             :                 } 
   13471           0 :                 |   PACKAGE
   13472             :                 {
   13473           0 :                         $$ = 0x1<<AUDIT_PACKAGE;
   13474             :                 }
   13475           0 :                 |   TYPE
   13476             :                 {
   13477           0 :                         $$ = 0x1<<AUDIT_TYPE;
   13478             :                 }
   13479           0 :                 |   DATABASE LINK
   13480             :                 {
   13481           0 :                         $$ = 0x1<<AUDIT_DB_LINK;
   13482             :                 }       
   13483           0 :                 |  SYNONYM
   13484             :                 {
   13485           0 :                         $$ = 0x1<<AUDIT_SYNONYM;
   13486             :                 }
   13487           0 :                 |       TRIGGER
   13488             :                 {
   13489           0 :                         $$ = 0x1<<AUDIT_TRIGGER;
   13490             :                 } 
   13491           0 :                 |       SEQUENCE
   13492             :                 {
   13493           0 :                         $$ = 0x1<<AUDIT_SEQUENCE;
   13494             :                 } 
   13495           0 :                 |  TABLESPACE
   13496             :                 {
   13497           0 :                         $$ = 0x1<<AUDIT_SPACE;
   13498             :                 }       
   13499           0 :                 |       POLICY
   13500             :                 {
   13501           0 :                         $$ = 0x1<<AUDIT_POLICY;
   13502             :                 }
   13503           0 :                 |       USER POLICY
   13504             :                 {
   13505           0 :                         $$ = 0x1<<AUDIT_USER_POLICY;
   13506             :                 }
   13507           0 :                 |       TABLE POLICY
   13508             :                 {
   13509           0 :                         $$ = 0x1<<AUDIT_TAB_POLICY;
   13510             :                 }
   13511           0 :                 |  INSERT TABLE
   13512             :                 {
   13513           0 :                         $$ = 0x1<<AUDIT_INSERT;
   13514             :                 }
   13515           0 : 
   13516             :                 |  INSERT ANY TABLE
   13517           0 :                 {
   13518             :                         $$ = 0x1<<AUDIT_INSERT;
   13519           0 :                 }
   13520             :                 |       UPDATE TABLE
   13521           0 :                 {
   13522             :                         $$ = 0x1<<AUDIT_UPDATE;
   13523           0 :                 }
   13524             :                 |       UPDATE ANY TABLE
   13525           0 :                 {
   13526             :                         $$ = 0x1<<AUDIT_UPDATE;
   13527           0 :                 }
   13528             :                 |       _DELETE TABLE
   13529             :                 {
   13530           0 :                         $$ = 0x1<<AUDIT_DELETE;
   13531             :                 } 
   13532           0 :                 |       _DELETE  ANY TABLE
   13533             :                 {
   13534           0 :                         $$ = 0x1<<AUDIT_DELETE;
   13535             :                 } 
   13536           0 :                 |       SELECT TABLE
   13537             :                 {
   13538           0 :                         $$ = 0x1<<AUDIT_SELECT;
   13539             :                 }
   13540           0 :                 |       SELECT  ANY TABLE
   13541             :                 {
   13542           0 :                         $$ = 0x1<<AUDIT_SELECT;
   13543             :                 }
   13544           0 :                 |       _LOCK TABLE
   13545             :                 {
   13546           0 :                         $$ = 0x1<<AUDIT_LOCK_TAB;
   13547             :                 }
   13548           0 :                 |       _LOCK  ANY TABLE
   13549             :                 {
   13550           0 :                         $$ = 0x1<<AUDIT_LOCK_TAB;
   13551             :                 }
   13552           0 :                 |       EXECUTE PROCEDURE
   13553             :                 {
   13554           0 :                         $$ = 0x1<<AUDIT_EXECUTE;
   13555             :                 } 
   13556           0 :                 |       EXECUTE  ANY PROCEDURE
   13557             :                 {
   13558           0 :                         $$ = 0x1<<AUDIT_EXECUTE;
   13559             :                 }               
   13560           0 :                 ;
   13561             :                                                         
   13562           0 : LocalAuditItems:
   13563             :                 ALL ON name_space
   13564           0 :                 {
   13565             :                         AuditStmt *p_stmt =makeNode(AuditStmt);
   13566           0 :                         p_stmt->audits = 0xffffffff;
   13567             :                         p_stmt->obj_name =   $3;
   13568           0 :                         $$ = (Node*)p_stmt;     
   13569             :                 }       
   13570           0 :                 |       ObjAuditItems ON name_space
   13571             :                 {
   13572           0 :                         AuditStmt *p_stmt =makeNode(AuditStmt);
   13573             :                         p_stmt->audits = $1;
   13574             :                         p_stmt->obj_name =   $3;
   13575             :                         $$ = (Node*)p_stmt;     
   13576             :                 }
   13577           0 :                 ;                       
   13578           0 :                 
   13579           0 : ObjAuditItems: ObjAuditItem
   13580           0 :                 {
   13581             :                         $$ = $1;
   13582           0 :                 }
   13583             :                 |       ObjAuditItems ',' ObjAuditItem
   13584           0 :                 {
   13585           0 :                         $$ = (($1)|($3));
   13586           0 :                 }
   13587           0 :                 ;
   13588             :  
   13589           0 : ObjAuditItem:   INSERT
   13590             :                 {
   13591             :                         $$ = 0x1<<AUDIT_INSERT;
   13592             :                 }
   13593           0 :                 |       UPDATE
   13594             :                 {
   13595           0 :                         $$ = 0x1<<AUDIT_UPDATE;
   13596             :                 }
   13597           0 :                 |       _DELETE
   13598             :                 {
   13599           0 :                         $$ = 0x1<<AUDIT_DELETE;
   13600             :                 }
   13601             :                 |       SELECT
   13602             :                 {
   13603           0 :                         $$ = 0x1<<AUDIT_SELECT;
   13604             :                 }
   13605           0 :                 |       EXECUTE
   13606             :                 {
   13607           0 :                         $$ = 0x1<<AUDIT_EXECUTE;
   13608             :                 }
   13609           0 :                 ;                       
   13610             :         
   13611           0 : optAuditUser:   /*empty*/
   13612             :                 {
   13613           0 :                         $$ = NIL;
   13614             :                 }
   13615           0 :                 |        BY name_list
   13616             :                 {
   13617           0 :                         $$ = $2;
   13618             :                 }
   13619           0 :                 ;
   13620             : 
   13621           0 : optAuditCond:   /*empty*/
   13622             :                 {
   13623             :                         $$ = 3;
   13624             :                 } 
   13625           0 :                 |       WHENEVER  SUCCESSFUL
   13626             :                 {
   13627           0 :                         $$ = 1;
   13628             :                 }
   13629           0 :                 |       WHENEVER  NO SUCCESSFUL
   13630             :                 {
   13631           0 :                         $$ = 2;
   13632             :                 }
   13633             :                 ;       
   13634             :         
   13635           0 : Sconst:   SCONST                                        { $$ = $1; };
   13636             :                 | NEWLINE                                       { $$ = (char*)"\n";}
   13637           0 : UserId:  ColLabel                                       { $$ = $1; };
   13638             : 
   13639           0 : /* Parser tokens to be used as identifiers.
   13640             :  * Tokens involving data types should appear in ColId only,
   13641           0 :  * since they will conflict with real Typenam productions.
   13642             :  */
   13643           0 : TokenId:  IDENT                                         { $$ = $1; }
   13644             :                 | unreserved_keyword            { $$ = $1; }
   13645           0 :                 ;
   13646             : 
   13647        5626 : /* Column identifier
   13648        5626 :  * Include date/time keywords as SQL92 extension.
   13649           9 :  * Include TYPE as a SQL92 unreserved keyword. - thomas 1997-10-05
   13650        1588 :  * Add other keywords. Note that as the syntax expands,
   13651             :  *  some of these keywords will have to be removed from this
   13652             :  *  list due to shift/reduce conflicts in yacc. If so, move
   13653             :  *  down to the ColLabel storage. - thomas 1997-11-06
   13654             :  */
   13655      102090 : ColId:  
   13656      102090 :                   TokenId                                       { $$ = $1; }
   13657           0 :                 | LANGUAGE                  { $$ = $1; }
   13658           0 :                 | SUBTYPE                                       { $$ = $1; }
   13659           0 :                 | TYPE                                          { $$ = $1; }
   13660           0 :                 ;
   13661           0 :                 
   13662           0 : /* Column label
   13663           0 :  * Allowed labels in "AS" clauses.
   13664           0 :  * Include true/false SQL3 reserved words for  backward
   13665           0 :  *  compatibility. Cannot allow this for column names since the
   13666           0 :  *  syntax would not distinguish between the constant value and
   13667           0 :  *  a column name. - thomas 1997-10-24
   13668           0 :  * Add other keywords to this list. Note that they appear here
   13669           0 :  *  rather than in ColId if there was a shift/reduce conflict
   13670           0 :  *  when used as a full identifier. - thomas 1997-11-06
   13671           0 :  */
   13672           0 : ColLabel: ColId                                         { $$ = $1; }
   13673           0 :                 | collabel_keyword                      { $$ = $1; }
   13674           0 :                 | reserved_keyword                      { $$ = $1; }
   13675           0 :                 ;
   13676           0 : 
   13677           0 : collabel_keyword:
   13678           0 :                   _ABORT                                        { $$ = $1; }
   13679           0 :                 | CAST                                          { $$ = $1; }
   13680           0 :                 | CHARACTER                                     { $$ = $1; }
   13681           0 :                 | COALESCE                                      { $$ = $1; }
   13682           0 :                 | CONSTRAINT                            { $$ = $1; }
   13683           0 :                 | CROSS                                         { $$ = $1; }
   13684           3 :                 | CURRENT                                       { $$ = $1; }
   13685           6 :                 | COMMENT                                       { $$ = $1; }
   13686           0 :                 | CUBE                                          { $$ = $1; }
   13687           0 :                 | DEFERRABLE                            { $$ = $1; }
   13688           0 :                 | _END                                          { $$ = $1; }
   13689           0 :                 | EXCEPT                                        { $$ = $1; }
   13690           0 :                 | EXPLAIN                                       { $$ = $1; }
   13691           0 :                 | MINUS                                         { $$ = $1; }
   13692           0 :                 | FOREIGN                                       { $$ = $1; }
   13693           0 :                 | FINALLY                                       { $$ = $1; }
   13694           0 :                 | ILIKE                                         { $$ = $1; }
   13695           0 :                 | _INNER                                        { $$ = $1; }
   13696          26 :                 | ISNULL                                        { $$ = $1; }
   13697           3 :                 | JOIN                                          { $$ = $1; }
   13698           0 :                 | LEADING                                       { $$ = $1; }
   13699           0 :                 | LEFT                                          { $$ = $1; }
   13700           0 :                 | LISTEN                                        { $$ = $1; }
   13701           0 :                 | LOCAL                                         { $$ = $1; }
   13702          11 :                 | LEAST                                         { $$ = $1; }
   13703           0 :                 | NATURAL                                       { $$ = $1; }
   13704           0 :                 | NCHAR                                         { $$ = $1; }
   13705           0 :                 | NOTNULL                                       { $$ = $1; }
   13706           0 :                 | NULLIF                                        { $$ = $1; }
   13707           0 :                 | NOWAIT                                        { $$ = $1; }
   13708           0 :                 | NOCYCLE                                       { $$ = $1; }
   13709           0 :                 | OFF                                           { $$ = $1; }
   13710           0 :                 | REFERENCES                            { $$ = $1; }
   13711           0 :                 | RIGHT                                         { $$ = $1; }
   13712           0 :                 | ROLLUP                                        { $$ = $1; }
   13713           0 :                 | SETOF                                         { $$ = $1; }
   13714           0 :                 | SOME                                          { $$ = $1; }
   13715           0 :                 | SHUTDOWN                                      { $$ = $1; }
   13716           0 :                 | SELF                                          { $$ = $1; }
   13717           0 :                 | TRANSACTION                           { $$ = $1; }
   13718           0 :                 | TRAN                                          { $$ = $1; }
   13719           0 :                 | TOP                                           { $$ = $1; }
   13720           6 :                 | _TRUE                                         { $$ = $1; }
   13721           6 :                 | USING                                         { $$ = $1; }
   13722           0 :                 | VACUUM                                        { $$ = $1; }
   13723           0 :                 | WHEN                                          { $$ = $1; }
   13724           0 :                 | GREATEST                                      { $$ = $1; }
   13725           0 :                 | WAIT                                          { $$ = $1; }
   13726           0 :                 | WORK                                          { $$ = $1; }
   13727           0 :                 | PRIOR                                         { $$ = $1; }
   13728           0 : 
   13729           0 : unreserved_keyword:
   13730           0 :                   _ABSOLUTE                                     { $$ = $1; }
   13731           0 :                 | ACCESS                                        { $$ = $1; }
   13732           0 :                 | ACTION                                        { $$ = $1; }
   13733           0 :                 | ADD                                           { $$ = $1; }
   13734           0 :                 | AFTER                                         { $$ = $1; }
   13735           0 :                 | AGGREGATE                                     { $$ = $1; }
   13736           0 :                 | ARCHIVELOG                            { $$ = $1; }
   13737           0 :                 | ARE                                           { $$ = $1; }    
   13738           0 :                 | AT                        { $$ = $1; }//WHY 2015-12-18 add
   13739           0 :                 | AUTHORIZATION                         { $$ = $1; }
   13740           0 :                 | ACCOUNT                       { $$ = $1; }
   13741           0 :                 | AUTO                          { $$ = $1; }
   13742           0 :                 | APPEND                                        { $$ = $1; }
   13743           0 :                 | AUDITOR                                       { $$ = $1; }
   13744           0 :                 | ALL_ROWS                                      { $$ = $1; }//++bysdc@20200417
   13745           0 :                 | BACKWARD                                      { $$ = $1; }
   13746          18 :                 | BEFORE                                        { $$ = $1; }
   13747          18 :                 | BACKUP                        { $$ = $1; }
   13748           0 :                 | BADFILE                                       { $$ = $1; }
   13749           1 :                 | BLOCK                         { $$ = $1; }
   13750           0 :                 | BLOCKS                                        { $$ = $1; }
   13751             :                 | BUFFER_POOL                   { $$ = $1; }
   13752             :                 | BREAK                                         { $$ = $1; }
   13753           0 :                 | BODY                                          { $$ = $1; }
   13754           0 :                 | BOUND                                         { $$ = $1; }
   13755           0 :                 | BUILD                                         { $$ = $1; }
   13756           0 :                 | BY                            { $$ = $1; }
   13757           0 :                 | _CALL                                         { $$ = $1; }
   13758           0 :                 | _CATCH                                        { $$ = $1; }
   13759           0 :                 | CACHE                         { $$ = $1; }
   13760           0 :                 | CATEGORY                                      { $$ = $1; }
   13761           0 :                 | CHUNK                         { $$ = $1; }
   13762           0 :                 | COLLECT                       { $$ = $1; }
   13763           0 :                 | COMPUTE                       { $$ = $1; }
   13764           0 :                 | CONTAINS                      { $$ = $1; }
   13765           0 :                 | CURSOR_QUOTA                  { $$ = $1; }
   13766           0 :                 | COLLATE                                       { $$ = $1; }
   13767           0 :                 | COPY                                          { $$ = $1; }
   13768           0 :                 | CORRESPONDING                         { $$ = $1; }
   13769           0 :                 | COMPLETE                                      { $$ = $1; }
   13770           0 :                 | CHAIN                                         { $$ = $1; }
   13771           0 :                 | CHARACTERISTICS                       { $$ = $1; }
   13772           1 :                 | COMMITTED                                     { $$ = $1; }
   13773           0 :                 | CONSTRAINTS                           { $$ = $1; }
   13774           0 :                 | CREATEDB                                      { $$ = $1; }
   13775           0 :                 | CREATEUSER                            { $$ = $1; }
   13776           0 :                 | CYCLE                                         { $$ = $1; }
   13777           0 :                 | COLUMNS                                       { $$ = $1; }
   13778           0 :                 | CPU_PER_SESSION                       { $$ = $1; }//++bysdc@20200417
   13779           0 :                 | CPU_PER_CALL                          { $$ = $1; }//++bysdc@20200417
   13780             :                 | CONNECT_NODES                         { $$ = $1; }//++bysdc@20200417
   13781             :                 | CHOOSE                                        { $$ = $1; }//++bysdc@20200417
   13782             :                 | _CONTXT                                       { $$ = $1; }
   13783           0 :                 | _DOMAIN_                                      { $$ = $1; }
   13784           0 :                 | DATABASE                                      { $$ = $1; }
   13785          37 :                 | DEFERRED                                      { $$ = $1; }
   13786             :                 | DELIMITERS                            { $$ = $1; }
   13787           0 :                 | _DAY                      { $$ = $1; }        
   13788           0 :                 | _DIR                                          { $$ = $1; }
   13789           0 :                 | DO                                            { $$ = $1; }
   13790           0 :                 | DRIVEN                                        { $$ = $1; }
   13791           0 :                 | DEALLOCATE                    { $$ = $1; }
   13792           0 :                 | DETERMINISTIC                 { $$ = $1; }
   13793           0 :                 | DISASSEMBLE                   { $$ = $1; }
   13794           0 :                 | DATAFILE                                      { $$ = $1; }
   13795           0 :                 | DBA                                           { $$ = $1; }
   13796           0 :                 | DECRYPT                                       { $$ = $1; } //why 2017-05-11 add an sdc
   13797           0 :                 | DESCRIBE                                      { $$ = $1; }
   13798           0 :                 | DISCORDFILE                           { $$ = $1; }
   13799           0 :                 | DELIMITED                                     { $$ = $1; }
   13800           0 :                 | DEMAND                                        { $$ = $1; }
   13801           0 :                 | DISABLE                                       { $$ = $1; }
   13802           6 :                 | EACH                                          { $$ = $1; }
   13803           6 :                 | ENCODING                                      { $$ = $1; }
   13804           0 :                 | ESCAPE                                        { $$ = $1; }
   13805           0 :                 | EXCLUSIVE                                     { $$ = $1; }
   13806           0 :                 | EXECUTE                                       { $$ = $1; }
   13807           0 :                 | EVERY                         { $$ = $1; }
   13808           0 :                 | EXCEPTIONS                    { $$ = $1; }
   13809           0 :                 | EXIST                         { $$ = $1; }
   13810           0 :                 | EXPIRE                        { $$ = $1; }
   13811           0 :                 | EXPORT                        { $$ = $1; }
   13812           0 :                 | ENABLE                                        { $$ = $1; }
   13813           0 :                 | ELEMENT                                       { $$ = $1; }
   13814             :                 | ENCRYPTOR                                     { $$ = $1; }
   13815             :                 | ENCRYPT                                       { $$ = $1; }
   13816             :                 | EXTEND                                        { $$ = $1; }
   13817             :                 | EXTERNAL                                      { $$ = $1; }            
   13818             :                 | FORCE                                         { $$ = $1; }
   13819             :                 | FORWARD                                       { $$ = $1; }
   13820             :                 | FAILED_LOGIN_ATTEMPTS         { $$ = $1; }
   13821             :                 | FINAL                         { $$ = $1; }
   13822             :                 | FLASHBACK                     { $$ = $1; }
   13823             :                 | FOLLOWING                     { $$ = $1; }
   13824           0 :                 | FORALL                        { $$ = $1; }
   13825           0 :                 | FREELIST                      { $$ = $1; }
   13826           0 :                 | FREELISTS                     { $$ = $1; }
   13827           0 :                 | FILTER                                        { $$ = $1; }
   13828           0 :                 | FIRST                                         { $$ = $1; }
   13829          10 :                 | FIELDS                                        { $$ = $1; }    
   13830          10 :                 | FIELD                                         { $$ = $1; }
   13831           0 :                 | FAST                                          { $$ = $1; }
   13832           0 :                 | FOUND                                         { $$ = $1; }
   13833           6 :                 | FIRST_ROWS                            { $$ = $1; }//++bysdc@20200417
   13834           0 :                 | G                                                 { $$ = $1; }
   13835           0 :                 | GET                                           { $$ = $1; }
   13836           0 :                 | GLOBAL                                        { $$ = $1; }
   13837           0 :                 | GROUPING                                      { $$ = $1; }
   13838           9 :                 | GOTO                          { $$ = $1; }
   13839           0 :                 | GROUPS                        { $$ = $1; }
   13840           0 :                 | GENERATED                                     { $$ = $1; }
   13841           0 :                 | HANDLER                                       { $$ = $1; }
   13842           0 :                 | HIDE                          { $$ = $1; }
   13843           0 :                 | HINT                          { $$ = $1; }
   13844           1 :                 | HEAP                                          { $$ = $1; }
   13845           0 :                 | HASH                                          { $$ = $1; }
   13846           0 :                 | HOTSPOT                                       { $$ = $1; }
   13847           0 :                 | _HOUR                     { $$ = $1; }
   13848          57 :                 | IDENTIFIED                    { $$ = $1; }
   13849           0 :                 | IMPORT                        { $$ = $1; }
   13850           0 :                 | INDICES                       { $$ = $1; }
   13851           0 :                 | INIT                          { $$ = $1; }
   13852           8 :                 | INITIAL                       { $$ = $1; }
   13853           7 :                 | INITRANS                      { $$ = $1; }
   13854           0 :                 | INOUT                                         { $$ = $1; }
   13855           0 :                 | INSENSITIVE                   { $$ = $1; }
   13856           0 :                 | INSTANTIABLE                  { $$ = $1; }
   13857           0 :                 | INDICATOR                                     { $$ = $1; }
   13858           0 :                 | INCREMENT                                     { $$ = $1; }
   13859           0 :                 | INHERITS                                      { $$ = $1; }
   13860           0 :                 | INSERT                                        { $$ = $1; }
   13861           0 :                 | INSTEAD                                       { $$ = $1; }
   13862           0 :                 | ISOLATION                                     { $$ = $1; }
   13863           0 :                 | INDEX_JOIN                            { $$ = $1; }//++bysdc@20200417
   13864           0 :                 | INDEX_ASC                                     { $$ = $1; }//++bysdc@20200417
   13865           0 :                 | INDEX_DESC                            { $$ = $1; }//++bysdc@20200417
   13866           0 :                 | INDEX_FSS                                     { $$ = $1; }//++bysdc@20200417
   13867           0 :                 | IDENTITY                                      { $$ = $1; }
   13868           0 :                 | IDENTIFIER                            { $$ = $1; }
   13869           0 :                 | INCLUDE                                       { $$ = $1; }
   13870           0 :                 | INDEXTYPE                                     { $$ = $1; }
   13871           0 :                 | IO                                            { $$ = $1; }
   13872           0 :                 | ISOPEN                                        { $$ = $1; }
   13873           0 :                 | _IGNORE                                       { $$ = $1; }
   13874           0 :                 | JOB                                           { $$ = $1; }
   13875           0 :                 | K                                                     { $$ = $1; }
   13876           3 :                 | KEEP                                          { $$ = $1; }
   13877           8 :                 | KEY                                           { $$ = $1; }
   13878           0 :                 | KEYSET                                        { $$ = $1; }
   13879           0 :                 | LEVEL                                         { $$ = $1; }
   13880           0 :                 | LOCATION                                      { $$ = $1; }
   13881          12 :                 | LOB                           { $$ = $1; }
   13882           0 :                 | LOGGING                       { $$ = $1; }
   13883           0 :                 | LOGOFF                        { $$ = $1; }
   13884           0 :                 | LOGON                         { $$ = $1; }
   13885           0 :                 | LOGFILE                                       { $$ = $1; }
   13886           0 :                 | LEVELS                                        { $$ = $1; }
   13887           0 :                 | LAST                                          { $$ = $1; }
   13888           3 :                 | LENGTH                                        { $$ = $1; }
   13889           0 :                 | LESS                                          { $$ = $1; }    
   13890           0 :                 | LOGIN                                         { $$ = $1; }
   13891           0 :                 | LOGOUT                                        { $$ = $1; }
   13892           0 :                 | LOCATOR                                       { $$ = $1; }
   13893          58 :                 | LABEL                     { $$ = $1; } //2016-01-25 add
   13894          96 :                 | LOAD                                          { $$ = $1; }
   13895           0 :                 | LIBRARY                                       { $$ = $1; }
   13896           0 :                 | LIST                                          { $$ = $1; }
   13897           6 :                 | MATCHED                       { $$ = $1; }
   13898           7 :                 | MAXEXTENTS                    { $$ = $1; }
   13899           3 :                 | MAXTRANS                      { $$ = $1; }
   13900           0 :                 | MINEXTENTS                    { $$ = $1; }
   13901           0 :                 | MODIFY                        { $$ = $1; }
   13902           0 :                 | MATCH                                         { $$ = $1; }
   13903           0 :                 | MAXVALUE                                      { $$ = $1; }
   13904           0 :                 | MINVALUE                                      { $$ = $1; }
   13905           0 :                 | MODE                                          { $$ = $1; }
   13906           0 :                 | M                                                     { $$ = $1; }            
   13907           0 :                 | MATERIALIZED                          { $$ = $1; }
   13908           0 :                 | MAX_STORE_NUM                         { $$ = $1; }//++bysdc@20200417
   13909           0 :                 | MAX_CONNECT_TIME                      { $$ = $1; }//++bysdc@20200417
   13910           0 :                 | MAX_IDLE_TIME                         { $$ = $1; }//++bysdc@20200417
   13911           0 :                 | MEMORY                                        { $$ = $1; }
   13912           0 :                 | MERGE                                         { $$ = $1; }
   13913           0 :                 | MISSING                                       { $$ = $1; }
   13914           0 :                 | MAXSIZE                                       { $$ = $1; }
   13915           0 :                 | MOVEMENT                                      { $$ = $1; }
   13916           0 :                 | _MONTH                    { $$ = $1; }
   13917           1 :                 | _MINUTE                   { $$ = $1; }
   13918           0 :                 | _MAX                                          { $$ = $1; }
   13919           0 :                 | NAMES                                         { $$ = $1; }
   13920           0 :                 | NO                                            { $$ = $1; }
   13921           0 :                 | NOCREATEDB                            { $$ = $1; }
   13922           0 :                 | NOCREATEUSER                          { $$ = $1; }
   13923           0 :                 | NOTHING                                       { $$ = $1; }
   13924           0 :                 | NOTIFY                                        { $$ = $1; }
   13925           0 :                 | NESTED                        { $$ = $1; }
   13926           0 :                 | NOAUDIT                       { $$ = $1; }
   13927           0 :                 | NOCOMPRESS                    { $$ = $1; }
   13928           0 :                 | NODE                          { $$ = $1; }
   13929           0 :                 | NOLOGGING                     { $$ = $1; }
   13930           0 :                 | NOVALIDATE                    { $$ = $1; }
   13931           0 :                 | NOFORCE                                       { $$ = $1; }
   13932           0 :                 | NOFOUND                                       { $$ = $1; }
   13933           0 :                 | NOTFOUND                                      { $$ = $1; }
   13934           0 :                 | NOCACHE                                       { $$ = $1; }
   13935           0 :                 | NOORDER                                       { $$ = $1; }
   13936           0 :                 | NULLS                                         { $$ = $1; }
   13937           0 :                 | NOAPPEND                                      { $$ = $1; }//++bysdc@20200417
   13938           0 :                 | NOINDEX                                       { $$ = $1; }//++bysdc@20200417
   13939             :                 | NAME                                          { $$ = $1; }
   13940             :                 | NEW                                           { $$ = $1; }
   13941             :                 | NEXT                                          { $$ = $1; }    
   13942             :                 | NOARCHIVELOG                          { $$ = $1; }
   13943             :                 | NATIONAL                                      { $$ = $1; }
   13944             :                 | NONE                                          { $$ = $1; }
   13945             :                 | OIDS                                          { $$ = $1; }
   13946             :                 | OPERATOR                                      { $$ = $1; }
   13947             :                 | OPTION                                        { $$ = $1; }
   13948             :                 | OWNER                                         { $$ = $1; }
   13949       79523 :                 | OF                            { $$ = $1; }
   13950       79523 :                 | OFFSET                        { $$ = $1; }
   13951           0 :                 | OPEN                          { $$ = $1; }
   13952           3 :                 | ONLY                                          { $$ = $1; }
   13953           2 :                 | OBJECT                                        { $$ = $1; }
   13954           0 :                 | ONLINE                                        { $$ = $1; }
   13955           0 :                 | OFFLINE                                       { $$ = $1; }
   13956           0 :                 | OIDINDEX                                      { $$ = $1; }
   13957           9 :                 | ORGANIZATION                          { $$ = $1; }
   13958           0 :                 | ORDERD                                        { $$ = $1; }//++bysdc@20200417
   13959           0 :                 | OLD                                           { $$ = $1; }
   13960           0 :                 | OVERLAPS                                      { $$ = $1; }
   13961           0 :                 | _O_JOIN                       { $$ = $1; }
   13962           0 :                 | _OUTER                                        { $$ = $1; }
   13963           0 :                 | PASSWORD                                      { $$ = $1; }
   13964           0 :                 | PARTIAL                       { $$ = $1; }
   13965           0 :                 | PASSWORD_LIFE_PERIOD          { $$ = $1; }
   13966           0 :                 | PASSWORD_LOCK_TIME            { $$ = $1; }
   13967           0 :                 | PCTINCREASE                   { $$ = $1; }
   13968           0 :                 | PCTVERSION                    { $$ = $1; }
   13969           0 :                 | PERIOD                                        { $$ = $1; }
   13970           0 :                 | PRECISION                                     { $$ = $1; }    
   13971           0 :                 | PRECEDING                     { $$ = $1; }
   13972             :                 | PREPARE                       { $$ = $1; }
   13973             :                 | PRIVILEGES                            { $$ = $1; }
   13974             :                 | PROCEDURAL                            { $$ = $1; }
   13975             :                 | PROTECTED                                     { $$ = $1; }
   13976             :                 | PARTITIONS                            { $$ = $1; }    
   13977             :                 | PARAMETERS                            { $$ = $1; }
   13978             :                 | PACKAGE                                       { $$ = $1; }
   13979             :                 | PCTFREE                       { $$ = $1; }
   13980             :                 | PCTUSED                                       { $$ = $1; }
   13981             :                 | PRIORITY                                      { $$ = $1; }
   13982             :                 | PROFILE                                       { $$ = $1; }//++bysdc@20200417
   13983       21273 :                 | PUBLIC                                        { $$ = $1; }
   13984       21273 :                 | PREBUILT                                      { $$ = $1; }
   13985           0 :                 | PRIVATE_SGA                           { $$ = $1; }//++bysdc@20200417
   13986           0 :                 | PRESERVE                                      { $$ = $1; }
   13987           0 :                 | QUERY                                         { $$ = $1; }
   13988           0 :                 | QUOTA                                         { $$ = $1; }
   13989           0 :                 | REINDEX                                       { $$ = $1; }
   13990           0 :                 | _RELATIVE                                     { $$ = $1; }
   13991           0 :                 | REVOKE                                        { $$ = $1; }
   13992           0 :                 | ROW                                           { $$ = $1; }
   13993           0 :                 | RULE                                          { $$ = $1; }
   13994           0 :                 | READS                                         { $$ = $1; }
   13995           0 :                 | RANGE                                         { $$ = $1; }
   13996           0 :                 | RECYCLE                       { $$ = $1; }
   13997           0 :                 | RESTORE                       { $$ = $1; }
   13998           0 :                 | RESULT_CACHE                          { $$ = $1; }//++bysdc@20200417
   13999           0 :                 | ROWTYPE                       { $$ = $1; }
   14000           0 :                 | RECORD                    { $$ = $1; } //2016-01-25 add
   14001           0 :                 | RECOMPILE                                     { $$ = $1; }
   14002           0 :                 | REPLICATION                           { $$ = $1; }
   14003           0 :                 | RESTART                                       { $$ = $1; }
   14004           0 :                 | READ                                          { $$ = $1; }
   14005           0 :                 | ROLE                                          { $$ = $1; }
   14006           0 :                 | ROWCOUNT                                      { $$ = $1; }
   14007           0 :                 | READS_PER_SESSION                     { $$ = $1; }//++bysdc@20200417
   14008           0 :                 | READS_PER_CALL                        { $$ = $1; }//++bysdc@20200417
   14009           0 :                 | ROWS                                          { $$ = $1; }
   14010           0 :                 | REF                                           { $$ = $1; }
   14011           0 :                 | REPLACE                                       { $$ = $1; }
   14012           0 :                 | REFERENCING                           { $$ = $1; }
   14013           0 :                 | RESOURCE                                      { $$ = $1; }
   14014           0 :                 | REBUILD                                       { $$ = $1; }
   14015           0 :                 | RECORDS                                       { $$ = $1; }    
   14016           0 :                 | RESULT                                        { $$ = $1; }
   14017           0 :                 | REFRESH                                       { $$ = $1; }
   14018           0 :                 | REDUCED                                       { $$ = $1; }
   14019           0 :                 | REWRITE                                       { $$ = $1; }
   14020           0 :                 | RUN                                           { $$ = $1; }
   14021           0 :                 | _REPEATABLE                           { $$ = $1; }            
   14022           0 :                 | _ROWID                                        { $$ = $1; }
   14023           0 :                 | SCHEMA                                        { $$ = $1; }
   14024           0 :                 | SESSION                                       { $$ = $1; }
   14025           0 :                 | SEQUENCE                                      { $$ = $1; }
   14026           0 :                 | SERIALIZABLE                          { $$ = $1; }
   14027           0 :                 | SHARE                                         { $$ = $1; }
   14028           0 :                 | STATEMENT                                     { $$ = $1; }
   14029           0 :                 | SAVEPOINT                     { $$ = $1; }
   14030           0 :                 | SCROLL                        { $$ = $1; }
   14031           0 :                 | SNAPSHOT                      { $$ = $1; }
   14032           0 :                 | STATISTICS                    { $$ = $1; }
   14033           0 :                 | STORE                         { $$ = $1; }
   14034           0 :                 | SUCCESSFUL                    { $$ = $1; }
   14035           0 :                 | SYNONYM                       { $$ = $1; }
   14036           0 :                 | SHOW                                          { $$ = $1; }
   14037           0 :                 | _SECOND                   { $$ = $1; }                
   14038           0 :                 | SEGMENT                                       { $$ = $1; }
   14039           0 :                 | SETS                                          { $$ = $1; }
   14040           0 :                 | STEP                                          { $$ = $1; }
   14041           0 :                 | STREAM                                        { $$ = $1; }
   14042           0 :                 | SIBLINGS                                      { $$ = $1; }
   14043           0 :                 | SLOW                                          { $$ = $1; }
   14044           0 :                 | SESSION_PER_USER                      { $$ = $1; }//++bysdc@20200417
   14045           0 :                 | STORE_NODES                           { $$ = $1; }//++bysdc@20200417
   14046           0 :                 | STANDBY                                       { $$ = $1; }
   14047           0 :                 | SSO                                           { $$ = $1; }
   14048           0 :                 | STOP                                          { $$ = $1; }
   14049           0 :                 | SPATIAL                                       { $$ = $1; }
   14050           0 :                 | SPLIT                                         { $$ = $1; }
   14051           0 :                 | SYSTEM                                        { $$ = $1; }
   14052           0 :                 | STORAGE                                       { $$ = $1; }
   14053           0 :                 | SUBPARTITIONS                         { $$ = $1; }
   14054           0 :                 | _SIZE_                        { $$ = $1; }
   14055           0 :                 | TEMP                                          { $$ = $1; }
   14056           0 :                 | TEMPLATE                                      { $$ = $1; }
   14057           0 :                 | TEMPORARY                                     { $$ = $1; }
   14058          72 :                 | TRUSTED                                       { $$ = $1; }
   14059           0 :                 | TOTAL_RESOURCE_LIMIT          { $$ = $1; }//++bysdc@20200417
   14060           0 :                 | TEMPSPACE_QUOTA                       { $$ = $1; }//++bysdc@20200417
   14061           0 :                 | TABLESPACE                    { $$ = $1; }
   14062           0 :                 | THROW                         { $$ = $1; }
   14063           0 :                 | TRUNCATE                      { $$ = $1; }
   14064           0 :                 | TRACE                                         { $$ = $1; }
   14065           0 :                 | TRIM                                          { $$ = $1; }
   14066             :                 | THAN                                          { $$ = $1; }
   14067             :                 | TERMINATED                            { $$ = $1; }    
   14068           0 :                 | _TRY                          { $$ = $1; }
   14069           0 :                 | UNTIL                                         { $$ = $1; }
   14070           0 :                 | UNPROTECTED                           { $$ = $1; }
   14071           0 :                 | UNLIMITED                                     { $$ = $1; }
   14072           0 :                 | UNIFORM                                       { $$ = $1; }
   14073           0 :                 | UNDO                                          { $$ = $1; }
   14074           0 :                 | UNLISTEN                      { $$ = $1; }
   14075           0 :                 | UNLOCK                        { $$ = $1; }
   14076           0 :                 | USE_HASH                                      { $$ = $1; }//++bysdc@20200417
   14077           0 :                 | VALID                                         { $$ = $1; }
   14078           0 :                 | VALIDATE                      { $$ = $1; }
   14079           0 :                 | VARRAY                        { $$ = $1; }
   14080           0 :                 | VALUE                                         { $$ = $1; }
   14081           0 :                 | VERSION                                       { $$ = $1; }
   14082           0 :                 | VOCABLE                                       { $$ = $1; }
   14083           0 :                 | WHENEVER                      { $$ = $1; }
   14084           0 :                 | WRITE                         { $$ = $1; }
   14085           0 :                 | XML                           { $$ = $1; }
   14086           0 :                 | _YEAR                     { $$ = $1; }
   14087           0 :                 | ZONE                                          { $$ = $1; }
   14088           0 :                 ; 
   14089           0 : 
   14090           0 : reserved_keyword:
   14091           0 :                   ALL                           { $$ = $1; }
   14092           0 :                 | ALTER                         { $$ = $1; }
   14093           0 :                 | ANALYZE                       { $$ = $1; }
   14094           0 :                 | AND                                           { $$ = $1; }
   14095           0 :                 | ANY                                           { $$ = $1; }
   14096           0 :                 | ARRAY                         { $$ = $1; }//ADD name clause
   14097           0 :                 | AUTHID                        { $$ = $1; }
   14098           0 :                 | AS                            { $$ = $1; }
   14099           0 :                 | _ASC                                          { $$ = $1; }
   14100           0 :                 | BETWEEN                                       { $$ = $1; }
   14101           0 :                 | BINARY                                        { $$ = $1; }
   14102           0 :                 | BIT                                           { $$ = $1; }
   14103           0 :                 | BOTH                                          { $$ = $1; }//ADD name clause
   14104           0 :                 | CASE                                          { $$ = $1; }//ADD name clause
   14105           0 :                 | CHECK                                         { $$ = $1; }
   14106           0 :                 | CLUSTER                                       { $$ = $1; }//ADD name clause
   14107           0 :                 | CONNECT                       { $$ = $1; }
   14108           0 :                 | COLUMN                        { $$ = $1; }
   14109           0 :                 | CONSTANT                      { $$ = $1; }
   14110           0 :                 | CONSTRUCTOR                   { $$ = $1; }//ADD name clause
   14111           0 :                 | COMPRESS                      { $$ = $1; }
   14112           0 :                 | CREATE                        { $$ = $1; }
   14113           0 :                 | _DATE                         { $$ = $1; }
   14114           0 :                 | DATETIME                      { $$ = $1; }
   14115           0 :                 | DECLARE                       { $$ = $1; }//ADD name clause
   14116           0 :                 | _DECIMAL                      { $$ = $1; }
   14117           0 :                 | DEFAULT                       { $$ = $1; }
   14118           0 :                 | _DELETE                       { $$ = $1; }
   14119             :                 | DEC                                           { $$ = $1; }
   14120             :                 | DESC                          { $$ = $1; }
   14121           0 :                 | DISTINCT                      { $$ = $1; }
   14122           0 :                 | DROP                          { $$ = $1; }
   14123           0 :                 | _DOUBLE                                       { $$ = $1; }
   14124           0 :                 | ELSE                          { $$ = $1; }
   14125           0 :                 | EXISTS                        { $$ = $1; }
   14126           0 :                 | _FALSE                        { $$ = $1; }//ADD name clause
   14127           0 :                 | FETCH                         { $$ = $1; }//ADD name clause
   14128           0 :                 | _FLOAT                        { $$ = $1; }
   14129           0 :                 | FOR                           { $$ = $1; }
   14130           0 :                 | FROM                          { $$ = $1; }
   14131           0 :                 | FUNCTION                                      { $$ = $1; }//ADD name clause
   14132           0 :                 | GRANT                         { $$ = $1; }
   14133           0 :                 | _GROUP                        { $$ = $1; }
   14134           0 :                 | HAVING                        { $$ = $1; }
   14135           0 :                 | _IN                           { $$ = $1; }
   14136           0 :                 | INDEX                         { $$ = $1; }
   14137           0 :                 | INITIALLY                     { $$ = $1; }//ADD name clause
   14138           0 :                 | INTERSECT                     { $$ = $1; }
   14139           0 :                 | INTO                          { $$ = $1; }
   14140           0 :                 | IMMEDIATE                     { $$ = $1; }
   14141           0 :                 | IS                            { $$ = $1; }
   14142           0 :                 | LINK                                          { $$ = $1; }
   14143           0 :                 | LIMIT                         { $$ = $1; }//ADD name clause
   14144           0 :                 | LIKE                          { $$ = $1; }
   14145           0 :                 | _LOCK                         { $$ = $1; }
   14146           0 :                 | NOT                           { $$ = $1; }
   14147           0 :                 | _NULL                         { $$ = $1; }
   14148           0 :                 | _NUMERIC                      { $$ = $1; }
   14149           0 :                 | NUMBER                                        { $$ = $1; }
   14150           0 :                 | NVARCHAR                      { $$ = $1; }
   14151           0 :                 | NVARCHAR2                     { $$ = $1; }
   14152           0 :                 | MEMBER                        { $$ = $1; }//ADD name clause
   14153           0 :                 | ON                            { $$ = $1; }
   14154           0 :                 | OR                            { $$ = $1; }
   14155           0 :                 | ORDER                         { $$ = $1; }
   14156           0 :                 | _OUT                                          { $$ = $1; }
   14157           0 :                 | PRAGMA                        { $$ = $1; }//ADD name clause
   14158           0 :                 | PRIMARY                       { $$ = $1; }//ADD name clause
   14159           0 :                 | PROCEDURE                     { $$ = $1; }//ADD name clause
   14160           0 :                 | _RAW_                         { $$ = $1; }
   14161           0 :                 | RENAME                        { $$ = $1; }//ADD name clause
   14162           0 :                 | SELECT                        { $$ = $1; }
   14163           0 :                 | SET                           { $$ = $1; }
   14164           0 :                 | STATIC                        { $$ = $1; }//ADD name clause
   14165           0 :                 | TABLE                         { $$ = $1; }
   14166           0 :                 | THEN                          { $$ = $1; }
   14167           0 :                 | TO                            { $$ = $1; }
   14168           0 :                 | TRAILING                      { $$ = $1; }//ADD name clause
   14169           0 :                 | TRIGGER                       { $$ = $1; }
   14170           0 :                 | TIME                                          { $$ = $1; }
   14171           0 :                 | TIMESTAMP                                     { $$ = $1; }
   14172           0 :                 | UNBOUNDED                     { $$ = $1; }//ADD name clause
   14173           0 :                 | UNION                         { $$ = $1; }
   14174           0 :                 | UNIQUE                        { $$ = $1; }
   14175           0 :                 | UPDATE                        { $$ = $1; }
   14176           0 :                 | VALUES                        { $$ = $1; }
   14177           0 :                 | VARCHAR                       { $$ = $1; }
   14178           0 :                 | VARCHAR2                      { $$ = $1; }
   14179           0 :                 | VERBOSE                                       { $$ = $1; }
   14180           0 :                 | VIEW                          { $$ = $1; }
   14181           0 :                 | WHERE                         { $$ = $1; }//ADD name clause
   14182           0 :                 ;
   14183           0 : 
   14184           0 : Keywords:
   14185           0 :                   reserved_keyword                      { $$ = $1; }
   14186           0 :                 | unreserved_keyword            { $$ = $1; }
   14187           0 :                 | collabel_keyword                      { $$ = $1; }
   14188           0 :                 | _BEGIN                                        { $$ = $1; }
   14189           0 :                 | _HINT_TEXT                    { $$ = $1; }
   14190           0 :                 | ABOVE                         { $$ = $1; }
   14191           0 :                 | AOVERLAPS                     { $$ = $1; }
   14192           0 :                 | ASSIGN                        { $$ = $1; }
   14193           0 :                 | AUDIT                         { $$ = $1; }
   14194           0 :                 | BCONTAINS                     { $$ = $1; }
   14195           0 :                 | BINTERSECTS                   { $$ = $1; }
   14196           0 :                 | BITCONST                      { $$ = $1; }
   14197           0 :                 | BOVERLAPS                     { $$ = $1; }
   14198           0 :                 | BULK                          { $$ = $1; }
   14199           0 :                 | BWITHIN                       { $$ = $1; }
   14200           0 :                 | CASCADE                       { $$ = $1; }
   14201           0 :                 | CHECKPOINT                    { $$ = $1; }
   14202           0 :                 | CLOSE                         { $$ = $1; }
   14203           0 :                 | COMMIT                        { $$ = $1; }
   14204           0 :                 | CONTINUE                      { $$ = $1; }
   14205           0 :                 | CROSSES                       { $$ = $1; }
   14206           0 :                 | CURSOR                        { $$ = $1; }
   14207           0 :                 | DECODE                        { $$ = $1; }
   14208           0 :                 | DISJOINT                      { $$ = $1; }
   14209           0 :                 | ELSIF                         { $$ = $1; }
   14210           0 :                 | ENDCASE                       { $$ = $1; }
   14211           0 :                 | ENDFOR                        { $$ = $1; }
   14212           0 :                 | ENDIF                         { $$ = $1; }
   14213           0 :                 | ENDLOOP                       { $$ = $1; }
   14214           0 :                 | EQUALS                        { $$ = $1; }
   14215           0 :                 | EXCEPTION                     { $$ = $1; }
   14216           0 :                 | EXIT                          { $$ = $1; }
   14217           0 :                 | EXTRACT                       { $$ = $1; }
   14218           0 :                 | FULL                          { $$ = $1; }
   14219           0 :                 | IF                            { $$ = $1; }
   14220           0 :                 | INTERSECTS                    { $$ = $1; }
   14221           0 :                 | INTERVAL                      { $$ = $1; }
   14222           0 :                 | LEAVE                         { $$ = $1; }
   14223           0 :                 | LEFTOF                        { $$ = $1; }
   14224           0 :                 | LEXER                         { $$ = $1; }
   14225           0 :                 | LOOP                          { $$ = $1; }
   14226           0 :                 | LOVERLAPS                     { $$ = $1; }
   14227           0 :                 | MAXVALUES                     { $$ = $1; }
   14228           0 :                 | NEWLINE                       { $$ = $1; }
   14229           0 :                 | NOPARALLEL                    { $$ = $1; }
   14230           0 :                 | NVL                           { $$ = $1; }
   14231           0 :                 | NVL2                          { $$ = $1; }
   14232           0 :                 | OTHERVALUES                   { $$ = $1; }
   14233           0 :                 | OVER                          { $$ = $1; }
   14234           0 :                 | PARALLEL                      { $$ = $1; }
   14235           0 :                 | PARTITION                     { $$ = $1; }
   14236           0 :                 | POLICY                        { $$ = $1; }
   14237           0 :                 | RAISE                         { $$ = $1; }
   14238           0 :                 | RESTRICT                      { $$ = $1; }
   14239           0 :                 | RETURN                        { $$ = $1; }
   14240           0 :                 | RETURNING                     { $$ = $1; }
   14241           0 :                 | REVERSE                       { $$ = $1; }
   14242           0 :                 | RIGHTOF                       { $$ = $1; }
   14243           0 :                 | ROLLBACK                      { $$ = $1; }
   14244           0 :                 | ROVERLAPS                     { $$ = $1; }
   14245           0 :                 | SCONST                        { $$ = $1; }
   14246           0 :                 | START                         { $$ = $1; }
   14247           0 :                 | SUBPARTITION                  { $$ = $1; }
   14248           0 :                 | TOUCHES                       { $$ = $1; }
   14249           0 :                 | UNDER                         { $$ = $1; }
   14250           0 :                 | UNIONJOIN                     { $$ = $1; }
   14251           0 :                 | UOVERLAPS                     { $$ = $1; }
   14252           0 :                 | USE                           { $$ = $1; }
   14253           0 :                 | USER                          { $$ = $1; }
   14254           0 :                 | VARYING                       { $$ = $1; }
   14255           0 :                 | WHILE                         { $$ = $1; }
   14256           0 :                 | WITH                          { $$ = $1; }
   14257           0 :                 | WITHIN                        { $$ = $1; }
   14258           0 :                 | WITHOUT                       { $$ = $1; }
   14259           0 :                 ;
   14260           0 : %%

Generated by: LCOV version 1.15