Merge pull request #13 from echiesse/master

Fixed compilation error on function "conn_escape" on Visual Studio 2008.
This commit is contained in:
Hisham Muhammad 2016-03-22 00:37:41 -03:00
commit 25eebb2222

View File

@ -320,7 +320,7 @@ static void sql_commit(conn_data *conn) {
static void sql_begin(conn_data *conn) {
PQclear(PQexec(conn->pg_conn, "BEGIN"));
PQclear(PQexec(conn->pg_conn, "BEGIN"));
}
@ -371,14 +371,17 @@ static int conn_escape (lua_State *L) {
conn_data *conn = getconnection (L);
size_t len;
const char *from = luaL_checklstring (L, 2, &len);
char to[len*sizeof(char)*2+1];
char *to = malloc(len*sizeof(char)*2+1);
int error;
int ret = 1;
len = PQescapeStringConn (conn->pg_conn, to, from, len, &error);
if (error == 0) { /* success ! */
lua_pushlstring (L, to, len);
return 1;
} else
return luasql_failmsg (L, "cannot escape string. PostgreSQL: ", PQerrorMessage (conn->pg_conn));
} else {
ret = luasql_failmsg (L, "cannot escape string. PostgreSQL: ", PQerrorMessage (conn->pg_conn));
}
free(to);
return ret;
}
@ -415,7 +418,7 @@ static int conn_commit (lua_State *L) {
conn_data *conn = getconnection (L);
sql_commit(conn);
if (conn->auto_commit == 0) {
sql_begin(conn);
sql_begin(conn);
lua_pushboolean (L, 1);
} else
lua_pushboolean (L, 0);
@ -430,7 +433,7 @@ static int conn_rollback (lua_State *L) {
conn_data *conn = getconnection (L);
sql_rollback(conn);
if (conn->auto_commit == 0) {
sql_begin(conn);
sql_begin(conn);
lua_pushboolean (L, 1);
} else
lua_pushboolean (L, 0);