From 71abc9f8d096e19fcc0d8b64a9475c75a4d1531c Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Fri, 17 Jun 2011 17:02:33 +0100 Subject: [PATCH] Fixed bug where the information about the return variable of a routine was not correctly loaded into the editor. --- libraries/db_routines.lib.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/libraries/db_routines.lib.php b/libraries/db_routines.lib.php index 51b6671ac9..78d1d07a98 100644 --- a/libraries/db_routines.lib.php +++ b/libraries/db_routines.lib.php @@ -243,6 +243,39 @@ function PMA_RTN_getRoutineDataFromName($db, $name, $all = true) $retval['returnopts_num'] = ''; $retval['returnopts_text'] = ''; if (! empty($routine['DTD_IDENTIFIER'])) { + if (strlen($routine['DTD_IDENTIFIER']) > 63) { + // If the DTD_IDENTIFIER string from INFORMATION_SCHEMA is + // at least 64 characters, then it may actually have been + // chopped because that column is a varchar(64), so we will + // parse the output of SHOW CREATE query to get accurate + // information about the return variable. + $dtd = ''; + $fetching = false; + for ($i=0; $i<$parsed_query['len']; $i++) { + if ($parsed_query[$i]['type'] == 'alpha_reservedWord' + && strtoupper($parsed_query[$i]['data']) == 'RETURNS') { + $fetching = true; + } else if ($fetching == true + && $parsed_query[$i]['type'] == 'alpha_reservedWord') { + // We will not be looking for options such as UNSIGNED + // or ZEROFILL because there is no way that a numeric + // field's DTD_IDENTIFIER can be longer than 64 + // characters. We can safely assume that the return + // datatype is either ENUM or SET, so we only look + // for CHARSET. + $word = strtoupper($parsed_query[$i]['data']); + if ($word == 'CHARSET' + && ($parsed_query[$i+1]['type'] == 'alpha_charset' + || $parsed_query[$i+1]['type'] == 'alpha_identifier')) { + $dtd .= $word . ' ' . $parsed_query[$i+1]['data']; + } + break; + } else if ($fetching == true) { + $dtd .= $parsed_query[$i]['data'] . ' '; + } + } + $routine['DTD_IDENTIFIER'] = $dtd; + } $returnparam = PMA_RTN_parseOneParameter($routine['DTD_IDENTIFIER']); $retval['returntype'] = $returnparam[2]; $retval['returnlength'] = $returnparam[3];