列表2023-week44
#最近读的东西
#1
Mysql 官方文档
With ON DUPLICATE KEY UPDATE, the affected-rows value per row is 1 if the row is inserted as a new row, 2 if an existing row is updated, and 0 if an existing row is set to its current values. If you specify the CLIENT_FOUND_ROWS flag to the mysql_real_connect() C API function when connecting to mysqld, the affected-rows value is 1 (not 0) if an existing row is set to its current values.
在用upsert
语句时,标准的返回值是 1 插入、2 更新、0 无影响。
In assignment value expressions in the ON DUPLICATE KEY UPDATE clause, you can use the VALUES(col_name) function to refer to column values from the INSERT portion of the INSERT … ON DUPLICATE KEY UPDATE statement. In other words, VALUES(col_name) in the ON DUPLICATE KEY UPDATE clause refers to the value of col_name that would be inserted, had no duplicate-key conflict occurred.
VALUES()
在上述语句的后面的时候,语法从来没见过,是存在歧义的,是代指数据库里的值还是插入语句中的值。
1 | INSERT INTO t1 (a,b,c) VALUES (1,2,3),(4,5,6) |
An INSERT … ON DUPLICATE KEY UPDATE statement against a table having more than one unique or primary key is also marked as unsafe. (Bug #11765650, Bug #58637)
当一个表中有多个唯一索引时,同时使用upsert
的结果是不确定的,只会更新随机一个。
#2
在开发时经常会出现 int 与 string 相互转换的场景,所以从int64
转换成interface{}
的时候,到底发生了什么 👆
1 | package main |
1 | [2023/11/03 13:11:15] mbp ➜ ~/Downloads/workspace/ct go test -bench=. conv_test.go |
#3
为什么对 map 的访问,接了一个参数就不会 panic,还没找到资料
1 | package main |
1 | [2023/11/03 13:21:49] mbp ➜ ~/Downloads/workspace/ct go test -v -run . map_test.go |