📄 preproc.y
字号:
if (INFORMIX_MODE) { /* * Informix also has a CLOSE DATABASE command that * essantially works like a DISCONNECT CURRENT * as far as I know. */ if (pg_strcasecmp($1+strlen("close "), "database") == 0) { if (connection) mmerror(PARSE_ERROR, ET_ERROR, "no at option for close database statement.\n"); fprintf(yyout, "{ ECPGdisconnect(__LINE__, \"CURRENT\");"); whenever_action(2); free($1); } else output_statement($1, 0, ECPGst_normal); } else output_statement($1, 0, ECPGst_normal); } | ClusterStmt { output_statement($1, 0, ECPGst_normal); } | CommentStmt { output_statement($1, 0, ECPGst_normal); } | ConstraintsSetStmt { output_statement($1, 0, ECPGst_normal); } | CopyStmt { output_statement($1, 0, ECPGst_normal); } | CreateAsStmt { output_statement($1, 0, ECPGst_normal); } | CreateAssertStmt { output_statement($1, 0, ECPGst_normal); } | CreateCastStmt { output_statement($1, 0, ECPGst_normal); } | CreateConversionStmt { output_statement($1, 0, ECPGst_normal); } | CreateDomainStmt { output_statement($1, 0, ECPGst_normal); } | CreateFunctionStmt { output_statement($1, 0, ECPGst_normal); } | CreateGroupStmt { output_statement($1, 0, ECPGst_normal); } | CreatePLangStmt { output_statement($1, 0, ECPGst_normal); } | CreateOpClassStmt { output_statement($1, 0, ECPGst_normal); } | CreateOpFamilyStmt { output_statement($1, 0, ECPGst_normal); } | AlterOpFamilyStmt { output_statement($1, 0, ECPGst_normal); } | CreateRoleStmt { output_statement($1, 0, ECPGst_normal); } | CreateSchemaStmt { output_statement($1, 0, ECPGst_normal); } | CreateSeqStmt { output_statement($1, 0, ECPGst_normal); } | CreateStmt { output_statement($1, 0, ECPGst_normal); } | CreateTableSpaceStmt { output_statement($1, 0, ECPGst_normal); } | CreateTrigStmt { output_statement($1, 0, ECPGst_normal); } | CreateUserStmt { output_statement($1, 0, ECPGst_normal); } | CreatedbStmt { output_statement($1, 0, ECPGst_normal); } | DeallocateStmt { if (connection) mmerror(PARSE_ERROR, ET_ERROR, "no at option for deallocate statement.\n"); output_deallocate_prepare_statement($1); } | DeclareCursorStmt { output_simple_statement($1); } | DefineStmt { output_statement($1, 0, ECPGst_normal); } | DeleteStmt { output_statement($1, 1, ECPGst_normal); } | DiscardStmt { output_statement($1, 1, ECPGst_normal); } | DropAssertStmt { output_statement($1, 0, ECPGst_normal); } | DropCastStmt { output_statement($1, 0, ECPGst_normal); } | DropGroupStmt { output_statement($1, 0, ECPGst_normal); } | DropOpClassStmt { output_statement($1, 0, ECPGst_normal); } | DropOpFamilyStmt { output_statement($1, 0, ECPGst_normal); } | DropOwnedStmt { output_statement($1, 0, ECPGst_normal); } | DropPLangStmt { output_statement($1, 0, ECPGst_normal); } | DropRoleStmt { output_statement($1, 0, ECPGst_normal); } | DropRuleStmt { output_statement($1, 0, ECPGst_normal); } | DropStmt { output_statement($1, 0, ECPGst_normal); } | DropTableSpaceStmt { output_statement($1, 0, ECPGst_normal); } | DropTrigStmt { output_statement($1, 0, ECPGst_normal); } | DropUserStmt { output_statement($1, 0, ECPGst_normal); } | DropdbStmt { output_statement($1, 0, ECPGst_normal); } | ExplainStmt { output_statement($1, 0, ECPGst_normal); } | ExecuteStmt { output_statement($1, 1, ECPGst_execute); } | FetchStmt { output_statement($1, 1, ECPGst_normal); } | GrantStmt { output_statement($1, 0, ECPGst_normal); } | GrantRoleStmt { output_statement($1, 0, ECPGst_normal); } | IndexStmt { output_statement($1, 0, ECPGst_normal); } | InsertStmt { output_statement($1, 1, ECPGst_normal); } | ListenStmt { output_statement($1, 0, ECPGst_normal); } | LoadStmt { output_statement($1, 0, ECPGst_normal); } | LockStmt { output_statement($1, 0, ECPGst_normal); } | NotifyStmt { output_statement($1, 0, ECPGst_normal); } | PrepareStmt { if ($1.type == NULL || strlen($1.type) == 0) /* use PQprepare without type parameters */ output_prepare_statement($1.name, $1.stmt); else /* use PQexec and let backend do its stuff */ { char *txt = cat_str(5, make_str("prepare"), $1.name, $1.type, make_str("as"), $1.stmt); output_statement(txt, 0, ECPGst_normal); } } | ReassignOwnedStmt { output_statement($1, 0, ECPGst_normal); } | ReindexStmt { output_statement($1, 0, ECPGst_normal); } | RemoveAggrStmt { output_statement($1, 0, ECPGst_normal); } | RemoveOperStmt { output_statement($1, 0, ECPGst_normal); } | RemoveFuncStmt { output_statement($1, 0, ECPGst_normal); } | RenameStmt { output_statement($1, 0, ECPGst_normal); } | RevokeStmt { output_statement($1, 0, ECPGst_normal); } | RevokeRoleStmt { output_statement($1, 0, ECPGst_normal); } | RuleStmt { output_statement($1, 0, ECPGst_normal); } | SelectStmt { output_statement($1, 1, ECPGst_normal); } | TransactionStmt { fprintf(yyout, "{ ECPGtrans(__LINE__, %s, \"%s\");", connection ? connection : "NULL", $1); whenever_action(2); free($1); } | TruncateStmt { output_statement($1, 0, ECPGst_normal); } | UnlistenStmt { output_statement($1, 0, ECPGst_normal); } | UpdateStmt { output_statement($1, 1, ECPGst_normal); } | VacuumStmt { output_statement($1, 0, ECPGst_normal); } | VariableSetStmt { output_statement($1, 0, ECPGst_normal); } | VariableShowStmt { output_statement($1, 0, ECPGst_normal); } | VariableResetStmt { output_statement($1, 0, ECPGst_normal); } | ViewStmt { output_statement($1, 0, ECPGst_normal); } | ECPGAllocateDescr { fprintf(yyout,"ECPGallocate_desc(__LINE__, %s);",$1); whenever_action(0); free($1); } | ECPGConnect { if (connection) mmerror(PARSE_ERROR, ET_ERROR, "no at option for connect statement.\n"); fprintf(yyout, "{ ECPGconnect(__LINE__, %d, %s, %d); ", compat, $1, autocommit); reset_variables(); whenever_action(2); free($1); } | ECPGCursorStmt { output_simple_statement($1); } | ECPGDeallocateDescr { if (connection) mmerror(PARSE_ERROR, ET_ERROR, "no at option for deallocate statement.\n"); fprintf(yyout,"ECPGdeallocate_desc(__LINE__, %s);",$1); whenever_action(0); free($1); } | ECPGDeclare { output_simple_statement($1); } | ECPGDescribe { fprintf(yyout, "{ ECPGdescribe(__LINE__, %s,", $1); dump_variables(argsresult, 1); fputs("ECPGt_EORT);", yyout); fprintf(yyout, "}"); output_line_number(); /* whenever_action(2); */ free($1); } | ECPGDisconnect { if (connection) mmerror(PARSE_ERROR, ET_ERROR, "no at option for disconnect statement.\n"); fprintf(yyout, "{ ECPGdisconnect(__LINE__, %s);", $1 ? $1 : "\"CURRENT\""); whenever_action(2); free($1); } | ECPGExecuteImmediateStmt { output_statement($1, 0, ECPGst_exec_immediate); } | ECPGFree { const char *con = connection ? connection : "NULL"; if (strcmp($1, "all")) fprintf(yyout, "{ ECPGdeallocate(__LINE__, %d, %s, \"%s\");", compat, con, $1); else fprintf(yyout, "{ ECPGdeallocate_all(__LINE__, %d, %s);", compat, con); whenever_action(2); free($1); } | ECPGGetDescriptor { lookup_descriptor($1.name, connection); output_get_descr($1.name, $1.str); free($1.name); free($1.str); } | ECPGGetDescriptorHeader { lookup_descriptor($1, connection); output_get_descr_header($1); free($1); } | ECPGOpen { struct cursor *ptr; if ((ptr = add_additional_variables($1, true)) != NULL) { connection = ptr->connection ? mm_strdup(ptr->connection) : NULL; output_statement(mm_strdup(ptr->command), 0, 0); ptr->opened = true; } } | ECPGSetAutocommit { fprintf(yyout, "{ ECPGsetcommit(__LINE__, \"%s\", %s);", $1, connection ? connection : "NULL"); whenever_action(2); free($1); } | ECPGSetConnection { if (connection) mmerror(PARSE_ERROR, ET_ERROR, "no at option for set connection statement.\n"); fprintf(yyout, "{ ECPGsetconn(__LINE__, %s);", $1); whenever_action(2); free($1); } | ECPGSetDescriptor { lookup_descriptor($1.name, connection); output_set_descr($1.name, $1.str); free($1.name); free($1.str); } | ECPGSetDescriptorHeader { lookup_descriptor($1, connection); output_set_descr_header($1); free($1); } | ECPGTypedef { if (connection) mmerror(PARSE_ERROR, ET_ERROR, "no at option for typedef statement.\n"); fprintf(yyout, "%s", $1); free($1); output_line_number(); } | ECPGVar { if (connection) mmerror(PARSE_ERROR, ET_ERROR, "no at option for var statement.\n"); output_simple_statement($1); } | ECPGWhenever { if (connection) mmerror(PARSE_ERROR, ET_ERROR, "no at option for whenever statement.\n"); output_simple_statement($1); } ;/* * We start with a lot of stuff that's very similar to the backend's parsing *//***************************************************************************** * * Create a new Postgres DBMS role * * *****************************************************************************/CreateRoleStmt: CREATE ROLE RoleId opt_with OptRoleList { $$ = cat_str(4, make_str("create role"), $3, make_str("with"), $5); } ;opt_with: WITH { $$ = make_str("with"); } | /*EMPTY*/ { $$ = EMPTY; } ;/* * Options for CREATE ROLE and ALTER ROLE (also used by CREATE/ALTER USER * for backwards compatibility). Note: the only option required by SQL99 * is "WITH ADMIN name". */OptRoleList: PASSWORD Sconst { $$ = cat2_str(make_str("password"), $2); } | PASSWORD NULL_P { $$ = make_str("password null"); } | ENCRYPTED PASSWORD Sconst { $$ = cat2_str(make_str("encrypted password"), $3); } | UNENCRYPTED PASSWORD Sconst { $$ = cat2_str(make_str("unencrypted password"), $3); } | SUPERUSER_P { $$ = make_str("superuser"); } | NOSUPERUSER { $$ = make_str("nosuperuser"); } | INHERIT { $$ = make_str("inherit"); } | NOINHERIT { $$ = make_str("noinherit"); } | CREATEDB { $$ = make_str("createdb"); } | NOCREATEDB { $$ = make_str("nocreatedb"); } | CREATEROLE { $$ = make_str("createrole"); } | NOCREATEROLE { $$ = make_str("nocreaterole"); } | LOGIN_P { $$ = make_str("login"); } | NOLOGIN_P { $$ = make_str("nologin"); } | CONNECTION LIMIT IntConst { $$ = cat2_str(make_str("connection limit"), $3); } | VALID UNTIL Sconst { $$ = cat2_str(make_str("valid until"), $3); } | USER name_list { $$ = cat2_str(make_str("user"), $2); } | SYSID PosIntConst { $$ = cat2_str(make_str("sysid"), $2); } | ADMIN name_list { $$ = cat2_str(make_str("admin"), $2); } | ROLE name_list { $$ = cat2_str(make_str("role"), $2); } | IN_P ROLE name_list { $$ = cat2_str(make_str("in role"), $3); } | IN_P GROUP_P name_list { $$ = cat2_str(make_str("in group"), $3); } ;/***************************************************************************** * * Create a new Postgres DBMS user (role with implied login ability) * *****************************************************************************/CreateUserStmt: CREATE USER RoleId opt_with OptRoleList {$$ = cat_str(4, make_str("create user"), $3, $4, $5); } ; /***************************************************************************** * * Alter a postgresql DBMS role * * *****************************************************************************/ AlterRoleStmt: ALTER ROLE RoleId opt_with OptRoleList { $$ = cat_str(4, make_str("alter role"), $3, $4, $5); } ; AlterRoleSetStmt: ALTER ROLE RoleId SetResetClause { $$ = cat_str(3, make_str("alter role"), $3, $4); } ; /***************************************************************************** * * Alter a postgresql DBMS user * *****************************************************************************/ AlterUserStmt: ALTER USER RoleId opt_with OptRoleList { $$ = cat_str(4, make_str("alter user"), $3, $4, $5); }; AlterUserSetStmt: ALTER USER RoleId SetResetClause { $$ = cat_str(3, make_str("alter user"), $3, $4); } ; /***************************************************************************** * * Drop a postgresql DBMS role * * *****************************************************************************/ DropRoleStmt: DROP ROLE name_list { $$ = cat2_str(make_str("drop role"), $3);} | DROP ROLE IF_P EXISTS name_list { $$ = cat2_str(make_str("drop role if exists"), $5);} ; /***************************************************************************** * * Drop a postgresql DBMS user * * *****************************************************************************/ DropUserStmt: DROP USER name_list { $$ = cat2_str(make_str("drop user"), $3);} | DROP USER IF_P EXISTS name_list { $$ = cat2_str(make_str("drop user if exists"), $5);} ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -