Bug #69522 Creata range partition using user defind function

Submitted: 20 Jun 2013 11:34 Modified: 20 Jun 2013 18:48
Reporter: rajnish kumar Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Partitions Severity:S1 (Critical)
Version:5.5.20 OS:Linux (Creata range partition using user defind function)
Assigned to: CPU Architecture:Any
Tags: Creata range partition using user defind function

[20 Jun 2013 11:34] rajnish kumar
Description:
Hi Team ,
I want to create a range based partition based on user defined function .
Details :
I have a table , design of table is below 
CREATE TABLE  Parttest (
  id  bigint(20) NOT NULL AUTO_INCREMENT,
  datetime1 BIGINT ,
  PRIMARY KEY (id,datetime1)
) ENGINE=InnoDB 

In datetime1 column contain unix timestamp value .
now i want to create a range  based partition on this table , when i am using FROM_UNIXTIME with month function  below is the details :
PARTITION BY RANGE(MONTH(DATE_FORMAT(FROM_UNIXTIME(datetime1), '%Y-%m-%d ') )) 
 (
PARTITION p_JAN VALUES LESS THAN(2)
);

it's throws error 
So I create a function below is the function body 
DROP FUNCTION IF EXISTS func1;
DELIMITER $$
CREATE FUNCTION  func1(dt1  bigint)
RETURNS  INT  READS SQL DATA
BEGIN
DECLARE mn2 INT ;
DECLARE dd   DATE  ; 

-- SET dd = 
select DATE_FORMAT(FROM_UNIXTIME(dt1), '%Y-%m-%d') into dd  ;

-- select dd  from DUAL;

set mn2 =  MONTH(dd) ;
 
 RETURN  (mn2) ;

END;
$$
DELIMITER ;

Now I want to call this function in range partition , below is the query .
 PARTITION BY RANGE( func1(datetime1  )    ) 
 (
PARTITION p_JAN VALUES LESS THAN(2)
);

it throws error :
[Err] 1064 - Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed near ') 
 (

I just want to know whether i can call a user defined function in partition or not ?

How to repeat:
Hi Team ,
I want to create a range based partition based on user defined function .
Details :
I have a table , design of table is below 
CREATE TABLE  Parttest (
  id  bigint(20) NOT NULL AUTO_INCREMENT,
  datetime1 BIGINT ,
  PRIMARY KEY (id,datetime1)
) ENGINE=InnoDB 

In datetime1 column contain unix timestamp value .
now i want to create a range  based partition on this table , when i am using FROM_UNIXTIME with month function  below is the details :
PARTITION BY RANGE(MONTH(DATE_FORMAT(FROM_UNIXTIME(datetime1), '%Y-%m-%d ') )) 
 (
PARTITION p_JAN VALUES LESS THAN(2)
);

it's throws error 
So I create a function below is the function body 
DROP FUNCTION IF EXISTS func1;
DELIMITER $$
CREATE FUNCTION  func1(dt1  bigint)
RETURNS  INT  READS SQL DATA
BEGIN
DECLARE mn2 INT ;
DECLARE dd   DATE  ; 

-- SET dd = 
select DATE_FORMAT(FROM_UNIXTIME(dt1), '%Y-%m-%d') into dd  ;

-- select dd  from DUAL;

set mn2 =  MONTH(dd) ;
 
 RETURN  (mn2) ;

END;
$$
DELIMITER ;

Now I want to call this function in range partition , below is the query .
 PARTITION BY RANGE( func1(datetime1  )    ) 
 (
PARTITION p_JAN VALUES LESS THAN(2)
);

it throws error :
[Err] 1064 - Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed near ') 
 (

I just want to know whether i can call a user defined function in partition or not ?
[20 Jun 2013 18:48] Sveta Smirnova
We're sorry, but the bug system is not the appropriate forum for asking help on using MySQL products. Your problem is not the result of a bug.

Support on using our products is available both free in our forums at http://forums.mysql.com/ and for a reasonable fee direct from our skilled support engineers at http://www.mysql.com/support/

Thank you for your interest in MySQL.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.