The branch, master has been updated
via 416277f3980f1bb56a513a106d28dbf4c902dee6 (commit)
via addeffabafb2fc1590559dc66cf0fb84573a338d (commit)
via 57ab1b3e20ea680f33d8c4e856e595d3edcc0b18 (commit)
via 48149c261c633baf517455079a2524a9a9aac6a0 (commit)
via 83d3c0d2fd729a2d09a480d19ec6484198b79379 (commit)
via f646fc8a559b687ad7eeeeff410c0b67a9b82055 (commit)
from 87c970b0f8672b60eddab3950c4535ab29b2395c (commit)
- Log -----------------------------------------------------------------
commit 416277f3980f1bb56a513a106d28dbf4c902dee6
Author: Michal ÄŒihaÅ™ <mcihar(a)suse.cz>
Date: Thu Aug 4 17:16:03 2011 +0200
Use standard field processing machinery
commit addeffabafb2fc1590559dc66cf0fb84573a338d
Author: Michal ÄŒihaÅ™ <mcihar(a)suse.cz>
Date: Thu Aug 4 17:14:36 2011 +0200
Use standard field processing machinery
commit 57ab1b3e20ea680f33d8c4e856e595d3edcc0b18
Author: Michal ÄŒihaÅ™ <mcihar(a)suse.cz>
Date: Thu Aug 4 17:12:08 2011 +0200
No longer needed
commit 48149c261c633baf517455079a2524a9a9aac6a0
Author: Michal ÄŒihaÅ™ <mcihar(a)suse.cz>
Date: Thu Aug 4 17:11:47 2011 +0200
Use already calculated values
commit 83d3c0d2fd729a2d09a480d19ec6484198b79379
Author: Michal ÄŒihaÅ™ <mcihar(a)suse.cz>
Date: Thu Aug 4 17:08:49 2011 +0200
Move attribute processing to PMA_extractFieldSpec
commit f646fc8a559b687ad7eeeeff410c0b67a9b82055
Author: Michal ÄŒihaÅ™ <mcihar(a)suse.cz>
Date: Thu Aug 4 17:04:12 2011 +0200
Use PMA_extractFieldSpec instead of own code
-----------------------------------------------------------------------
Summary of changes:
db_datadict.php | 11 +----
libraries/common.lib.php | 12 +++++
libraries/export/texytext.php | 39 +++-------------
libraries/schema/Pdf_Relation_Schema.class.php | 45 +++----------------
libraries/tbl_properties.inc.php | 26 ++---------
tbl_printview.php | 47 +++-----------------
tbl_structure.php | 11 +----
.../libraries/common/PMA_extractFieldSpec_test.php | 5 ++
8 files changed, 43 insertions(+), 153 deletions(-)
diff --git a/db_datadict.php b/db_datadict.php
index 1c46cbb..86b4b80 100644
--- a/db_datadict.php
+++ b/db_datadict.php
@@ -196,16 +196,7 @@ while ($row = PMA_DBI_fetch_row($rowset)) {
$type_nowrap = ' nowrap="nowrap"';
}
$type = htmlspecialchars($extracted_fieldspec['print_type']);
- $attribute = ' ';
- if ($extracted_fieldspec['binary']) {
- $attribute = 'BINARY';
- }
- if ($extracted_fieldspec['unsigned']) {
- $attribute = 'UNSIGNED';
- }
- if ($extracted_fieldspec['zerofill']) {
- $attribute = 'UNSIGNED ZEROFILL';
- }
+ $attribute = $extracted_fieldspec['attribute']
if (! isset($row['Default'])) {
if ($row['Null'] != 'NO') {
$row['Default'] = '<i>NULL</i>';
diff --git a/libraries/common.lib.php b/libraries/common.lib.php
index 352446b..13983de 100644
--- a/libraries/common.lib.php
+++ b/libraries/common.lib.php
@@ -2650,6 +2650,17 @@ function PMA_extractFieldSpec($fieldspec) {
}
+ $attribute = ' ';
+ if ($binary) {
+ $attribute = 'BINARY';
+ }
+ if ($unsigned) {
+ $attribute = 'UNSIGNED';
+ }
+ if ($zerofill) {
+ $attribute = 'UNSIGNED ZEROFILL';
+ }
+
return array(
'type' => $type,
'spec_in_brackets' => $spec_in_brackets,
@@ -2658,6 +2669,7 @@ function PMA_extractFieldSpec($fieldspec) {
'binary' => $binary,
'unsigned' => $unsigned,
'zerofill' => $zerofill,
+ 'attribute' => $attribute,
);
}
diff --git a/libraries/export/texytext.php b/libraries/export/texytext.php
index d248c1b..565907e 100644
--- a/libraries/export/texytext.php
+++ b/libraries/export/texytext.php
@@ -252,40 +252,15 @@ if (isset($plugin_list)) {
foreach ($columns as $column) {
$text_output = '';
- $type = $column['Type'];
- // reformat mysql query output
- // set or enum types: slashes single quotes inside options
- if (preg_match('/^(set|enum)\((.+)\)$/i', $type, $tmp)) {
- $tmp[2] = substr(preg_replace('/([^,])\'\'/', '\\1\\\'', ',' . $tmp[2]), 1);
- $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
- $type_nowrap = '';
-
- $binary = 0;
- $unsigned = 0;
- $zerofill = 0;
- } else {
- $type_nowrap = ' nowrap="nowrap"';
- $type = preg_replace('/BINARY/i', '', $type);
- $type = preg_replace('/ZEROFILL/i', '', $type);
- $type = preg_replace('/UNSIGNED/i', '', $type);
- if (empty($type)) {
- $type = ' ';
- }
- $binary = preg_match('/BINARY/i', $column['Type']);
- $unsigned = preg_match('/UNSIGNED/i', $column['Type']);
- $zerofill = preg_match('/ZEROFILL/i', $column['Type']);
- }
- $attribute = ' ';
- if ($binary) {
- $attribute = 'BINARY';
- }
- if ($unsigned) {
- $attribute = 'UNSIGNED';
- }
- if ($zerofill) {
- $attribute = 'UNSIGNED ZEROFILL';
+ $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
+ $type = $extracted_fieldspec['print_type'];
+ if (empty($type)) {
+ $type = ' ';
}
+
+ $attribute = $extracted_fieldspec['attribute']
+
if (! isset($column['Default'])) {
if ($column['Null'] != 'NO') {
$column['Default'] = 'NULL';
diff --git a/libraries/schema/Pdf_Relation_Schema.class.php b/libraries/schema/Pdf_Relation_Schema.class.php
index ec03d37..6fd1976 100644
--- a/libraries/schema/Pdf_Relation_Schema.class.php
+++ b/libraries/schema/Pdf_Relation_Schema.class.php
@@ -1176,8 +1176,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
/**
* Gets fields properties
*/
- $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
- $fields_cnt = PMA_DBI_num_rows($result);
+ $columns = PMA_DBI_get_columns($db, $table);
// Check if we can use Relations
if (!empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
@@ -1259,41 +1258,10 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
}
$pdf->SetFont($this->_ff, '');
- while ($row = PMA_DBI_fetch_assoc($result)) {
- $type = $row['Type'];
- // reformat mysql query output
- // set or enum types: slashes single quotes inside options
- if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
- $tmp[2] = substr(preg_replace("@([^,])''@", "\\1\\'", ',' . $tmp[2]), 1);
- $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
- $type_nowrap = '';
-
- $binary = 0;
- $unsigned = 0;
- $zerofill = 0;
- } else {
- $type_nowrap = ' nowrap="nowrap"';
- $type = preg_replace('@BINARY@i', '', $type);
- $type = preg_replace('@ZEROFILL@i', '', $type);
- $type = preg_replace('@UNSIGNED@i', '', $type);
- if (empty($type)) {
- $type = ' ';
- }
-
- $binary = stristr($row['Type'], 'BINARY');
- $unsigned = stristr($row['Type'], 'UNSIGNED');
- $zerofill = stristr($row['Type'], 'ZEROFILL');
- }
- $attribute = ' ';
- if ($binary) {
- $attribute = 'BINARY';
- }
- if ($unsigned) {
- $attribute = 'UNSIGNED';
- }
- if ($zerofill) {
- $attribute = 'UNSIGNED ZEROFILL';
- }
+ foreach ($columns as $row) {
+ $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
+ $type = $extracted_fieldspec['print_type'];
+ $attribute = $extracted_fieldspec['attribute'];
if (! isset($row['Default'])) {
if ($row['Null'] != '' && $row['Null'] != 'NO') {
$row['Default'] = 'NULL';
@@ -1325,9 +1293,8 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
unset($links[6]);
}
$pdf->Row($pdf_row, $links);
- } // end while
+ } // end foreach
$pdf->SetFont($this->_ff, '', 14);
- PMA_DBI_free_result($result);
} //end each
}
}
diff --git a/libraries/tbl_properties.inc.php b/libraries/tbl_properties.inc.php
index 7208ea3..5b099cf 100644
--- a/libraries/tbl_properties.inc.php
+++ b/libraries/tbl_properties.inc.php
@@ -298,11 +298,7 @@ for ($i = 0; $i < $num_fields; $i++) {
if ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type']) {
$length = $extracted_fieldspec['spec_in_brackets'];
} else {
- // strip the "BINARY" attribute, except if we find "BINARY(" because
- // this would be a BINARY or VARBINARY field type
- $type = preg_replace('@BINARY([^\(])@i', '', $type);
- $type = preg_replace('@ZEROFILL@i', '', $type);
- $type = preg_replace('@UNSIGNED@i', '', $type);
+ $type = $extracted_fieldspec['print_type'];
$length = $extracted_fieldspec['spec_in_brackets'];
} // end if else
} else {
@@ -336,15 +332,6 @@ for ($i = 0; $i < $num_fields; $i++) {
}
// column length
- if (isset($extracted_fieldspec) && ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type'])) {
- $binary = 0;
- $unsigned = 0;
- $zerofill = 0;
- } else {
- $binary = false;
- $unsigned = stristr($row['Type'], 'unsigned');
- $zerofill = stristr($row['Type'], 'zerofill');
- }
$length_to_display = $length;
$content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '"'
@@ -425,15 +412,10 @@ for ($i = 0; $i < $num_fields; $i++) {
. ' id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
$attribute = '';
- if ($binary) {
- $attribute = 'BINARY';
- }
- if ($unsigned) {
- $attribute = 'UNSIGNED';
- }
- if ($zerofill) {
- $attribute = 'UNSIGNED ZEROFILL';
+ if (isset($extracted_fieldspec)) {
+ $attribute = $extracted_fieldspec['attribute'];
}
+
if (isset($row['Extra']) && $row['Extra'] == 'on update CURRENT_TIMESTAMP') {
$attribute = 'on update CURRENT_TIMESTAMP';
}
diff --git a/tbl_printview.php b/tbl_printview.php
index 9b7e7ff..068cfbc 100644
--- a/tbl_printview.php
+++ b/tbl_printview.php
@@ -51,7 +51,7 @@ PMA_DBI_select_db($db);
/**
- * Multi-tables printview
+ * Multi-tables printview
*/
if (isset($selected_tbl) && is_array($selected_tbl)) {
$the_tables = $selected_tbl;
@@ -98,10 +98,7 @@ foreach ($the_tables as $key => $table) {
/**
* Gets fields properties
*/
- $result = PMA_DBI_query(
- 'SHOW FIELDS FROM ' . PMA_backquote($table) . ';', null,
- PMA_DBI_QUERY_STORE);
- $fields_cnt = PMA_DBI_num_rows($result);
+ $columns = PMA_DBI_get_columns($db, $table);
// We need this to correctly learn if a TIMESTAMP is NOT NULL, since
@@ -155,40 +152,11 @@ foreach ($the_tables as $key => $table) {
</thead>
<tbody>
<?php
- while ($row = PMA_DBI_fetch_assoc($result)) {
- $type = $row['Type'];
- // reformat mysql query output
- // set or enum types: slashes single quotes inside options
- if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
- $tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'',
- ',' . $tmp[2]), 1);
- $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
-
- $binary = 0;
- $unsigned = 0;
- $zerofill = 0;
- } else {
- $type = preg_replace('@BINARY@i', '', $type);
- $type = preg_replace('@ZEROFILL@i', '', $type);
- $type = preg_replace('@UNSIGNED@i', '', $type);
- if (empty($type)) {
- $type = ' ';
- }
+ foreach ($columns as $row) {
+ $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
+ $type = $extracted_fieldspec['print_type'];
+ $attribute = $extracted_fieldspec['attribute'];
- $binary = stristr($row['Type'], 'binary');
- $unsigned = stristr($row['Type'], 'unsigned');
- $zerofill = stristr($row['Type'], 'zerofill');
- }
- $attribute = ' ';
- if ($binary) {
- $attribute = 'BINARY';
- }
- if ($unsigned) {
- $attribute = 'UNSIGNED';
- }
- if ($zerofill) {
- $attribute = 'UNSIGNED ZEROFILL';
- }
if (! isset($row['Default'])) {
if ($row['Null'] != '' && $row['Null'] != 'NO') {
$row['Default'] = '<i>NULL</i>';
@@ -252,8 +220,7 @@ foreach ($the_tables as $key => $table) {
?>
</tr>
<?php
- } // end while
- PMA_DBI_free_result($result);
+ } // end foreach
?>
</tbody>
</table>
diff --git a/tbl_structure.php b/tbl_structure.php
index b104e79..077603c 100644
--- a/tbl_structure.php
+++ b/tbl_structure.php
@@ -294,16 +294,7 @@ foreach ($fields as $row) {
$type_mime = '';
}
- $attribute = ' ';
- if ($extracted_fieldspec['binary']) {
- $attribute = 'BINARY';
- }
- if ($extracted_fieldspec['unsigned']) {
- $attribute = 'UNSIGNED';
- }
- if ($extracted_fieldspec['zerofill']) {
- $attribute = 'UNSIGNED ZEROFILL';
- }
+ $attribute = $extracted_fieldspec['attribute'];
// MySQL 4.1.2+ TIMESTAMP options
// (if on_update_current_timestamp is set, then it's TRUE)
diff --git a/test/libraries/common/PMA_extractFieldSpec_test.php b/test/libraries/common/PMA_extractFieldSpec_test.php
index b27b2b9..9aa337d 100644
--- a/test/libraries/common/PMA_extractFieldSpec_test.php
+++ b/test/libraries/common/PMA_extractFieldSpec_test.php
@@ -45,6 +45,7 @@ class PMA_extractFieldSpec_test extends PHPUnit_Extensions_OutputTestCase
'zerofill' => false,
'spec_in_brackets' => "'a','b'",
'enum_set_values' => array('a', 'b'),
+ 'attribute' => ' ',
),
),
array(
@@ -57,6 +58,7 @@ class PMA_extractFieldSpec_test extends PHPUnit_Extensions_OutputTestCase
'zerofill' => false,
'spec_in_brackets' => "'\'a','b'",
'enum_set_values' => array("'a", 'b'),
+ 'attribute' => ' ',
),
),
array(
@@ -69,6 +71,7 @@ class PMA_extractFieldSpec_test extends PHPUnit_Extensions_OutputTestCase
'zerofill' => true,
'spec_in_brackets' => '',
'enum_set_values' => array(),
+ 'attribute' => 'UNSIGNED ZEROFILL',
),
),
array(
@@ -81,6 +84,7 @@ class PMA_extractFieldSpec_test extends PHPUnit_Extensions_OutputTestCase
'zerofill' => false,
'spec_in_brackets' => '255',
'enum_set_values' => array(),
+ 'attribute' => ' ',
),
),
array(
@@ -93,6 +97,7 @@ class PMA_extractFieldSpec_test extends PHPUnit_Extensions_OutputTestCase
'zerofill' => false,
'spec_in_brackets' => '255',
'enum_set_values' => array(),
+ 'attribute' => ' ',
),
),
);
hooks/post-receive
--
phpMyAdmin