Comments (4)
#include <stdio.h>
#include <mysql.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include "c.h"
int main(int argc, char* argv[])
{
MYSQL *mysql,*sock;
MYSQL_ROW row;
MYSQL_RES *result;
mysql = mysql_init(NULL);
if (!(sock = CONN(0))) {
fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql));
perror("");
exit(1);
}
// simple
char sql[100] = {};
sprintf(sql, "INSERT INTO blob_test(a, b) VALUE (1, 2)");
mysql_query(sock, sql);
mysql_query(sock, "select * from blob_test");
result = mysql_store_result(mysql);
mysql_free_result(result);
#define INSERT_QUERY "INSERT INTO blob_test(a, b) VALUES(?,?)"
MYSQL_STMT *stmt;
MYSQL_BIND bind[2];
long length;
int int_data = 10;
char str[100];
int ret;
stmt = mysql_stmt_init(mysql);
mysql_stmt_prepare(stmt, INSERT_QUERY, strlen(INSERT_QUERY));
memset(bind, 0, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_LONG;
bind[0].buffer= (char *)&int_data;
bind[0].is_null= 0;
bind[1].buffer_type= MYSQL_TYPE_BLOB;
bind[1].buffer = (char*)&str;
bind[1].is_null= 0;
mysql_stmt_bind_param(stmt, bind);
ret = mysql_stmt_send_long_data(stmt,1,"MySQL",5);
ret = mysql_stmt_send_long_data(stmt,1," - The most popular Open Source database",40);
mysql_stmt_execute(stmt);
return 0;
}
from tcpcollect.
T 127.0.0.1:57019 -> 127.0.0.1:3306 [AP]
28 00 00 00 16 49 4e 53 45 52 54 20 49 4e 54 4f (....INSERT INTO
20 62 6c 6f 62 5f 74 65 73 74 28 61 2c 20 62 29 blob_test(a, b)
20 56 41 4c 55 45 53 28 3f 2c 3f 29 VALUES(?,?)
T 127.0.0.1:3306 -> 127.0.0.1:57019 [AP]
0c 00 00 01 00 01 00 00 00 00 00 02 00 00 00 00 ................
17 00 00 02 03 64 65 66 00 00 00 01 3f 00 0c 3f .....def....?..?
00 00 00 00 00 fd 80 00 00 00 00 17 00 00 03 03 ................
64 65 66 00 00 00 01 3f 00 0c 3f 00 00 00 00 00 def....?..?.....
fd 80 00 00 00 00 05 00 00 04 fe 00 00 02 00 ...............
T 127.0.0.1:57019 -> 127.0.0.1:3306 [AP]
0c 00 00 00 18 01 00 00 00 01 00 4d 79 53 51 4c ...........MySQL
T 127.0.0.1:57019 -> 127.0.0.1:3306 [AP]
2f 00 00 00 18 01 00 00 00 01 00 20 2d 20 54 68 /.......... - Th
65 20 6d 6f 73 74 20 70 6f 70 75 6c 61 72 20 4f e most popular O
70 65 6e 20 53 6f 75 72 63 65 20 64 61 74 61 62 pen Source datab
61 73 65 ase
T 127.0.0.1:57019 -> 127.0.0.1:3306 [AP]
14 00 00 00 17 01 00 00 00 00 01 00 00 00 00 01 ................
03 00 fc 00 0a 00 00 00 ........
T 127.0.0.1:3306 -> 127.0.0.1:57019 [AP]
07 00 00 01 00 01 00 02 00 00 00 ...........
from tcpcollect.
18 is COM_STMT_SEND_LONG_DATA
below sniffering process illustrate, after COM_STMT_SEND_LONG_DATA, that second column data will like NULL type
second column has only column type without data part
03 00 fc 00 0a 00 00 00
from tcpcollect.
Current method, encounter the COM, we will skip parse_param.
from tcpcollect.
Related Issues (20)
- libpcap 的一处修改和 fakeNow导致断言的问题.
- replicator 用户的 hash slot 未能删除的bug
- filterUser 用户 slot 没有及时删除 HOT 1
- 增加一个辅助线程 HOT 1
- prepare ok resultset big packet bug HOT 1
- prepare sql more than one packet bug
- load data local file protocol HOT 1
- COM_FIELD_LIST protocol HOT 1
- COM_PROCESSINFO and COM_USER
- test_bug9159 会带来bug
- stmt 和 普通 sql 混合执行的bug HOT 1
- 快速短连接造成的问题。 HOT 1
- handle fin packet
- multistatement protocol HOT 1
- big com_stmt_execute bug HOT 1
- support 10240 byte len, support multi packet sql
- tcpcollect client 模式 HOT 1
- prepare statement HOT 1
- null显示
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tcpcollect.