analyzer and CONSTRAINT

This commit is contained in:
Marc Delisle
2003-08-23 18:50:52 +00:00
parent efc769bebf
commit e948ec2ac2
2 changed files with 18 additions and 2 deletions

View File

@@ -12,6 +12,7 @@ $Source$
* lang/polish: Updated, thanks to Jakub Wilk (ubanus).
* lang/swedish: Updated, thanks to Bj<42>rn T. Hallberg (bth).
* lang/greek: update, thanks to Kyriakos Xagoraris (theremon)
* libraries/sqlparser.lib.php3: extract the CONSTRAINTs for FOREIGN KEYs
2003-08-21 Marc Delisle <lem9@users.sourceforge.net>
* tbl_relation.php3: improve variables, remove some code

View File

@@ -747,7 +747,8 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
* lem9: foreign keys
* ------------
* The CREATE TABLE may contain FOREIGN KEY clauses, so they get
* analyzed and ['foreign_keys'] is an array filled with the index list,
* analyzed and ['foreign_keys'] is an array filled with
* the constraint name, the index list,
* the REFERENCES table name and REFERENCES index list.
*
* lem9: position_of_first_select
@@ -1376,20 +1377,29 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
$seen_foreign = FALSE;
$seen_references = FALSE;
$seen_constraint = FALSE;
$in_bracket = FALSE;
$foreign_key_number = -1;
for ($i = 0; $i < $size; $i++) {
if ($arr[$i]['type'] == 'alpha_reservedWord') {
$upper_data = strtoupper($arr[$i]['data']);
if ($upper_data == 'CONSTRAINT') {
$foreign_key_number++;
$seen_foreign = FALSE;
$seen_references = FALSE;
$seen_constraint = TRUE;
}
if ($upper_data == 'FOREIGN') {
$seen_foreign = TRUE;
$seen_references = FALSE;
$foreign_key_number++;
$seen_constraint = FALSE;
}
if ($upper_data == 'REFERENCES') {
$seen_foreign = FALSE;
$seen_references = TRUE;
$seen_constraint = FALSE;
}
}
@@ -1406,6 +1416,11 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
if (($arr[$i]['type'] == 'quote_backtick')) {
if ($seen_constraint) {
// remove backquotes
$identifier = str_replace('`','',$arr[$i]['data']);
$foreign[$foreign_key_number]['constraint'] = $identifier;
}
if ($seen_foreign && $in_bracket) {
// remove backquotes
$identifier = str_replace('`','',$arr[$i]['data']);