我想使用 MYSQL 触发器监视一张表上的多个事件。当这些事件发生时,我可以在这个数据库上做一些事情。下面的代码可以完成这个任务:
DROP TRIGGER if exists trigger_sample1;;
CREATE TRIGGER trigger_sample1
after UPDATE on table_1 for each row
begin
/* do something */
end ;;
DROP TRIGGER if exists trigger_sample2;;
CREATE TRIGGER trigger_sample2
after INSERT on table_1 for each row
begin
/* do something */
end ;;
DROP TRIGGER if exists trigger_sample3;;
CREATE TRIGGER trigger_sample3
after DELETE on table_1 for each row
begin
/* do something */
end ;;
Run Code Online (Sandbox Code Playgroud)
但我希望将这些触发器合并为一个触发器。我尝试了一些代码,例如:
DROP TRIGGER if exists trigger_sample;;
CREATE TRIGGER trigger_sample
after UPDATE, …Run Code Online (Sandbox Code Playgroud) 我们正在使用syslog-ng通过 将访问日志文件发送到远程服务器tcp。而且我已经知道可以配置多个目的地来完成这项工作,就像:
source s_xxx { file("/xxx/access.log"); };
destination d_one {tcp("1.2.3.4", port(1234));};
destination d_two {tcp("1.2.3.5", port(1234));};
log {source(s_xxx); destination(d_one); destination(d_two);};
Run Code Online (Sandbox Code Playgroud)
我要弄清楚的是如何将我的内容轮询到这两个目的地(例如循环)。换句话说,我的内容要么发送到d_one要么d_two,而不是两者都发送。
非常感谢。
我编写了以下示例程序,但它们的输出并不是我所期望的.
在我的第一个程序中,s包含一些字符,但其中一个大于127(0xe1).当我打印s输出不是我所期望的.
#include <stdio.h>
int main()
{
int i, len;
unsigned char s[] = {0x74, 0x61, 0x6f, 0x62, 0xe1, 0x6f, 0x63, 0x64, 0x6e};
for (i = 0; i < sizeof(s) / sizeof(unsigned char); i++) {
printf("%c ", s[i]);
}
printf("\n%s\n", s);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
你猜怎么着?产出是:
t a o b c d n
taobn@
Run Code Online (Sandbox Code Playgroud)
然后我对第一个程序进行了一些小改动,这是我的第二个程序:
#include <stdio.h>
int main()
{
int i, len;
unsigned char s[] = {0x74, 0x61, 0x6f, 0x62, 0xe1, 0x6f, 0x63, 0x64, …Run Code Online (Sandbox Code Playgroud)