
var csvParseRegExp = /^\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|"[^"\\]*(?:\\[\S\s][^"\\]*)*"|[^,'"\s\\]*(?:\s+[^,'"\s\\]+)*)\s*(?:,\s*(?:'[^'\\]*(?:\\[\S\s][^'\\]*)*'|"[^"\\]*(?:\\[\S\s][^"\\]*)*"|[^,'"\s\\]*(?:\s+[^,'"\s\\]+)*)\s*)*$/;

ver GET DIAGNOSTICS
    DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
        GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
         @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
        SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
        SELECT @full_error;
    END;
    daria
    mysql> call my_proc('abc');
    +--------------------------------------------------+
    | @full_error                                      |
    +--------------------------------------------------+
    | ERROR 1146 (42S02): Table 'db1.t1' doesn't exist |
    +--------------------------------------------------+

information_schema.tables
        TABLE_SCHEMA dbname
        TABLE_NAME
        TABLE_TYPE: BASE TABLE
        AUTO_INCREMENT: 14
        CREATE_TIME: 2015-05-02 09:17:50
        UPDATE_TIME: NULL
         CHECK_TIME: NULL
        TABLE_COLLATION: latin1_swedish_ci
           CHECKSUM: NULL
        CREATE_OPTIONS:
        TABLE_COMMENT:

column
    extra: autoincrement, on update CURRENT_TIMESTAMP
    column_type: create table def

SHOW columns FROM quantix.plantilla;


SELECT TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME, ORDINAL_POSITION, POSITION_IN_UNIQUE_CONSTRAINT, REFERENCED_TABLE_SCHEMA, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
FROM information_schema.KEY_COLUMN_USAGE
WHERE table_schema='quantix'
ORDER BY TABLE_NAME,CONSTRAINT_NAME, ORDINAL_POSITION, POSITION_IN_UNIQUE_CONSTRAINT;

SHOW INDEX FROM quantix.plantilla

SELECT *
FROM information_schema.KEY_COLUMN_USAGE
WHERE
    `CONSTRAINT_SCHEMA` = `test` -- o table_schema si no multiple db app
    AND `TABLE_NAME` = `book`
y
REFERENTIAL_CONSTRAINTS en conjunto
-- falta db name en las otras tablas, mas columnas interesantes?, order by
SELECT i.TABLE_SCHEMA, i.TABLE_NAME, i.CONSTRAINT_TYPE, i.CONSTRAINT_NAME
     , k.COLUMN_NAME, k.ORDINAL_POSITION, k.POSITION_IN_UNIQUE_CONSTRAINT
     , k.REFERENCED_TABLE_NAME, k.REFERENCED_COLUMN_NAME
     , r.MATCH_OPTION, r.UPDATE_RULE, r.DELETE_RULE
FROM information_schema.TABLE_CONSTRAINTS i
LEFT JOIN information_schema.KEY_COLUMN_USAGE k ON i.CONSTRAINT_NAME = k.CONSTRAINT_NAME
LEFT JOIN information_schema.REFERENTIAL_CONSTRAINTS r ON i.CONSTRAINT_NAME = r.CONSTRAINT_NAME
WHERE i.CONSTRAINT_TYPE = 'FOREIGN KEY' -- primary, unique key
AND i.TABLE_SCHEMA = DATABASE();

chquita
select
    concat(table_name, '.', column_name) as 'foreign key',
    concat(referenced_table_name, '.', referenced_column_name) as 'references',
    constraint_name as 'constraint name'
from
    information_schema.key_column_usage
where
    referenced_table_name is not null;


