bug #1533945, wrong table name in header (SELECT from query window)
This commit is contained in:
@@ -5,6 +5,10 @@ phpMyAdmin - ChangeLog
|
|||||||
$Id$
|
$Id$
|
||||||
$Source$
|
$Source$
|
||||||
|
|
||||||
|
2006-08-11 Marc Delisle <lem9@users.sourceforge.net>
|
||||||
|
* sql.php, import.php, libraries/parse_analyze.lib.php:
|
||||||
|
bug #1533945, wrong table name in header (SELECT from query window)
|
||||||
|
|
||||||
2006-08-11 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
2006-08-11 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
||||||
* css\phpmyadmin.css.php, themes\*:
|
* css\phpmyadmin.css.php, themes\*:
|
||||||
updated themes to 2.9 and some minor fixes
|
updated themes to 2.9 and some minor fixes
|
||||||
|
@@ -387,6 +387,10 @@ if ($timeout_passed) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse and analyze the query, for correct db and table name
|
||||||
|
// in case of a query typed in the query window
|
||||||
|
require_once('./libraries/parse_analyze.lib.php');
|
||||||
|
|
||||||
// Display back import page
|
// Display back import page
|
||||||
require_once('./libraries/header.inc.php');
|
require_once('./libraries/header.inc.php');
|
||||||
|
|
||||||
|
49
libraries/parse_analyze.lib.php
Normal file
49
libraries/parse_analyze.lib.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
/* $Id$ */
|
||||||
|
// vim: expandtab sw=4 ts=4 sts=4:
|
||||||
|
|
||||||
|
$GLOBALS['unparsed_sql'] = $sql_query;
|
||||||
|
$parsed_sql = PMA_SQP_parse($sql_query);
|
||||||
|
$analyzed_sql = PMA_SQP_analyze($parsed_sql);
|
||||||
|
|
||||||
|
// lem9: for bug 780516: now that we use case insensitive preg_match
|
||||||
|
// or flags from the analyser, do not put back the reformatted query
|
||||||
|
// into $sql_query, to make this kind of query work without
|
||||||
|
// capitalizing keywords:
|
||||||
|
//
|
||||||
|
// CREATE TABLE SG_Persons (
|
||||||
|
// id int(10) unsigned NOT NULL auto_increment,
|
||||||
|
// first varchar(64) NOT NULL default '',
|
||||||
|
// PRIMARY KEY (`id`)
|
||||||
|
// )
|
||||||
|
|
||||||
|
// check for a real SELECT ... FROM
|
||||||
|
$is_select = isset($analyzed_sql[0]['queryflags']['select_from']);
|
||||||
|
|
||||||
|
// If the query is a Select, extract the db and table names and modify
|
||||||
|
// $db and $table, to have correct page headers, links and left frame.
|
||||||
|
// db and table name may be enclosed with backquotes, db is optionnal,
|
||||||
|
// query may contain aliases.
|
||||||
|
|
||||||
|
// (TODO: if there are more than one table name in the Select:
|
||||||
|
// - do not extract the first table name
|
||||||
|
// - do not show a table name in the page header
|
||||||
|
// - do not display the sub-pages links)
|
||||||
|
|
||||||
|
if ($is_select) {
|
||||||
|
$prev_db = $db;
|
||||||
|
if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name'])) {
|
||||||
|
$table = $analyzed_sql[0]['table_ref'][0]['table_true_name'];
|
||||||
|
}
|
||||||
|
if (isset($analyzed_sql[0]['table_ref'][0]['db'])
|
||||||
|
&& strlen($analyzed_sql[0]['table_ref'][0]['db'])) {
|
||||||
|
$db = $analyzed_sql[0]['table_ref'][0]['db'];
|
||||||
|
} else {
|
||||||
|
$db = $prev_db;
|
||||||
|
}
|
||||||
|
// Nijel: don't change reload, if we already decided to reload in import
|
||||||
|
if (empty($reload)) {
|
||||||
|
$reload = ($db == $prev_db) ? 0 : 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
57
sql.php
57
sql.php
@@ -131,62 +131,9 @@ if (isset($btnDrop) || isset($navig)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reformat the query
|
* Parse and analyze the query
|
||||||
*/
|
*/
|
||||||
|
require_once('./libraries/parse_analyze.lib.php');
|
||||||
$GLOBALS['unparsed_sql'] = $sql_query;
|
|
||||||
$parsed_sql = PMA_SQP_parse($sql_query);
|
|
||||||
$analyzed_sql = PMA_SQP_analyze($parsed_sql);
|
|
||||||
|
|
||||||
// Bug #641765 - Robbat2 - 12 January 2003, 10:49PM
|
|
||||||
// Reverted - Robbat2 - 13 January 2003, 2:40PM
|
|
||||||
|
|
||||||
// lem9: for bug 780516: now that we use case insensitive preg_match
|
|
||||||
// or flags from the analyser, do not put back the reformatted query
|
|
||||||
// into $sql_query, to make this kind of query work without
|
|
||||||
// capitalizing keywords:
|
|
||||||
//
|
|
||||||
// CREATE TABLE SG_Persons (
|
|
||||||
// id int(10) unsigned NOT NULL auto_increment,
|
|
||||||
// first varchar(64) NOT NULL default '',
|
|
||||||
// PRIMARY KEY (`id`)
|
|
||||||
// )
|
|
||||||
//
|
|
||||||
// Note: now we probably do not need to fill and use $GLOBALS['unparsed_sql']
|
|
||||||
// but I let this intact for now.
|
|
||||||
//
|
|
||||||
//$sql_query = PMA_SQP_formatHtml($parsed_sql, 'query_only');
|
|
||||||
|
|
||||||
|
|
||||||
// check for a real SELECT ... FROM
|
|
||||||
$is_select = isset($analyzed_sql[0]['queryflags']['select_from']);
|
|
||||||
|
|
||||||
// If the query is a Select, extract the db and table names and modify
|
|
||||||
// $db and $table, to have correct page headers, links and left frame.
|
|
||||||
// db and table name may be enclosed with backquotes, db is optionnal,
|
|
||||||
// query may contain aliases.
|
|
||||||
|
|
||||||
// (TODO: if there are more than one table name in the Select:
|
|
||||||
// - do not extract the first table name
|
|
||||||
// - do not show a table name in the page header
|
|
||||||
// - do not display the sub-pages links)
|
|
||||||
|
|
||||||
if ($is_select) {
|
|
||||||
$prev_db = $db;
|
|
||||||
if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name'])) {
|
|
||||||
$table = $analyzed_sql[0]['table_ref'][0]['table_true_name'];
|
|
||||||
}
|
|
||||||
if (isset($analyzed_sql[0]['table_ref'][0]['db'])
|
|
||||||
&& strlen($analyzed_sql[0]['table_ref'][0]['db'])) {
|
|
||||||
$db = $analyzed_sql[0]['table_ref'][0]['db'];
|
|
||||||
} else {
|
|
||||||
$db = $prev_db;
|
|
||||||
}
|
|
||||||
// Nijel: don't change reload, if we already decided to reload in import
|
|
||||||
if (empty($reload)) {
|
|
||||||
$reload = ($db == $prev_db) ? 0 : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets or modifies the $goto variable if required
|
* Sets or modifies the $goto variable if required
|
||||||
|
Reference in New Issue
Block a user