forked from jsuto/piler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
41 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* mysql.c, SJ | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <syslog.h> | ||
#include <piler.h> | ||
|
||
|
||
int prepare_a_mysql_statement(struct session_data *sdata, MYSQL_STMT **stmt, char *s){ | ||
|
||
*stmt = mysql_stmt_init(&(sdata->mysql)); | ||
if(!*stmt){ | ||
syslog(LOG_PRIORITY, "%s: mysql_stmt_init() error", sdata->ttmpfile); | ||
return ERR; | ||
} | ||
|
||
if(mysql_stmt_prepare(*stmt, s, strlen(s))){ | ||
syslog(LOG_PRIORITY, "%s: mysql_stmt_prepare() error: %s => sql: %s", sdata->ttmpfile, mysql_stmt_error(*stmt), s); | ||
return ERR; | ||
} | ||
|
||
return OK; | ||
} | ||
|
||
|
||
void insert_offset(struct session_data *sdata, int server_id){ | ||
char s[SMALLBUFSIZE]; | ||
uint64 id = server_id * 1000000000000ULL; | ||
|
||
snprintf(s, sizeof(s)-1, "INSERT INTO %s (`id`) VALUES (%llu)", SQL_METADATA_TABLE, id); | ||
|
||
mysql_real_query(&(sdata->mysql), s, strlen(s)); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters