 /****************************************************************************/
 
 
--- _has_table( schema, table )
+-- _has_table(schema, table)
 DROP FUNCTION IF EXISTS _has_table //
-CREATE FUNCTION _has_table(dbname TEXT, tname TEXT)
+CREATE FUNCTION _has_table(sname VARCHAR(64), tname VARCHAR(64))
 RETURNS BOOLEAN
 BEGIN
-    DECLARE ret BOOLEAN;
-    SELECT 1
-      INTO ret
-      FROM `information_schema`.`tables`
-     WHERE `table_name` = tname
-       AND `table_schema` = dbname
-       AND `table_type` = 'BASE TABLE';
-    RETURN COALESCE(ret, 0);
-END //
-
-
--- has_table( schema, table, description )
+  DECLARE ret BOOLEAN;
+    
+  SELECT 1 INTO ret
+  FROM `information_schema`.`tables`
+  WHERE `table_name` = tname
+  AND `table_schema` = sname
+  AND `table_type` = 'BASE TABLE';
+  
+  RETURN COALESCE(ret, 0);
+END //
+
+
+-- has_table(schema, table, description)
 DROP FUNCTION IF EXISTS has_table //
-CREATE FUNCTION has_table (dbname TEXT, tname TEXT, description TEXT)
-RETURNS TEXT
-BEGIN
-    IF description = '' THEN
-        SET description = concat('Table ',
-            quote_ident(dbname), '.', quote_ident(tname), ' should exist' );
-    END IF;
-
-    RETURN ok( _has_table( dbname, tname ), description );
-END //
-
-
--- hasnt_table( schema, table, description )
+CREATE FUNCTION has_table (sname VARCHAR(64), tname VARCHAR(64), description TEXT)
+RETURNS TEXT
+BEGIN
+  IF description = '' THEN
+    SET description = concat('Table ',
+      quote_ident(sname), '.', quote_ident(tname), ' should exist');
+  END IF;
+
+  RETURN ok(_has_table(sname, tname), description);
+END //
+
+
+-- hasnt_table(schema, table, description)
 DROP FUNCTION IF EXISTS hasnt_table //
-CREATE FUNCTION hasnt_table (dbname TEXT, tname TEXT, description TEXT)
-RETURNS TEXT
-BEGIN
-    IF description = '' THEN
-        SET description = CONCAT('Table ',
-            quote_ident(dbname), '.', quote_ident(tname), ' should not exist' );
-    END IF;
-
-    RETURN ok( NOT _has_table( dbname, tname ), description );
-END //
-
-/****************************************************************************/
-
-/*
--- _has_trigger( schema, table, trigger, description )
-DROP FUNCTION IF EXISTS _has_trigger //
-CREATE FUNCTION _has_trigger(dbname TEXT, tname TEXT, triggername TEXT)
-RETURNS BOOLEAN
-BEGIN
-    DECLARE ret BOOLEAN;
-    SELECT 1
-      INTO ret
-      FROM information_schema.triggers
-     WHERE event_object_table = tname
-       AND trigger_schema = dbname
-       AND trigger_name = triggername;
-    RETURN COALESCE(ret, 0);
-END //
-
--- has_trigger( schema, table, trigger, description )
-DROP FUNCTION IF EXISTS has_trigger //
-
-CREATE FUNCTION has_trigger( dbname TEXT, tname TEXT, triggername TEXT, description TEXT )
-RETURNS text CHARSET utf8
-BEGIN
-
-    IF description = '' THEN
-        SET description = CONCAT('Trigger ', quote_ident(dbname), '.',
-            quote_ident(tname), '.', quote_ident(triggername), ' should exist' );
-    END IF;
-
-    IF NOT _has_table( dbname, tname ) THEN
-        RETURN CONCAT(ok( FALSE, description), '\n', 
-        diag(CONCAT('   Table ', quote_ident(dbname), '.', quote_ident(tname), ' does not exist')));
-    END IF;
-
-    RETURN ok( _has_trigger( dbname, tname, triggername ), description );
-END //
-
--- hasnt_trigger( schema, table, trigger, description )
-DROP FUNCTION IF EXISTS hasnt_trigger //
-
-CREATE FUNCTION hasnt_trigger( dbname TEXT, tname TEXT, triggername TEXT, description TEXT )
-RETURNS text CHARSET utf8
-BEGIN
-    IF description = '' THEN
-        SET description = CONCAT('Trigger ', quote_ident(dbname), '.',
-            quote_ident(tname), '.', quote_ident(triggername), ' should not exist' );
-    END IF;
-
-    IF NOT _has_table( dbname, tname ) THEN
-        RETURN CONCAT(ok( FALSE, description), '\n', 
-        diag(CONCAT('   Table ', quote_ident(dbname), '.', quote_ident(tname), ' does not exist')));
-    END IF;
-
-    RETURN ok(NOT _has_trigger( dbname, tname, triggername ), description );
-END //
-
-/*
-
-/**************************************************************************/
-
--- Loose check on the existence of a named constraint on the table
-
--- _has_constraint( schema, table, constraint type)
-DROP FUNCTION IF EXISTS _has_constraint //
-CREATE FUNCTION _has_constraint(dbname TEXT, tname TEXT, ctype TEXT)
-RETURNS BOOLEAN
-BEGIN
-  DECLARE ret BOOLEAN;
-  
-  SELECT 1 INTO ret
-  FROM `information_schema`.`table_constraints`
-  WHERE `table_schema` = dbname
-  AND `table_name` = tname
-  AND `constraint_type` = ctype
-  LIMIT 1;
-  
-  RETURN COALESCE(ret, 0);
-END //
-
-
--- PRIMARY KEY exists
-DROP FUNCTION IF EXISTS has_pk //
-CREATE FUNCTION has_pk(sname VARCHAR(64), tname VARCHAR(64), description TEXT)
-RETURNS TEXT
-BEGIN
-  IF description = '' THEN
-    SET description = CONCAT('A Primary Key should be defined for Table ', 
-      quote_ident(sname), '.', quote_ident(tname));
-  END IF;
-
-  IF NOT _has_table( sname, tname ) THEN
-    RETURN CONCAT(ok( FALSE, description), '\n', 
-      diag(CONCAT('   Table ', quote_ident(sname), '.', quote_ident(tname), ' does not exist')));
-  END IF;
-
-  RETURN ok(_has_constraint(sname, tname, 'PRIMARY KEY'), description);
-END //
-
-
-DROP FUNCTION IF EXISTS hasnt_pk //
-CREATE FUNCTION hasnt_pk(sname VARCHAR(64), tname VARCHAR(64), description TEXT)
-RETURNS TEXT
-BEGIN
-  IF description = '' THEN
-    SET description = CONCAT('A Primary Key shouldn\'t be defined for Table ', 
-      quote_ident(sname), '.', quote_ident(tname));
-  END IF;
-
-  IF NOT _has_table( sname, tname ) THEN
-    RETURN CONCAT(ok( FALSE, description), '\n', 
-      diag(CONCAT('   Table ', quote_ident(sname), '.', quote_ident(tname), ' does not exist')));
-  END IF;
-
-  RETURN ok(NOT _has_constraint(sname, tname, 'PRIMARY KEY'), description);
-END //
-
--- Loose check on the existence of an FK on the table
-DROP FUNCTION IF EXISTS has_fk //
-CREATE FUNCTION has_fk(sname VARCHAR(64), tname VARCHAR(64), description TEXT)
-RETURNS TEXT
-BEGIN
-  IF description = '' THEN
-    SET description = CONCAT('A Foreign Key should be defined for Table ', 
-      quote_ident(sname), '.', quote_ident(tname));
-  END IF;
-
-  IF NOT _has_table( sname, tname ) THEN
-    RETURN CONCAT(ok( FALSE, description), '\n', 
-      diag(CONCAT('   Table ', quote_ident(sname), '.', quote_ident(tname), ' does not exist')));
-  END IF;
-
-  RETURN ok(_has_constraint(sname, tname, 'FOREIGN KEY'), description);
-END //
-
-DROP FUNCTION IF EXISTS hasnt_fk //
-CREATE FUNCTION hasnt_fk( sname VARCHAR(64), tname VARCHAR(64), description TEXT)
-RETURNS TEXT
-BEGIN
-  IF description = '' THEN
-    SET description = CONCAT('Foreign Key should NOT be defined for Table ', 
-      quote_ident(sname), '.', quote_ident(tname));
-  END IF;
-
-  IF NOT _has_table( dbname, tname ) THEN
-    RETURN CONCAT(ok( FALSE, description), '\n', 
-      diag(CONCAT('   Table ', quote_ident(sname), '.', quote_ident(tname), ' does not exist')));
-  END IF;
-
-  RETURN ok(NOT _has_constraint(sname, tname, 'FOREIGN KEY'), description);
+CREATE FUNCTION hasnt_table (sname VARCHAR(64), tname VARCHAR(64), description TEXT)
+RETURNS TEXT
+BEGIN
+  IF description = '' THEN
+    SET description = CONCAT('Table ',
+      quote_ident(sname), '.', quote_ident(tname), ' should not exist');
+  END IF;
+
+  RETURN ok(NOT _has_table(sname, tname), description);
 END //
 
 

      diag(CONCAT('    Table ', quote_ident(sname), '.', quote_ident(tname), ' does not exist')));
  END IF;

  IF NOT _has_engine( ename ) THEN
    RETURN CONCAT(ok(FALSE, description), '\n', 
      diag(CONCAT('    Storare Engine ', quote_ident(ename), ' is not available')));
  END IF;


-- TABLE COLLATION DEFINITION

-- _table_collation(schema, table)
DROP FUNCTION IF EXISTS _table_collation //
CREATE FUNCTION _table_collation(sname VARCHAR(64), tname VARCHAR(64))
RETURNS VARCHAR(32)
