OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: using column "comment" to store metadata

From: Ezequiel Panepucci (ezequiel.panepuccipsi.ch)
Date: Mon Sep 17 2007 - 05:11:49 CDT


> > I currently use MyISAM, but I just tried a simple
> > create(InnoDB)/show full columns from/ and
> > it actually does return the JSON strings I put in.
>
> Try it on columns with a foreign key constraint.

I did and it still works (maybe the behaviour is version
dependent?).

Here is what I did:

CREATE TABLE parent (
    id INT NOT NULL comment '{"com": "the primary key of the parent."}',
    PRIMARY KEY (id)
) ENGINE=INNODB;

CREATE TABLE child (
    id INT comment '{"com": "the primary key"}',
    parent_id INT comment '{"com": "the foreing key"}',
    INDEX par_ind (parent_id),
    FOREIGN KEY (parent_id) REFERENCES parent(id)
        ON DELETE CASCADE
) ENGINE=INNODB;

mysql> show full columns from parent;
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+-------------------------------------------+
| Field | Type | Collation | Null | Key | Default | Extra |
Privileges | Comment
     |
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+-------------------------------------------+
| id | int(11) | NULL | NO | PRI | | |
select,insert,update,references | {"com": "the primary key of the
parent."} |
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+-------------------------------------------+
1 row in set (0.00 sec)

mysql> show full columns from child;
+-----------+---------+-----------+------+-----+---------+-------+---------------------------------+----------------------------+
| Field | Type | Collation | Null | Key | Default | Extra |
Privileges | Comment |
+-----------+---------+-----------+------+-----+---------+-------+---------------------------------+----------------------------+
| id | int(11) | NULL | YES | | NULL | |
select,insert,update,references | {"com": "the primary key"} |
| parent_id | int(11) | NULL | YES | MUL | NULL | |
select,insert,update,references | {"com": "the foreing key"} |
+-----------+---------+-----------+------+-----+---------+-------+---------------------------------+----------------------------+
2 rows in set (0.00 sec)

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql