+
+ // Show indexes
+ $result = SQL_QUERY_ESC("SHOW INDEX FROM `%s`", array($tableName), __FILE__, __LINE__);
+
+ // Non-skipping is default for ADD
+ $skip = false;
+
+ // But should we DROP?
+ if ($tableArray[3] == 'DROP') {
+ // Then skip if nothing found!
+ $skip = true;
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Going to drop key ' . $keyName);
+ } // END - if
+
+ // Walk through all
+ while ($content = SQL_FETCHARRAY($result)) {
+ // Is it found?
+ //* DEBUG: */ print(__LINE__.':columnName='.$keyName.',content=<pre>' . print_r($content, true) . '</pre>');
+ if (($content['Key_name'] == $keyName) && ($tableArray[3] == 'ADD')) {
+ // Skip this query!
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("ADD: Skiped: %s", $sql));
+ $skip = true;
+ break;
+ } elseif (($content['Key_name'] == $keyName) && ($tableArray[3] == 'DROP')) {
+ // Don't skip this!
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("DROP: Not skiped: %s", $sql));
+ $skip = false;
+ break;
+ }
+ } // END - while
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Shall we run it?
+ if ($skip === false) {
+ // Send it to the SQL_QUERY() function
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql);
+ $result = SQL_QUERY($sql, $F, $L, false);
+ } else {
+ // Not executed
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Not executed: ' . $sql);
+ }
+ } else {
+ // Other ALTER TABLE query
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql);
+ $result = SQL_QUERY($sql, $F, $L, false);
+ }
+
+ // Return result
+ return $result;
+}
+
+// Getter for SQL link
+function SQL_GET_LINK () {
+ // Init link
+ $link = null;
+
+ // Is it in the globals?
+ if (isset($GLOBALS['sql_link'])) {
+ // Then take it
+ $link = $GLOBALS['sql_link'];
+ } // END - if
+
+ // Return it
+ return $link;
+}
+
+// Setter for link
+function SQL_SET_LINK ($link) {
+ // Is this a resource or null?
+ if ((!is_resource($link)) && (!is_null($link))) {
+ // This should never happen!
+ debug_report_bug(sprintf("link is not resource or null. Type: %s", gettype($link)));
+ } // END - if
+
+ // Set it
+ $GLOBALS['sql_link'] = $link;
+}
+
+// Checks if the link is up
+function SQL_IS_LINK_UP () {
+ // Default is not up
+ $linkUp = false;
+
+ // Do we have cached this?
+ if (isset($GLOBALS['sql_link_res'])) {
+ // Then use this
+ $linkUp = $GLOBALS['sql_link_res'];