我有一个用 Perl 编写的非分叉游戏守护进程,它使用 acync 查询将玩家统计数据写入 PostgreSQL 9.3 数据库。但是当我需要从数据库中读取某些内容时(例如玩家是否被禁止或玩家是否具有 VIP 身份),那么我使用同步查询。
这会使游戏停止一小会,直到从数据库中读取该值。
我无法重写我的游戏守护程序以使用异步查询来读取值(我尝试过,但它需要进行太多更改),所以我的问题是:将几个不相关的查询组合在一起是否有意义(我需要在新玩家连接) 到 1 个过程,如何同时将多个值返回到我的 Perl 程序?
我当前的查询都以玩家 ID 作为参数并返回 1 个值:
-- Has the player been banned?
select true from pref_ban where id=?
-- What is the reputation of this player?
select
count(nullif(nice, false)) -
count(nullif(nice, true)) as rep
from pref_rep where id=?
-- Is he or she a special VIP player?
select vip > now() as vip from pref_users where id=?
-- How many …
Run Code Online (Sandbox Code Playgroud) 我正在使用 5.6.28 MySQL 社区服务器在 CentOS 6.7 Linux 服务器上以德语托管 WordPress + ProPhoto 博客:
mysql> show tables;
+-----------------------+
| Tables_in_blog |
+-----------------------+
| wp_commentmeta |
| wp_comments |
| wp_links |
| wp_options |
| wp_postmeta |
| wp_posts |
| wp_term_relationships |
| wp_term_taxonomy |
| wp_terms |
| wp_usermeta |
| wp_users |
+-----------------------+
11 rows in set (0.00 sec)
Run Code Online (Sandbox Code Playgroud)
然后最近我开始开发俄语应用程序,不得不在/etc/my.cnf中将MySQL 设置更改为utf8mb4编码:
[client]
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
[mysqld]
character-set-client-handshake=FALSE
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
Run Code Online (Sandbox Code Playgroud)
现在我的第一个数据库有一个小问题,它仍然显示为latin1:
mysql> show …
Run Code Online (Sandbox Code Playgroud) 请帮助我了解 MySQL 5.6 的语法。
出于某种原因,我收到错误消息:
ERROR 1064 (42000): You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version
for the right syntax to use near '('WRONG SOCIAL: ', new.social);
end if;
if not (new.photo is nul'
Run Code Online (Sandbox Code Playgroud)
尝试运行此 SQL 代码时:
create table table_social (
sid varchar(250) primary key,
auth char(32) not null,
social integer, -- to be checked by triggers
female boolean,
given varchar(250) not null,
family varchar(250) null,
photo varchar(1000) null, -- …
Run Code Online (Sandbox Code Playgroud)