handlersocket使用 第六章 Inserting data
2013-02-05 15:37
218 查看
注: 本文档主要根据原作者的英文文档protocol.en.txt写成,做了一些翻译工作和添加了一些例子以及一些需要注意的地方。如果本文档对你有所帮助,欢迎关注我的新浪微博:http://weibo.com/u/1857063732 如果有建议,欢迎发送到我的邮箱xiaoxuye1988@163.com 目前就职于 欢聚时代(YY), 从事于后台开发工作
Insertingdata
英文原文如下
Insertingdata
The'insert' request has the following syntax.
<indexid> + <vlen> <v1>... <vn>
-<vlen> indicates the length of the trailing parameters <v1> ...<vn>. This
must be smaller than or equal to the lengthof <columns> specified by the
corresponding 'open_index' request.
-<v1> ... <vn> specify the column values to set. For columns not in
<columns>, the default values for eachcolumn are set.
‘insert’请求有以下参数:
<indexid>+ <vlen> <v1> ... <vn>
-<vlen>是接下来参数<v1> ... <vn>的个数。这个数字必须不大于那个在其相对于的‘open_index’请求中指定的参数<columns>的的列数。
-<v1>... <vn>指定了要被插入的列值。对于那些不在<columns>中的列,将被设为默认的值。
Response for 'insert'
英文原文如下
If'insert' is succeeded, HandlerSocket returns a line of the following
syntax.
0 1
如果‘insert’请求发送成功,Handlersocket将会返回以下返回值0(插入成功)或1(插入失败)。
下面发给例子:
cli->request_buf_open_index(1, "test","test1", "index1", "col1,col2,col3");
........
vector<string_ref> vec;
vec.push(..)
.....
const string kTestInsertOp("+");
const string_ref kTestInsertOpRef(kTestInsertOp.data(),kTestInsertOp.size());
cli->request_buf_exec_generic(indexid,kTestInsertOpRef,&vec[0],vec_length,0,0,0, 0, 0, 0);
int res = cli->request_send();
.....
a.当表的主键是自增的一个值时,如上例中col0为主键,则将会把新建行的主键的值以类似‘find’请求的结果返回。
b.注意:当某一个列的类型为timestamp default CURRENT_TIMESTAMP时,插入的值将为
0000-00-00 00:00:00(无论在request_buf_open_index中是否打开)。
1.可以使用的间接解决方法,insert之后update,如:
cli->request_buf_exec_generic(1,kTestInsertOpRef,&vec[0],vec_size,0,0,0, 0, 0, 0);
cli->request_buf_exec_generic(1,kTestEqualOpRef,&vec[0],vec_size,limit,offset,kTestUpdateOpRef,&vec_in[0],vec_in_szie);
cli->request_send()......
2.把timestamp时间类型改为datetime类型。但是datetime类型不支持default,好像得写触发器实现。
Insertingdata
英文原文如下
Insertingdata
The'insert' request has the following syntax.
<indexid> + <vlen> <v1>... <vn>
-<vlen> indicates the length of the trailing parameters <v1> ...<vn>. This
must be smaller than or equal to the lengthof <columns> specified by the
corresponding 'open_index' request.
-<v1> ... <vn> specify the column values to set. For columns not in
<columns>, the default values for eachcolumn are set.
‘insert’请求有以下参数:
<indexid>+ <vlen> <v1> ... <vn>
-<vlen>是接下来参数<v1> ... <vn>的个数。这个数字必须不大于那个在其相对于的‘open_index’请求中指定的参数<columns>的的列数。
-<v1>... <vn>指定了要被插入的列值。对于那些不在<columns>中的列,将被设为默认的值。
Response for 'insert'
英文原文如下
If'insert' is succeeded, HandlerSocket returns a line of the following
syntax.
0 1
如果‘insert’请求发送成功,Handlersocket将会返回以下返回值0(插入成功)或1(插入失败)。
下面发给例子:
cli->request_buf_open_index(1, "test","test1", "index1", "col1,col2,col3");
........
vector<string_ref> vec;
vec.push(..)
.....
const string kTestInsertOp("+");
const string_ref kTestInsertOpRef(kTestInsertOp.data(),kTestInsertOp.size());
cli->request_buf_exec_generic(indexid,kTestInsertOpRef,&vec[0],vec_length,0,0,0, 0, 0, 0);
int res = cli->request_send();
.....
a.当表的主键是自增的一个值时,如上例中col0为主键,则将会把新建行的主键的值以类似‘find’请求的结果返回。
b.注意:当某一个列的类型为timestamp default CURRENT_TIMESTAMP时,插入的值将为
0000-00-00 00:00:00(无论在request_buf_open_index中是否打开)。
1.可以使用的间接解决方法,insert之后update,如:
cli->request_buf_exec_generic(1,kTestInsertOpRef,&vec[0],vec_size,0,0,0, 0, 0, 0);
cli->request_buf_exec_generic(1,kTestEqualOpRef,&vec[0],vec_size,limit,offset,kTestUpdateOpRef,&vec_in[0],vec_in_szie);
cli->request_send()......
2.把timestamp时间类型改为datetime类型。但是datetime类型不支持default,好像得写触发器实现。
相关文章推荐
- NoSQL for MySQL [HandlerSocket] 之安装与使用
- Mysql插件之HandlerSocket的安装、配置、使用
- handlersocket使用 第一章 基本语法和一个简单示例
- NoSQL for MySQL [HandlerSocket] 之安装与使用
- handlersocket使用 第四章 Getting data
- HandlerSocket使用经验
- handlersocket使用 第五章 Updating/Deleting data
- handlersocket使用 第七章 Authentication
- 跪求INDY10中idpop3和IdSSLIOHandlerSocketOpenSSL使用SSL连接Gmail用法,该怎么解决
- MYSQL Handler Socket插件(四)安装与使用
- Android-Socket多线程应用(聊天室客户端、Handler的简单使用)
- Android-Socket多线程应用(聊天室客户端、Handler的简单使用)
- handlersocket使用
- JAVA使用Socket实现多人通讯以及文件传输
- 如何使用SOCKET 发送HTTP1.1 GET POST请求包
- new Handler()和new Handler(Looper.getMainLooper())的使用区别
- Android使用Handler防止内存泄漏
- 一些关于handlersocket的资料
- 在Android上使用Socket
- Java UDP使用Socket进行网络聊天(1)