📄 preproc.y
字号:
{ if (connection) mmerror(PARSE_ERROR, ET_ERROR, "no at option for deallocate statement.\n"); fprintf(yyout, "{ ECPGdeallocate(__LINE__, %d, %s);", compat, $1); whenever_action(2); free($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); } | ECPGExecute { output_statement($1, 0, connection); } | ECPGFree { fprintf(yyout, "{ ECPGdeallocate(__LINE__, %d, \"%s\");", compat, $1); 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) output_statement(mm_strdup(ptr->command), 0, ptr->connection ? mm_strdup(ptr->connection) : NULL); ptr->opened = true; } | ECPGPrepare { if (connection) mmerror(PARSE_ERROR, ET_ERROR, "no at option for prepare statement.\n"); fprintf(yyout, "{ ECPGprepare(__LINE__, %s);", $1); whenever_action(2); free($1); } /* | ECPGRelease { / * output already done * / } */ | 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); } | 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 SET set_rest { $$ = cat_str(4, make_str("alter role"), $3, make_str("set"), $5); } | ALTER ROLE RoleId VariableResetStmt { $$ = 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); };AlterRoleSetStmt: ALTER USER RoleId SET set_rest { $$ = cat_str(4, make_str("alter user"), $3, make_str("set"), $5); } | ALTER USER RoleId VariableResetStmt { $$ = 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 a postgresql DBMS user * * *****************************************************************************/DropUserStmt: DROP USER name_list { $$ = cat2_str(make_str("drop user"), $3);} ;/***************************************************************************** * * Create a postgresql group * * ****************************************************************************/CreateGroupStmt: CREATE GROUP_P RoleId opt_with OptRoleList { $$ = cat_str(4, make_str("create group"), $3, $4, $5); } ;/***************************************************************************** * * Alter a postgresql group * * *****************************************************************************/AlterGroupStmt: ALTER GROUP_P RoleId add_drop USER name_list { $$ = cat_str(5, make_str("alter group"), $3, $4, make_str("user"), $6); } ;add_drop: ADD { $$ = make_str("add"); } | DROP { $$ = make_str("drop"); } ; /***************************************************************************** * * Drop a postgresql group * * *****************************************************************************/DropGroupStmt: DROP GROUP_P name_list { $$ = cat2_str(make_str("drop group"), $3); } ;/***************************************************************************** * * Manipulate a schema * * *****************************************************************************/CreateSchemaStmt: CREATE SCHEMA OptSchemaName AUTHORIZATION RoleId OptSchemaEltList { $$ = cat_str(5, make_str("create schema"), $3, make_str("authorization"), $5, $6); } | CREATE SCHEMA ColId OptSchemaEltList { $$ = cat_str(3, make_str("create schema"), $3, $4); } ;OptSchemaName: ColId { $$ = $1; } | /* EMPTY */ { $$ = EMPTY; } ;OptSchemaEltList: OptSchemaEltList schema_stmt { $$ = cat2_str($1, $2); } | /* EMPTY */ { $$ = EMPTY; } ;/* * schema_stmt are the ones that can show up inside a CREATE SCHEMA * statement (in addition to by themselves). */schema_stmt: CreateStmt { $$ = $1; } | IndexStmt { $$ = $1; } | CreateSeqStmt { $$ = $1; } | CreateTrigStmt { $$ = $1; } | GrantStmt { $$ = $1; } | ViewStmt { $$ = $1; } ;/***************************************************************************** * * Set PG internal variable * SET name TO 'var_value' * Include SQL92 syntax (thomas 1997-10-22): * SET TIME ZONE 'var_value' * *****************************************************************************/VariableSetStmt: SET set_rest { $$ = cat2_str(make_str("set"), $2 ); } | SET LOCAL set_rest { $$ = cat2_str(make_str("set local"), $3 ); } | SET SESSION set_rest { $$ = cat2_str(make_str("set session"), $3 ); } ;set_rest: var_name TO var_list_or_default { $$ = cat_str(3, $1, make_str("to"), $3); } | var_name "=" var_list_or_default { $$ = cat_str(3, $1, make_str("="), $3); } | TIME ZONE zone_value { $$ = cat2_str(make_str("time zone"), $3); } | TRANSACTION transaction_mode_list { $$ = cat2_str(make_str("transaction"), $2); } | SESSION CHARACTERISTICS AS TRANSACTION transaction_mode_list { $$ = cat2_str(make_str("session characteristics as transaction"), $5); } | NAMES opt_encoding { $$ = cat2_str(make_str("names"), $2); } | ROLE ColId_or_Sconst { $$ = cat2_str(make_str("role"), $2); } | SESSION AUTHORIZATION ColId_or_Sconst { $$ = cat2_str(make_str("session authorization"), $3); } | SESSION AUTHORIZATION DEFAULT { $$ = make_str("session authorization default"); } ;var_name: ECPGColId { $$ = $1; } | var_name '.' ColId { $$ = cat_str(3, $1, make_str("."), $3); } ; var_list_or_default: var_list { $$ = $1; } | DEFAULT { $$ = make_str("default"); } ;var_list: var_value { $$ = $1; } | var_list ',' var_value { $$ = cat_str(3, $1, make_str(","), $3); } ;iso_level: READ UNCOMMITTED { $$ = make_str("read uncommitted"); } | READ COMMITTED { $$ = make_str("read committed"); } | REPEATABLE READ { $$ = make_str("repeatable read"); } | SERIALIZABLE { $$ = make_str("serializable"); } ;var_value: opt_boolean { $$ = $1; } | AllConst { $$ = $1; } | ColId { $$ = $1; } ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -