From a750003f574abd30a8183efd3aced152e71ad6a7 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Oct 2004 18:07:09 +0200 Subject: Implemented the stored procedure data access characteristics: NO SQL CONTAINS SQL (default) READS SQL DATA MODIFIES SQL DATA These are needed as hints for the replication. (Before this, we did have the default in the mysql.proc table, but no support in the parser.) mysql-test/r/sp.result: Modified test cases for new data access characteristics. mysql-test/t/sp.test: Modified test cases for new data access characteristics. scripts/mysql_create_system_tables.sh: We now support all the SP data access characteristics (not just CONTAINS SQL). scripts/mysql_fix_privilege_tables.sql: We now support all the SP data access characteristics (not just CONTAINS SQL). sql/lex.h: New tokens for SP data access characteristics. sql/sp.cc: Store, print and support alter of data access characteristics. sql/sp_head.cc: Added SP_ prefix to some symbols. sql/sql_lex.h: Added SP_ prefix to some symbols, and added SP data access enum. sql/sql_yacc.yy: Parse SP data access characteristics. (And allow "alter ... language sql", mostly as a formality, it was accidently put in the wrong clause before.) --- sql/sp.cc | 55 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 7 deletions(-) (limited to 'sql/sp.cc') diff --git a/sql/sp.cc b/sql/sp.cc index 6475b64eb18..8211d06376c 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -165,13 +165,36 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp) goto done; } + bzero((char *)&chistics, sizeof(chistics)); + if ((ptr= get_field(&thd->mem_root, + table->field[MYSQL_PROC_FIELD_ACCESS])) == NULL) + { + ret= SP_GET_FIELD_FAILED; + goto done; + } + switch (ptr[0]) { + case 'N': + chistics.daccess= SP_NO_SQL; + break; + case 'C': + chistics.daccess= SP_CONTAINS_SQL; + break; + case 'R': + chistics.daccess= SP_READS_SQL_DATA; + break; + case 'M': + chistics.daccess= SP_MODIFIES_SQL_DATA; + break; + default: + chistics.daccess= SP_CONTAINS_SQL; + } + if ((ptr= get_field(&thd->mem_root, table->field[MYSQL_PROC_FIELD_DETERMINISTIC])) == NULL) { ret= SP_GET_FIELD_FAILED; goto done; } - bzero((char *)&chistics, sizeof(chistics)); chistics.detistic= (ptr[0] == 'N' ? FALSE : TRUE); if ((ptr= get_field(&thd->mem_root, @@ -180,7 +203,7 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp) ret= SP_GET_FIELD_FAILED; goto done; } - chistics.suid= (ptr[0] == 'I' ? IS_NOT_SUID : IS_SUID); + chistics.suid= (ptr[0] == 'I' ? SP_IS_NOT_SUID : SP_IS_SUID); if ((params= get_field(&thd->mem_root, table->field[MYSQL_PROC_FIELD_PARAM_LIST])) == NULL) @@ -356,9 +379,12 @@ db_create_routine(THD *thd, int type, sp_head *sp) store((longlong)type); table->field[MYSQL_PROC_FIELD_SPECIFIC_NAME]-> store(sp->m_name.str, sp->m_name.length, system_charset_info); + if (sp->m_chistics->daccess != SP_DEFAULT_ACCESS) + table->field[MYSQL_PROC_FIELD_ACCESS]-> + store((longlong)sp->m_chistics->daccess); table->field[MYSQL_PROC_FIELD_DETERMINISTIC]-> store((longlong)(sp->m_chistics->detistic ? 1 : 2)); - if (sp->m_chistics->suid != IS_DEFAULT_SUID) + if (sp->m_chistics->suid != SP_IS_DEFAULT_SUID) table->field[MYSQL_PROC_FIELD_SECURITY_TYPE]-> store((longlong)sp->m_chistics->suid); table->field[MYSQL_PROC_FIELD_PARAM_LIST]-> @@ -433,12 +459,16 @@ db_update_routine(THD *thd, int type, sp_name *name, store_record(table,record[1]); table->timestamp_on_update_now = 0; // Don't update create time now. ((Field_timestamp *)table->field[MYSQL_PROC_FIELD_MODIFIED])->set_time(); - if (chistics->suid != IS_DEFAULT_SUID) - table->field[MYSQL_PROC_FIELD_SECURITY_TYPE]->store((longlong)chistics->suid); + if (chistics->suid != SP_IS_DEFAULT_SUID) + table->field[MYSQL_PROC_FIELD_SECURITY_TYPE]-> + store((longlong)chistics->suid); if (newname) table->field[MYSQL_PROC_FIELD_NAME]->store(newname, newnamelen, system_charset_info); + if (chistics->daccess != SP_DEFAULT_ACCESS) + table->field[MYSQL_PROC_FIELD_ACCESS]-> + store((longlong)chistics->daccess); if (chistics->comment.str) table->field[MYSQL_PROC_FIELD_COMMENT]->store(chistics->comment.str, chistics->comment.length, @@ -1027,9 +1057,20 @@ create_string(THD *thd, String *buf, buf->append(returns, returnslen); } buf->append('\n'); + switch (chistics->daccess) { + case SP_NO_SQL: + buf->append(" NO SQL\n"); + break; + case SP_READS_SQL_DATA: + buf->append(" READS SQL DATA\n"); + break; + case SP_MODIFIES_SQL_DATA: + buf->append(" MODIFIES SQL DATA\n"); + break; + } if (chistics->detistic) - buf->append( " DETERMINISTIC\n", 18); - if (chistics->suid == IS_NOT_SUID) + buf->append(" DETERMINISTIC\n", 18); + if (chistics->suid == SP_IS_NOT_SUID) buf->append(" SQL SECURITY INVOKER\n", 25); if (chistics->comment.length) { -- cgit v1.2.1