179 } |
179 } |
180 free(params); |
180 free(params); |
181 |
181 |
182 if (!result) { |
182 if (!result) { |
183 lua_pushboolean(L, 0); |
183 lua_pushboolean(L, 0); |
184 lua_pushstring(L, "Unable to allocate result handle"); |
184 lua_pushfstring(L, DBI_ERR_ALLOC_RESULT, PQerrorMessage(statement->postgresql)); |
185 return 2; |
185 return 2; |
186 } |
186 } |
187 |
187 |
188 status = PQresultStatus(result); |
188 status = PQresultStatus(result); |
189 if (status != PGRES_COMMAND_OK && status != PGRES_TUPLES_OK) { |
189 if (status != PGRES_COMMAND_OK && status != PGRES_TUPLES_OK) { |
190 lua_pushboolean(L, 0); |
190 lua_pushboolean(L, 0); |
191 lua_pushfstring(L, "Unable to execute statment: %s", PQresultErrorMessage(result)); |
191 lua_pushfstring(L, DBI_ERR_BINDING_EXEC, PQresultErrorMessage(result)); |
192 return 2; |
192 return 2; |
193 } |
193 } |
194 |
194 |
195 statement->result = result; |
195 statement->result = result; |
196 |
196 |
337 */ |
337 */ |
338 free(new_sql); |
338 free(new_sql); |
339 |
339 |
340 if (!result) { |
340 if (!result) { |
341 lua_pushnil(L); |
341 lua_pushnil(L); |
342 lua_pushstring(L, "Unable to allocate prepare result handle"); |
342 lua_pushfstring(L, DBI_ERR_ALLOC_STATEMENT, PQerrorMessage(statement->postgresql)); |
343 return 2; |
343 return 2; |
344 } |
344 } |
345 |
345 |
346 status = PQresultStatus(result); |
346 status = PQresultStatus(result); |
347 if (status != PGRES_COMMAND_OK && status != PGRES_TUPLES_OK) { |
347 if (status != PGRES_COMMAND_OK && status != PGRES_TUPLES_OK) { |
348 const char *err_string = PQresultErrorMessage(result); |
348 const char *err_string = PQresultErrorMessage(result); |
349 PQclear(result); |
349 PQclear(result); |
350 |
350 |
351 lua_pushnil(L); |
351 lua_pushnil(L); |
352 lua_pushfstring(L, "Unable to prepare statment: %s", err_string); |
352 lua_pushfstring(L, DBI_ERR_PREP_STATEMENT, err_string); |
353 return 2; |
353 return 2; |
354 } |
354 } |
355 |
355 |
356 PQclear(result); |
356 PQclear(result); |
357 |
357 |