2 /* vim: set expandtab sw=4 ts=4 sts=4: */
5 * @todo Support seeing the "results" of the called procedure or
6 * function. This needs further reseach because a procedure
7 * does not necessarily contain a SELECT statement that
8 * produces something to see. But it seems we could at least
9 * get the number of rows affected. We would have to
10 * use the CLIENT_MULTI_RESULTS flag to get the result set
11 * and also the call status. All this does not fit well with
12 * our current sql.php.
13 * Of course the interface would need a way to pass calling parameters.
14 * Also, support DEFINER (like we do in export).
17 if (! defined('PHPMYADMIN')) {
21 $routines = PMA_DBI_fetch_result('SELECT SPECIFIC_NAME,ROUTINE_NAME,ROUTINE_TYPE,DTD_IDENTIFIER FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA= \'' . PMA_sqlAddslashes($db,true) . '\';');
24 PMA_generate_slider_effect('routines', __('Routines'));
25 echo '<fieldset>' . "\n";
26 echo ' <legend>' . __('Routines') . '</legend>' . "\n";
27 echo '<table border="0">';
40 if ($GLOBALS['cfg']['AjaxEnable']) {
41 $conditional_class = 'class="drop_procedure_anchor"';
43 $conditional_class = '';
46 foreach ($routines as $routine) {
48 // information_schema (at least in MySQL 5.0.45)
49 // does not return the routine parameters
50 // so we rely on PMA_DBI_get_definition() which
53 $definition = 'DROP ' . $routine['ROUTINE_TYPE'] . ' ' . PMA_backquote($routine['SPECIFIC_NAME']) . $delimiter . "\n"
54 . PMA_DBI_get_definition($db, $routine['ROUTINE_TYPE'], $routine['SPECIFIC_NAME'])
57 //if ($routine['ROUTINE_TYPE'] == 'PROCEDURE') {
58 // $sqlUseProc = 'CALL ' . $routine['SPECIFIC_NAME'] . '()';
60 // $sqlUseProc = 'SELECT ' . $routine['SPECIFIC_NAME'] . '()';
61 /* this won't get us far: to really use the function
62 i'd need to know how many parameters the function needs and then create
63 something to ask for them. As i don't see this directly in
64 the table i am afraid that requires parsing the ROUTINE_DEFINITION
65 and i don't really need that now so i simply don't offer
66 a method for running the function*/
68 if ($routine['ROUTINE_TYPE'] == 'PROCEDURE') {
69 $sqlDropProc = 'DROP PROCEDURE ' . PMA_backquote($routine['SPECIFIC_NAME']);
71 $sqlDropProc = 'DROP FUNCTION ' . PMA_backquote($routine['SPECIFIC_NAME']);
74 echo sprintf('<tr class="%s">
75 <td><input type="hidden" class="drop_procedure_sql" value="%s" /><strong>%s</strong></td>
81 ($ct%2
== 0) ?
'even' : 'odd',
83 $routine['ROUTINE_NAME'],
84 ! empty($definition) ?
PMA_linkOrButton('db_sql.php?' . $url_query . '&sql_query=' . urlencode($definition) . '&show_query=1&db_query_force=1&delimiter=' . urlencode($delimiter), $titles['Edit']) : ' ',
85 '<a ' . $conditional_class . ' href="sql.php?' . $url_query . '&sql_query=' . urlencode($sqlDropProc) . '" >' . $titles['Drop'] . '</a>',
86 $routine['ROUTINE_TYPE'],
87 $routine['DTD_IDENTIFIER']);
91 echo '</fieldset>' . "\n";