GBase 8a
运维管理
文章

解决V86升级V95后audit_log表缺少vc_id列问题

发表于2025-08-08 18:13:0169次浏览5个评论
desc gbase.audit_log;

-- 重建 audit_log表 (修复缺少vc_id)
use vc00001.gclusterdb;

delimiter //
create event rebuild_audit_log on schedule at now() ON COMPLETION NOT PRESERVE enable local 
do
begin

     declare errno int; 
	 declare msg text; 
	 declare exit handler for sqlexception 
	     begin 
		     get diagnostics condition 1 errno = gbase_errno, msg = message_text; 
			 insert into gclusterdb.import_audit_log_errors 
			     values (now(), @@hostname, errno, substr(msg, 0, 1024)); 
		 end; 


			 insert into gclusterdb.import_audit_log_errors 
			     values (now(), @@hostname, 0, 'before create');


	 set self sql_mode = ''; 

	CREATE self TABLE if not exists  gbase.audit_log_bak2 (
	  "thread_id" int(10) unsigned NOT NULL,
	  "taskid" bigint(20) NOT NULL,
	  "start_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
	  "end_time" timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
	  "user_host" mediumtext NOT NULL,
	  "uid" bigint(20) NOT NULL,
	  "user" mediumtext NOT NULL,
	  "host_ip" mediumtext NOT NULL,
	  "query_time" time NOT NULL,
	  "rows" bigint(20) NOT NULL,
      "vc_id" varchar(64) NOT NULL,
	  "db" varchar(512) NOT NULL,
	  "table_list" mediumtext NOT NULL,
	  "sql_text" mediumtext NOT NULL,
	  "sql_type" mediumtext NOT NULL,
	  "sql_command" mediumtext NOT NULL,
	  "operators" mediumtext NOT NULL,
	  "status" mediumtext NOT NULL,
	  "conn_type" mediumtext NOT NULL
	) ENGINE=GsSYS DEFAULT CHARSET=utf8mb4 COMMENT='Audit log' ;

	 
			 insert into gclusterdb.import_audit_log_errors 
			     values (now(), @@hostname, 1, 'after create');


	 
	 set self sql_mode = default; 
	 
	 drop self table if exists gbase.audit_log_bak1; 
			 insert into gclusterdb.import_audit_log_errors 
			     values (now(), @@hostname, 2, 'after drop');
	 rename self table gbase.audit_log to gbase.audit_log_bak1, gbase.audit_log_bak2 to gbase.audit_log; 

	
			 insert into gclusterdb.import_audit_log_errors 
			     values (now(), @@hostname, 3, 'after rename');

     drop self table if exists gbase.audit_log_bak1; 
end;

//
delimiter ;

show tables from gbase like '%audit%';
desc gbase.audit_log;

评论

登录后才可以发表评论
用户头像
levvel发表于 6个月前
观点很新颖!
崔哥发表于 5个月前
晨起开门雪满山,雪晴云淡日光寒。檐流未滴梅花冻,一种清孤不等闲。
用户头像
levvel发表于 4个月前
观点很新颖!
GBase-doudouer发表于 2个月前
学会了
GBase用户51884发表于 2个月前
三人行必有我师