Bug #42938 Comments not available to custom storage engine when partitioned
Submitted: 17 Feb 2009 16:40 Modified: 5 Aug 2009 16:28
Reporter: Steven Carr Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Partitions Severity:S3 (Non-critical)
Version:5.1.31 OS:Any
Assigned to: CPU Architecture:Any
Tags: partition, storage engine
Triage: Triaged: D4 (Minor)

[17 Feb 2009 16:40] Steven Carr
Description:
Partitioned storage engines do not have access to the partition comment.   This prevents the use of the comment field as a way to pass initialization parameters to the storage engine, if it is to be used in a partitioned environment.

Thank You,
~Steven

How to repeat:
Modify the CSV storage engine ::create() function to print create_info->comment.str.

create table xyzzy (
`mdate`     DATE  NOT NULL COMMENT 'Message date', 
`whatever`  char(32)       COMMENT 'Whatever you want'
) ENGINE=csv
 PARTITION BY LIST(to_days(mdate))(
 PARTITION p20090101 VALUES IN (TO_DAYS('2009-01-01')) COMMENT='delim=tab',
 PARTITION p20090102 VALUES IN (TO_DAYS('2009-01-02')) COMMENT='delim=tab',
 PARTITION p20090103 VALUES IN (TO_DAYS('2009-01-03')) COMMENT='delim=tab',
 PARTITION p20090104 VALUES IN (TO_DAYS('2009-01-04')) COMMENT='delim=tab',
 PARTITION p20090105 VALUES IN (TO_DAYS('2009-01-05')) COMMENT='delim=tab',
 PARTITION p20090106 VALUES IN (TO_DAYS('2009-01-06')) COMMENT='delim=tab'
);

Suggested fix:
int ha_partition::set_up_table_before_create()

I added the following to the end of the function

  if (part_elem->part_comment!=NULL)
  {
    info->comment.str = part_elem->part_comment;
    info->comment.length = strlen(part_elem->part_comment);
  }
[17 Feb 2009 22:11] Sveta Smirnova
Thank you for the report.

Verified as described, but used MyISAM storage engine instead of CSV:

$bzr diff
=== modified file 'storage/myisam/ha_myisam.cc'
--- storage/myisam/ha_myisam.cc 2009-02-05 06:16:00 +0000
+++ storage/myisam/ha_myisam.cc 2009-02-17 22:04:47 +0000
@@ -1892,6 +1892,8 @@
   if (options & HA_OPTION_DELAY_KEY_WRITE)
     create_flags|= HA_CREATE_DELAY_KEY_WRITE;
 
+fprintf(stderr, "Comment: %s \n", ha_create_info->comment.str);
+
   /* TODO: Check that the following fn_format is really needed */
   error= mi_create(fn_format(buff, name, "", "",
                              MY_UNPACK_FILENAME|MY_APPEND_EXT),

$cat t/bug42938.test 
create table xyzzy (
`mdate`     DATE  NOT NULL COMMENT 'Message date', 
`whatever`  char(32) not null      COMMENT 'Whatever you want'
) ENGINE=myisam
 PARTITION BY LIST(to_days(mdate))(
 PARTITION p20090101 VALUES IN (TO_DAYS('2009-01-01')) COMMENT='delim=tab',
 PARTITION p20090102 VALUES IN (TO_DAYS('2009-01-02')) COMMENT='delim=tab',
 PARTITION p20090103 VALUES IN (TO_DAYS('2009-01-03')) COMMENT='delim=tab',
 PARTITION p20090104 VALUES IN (TO_DAYS('2009-01-04')) COMMENT='delim=tab',
 PARTITION p20090105 VALUES IN (TO_DAYS('2009-01-05')) COMMENT='delim=tab',
 PARTITION p20090106 VALUES IN (TO_DAYS('2009-01-06')) COMMENT='delim=tab'
);

create table t1(f1 int not null) engine=myisam comment='foobar';

$cat var/mysqld.1/mysqld.err
CURRENT_TEST: main.bug42938
090218  1:06:15 [Warning] The syntax '--log' is deprecated and will be removed in MySQL 7.0. Please use '--general_log'/'--general_log_file' instead.
090218  1:06:15 [Warning] The syntax '--log_slow_queries' is deprecated and will be removed in MySQL 7.0. Please use '--slow_query_log'/'--slow_query_log_file' instead.
090218  1:06:15 [Note] Plugin 'InnoDB' disabled by command line option
090218  1:06:15 [Note] Event Scheduler: Loaded 0 events
090218  1:06:15 [Note] /users/ssmirnova/src/mysql-5.1/sql/mysqld: ready for connections.
Version: '5.1.33-debug-log'  socket: '/users/ssmirnova/src/mysql-5.1/mysql-test/var/tmp/mysqld.1.sock'  port: 12500  Source distribution
Comment: (null) 
Comment: (null) 
Comment: (null) 
Comment: (null) 
Comment: (null) 
Comment: (null) 
Comment: foobar 
Comment: (null) 
Comment:
[16 Mar 2009 17:34] Timothy Smith
Steven,

Hi.  I've opened Bug #43681 to track your underlying request of having a way to pass information to the storage engine during table creation.  If you have more details regarding your needs, please add them there.

Using the COMMENT field for such purposes is at best an expedient hack, but isn't a correct implementation.  This bug's (42938) scope is being restricted to just the fact that partitioning comments are not available.
[5 Aug 2009 16:28] Mikael Ronström
Information is available in partition_element which is available to
storage engines.