diff --git a/ChangeLog b/ChangeLog index a22a42dea..681060638 100755 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,8 @@ $Source$ solution of support request #728820 * Documentation.html: Enhance FAQ 2.3 (mysql.sock readable, thanks to Ryan) + * Added scripts/inno2pma (from Ernie Hershey). Please see + Patch Tracker #709383 for further information. 2003-04-30 Marc Delisle * pdf_schema.php3, bug 729517, better comment output, diff --git a/scripts/inno2pma.sh b/scripts/inno2pma.sh new file mode 100644 index 000000000..17a599da6 --- /dev/null +++ b/scripts/inno2pma.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# +# inno2pma +# +# insert InnoDB foreign keys into phpmyadmin relation table +# by Ernie Hershey 3/15/2003 +# +# THIS IS AN EXPERIMENTAL SCRIPT - PLEASE DO NOT USE THIS +# IF YOU DON'T UNDERSTAND WHAT IT IS DOING! +# +# This was posted on the Open Discussion forum by +# ehershey. The idea is interesting, however we should +# implement it in PHP. +# +# In future versions of phpMyAdmin the use of a proprietary +# storage of relational tables will be discarded in favor of +# the InnoDB relations (or in addition to). Support of InnoDB +# relations is on our ToDo-List. +# +# requires : +# mysql client tools +# standard unix shell tools +# special PHPMyAdmin relation table setup +# +# + +# config + +database="triohost2" +#table="domains" +relationdb="phpmyadmin" +relationtable="PMA_relation" + +# end config + +mysqldump --no-data $database $table | egrep "^CREATE|^ FOREIGN" | while read line +do + line=`echo "$line"|sed 's/^ *//g` + first_token=`echo "$line" | cut -f1 -d" "` + case $first_token in + CREATE) + table_name=`echo "$line"|sed 's/CREATE TABLE \(.*\) (/\1/'` + echo "DELETE FROM $relationtable WHERE master_db='$database' AND master_table='$table_name'" | mysql $relationdb + ;; + FOREIGN) + localcolumn=`echo "$line" | cut -f2 -d\\\`` + foreigntablefull=`echo "$line" | cut -f4 -d\\\`` + foreigndb=`echo $foreigntablefull | cut -f1 -d.` + foreigntable=`echo $foreigntablefull | cut -f2 -d.` + foreigncolumn=`echo "$line" | cut -f6 -d\\\`` + + echo processing foreign key on column $database.$table_name.$localcolumn to $foreigndb.$foreigntable.$foreigncolumn >&2 + echo "INSERT INTO $relationtable VALUES ('$database','$table_name','$localcolumn','$foreigndb','$foreigntable','$foreigncolumn');" | mysql $relationdb + ;; + esac +done \ No newline at end of file