Bug #69522 Creata range partition using user defind function
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 ?
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.