888 lines
		
	
	
		
			34 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			888 lines
		
	
	
		
			34 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| # owner: yuchen.wyc
 | |
| #tags: pl, optimizer
 | |
| # owner group: SQL1
 | |
| # description: foobar
 | |
| # tags: dml
 | |
| # case_transfer: 
 | |
| # (1) update ignore语法不支持;
 | |
| # (2)update 多表操作不支持;
 | |
| # (3)create table t1 (a int, b char(255), key(a, b(20))); 不支持key为列的部分长度
 | |
| # (4)alter table t1 disable keys; 不支持;
 | |
| # (5)flush status;不支持
 | |
| # (6)系统变量%Handler_read% 不支持;
 | |
| # (7)set tmp_table_size=1024; 不支持
 | |
| # (8)系统变量不支持;SET SESSION sql_safe_updates = DEFAULT;
 | |
| # (9)HANDLER_UPDATE 系统变量不支持
 | |
| #
 | |
| # test of updating of keys
 | |
| #
 | |
| --source mysql_test/include/backup_spm_var.inc
 | |
| --disable_query_log
 | |
| set @@session.explicit_defaults_for_timestamp=off;
 | |
| connect (conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
 | |
| connection conn_admin;
 | |
| alter system set_tp tp_no = 509, error_code = 4016, frequency = 1;
 | |
| connection default;
 | |
| --enable_query_log
 | |
| 
 | |
| --disable_warnings
 | |
| drop table if exists t1,t2;
 | |
| --enable_warnings
 | |
| --explain_protocol 1
 | |
| --result_format 4
 | |
| 
 | |
| alter system set ob_enable_batched_multi_statement=true;
 | |
| --real_sleep 1
 | |
| create table t1 (a int auto_increment , primary key (a));
 | |
| insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); 
 | |
| update t1 set a=a+10 where a > 34;
 | |
| update t1 set a=a+100 where a > 0;
 | |
| 
 | |
| # Some strange updates to test some otherwise unused code
 | |
| update t1 set a=a+100 where a=1 and a=2;
 | |
| --error 1054
 | |
| update t1 set a=b+100 where a=1 and a=2; 
 | |
| --error 1054
 | |
| update t1 set a=b+100 where c=1 and a=2; 
 | |
| --error 1054
 | |
| update t1 set d=a+100 where a=1;
 | |
| select * from t1;
 | |
| drop table t1;
 | |
| 
 | |
| create table t1(a int primary key, b int) partition by hash(a) partitions 3;
 | |
| insert into t1 values(1, 1), (2, 2);
 | |
| update t1 set b=b+1 where a>0;
 | |
| select * from t1;
 | |
| drop table t1;
 | |
| 
 | |
| create table t1(a int primary key, b int) partition by hash(a) partitions 3;
 | |
| insert into t1 values(1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
 | |
| update t1 set b=b+1 where a>0;
 | |
| select * from t1;
 | |
| drop table t1;
 | |
| 
 | |
| create table t1(a int primary key, b int) partition by hash(a) partitions 3;
 | |
| create index gkey on t1(b) global;
 | |
| insert into t1 values(1, 1), (2, 2); 
 | |
| update t1 set b=b+1 where a>0;
 | |
| select * from t1; 
 | |
| drop table t1; 
 | |
| 
 | |
| create table t1(a int primary key, b int) partition by hash(a) partitions 3;
 | |
| create index gkey on t1(b) global;
 | |
| insert into t1 values(1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
 | |
| update t1 set b=b+1 where a>0;
 | |
| select * from t1;
 | |
| drop table t1;
 | |
| 
 | |
| create table t1(a int primary key, b int);
 | |
| create index gkey on t1(b) partition by hash(b) partitions 2;
 | |
| insert into t1 values(1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
 | |
| update /*+index(t1 gkey)*/ t1 set b=b+1 where b>0 and b<5;
 | |
| select /*+index(t1 primary)*/ * from t1 order by a;
 | |
| drop table t1;
 | |
| 
 | |
| create table t1(a int primary key, b int) partition by hash(a) partitions 3;
 | |
| create table t2(a int primary key, b int) partition by hash(a) partitions 3;
 | |
| insert into t1 values(1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
 | |
| update /*+use_nl(t1, t2), leading(t1)*/ t1 set b=b+1 where a in (select a from t2);
 | |
| select * from t1;
 | |
| drop table t1, t2;
 | |
| 
 | |
| CREATE TABLE t1
 | |
|  (
 | |
|  place_id int (10) unsigned NOT NULL,
 | |
|  shows int(10) unsigned DEFAULT '0' NOT NULL,
 | |
|  ishows int(10) unsigned DEFAULT '0' NOT NULL,
 | |
|  ushows int(10) unsigned DEFAULT '0' NOT NULL,
 | |
|  clicks int(10) unsigned DEFAULT '0' NOT NULL,
 | |
|  iclicks int(10) unsigned DEFAULT '0' NOT NULL,
 | |
|  uclicks int(10) unsigned DEFAULT '0' NOT NULL,
 | |
|  ts timestamp,
 | |
|  PRIMARY KEY (place_id,ts)
 | |
|  );
 | |
| 
 | |
| INSERT INTO t1 (place_id,shows,ishows,ushows,clicks,iclicks,uclicks,ts)
 | |
| VALUES (1,0,0,0,0,0,0,20000928174434);
 | |
| UPDATE t1 SET shows=shows+1,ishows=ishows+1,ushows=ushows+1,clicks=clicks+1,iclicks=iclicks+1,uclicks=uclicks+1 WHERE place_id=1 AND ts>="2000-09-28 00:00:00";
 | |
| select place_id,shows from t1;
 | |
| drop table t1;
 | |
| 
 | |
| #
 | |
| # Test bug with update reported by Jan Legenhausen
 | |
| #
 | |
| 
 | |
| CREATE TABLE t1 (
 | |
|   lfdnr int(10) unsigned NOT NULL default '0',
 | |
|   ticket int(10) unsigned NOT NULL default '0',
 | |
|   client varchar(255) NOT NULL default '',
 | |
|   replyto varchar(255) NOT NULL default '',
 | |
|   subject varchar(100) NOT NULL default '',
 | |
|   timestamp int(10) unsigned NOT NULL default '0',
 | |
|   tstamp timestamp NOT NULL,
 | |
|   status int(3) NOT NULL default '0',
 | |
|   type varchar(15) NOT NULL default '',
 | |
|   assignment int(10) unsigned NOT NULL default '0',
 | |
|   fupcount int(4) unsigned NOT NULL default '0',
 | |
|   parent int(10) unsigned NOT NULL default '0',
 | |
|   activity int(10) unsigned NOT NULL default '0',
 | |
|   priority tinyint(1) unsigned NOT NULL default '1',
 | |
|   cc varchar(255) NOT NULL default '',
 | |
|   bcc varchar(255) NOT NULL default '',
 | |
|   body varchar(255) NOT NULL,
 | |
|   comment varchar(255),
 | |
|   header varchar(255),
 | |
|   PRIMARY KEY  (lfdnr),
 | |
|   KEY k1 (timestamp),
 | |
|   KEY k2 (type),
 | |
|   KEY k3 (parent),
 | |
|   KEY k4 (assignment),
 | |
|   KEY ticket (ticket)
 | |
| ) ;
 | |
| 
 | |
| INSERT INTO t1 VALUES (773,773,'','','',980257344,20010318180652,0,'Open',10,0,0,0,1,'','','','','');
 | |
| 
 | |
| alter table t1 change lfdnr lfdnr int(10) unsigned not null auto_increment;
 | |
| update t1 set status=1 where type='Open';
 | |
| select status from t1;
 | |
| drop table t1;
 | |
| 
 | |
| #
 | |
| # Test of ORDER BY
 | |
| #
 | |
| 
 | |
| create table t1 (a int not null, b int not null, key (a));
 | |
| insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3);
 | |
| SET @tmp=0;
 | |
| update t1 set b=(@tmp:=@tmp+1) order by a;
 | |
| update /*+index(t1 a)*/ t1 set b=99 where a=1 order by b asc limit 1;
 | |
| select * from t1 order by a,b;
 | |
| update t1 set b=100 where a=1 order by b desc limit 2;
 | |
| update t1 set a=a+10+b where a=1 order by b;
 | |
| select * from t1 order by a,b;
 | |
| create table t2 (a int not null, b int not null);
 | |
| insert into t2 values (1,1),(1,2),(1,3);
 | |
| update t1 set b=(select distinct 1 from (select * from t2) a);
 | |
| drop table t1,t2;
 | |
| 
 | |
| #
 | |
| # Test with limit (Bug #393)
 | |
| #
 | |
| 
 | |
| CREATE TABLE t1 (
 | |
|    `id_param` smallint(3) unsigned NOT NULL default '0',
 | |
|    `nom_option` char(40) NOT NULL default '',
 | |
|    `valid` tinyint(1) NOT NULL default '0',
 | |
|    KEY `id_param` (`id_param`,`nom_option`)
 | |
|  );
 | |
| 
 | |
| INSERT INTO t1 (id_param,nom_option,valid) VALUES (185,'600x1200',1);
 | |
| 
 | |
| UPDATE t1 SET nom_option='test' WHERE id_param=185 AND nom_option='600x1200' AND valid=1 LIMIT 1;
 | |
| select * from t1;
 | |
| drop table t1;
 | |
| 
 | |
| #
 | |
| # Multi table update test from bugs
 | |
| #
 | |
| 
 | |
| create table t1 (F1 VARCHAR(30), F2 VARCHAR(30), F3 VARCHAR(30), cnt int, groupid int, KEY groupid_index (groupid));
 | |
| 
 | |
| insert into t1 (F1,F2,F3,cnt,groupid) values ('0','0','0',1,6),
 | |
| ('0','1','2',1,5), ('0','2','0',1,3), ('1','0','1',1,2),
 | |
| ('1','2','1',1,1), ('1','2','2',1,1), ('2','0','1',2,4),
 | |
| ('2','2','0',1,7);
 | |
| delete from m1 using t1 m1,t1 m2 where m1.groupid=m2.groupid and (m1.cnt < m2.cnt or m1.cnt=m2.cnt and m1.F3>m2.F3);
 | |
| select * from t1;
 | |
| drop table t1;
 | |
| 
 | |
| 
 | |
| # Bug#5553 - Multi table UPDATE IGNORE fails on duplicate keys 
 | |
| 
 | |
| 
 | |
| CREATE TABLE t1 ( 
 | |
|    `colA` int(10) unsigned NOT NULL auto_increment,
 | |
|    `colB` int(11) NOT NULL default '0',
 | |
|    PRIMARY KEY  (`colA`)
 | |
| );
 | |
| INSERT INTO t1 VALUES (4433,5424);
 | |
| CREATE TABLE t2 (
 | |
|   `colC` int(10) unsigned NOT NULL default '0',
 | |
|   `colA` int(10) unsigned NOT NULL default '0',
 | |
|   `colD` int(10) unsigned NOT NULL default '0',
 | |
|   `colE` int(10) unsigned NOT NULL default '0',
 | |
|   `colF` int(10) unsigned NOT NULL default '0',
 | |
|   PRIMARY KEY  (`colC`,`colA`,`colD`,`colE`)
 | |
| );
 | |
| INSERT INTO t2 VALUES (3,4433,10005,495,500);
 | |
| INSERT INTO t2 VALUES (3,4433,10005,496,500);
 | |
| INSERT INTO t2 VALUES (3,4433,10009,494,500);
 | |
| INSERT INTO t2 VALUES (3,4433,10011,494,500);
 | |
| INSERT INTO t2 VALUES (3,4433,10005,497,500);
 | |
| INSERT INTO t2 VALUES (3,4433,10013,489,500);
 | |
| INSERT INTO t2 VALUES (3,4433,10005,494,500);
 | |
| INSERT INTO t2 VALUES (3,4433,10005,493,500);
 | |
| INSERT INTO t2 VALUES (3,4433,10005,492,500);
 | |
| #UPDATE IGNORE t2,t1 set t2.colE = t2.colE + 1,colF=0 WHERE t1.colA = t2.colA AND (t1.colB & 4096) > 0 AND (colE + 1) < colF;
 | |
| --error 1062
 | |
| UPDATE t2,t1 set t2.colE = t2.colE + 1,colF=0 WHERE t1.colA = t2.colA AND (t1.colB & 4096) > 0 AND (colE + 1) < colF;
 | |
| 
 | |
| SELECT * FROM t2;
 | |
| DROP TABLE t1;
 | |
| DROP TABLE t2;
 | |
| 
 | |
| #
 | |
| # Bug #6054 
 | |
| #
 | |
| create table t1 (c1 int, c2 char(6), c3 int);
 | |
| create table t2 (c1 int, c2 char(6));
 | |
| insert into t1 values (1, "t1c2-1", 10), (2, "t1c2-2", 20);
 | |
| update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1";
 | |
| update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1" where t1.c3 = 10;
 | |
| drop table t1, t2;
 | |
| 
 | |
| #
 | |
| # Bug #8057
 | |
| #
 | |
| create table t1 (id int not null auto_increment primary key, id_str varchar(32));
 | |
| insert into t1 (id_str) values ("test");
 | |
| update t1 set id_str = concat(id_str, id) where id = last_insert_id();
 | |
| select * from t1;
 | |
| drop table t1;
 | |
| 
 | |
| #
 | |
| # Bug #8942: a problem with update and partial key part
 | |
| #
 | |
| 
 | |
| create table t1 (a int, b char(255), key(a, b(20)));
 | |
| insert into t1 values (0, '1');
 | |
| update /*+index(t1 a)*/ t1 set b = b + 1 where a = 0;
 | |
| select * from t1;
 | |
| drop table t1;
 | |
| 
 | |
| # BUG#9103 "Erroneous data truncation warnings on multi-table updates"
 | |
| create table t1 (a int, b varchar(10), key b(b(5)));
 | |
| create table t2 (a int, b varchar(10));
 | |
| 
 | |
| insert into t1 values ( 1, 'abcd1e');
 | |
| insert into t1 values ( 2, 'abcd2e');
 | |
| insert into t2 values ( 1, 'abcd1e');
 | |
| insert into t2 values ( 2, 'abcd2e');
 | |
| update t1, t2 set t1.a = t2.a where t2.b = t1.b;
 | |
| show warnings;
 | |
| select * from t1;
 | |
| select * from t2;
 | |
| drop table t1, t2;
 | |
| 
 | |
| #
 | |
| # Bug #11868 Update with subquery with ref built with a key from the updated
 | |
| #            table crashes server
 | |
| #
 | |
| create table t1(f1 int, f2 int);
 | |
| create table t2(f3 int, f4 int);
 | |
| create index idx on t2(f3);
 | |
| insert into t1 values(1,0),(2,0);
 | |
| insert into t2 values(1,1),(2,2);
 | |
| UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1);
 | |
| select * from t1;
 | |
| drop table t1,t2;
 | |
| 
 | |
| #
 | |
| # Bug #13180 sometimes server accepts sum func in update/delete where condition
 | |
| #
 | |
| create table t1(f1 int);
 | |
| select DATABASE();
 | |
| --error 1111
 | |
| update t1 set f1=1 where count(*)=1;
 | |
| select DATABASE();
 | |
| --error 1111
 | |
| delete from t1 where count(*)=1;
 | |
| drop table t1;
 | |
| 
 | |
| # BUG#12915: Optimize "DELETE|UPDATE ... ORDER BY ... LIMIT n" to use an index
 | |
| create table t1 ( a int, b int default 0, index (a) );
 | |
| insert into t1 (a) values (0),(0),(0),(0),(0),(0),(0),(0);
 | |
| 
 | |
| #flush status;
 | |
| select a from t1 order by a limit 1;
 | |
| #show status like 'handler_read%';
 | |
| 
 | |
| #flush status;
 | |
| update t1 set a=9999 order by a limit 1;
 | |
| update t1 set b=9999 order by a limit 1;
 | |
| #show status like 'handler_read%';
 | |
| 
 | |
| #flush status;
 | |
| delete from t1 order by a limit 1;
 | |
| #show status like 'handler_read%';
 | |
| 
 | |
| #flush status;
 | |
| delete from t1 order by a desc limit 1;
 | |
| #show status like 'handler_read%';
 | |
| 
 | |
| #alter table t1 disable keys;
 | |
| 
 | |
| #flush status;
 | |
| delete from t1 order by a limit 1;
 | |
| #show status like 'handler_read%';
 | |
| 
 | |
| select * from t1;
 | |
| update t1 set a=a+10,b=1 order by a limit 3;
 | |
| update t1 set a=a+11,b=2 order by a limit 3;
 | |
| update t1 set a=a+12,b=3 order by a limit 3;
 | |
| select * from t1 order by a;
 | |
| 
 | |
| drop table t1;
 | |
| 
 | |
| #
 | |
| # Bug#14186 select datefield is null not updated
 | |
| #
 | |
| create table t1 (f1 date not null);
 | |
| insert into t1 values('2000-01-01'),('0000-00-00');
 | |
| update t1 set f1='2002-02-02' where f1 is null;
 | |
| select * from t1;
 | |
| drop table t1;
 | |
| 
 | |
| #
 | |
| # Bug#15028 Multitable update returns different numbers of matched rows
 | |
| #           depending on table order
 | |
| create table t1 (f1 int);
 | |
| create table t2 (f2 int);
 | |
| insert into t1 values(1),(2);
 | |
| insert into t2 values(1),(1);
 | |
| #--enable_info
 | |
| #update t1,t2 set f1=3,f2=3 where f1=f2 and f1=1;
 | |
| #--disable_info
 | |
| update t2 set f2=1;
 | |
| update t1 set f1=1 where f1=3;
 | |
| #--enable_info
 | |
| #update t2,t1 set f1=3,f2=3 where f1=f2 and f1=1;
 | |
| #--disable_info
 | |
| drop table t1,t2;
 | |
| 
 | |
| 
 | |
| # BUG#15935
 | |
| #create table t1 (a int);
 | |
| #insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
 | |
| #create table t2 (a int, filler1 char(200), filler2 char(200), key(a));
 | |
| #insert into t2 select A.a + 10*B.a, 'filler','filler' from t1 A, t1 B;
 | |
| #flush status;
 | |
| #update t2 set a=3 where a=2;
 | |
| #show status like 'handler_read%';
 | |
| #drop table t1, t2;
 | |
| 
 | |
| #
 | |
| # Bug #16510 Updating field named like '*name' caused server crash
 | |
| #
 | |
| create table t1(f1 int, `*f2` int);
 | |
| insert into t1 values (1,1);
 | |
| update t1 set `*f2`=1;
 | |
| drop table t1;
 | |
| 
 | |
| #
 | |
| # Bug#25126: Wrongly resolved field leads to a crash
 | |
| #
 | |
| create table t1(f1 int);
 | |
| --error 1054
 | |
| update t1 set f2=1 order by f2;
 | |
| drop table t1;
 | |
| # End of 4.1 tests
 | |
| 
 | |
| #
 | |
| # Bug #24035: performance degradation with condition int_field=big_decimal
 | |
| #
 | |
| 
 | |
| CREATE TABLE t1 (
 | |
|   request_id int unsigned NOT NULL auto_increment,
 | |
|   user_id varchar(12) default NULL,
 | |
|   time_stamp datetime NOT NULL default '0000-00-00 00:00:00',
 | |
|   ip_address varchar(15) default NULL,
 | |
|   PRIMARY KEY (request_id),
 | |
|   KEY user_id_2 (user_id,time_stamp)
 | |
| );
 | |
| 
 | |
| INSERT INTO t1 (user_id) VALUES ('user1');
 | |
| INSERT INTO t1 (user_id) VALUES ('user1');
 | |
| INSERT INTO t1 (user_id) VALUES ('user1');
 | |
| INSERT INTO t1 (user_id) VALUES ('user1');
 | |
| INSERT INTO t1 (user_id) VALUES ('user1');
 | |
| #INSERT INTO t1(user_id) SELECT user_id FROM t1;
 | |
| #INSERT INTO t1(user_id) SELECT user_id FROM t1;
 | |
| #INSERT INTO t1(user_id) SELECT user_id FROM t1;
 | |
| #INSERT INTO t1(user_id) SELECT user_id FROM t1;
 | |
| #INSERT INTO t1(user_id) SELECT user_id FROM t1;
 | |
| #INSERT INTO t1(user_id) SELECT user_id FROM t1;
 | |
| #INSERT INTO t1(user_id) SELECT user_id FROM t1;
 | |
| #INSERT INTO t1(user_id) SELECT user_id FROM t1;
 | |
| #
 | |
| #flush status;
 | |
| SELECT user_id FROM t1 WHERE request_id=9999999999999; 
 | |
| #show status like '%Handler_read%';
 | |
| SELECT user_id FROM t1 WHERE request_id=999999999999999999999999999999; 
 | |
| #show status like '%Handler_read%';
 | |
| UPDATE t1 SET user_id=null WHERE request_id=9999999999999;
 | |
| #show status like '%Handler_read%';
 | |
| UPDATE t1 SET user_id=null WHERE request_id=999999999999999999999999999999;
 | |
| #show status like '%Handler_read%';
 | |
| 
 | |
| DROP TABLE t1;
 | |
| 
 | |
| #
 | |
| # Bug #24010: INSERT INTO ... SELECT fails on unique constraint with data it 
 | |
| # doesn't select
 | |
| #
 | |
| CREATE TABLE t1 (
 | |
| 
 | |
|   a INT(11),
 | |
|   quux decimal( 31, 30 ),
 | |
| 
 | |
|   UNIQUE KEY bar (a),
 | |
|   KEY quux (quux)
 | |
| );
 | |
| 
 | |
| INSERT INTO
 | |
|  t1 ( a, quux )
 | |
| VALUES
 | |
|     ( 1,    1 ),
 | |
|     ( 2,  0.1 );
 | |
| 
 | |
| #INSERT INTO t1( a )
 | |
| #  SELECT @newA := 1 + a FROM t1 WHERE quux <= 0.1;
 | |
| 
 | |
| SELECT * FROM t1;
 | |
| 
 | |
| DROP TABLE t1;
 | |
| 
 | |
| #
 | |
| # Bug #22364: Inconsistent "matched rows" when executing UPDATE
 | |
| #
 | |
| 
 | |
| #connect (con1,localhost,root,,test);
 | |
| #connection con1;
 | |
| #
 | |
| #set tmp_table_size=1024;
 | |
| #
 | |
| ## Create the test tables
 | |
| #create table t1 (id int, a int, key idx(a));
 | |
| #create table t2 (id int unsigned not null auto_increment primary key, a int);
 | |
| #insert into t2(a) values(1),(2),(3),(4),(5),(6),(7),(8);
 | |
| ##insert into t2(a) select a from t2; 
 | |
| ##insert into t2(a) select a from t2;
 | |
| ##insert into t2(a) select a from t2; 
 | |
| #insert into t2(a) values(1),(2),(3),(4),(5),(6),(7),(8);
 | |
| #insert into t2(a) values(1),(2),(3),(4),(5),(6),(7),(8);
 | |
| #insert into t2(a) values(1),(2),(3),(4),(5),(6),(7),(8);
 | |
| #insert into t2(a) values(1),(2),(3),(4),(5),(6),(7),(8);
 | |
| #insert into t2(a) values(1),(2),(3),(4),(5),(6),(7),(8);
 | |
| #update t2 set a=id;
 | |
| #insert into t1 select * from t2;
 | |
| #
 | |
| ## Check that the number of matched rows is correct when the temporary
 | |
| ## table is small enough to not be converted to MyISAM
 | |
| #select count(*) from t1 join t2 on (t1.a=t2.a);
 | |
| ##--enable_info
 | |
| ##update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
 | |
| ##--disable_info
 | |
| #
 | |
| ## Increase table sizes
 | |
| ##insert into t2(a) select a from t2; 
 | |
| #update t2 set a=id; 
 | |
| #truncate t1; 
 | |
| ##insert into t1 select * from t2; 
 | |
| #
 | |
| ## Check that the number of matched rows is correct when the temporary
 | |
| ## table has to be converted to MyISAM
 | |
| #select count(*) from t1 join t2 on (t1.a=t2.a);
 | |
| #--enable_info
 | |
| #update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
 | |
| #--disable_info
 | |
| #
 | |
| ## Check that the number of matched rows is correct when there are duplicate
 | |
| ## key errors
 | |
| #update t1 set a=1;
 | |
| #update t2 set a=1;
 | |
| #select count(*) from t1 join t2 on (t1.a=t2.a);
 | |
| #--enable_info
 | |
| #update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
 | |
| #--disable_info
 | |
| #
 | |
| #drop table t1,t2;
 | |
| #
 | |
| #connection default;
 | |
| #disconnect con1;
 | |
| 
 | |
| #
 | |
| # Bug #40745: Error during WHERE clause calculation in UPDATE
 | |
| #             leads to an assertion failure
 | |
| #
 | |
| #--disable_warnings
 | |
| #DROP TABLE IF EXISTS t1;
 | |
| #DROP FUNCTION IF EXISTS f1;
 | |
| #--enable_warnings
 | |
| #
 | |
| #CREATE FUNCTION f1() RETURNS INT RETURN f1();
 | |
| #CREATE TABLE t1 (i INT);
 | |
| #INSERT INTO t1 VALUES (1);
 | |
| #
 | |
| #--error ER_SP_NO_RECURSION
 | |
| #UPDATE t1 SET i = 3 WHERE f1();
 | |
| #--error ER_SP_NO_RECURSION
 | |
| #UPDATE t1 SET i = f1();
 | |
| #
 | |
| #DROP TABLE t1;
 | |
| #DROP FUNCTION f1;
 | |
| #
 | |
| #--echo End of 5.0 tests
 | |
| #
 | |
| #--echo #
 | |
| #--echo # Bug #47919 assert in open_table during ALTER temporary table
 | |
| #--echo #
 | |
| #
 | |
| CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT, PRIMARY KEY (f1));
 | |
| #CREATE TEMPORARY TABLE t2 LIKE t1;
 | |
| CREATE TABLE t2(f1 INTEGER AUTO_INCREMENT, PRIMARY KEY (f1));
 | |
| INSERT INTO t1 VALUES (1);
 | |
| INSERT INTO t2 VALUES (1);
 | |
| 
 | |
| ALTER TABLE t2 COMMENT = 'ABC';
 | |
| #UPDATE t2, t1 SET t2.f1 = 2, t1.f1 = 9;
 | |
| ALTER TABLE t2 COMMENT = 'DEF';
 | |
| 
 | |
| DROP TABLE t1, t2;
 | |
| 
 | |
| --echo #
 | |
| --echo # Bug#50545: Single table UPDATE IGNORE crashes on join view in
 | |
| --echo # sql_safe_updates mode.
 | |
| --echo #
 | |
| CREATE TABLE t1 ( a INT, KEY( a ) );
 | |
| INSERT INTO t1 VALUES (0), (1);
 | |
| CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12;
 | |
| #SET SESSION sql_safe_updates = 1;
 | |
| 
 | |
| #--error ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE
 | |
| #UPDATE IGNORE v1 SET a = 1;
 | |
| 
 | |
| #SET SESSION sql_safe_updates = DEFAULT;
 | |
| DROP TABLE t1;
 | |
| DROP VIEW v1;
 | |
| 
 | |
| --echo #
 | |
| --echo # Bug#54734 assert in Diagnostics_area::set_ok_status
 | |
| --echo #
 | |
| 
 | |
| #--disable_warnings
 | |
| #DROP TABLE IF EXISTS t1, not_exists;
 | |
| #DROP FUNCTION IF EXISTS f1;
 | |
| #DROP VIEW IF EXISTS v1;
 | |
| #--enable_warnings
 | |
| #
 | |
| #CREATE TABLE t1 (PRIMARY KEY(pk)) AS SELECT 1 AS pk;
 | |
| #CREATE FUNCTION f1() RETURNS INTEGER RETURN (SELECT 1 FROM not_exists);
 | |
| #CREATE VIEW v1 AS SELECT pk FROM t1 WHERE f1() = 13;
 | |
| #--error ER_VIEW_INVALID
 | |
| #UPDATE v1 SET pk = 7 WHERE pk > 0;
 | |
| #
 | |
| #DROP VIEW v1;
 | |
| #DROP FUNCTION f1;
 | |
| #DROP TABLE t1;
 | |
| 
 | |
| --echo #
 | |
| --echo # Verify that UPDATE does the same number of handler_update
 | |
| --echo # operations, no matter if there is ORDER BY or not.
 | |
| --echo #
 | |
| 
 | |
| CREATE TABLE t1 (i INT);
 | |
| INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19),
 | |
|                       (20),(21),(22),(23),(24),(25),(26),(27),(28),(29),
 | |
|                       (30),(31),(32),(33),(34),(35);
 | |
| #CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2),
 | |
| #                 INDEX idx (a,b(1),c));
 | |
| CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2),
 | |
|                  INDEX idx (a,b,c));
 | |
| 
 | |
| INSERT INTO t2 VALUES (10,10,10,10),(11,11,11,11),(12,12,12,12),(13,13,13,13),(14,14,14,14),(15,15,15,15),(16,16,16,16),(17,17,17,17),(18,18,18,18),(19,19,19,19);
 | |
| 
 | |
| #INSERT INTO t2 SELECT i, i, i, i FROM t1;
 | |
| #FLUSH STATUS; # FLUSH is autocommit, so we put it outside of transaction
 | |
| START TRANSACTION;
 | |
| UPDATE t2 SET d = 10 WHERE b = 10 LIMIT 5;
 | |
| #SHOW STATUS LIKE 'HANDLER_UPDATE';
 | |
| ROLLBACK;
 | |
| #FLUSH STATUS;
 | |
| START TRANSACTION;
 | |
| UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
 | |
| #SHOW STATUS LIKE 'HANDLER_UPDATE';
 | |
| ROLLBACK;
 | |
| 
 | |
| --echo Same test with a different UPDATE.
 | |
| 
 | |
| ALTER TABLE t2 DROP INDEX idx;
 | |
| alter table t2 ADD INDEX idx2 (a, b);
 | |
| #FLUSH STATUS;
 | |
| START TRANSACTION;
 | |
| UPDATE t2 SET c = 10 LIMIT 5;
 | |
| #SHOW STATUS LIKE 'HANDLER_UPDATE';
 | |
| ROLLBACK;
 | |
| #FLUSH STATUS;
 | |
| START TRANSACTION;
 | |
| UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5;
 | |
| #SHOW STATUS LIKE 'HANDLER_UPDATE';
 | |
| ROLLBACK;
 | |
| DROP TABLE t1, t2;
 | |
| 
 | |
| --disable_warnings
 | |
| drop table if exists table10_bigint;
 | |
| --enable_warnings
 | |
| 
 | |
| CREATE TABLE table10_bigint (col_char_34_key char(34),col_char_24 char(24),col_char_48_unique_index char(48),col_char_26_unique_index char(26),col_char_36 char(36),col_char_26 char(26),col_char_20 char(20),col_char_37 char(37),col_char_29_key char(29),pk bigint,col_char_20_unique_index char(20),col_char_39 char(39),col_char_23 char(23),col_char_28_key char(28),col_char_45 char(45),col_char_40_unique_index char(40),col_char_43_unique_index char(43),col_char_21_key char(21),col_char_29 char(29),col_char_25_key char(25),col_timestamp_6 timestamp(6) NULL DEFAULT NULL,col_char_32_key char(32),col_char_22 char(22),col_char_45_key char(45),col_char_20_key char(20),col_char_35_key char(35),col_char_22_unique_index char(22),col_char_46_unique_index char(46),col_char_28_unique_index char(28),col_char_25 char(25),col_char_42_unique_index char(42),col_char_30_key char(30),col_char_33_unique_index char(33),col_char_42 char(42),col_char_23_key char(23),col_char_36_key char(36),col_timestamp_6_unique_index timestamp(6) NULL DEFAULT NULL,col_char_37_unique_index char(37),col_char_46_key char(46),col_char_32_unique_index char(32),col_char_34_unique_index char(34),col_char_28 char(28),col_char_25_unique_index char(25),col_char_39_unique_index char(39),col_char_30 char(30),col_char_36_unique_index char(36),col_char_47_key char(47),col_char_41_unique_index char(41),col_char_42_key char(42),col_char_48 char(48),col_char_46 char(46),col_char_48_key char(48),col_char_22_key char(22),col_bigint_unique_index bigint,col_char_38 char(38),col_char_21 char(21),col_char_43 char(43),col_char_27 char(27),col_char_40_key char(40),col_char_40 char(40),col_char_47_unique_index char(47),col_char_21_unique_index char(21),col_char_33 char(33),col_char_27_unique_index char(27),col_char_44_key char(44),col_char_35_unique_index char(35),col_char_26_key char(26),col_bigint bigint,col_char_30_unique_index char(30),col_char_45_unique_index char(45),col_char_32 char(32),col_char_41 char(41),col_char_24_unique_index char(24),col_char_31_unique_index char(31),col_char_33_key char(33),col_char_39_key char(39),col_char_35 char(35),col_timestamp_6_key timestamp(6) NULL DEFAULT NULL,col_char_44 char(44),col_char_31 char(31),col_char_43_key char(43),col_char_29_unique_index char(29),col_char_37_key char(37),col_char_23_unique_index char(23),col_char_41_key char(41),col_char_38_unique_index char(38),col_char_44_unique_index char(44),col_bigint_key bigint,col_char_24_key char(24),col_char_27_key char(27),col_char_38_key char(38),col_char_47 char(47),col_char_31_key char(31),col_char_34 char(34),key idx46(col_char_34_key ),key idx31(col_char_29_key ),primary key (pk)) ;
 | |
| insert into table10_bigint values('a', 'b','c','d','e', 'f', 'h','i','j',1,'a', 'b','c','d','e', 'f', 'h','i','j','k','2001-03-04 10:10:10', 'a', 'b','c','d','e', 'f', 'h','i','j','k','j','i','o','p','u','2001-03-04 10:10:10','a', 'b','c','d','e', 'f',     'h','i','j','k','j','i','o','p','u','y',2,'a', 'b','c','d','e', 'f','h','i','j','k','j','i','o',3,'a', 'b','c','d','e', 'f', 'h','i','j','2001-03-04 10:10:10','a', 'b','c','d','e', 'f', 'h','i','j',4,'a', 'b','c','d','e', 'f');
 | |
| UPDATE table10_bigint SET col_char_20 = 'a' ;
 | |
| delete from table10_bigint;
 | |
| alter system set ob_enable_batched_multi_statement=false;
 | |
| DROP TABLE /*! IF EXISTS*/ table10_bigint;
 | |
| 
 | |
| --disable_warnings
 | |
| drop table if exists t1,t2;
 | |
| drop view if exists update_view, update_view1;
 | |
| --enable_warnings
 | |
| create table t1 (c1 int, c2 int, c3 int);
 | |
| create table t2 (c1 int, c2 int, c3 int);
 | |
| create view update_view (c1,c2) as select t1.c2 as c1, t2.c2 as c2 from t1, t2 where t1.c1 = t2.c1;
 | |
| create view update_view1 (c1,c2) as select t1.c2 as c1, t2.c2 as c2 from t1 join t2 on t1.c1 = t2.c1;
 | |
| --error 5868
 | |
| update t1, t2 set t1.c2 = t2.c2 where t1.c1 = t2.c1 order by t2.c2;
 | |
| --error 5868
 | |
| update t1 join t2 on t1.c1 = t2.c1 set t1.c2 = t2.c2 order by t2.c2;
 | |
| --error 5868
 | |
| update t1 left join t2 on t1.c1 = t2.c1 set t1.c2 = t2.c2 order by t2.c2;
 | |
| --error 5868
 | |
| update update_view set c1 = c2 order by c2;
 | |
| --error 5868
 | |
| update update_view1 set c1 = c2 order by c2;
 | |
| --error 5869
 | |
| update t1, t2 set t1.c2 = t2.c2 where t1.c1 = t2.c1 limit 10;
 | |
| --error 5869
 | |
| update t1 join t2 on t1.c1 = t2.c1 set t1.c2 = t2.c2 limit 10;
 | |
| --error 5869
 | |
| update t1 left join t2 on t1.c1 = t2.c1 set t1.c2 = t2.c2 limit 10;
 | |
| --error 5869
 | |
| update update_view set c1 = c2 limit 10;
 | |
| --error 5869
 | |
| update update_view1 set c1 = c2 limit 10;
 | |
| drop view update_view;
 | |
| drop view update_view1;
 | |
| drop table t1;
 | |
| drop table t2;
 | |
| 
 | |
| --disable_warnings
 | |
| drop table if exists gf_ar_mthly_bill;
 | |
| --enable_warnings
 | |
| 
 | |
| set binlog_row_image='MINIMAL';
 | |
| CREATE TABLE `gf_ar_mthly_bill` (
 | |
|    `tnt_inst_id` varchar(8) COLLATE utf8mb4_bin NOT NULL COMMENT '租户机构id',
 | |
|    `bill_no` varchar(64) COLLATE utf8mb4_bin NOT NULL COMMENT '账单号',
 | |
|    `ip_id` varchar(32) COLLATE utf8mb4_bin NOT NULL COMMENT '结算对象ipid',
 | |
|    `ip_role_id` varchar(32) COLLATE utf8mb4_bin NOT NULL COMMENT '结算对象pid',
 | |
|    `inst_id` varchar(32) COLLATE utf8mb4_bin NOT NULL COMMENT '分支机构',
 | |
|    `pd_code` varchar(64) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '产品码',
 | |
|    `ar_no` varchar(34) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '合约号',
 | |
|    `bill_tp` varchar(2) COLLATE utf8mb4_bin NOT NULL COMMENT '账单类型',
 | |
|    `setl_tp` varchar(2) COLLATE utf8mb4_bin NOT NULL COMMENT '结算方式',
 | |
|    `bill_st` varchar(2) COLLATE utf8mb4_bin NOT NULL COMMENT '核销状态',
 | |
|    `bill_strt_dt` varchar(8) COLLATE utf8mb4_bin NOT NULL COMMENT '账单开始日期',
 | |
|    `bill_end_dt` varchar(8) COLLATE utf8mb4_bin NOT NULL COMMENT '账单结束日期',
 | |
|    `bill_mth` varchar(6) COLLATE utf8mb4_bin NOT NULL COMMENT '账单月份',
 | |
|    `acrd_dt` varchar(8) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应收日期',
 | |
|    `gmt_pay` timestamp(6) NULL DEFAULT NULL COMMENT '付款时间',
 | |
|    `payee_ac` varchar(34) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '收款方账号',
 | |
|    `payer_ac` varchar(34) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '付款方账号',
 | |
|    `pay_way` varchar(2) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '支付方式',
 | |
|    `pay_orig` varchar(2) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '支付来源',
 | |
|    `clcn_bsc_amt` decimal(25,4) DEFAULT NULL COMMENT '计算交易量',
 | |
|    `clcn_bsc_tp` varchar(2) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '计算依据',
 | |
|    `clcn_mthd` varchar(2) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '计算方法',
 | |
|    `chrg_itm_code` varchar(64) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '收费项编码',
 | |
|    `ccy` varchar(3) COLLATE utf8mb4_bin NOT NULL COMMENT '币种',
 | |
|    `bill_amt` bigint(20) NOT NULL COMMENT '账单金额',
 | |
|    `adj_amt` bigint(20) NOT NULL COMMENT '调整金额',
 | |
|    `rcvd_amt` bigint(20) NOT NULL COMMENT '已收金额',
 | |
|    `tax_tp` varchar(16) COLLATE utf8mb4_bin NOT NULL COMMENT '税种 01:增值税 02:营业税',
 | |
|    `tax_rate` decimal(10,8) NOT NULL COMMENT '税率',
 | |
|    `tax_amt` bigint(20) NOT NULL COMMENT '税额',
 | |
|    `exn_inf` varchar(4000) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '扩展信息',
 | |
|    `anl_dmsn1` varchar(1000) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '分析维度1',
 | |
|    `anl_dmsn2` varchar(1000) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '分析维度2',
 | |
|    `anl_dmsn3` varchar(1000) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '分析维度3',
 | |
|    `anl_dmsn4` varchar(1000) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '分析维度4',
 | |
|    `wrtof_dtl_cnt` bigint(20) DEFAULT NULL COMMENT '已核销明细数量',
 | |
|    `to_wrtof_dtl_cnt` bigint(20) DEFAULT NULL COMMENT '待核销明细数量',
 | |
|    `rcrd_id` varchar(64) COLLATE utf8mb4_bin NOT NULL COMMENT '数据唯一ID',
 | |
|    `last_moder` varchar(32) COLLATE utf8mb4_bin NOT NULL COMMENT '最近修改人',
 | |
|    `gmt_create` timestamp(6) NOT NULL COMMENT '创建时间',
 | |
|    `gmt_modified` timestamp(6) NOT NULL COMMENT '修改时间',
 | |
|    `charge_tp` varchar(32) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '计收费环境类型 01 主站云计收费 02 主站离线计收费 03 主站老计收费',
 | |
|    `stl_ip_role_id` varchar(32) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '结算对象',
 | |
|    `svc_amt` bigint(20) DEFAULT NULL COMMENT '交易金额',
 | |
|    `inved_amt` bigint(20) DEFAULT NULL COMMENT '已开票金额',
 | |
|    `chk_st` varchar(2) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '出账状态 01 初始化 02 待确认出账 03 已出账 04 客户已对账 05 对账差异',
 | |
|    `acnt_day` varchar(14) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '出账日',
 | |
|    `inv_amt` bigint(20) DEFAULT NULL COMMENT '可开票金额',
 | |
|    `rel_inv_amt` bigint(20) DEFAULT NULL COMMENT '已关联发票金额',
 | |
|    `tp` varchar(2) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '应收1 返点2',
 | |
|    `payer_ip_role_id` varchar(32) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '扣款对象pid',
 | |
|    `sgn_ip_id` varchar(32) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '签约对象ipid',
 | |
|    `sgn_ip_role_id` varchar(32) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '签约对象pid',
 | |
|    `chking_amt` bigint(20) DEFAULT '0' COMMENT '出账中金额',
 | |
|    `frz_amt` bigint(20) DEFAULT '0' COMMENT '冻结金额(用于控制流程上互斥的业务)',
 | |
|    `chked_amt` bigint(20) DEFAULT '0' COMMENT '已出账金额',
 | |
|    `writingoff_amt` bigint(20) DEFAULT '0' COMMENT '核销中金额',
 | |
|    `svc_bill_amt` bigint(20) DEFAULT NULL COMMENT '账单计费金额,计收费计费时生成的中间金额',
 | |
|    `svc_ccy` varchar(3) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '账单计费币种',
 | |
|    `env_source` varchar(16) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '环境标识',
 | |
|    `metadata_source` varchar(1024) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '元数据来源标识,包括(用户、商户、产品、合约、计费)来源',
 | |
|    `setl_time_zone` varchar(12) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '账单结算时区',
 | |
|    `actg_time_zone` varchar(12) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '账单核算时区',
 | |
|    `inter_trade_flag` varchar(1) COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'Y: 是关联交易 N: 不是关联交易',
 | |
|    `actg_bill_mth` varchar(6) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '核算时区账单月份',
 | |
|    `auto_writeoff_group_no` varchar(64) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '自动核销关联组号',
 | |
|    `partition_id` varchar(4) COLLATE utf8mb4_bin GENERATED ALWAYS AS (substr(`bill_no`,23,2)) VIRTUAL,
 | |
|    PRIMARY KEY (`tnt_inst_id`, `bill_no`),
 | |
|    UNIQUE KEY `uk_tnt_inst_id_rcrd_id` (`tnt_inst_id`, `rcrd_id`) GLOBAL  BLOCK_SIZE 16384,
 | |
|    KEY `idx_tnt_inst_id_acnt_day_chk_st_gmt_create` (`tnt_inst_id`, `acnt_day`, `chk_st`, `gmt_create`) GLOBAL  BLOCK_SIZE 16384,
 | |
|    KEY `idx_tnt_inst_id_acnt_day_chk_st` (`tnt_inst_id`, `acnt_day`, `chk_st`) GLOBAL  BLOCK_SIZE 16384,
 | |
|    KEY `idx_tnt_inst_id_ip_role_id` (`tnt_inst_id`, `ip_role_id`) LOCAL  BLOCK_SIZE 16384,
 | |
|    KEY `idx_tnt_inst_id_setl_tp_bill_st` (`tnt_inst_id`, `setl_tp`, `bill_st`) GLOBAL  BLOCK_SIZE 16384,
 | |
|    KEY `idx_tnt_inst_id_ar_no` (`tnt_inst_id`, `ar_no`) GLOBAL  BLOCK_SIZE 16384,
 | |
|    KEY `idx_tnt_inst_id_bill_mth` (`tnt_inst_id`, `bill_mth`) GLOBAL  BLOCK_SIZE 16384,
 | |
|    KEY `idx_ip_role_id_bill_mth` (`tnt_inst_id`, `ip_role_id`, `bill_mth`) LOCAL  BLOCK_SIZE 16384,
 | |
|    KEY `idx_tnt_inst_id_ip_id` (`tnt_inst_id`, `ip_id`, `bill_mth`, `setl_tp`) GLOBAL  BLOCK_SIZE 16384,
 | |
|    KEY `idx_acrd_dt_setl_tp_bill_st` (`tnt_inst_id`, `acrd_dt`, `setl_tp`, `bill_st`) GLOBAL  BLOCK_SIZE 16384,
 | |
|    KEY `idx_tnt_inst_id_ip_role_id_bill_mth_setl_tp` (`tnt_inst_id`, `ip_role_id`, `bill_mth`, `setl_tp`) LOCAL  BLOCK_SIZE 16384,
 | |
|    KEY `idx_bill_mth` (`bill_mth`, `tnt_inst_id`) GLOBAL  BLOCK_SIZE 16384,
 | |
|    KEY `idx_payer_ip_role_id_bill_mth` (`tnt_inst_id`, `payer_ip_role_id`, `bill_mth`) GLOBAL  BLOCK_SIZE 16384,
 | |
|    KEY `idx_ip_id_bill_mth` (`tnt_inst_id`, `ip_id`, `bill_mth`) GLOBAL  BLOCK_SIZE 16384,
 | |
|    KEY `idx_policy_id_bill_mth_inst_id_type` (`tnt_inst_id`, `inst_id`, `bill_mth`, `tp`, `anl_dmsn2`) GLOBAL,
 | |
|    KEY `idx_tnt_inst_id_inst_id_tp_anl_dmsn_1_bill_mth` (`tnt_inst_id`, `inst_id`, `tp`, `anl_dmsn1`, `bill_mth`) GLOBAL,
 | |
|    KEY `idx_tnt_inst_id_inst_id_tp_anl_dmsn_3_bill_mth` (`tnt_inst_id`, `inst_id`, `tp`, `anl_dmsn3`, `bill_mth`) GLOBAL,
 | |
|    KEY `idx_tnt_inst_id_inst_id_tp_anl_dmsn_4_bill_mth` (`tnt_inst_id`, `inst_id`, `tp`, `anl_dmsn4`, `bill_mth`) GLOBAL,
 | |
|    KEY `idx_tnt_inst_id_inst_id_tp_anl_dmsn_2_bill_mth` (`tnt_inst_id`, `inst_id`, `tp`, `anl_dmsn2`, `bill_mth`) GLOBAL
 | |
|  ) partition by list columns(partition_id)
 | |
|  (partition p0 values in ('00'),
 | |
|  partition p80 values in ('80'),
 | |
|  partition p81 values in ('81'),
 | |
|  partition p82 values in ('82'),
 | |
|  partition p95 values in ('95'),
 | |
|  partition p96 values in ('96'),
 | |
|  partition p97 values in ('97'),
 | |
|  partition p98 values in ('98'),
 | |
|  partition p99 values in ('99'));
 | |
| 
 | |
| insert into gf_ar_mthly_bill(tnt_inst_id, bill_no, ip_id, ip_role_id, inst_id,
 | |
| bill_tp, setl_tp, bill_st, bill_strt_dt, bill_end_dt, bill_mth, ccy, bill_amt,
 | |
| adj_amt, rcvd_amt, tax_tp, tax_rate, tax_amt, rcrd_id, last_moder, gmt_create, gmt_modified)
 | |
| values('ylctest', '2018090310122000040400820033834415',
 | |
| 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2021-05-17 12:09:34', '2021-05-17 12:09:34');
 | |
| begin;
 | |
| update gf_ar_mthly_bill
 | |
|     set bill_st='01',
 | |
|     gmt_pay='2021-05-17 12:09:35',
 | |
|     clcn_bsc_amt='123.12',
 | |
|     bill_amt=1,
 | |
|     rcvd_amt=2,
 | |
|     tax_amt=3,
 | |
|     exn_inf='123456',
 | |
|     anl_dmsn1='123456',
 | |
|     anl_dmsn2='234567',
 | |
|     anl_dmsn3='345678',
 | |
|     anl_dmsn4='456789',
 | |
|     last_moder='ylc',
 | |
|     adj_amt=4,
 | |
|     svc_amt = 5,
 | |
|     chk_st = '06',
 | |
|     inv_amt = 6,
 | |
|     writingoff_amt = 7,
 | |
|     wrtof_dtl_cnt = 9 ,
 | |
|     to_wrtof_dtl_cnt = 8,
 | |
|     chking_amt=10,
 | |
|     chked_amt=11,
 | |
|     frz_amt=12,
 | |
|     svc_bill_amt=13,
 | |
|     gmt_modified='2021-05-17 12:09:34'
 | |
|  where
 | |
|     tnt_inst_id='ylctest' and bill_no='2018090310122000040400820033834415';
 | |
| 
 | |
| select * from gf_ar_mthly_bill;
 | |
| rollback;
 | |
| connect (obsys,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
 | |
| connection obsys;
 | |
| --sleep 3
 | |
| connection default;
 | |
| set binlog_row_image='MINIMAL';
 | |
| update gf_ar_mthly_bill
 | |
|     set bill_st='01',
 | |
|     gmt_pay='2021-05-17 12:09:35',
 | |
|     clcn_bsc_amt='123.12',
 | |
|     bill_amt=1,
 | |
|     rcvd_amt=2,
 | |
|     tax_amt=3,
 | |
|     exn_inf='123456',
 | |
|     anl_dmsn1='123456',
 | |
|     anl_dmsn2='234567',
 | |
|     anl_dmsn3='345678',
 | |
|     anl_dmsn4='456789',
 | |
|     last_moder='ylc',
 | |
|     adj_amt=4,
 | |
|     svc_amt = 5,
 | |
|     chk_st = '06',
 | |
|     inv_amt = 6,
 | |
|     writingoff_amt = 7,
 | |
|     wrtof_dtl_cnt = 9 , 
 | |
|     to_wrtof_dtl_cnt = 8,
 | |
|     chking_amt=10,
 | |
|     chked_amt=11,
 | |
|     frz_amt=12,
 | |
|     svc_bill_amt=13,
 | |
|     gmt_modified='2021-05-17 12:09:34'
 | |
|  where
 | |
|     tnt_inst_id='ylctest' and bill_no='2018090310122000040400820033834415';
 | |
| 
 | |
| select * from gf_ar_mthly_bill;
 | |
| drop table gf_ar_mthly_bill;
 | |
| set binlog_row_image='FULL';
 | |
| connection obsys;
 | |
| connection default;
 | |
| 
 | |
| #bug fix:
 | |
| drop table if exists TBFUNDSALESTAT;
 | |
| CREATE TABLE TBFUNDSALESTAT (
 | |
|   PRD_CODE VARCHAR(32) DEFAULT ' ',
 | |
|   SELLER_CODE VARCHAR(9) DEFAULT ' ',
 | |
|   HOLD_AMT NUMBER(18,2) DEFAULT 0 
 | |
| );
 | |
| 
 | |
| connection obsys;
 | |
| connection default;
 | |
| 
 | |
| UPDATE tbfundsalestat a
 | |
| SET    a.hold_amt = (SELECT /*+merge*/Sum(c.hold_amt)
 | |
|                       FROM tbfundsalestat c
 | |
|                       WHERE c.prd_code = a.prd_code)
 | |
| WHERE  a.seller_code = (SELECT /*+unnest*/Max(b.seller_code)
 | |
|                             FROM   tbfundsalestat b
 | |
|                             WHERE  a.prd_code = b.prd_code);
 | |
| 
 | |
| connection obsys;
 | |
| connection default;
 | |
| 
 | |
| UPDATE tbfundsalestat a
 | |
| SET    a.hold_amt = (SELECT /*+merge*/Sum(c.hold_amt)
 | |
|                       FROM tbfundsalestat c
 | |
|                       WHERE c.prd_code = a.prd_code)
 | |
| WHERE  a.seller_code = (SELECT /*+unnest*/Max(b.seller_code)
 | |
|                             FROM   tbfundsalestat b
 | |
|                             WHERE  a.prd_code = b.prd_code);
 | |
| 
 | |
| drop table if exists TBFUNDSALESTAT;
 | |
| --source mysql_test/include/recover_spm_var.inc
 | 
