Fixed Launchpad bug #654832.
Fixed a couple of build warnings in drv_pgsql.c.
This commit is contained in:
@ -84,15 +84,15 @@ db_pgsql_bind_map_t db_pgsql_bind_map[] =
|
||||
|
||||
static drv_caps_t pgsql_drv_caps =
|
||||
{
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1, /* multi_rows_insert */
|
||||
1, /* transactions */
|
||||
1, /* prepared_statements */
|
||||
0, /* auto_increment */
|
||||
0, /* needs_commit */
|
||||
1, /* serial */
|
||||
0, /* unsigned int */
|
||||
|
||||
NULL
|
||||
NULL /* table_options_str */
|
||||
};
|
||||
|
||||
/* Describes the PostgreSQL prepared statement */
|
||||
@ -198,9 +198,32 @@ int pgsql_drv_init(void)
|
||||
|
||||
int pgsql_drv_describe(drv_caps_t *caps, const char * table_name)
|
||||
{
|
||||
PGconn *con;
|
||||
(void)table_name; /* unused */
|
||||
|
||||
*caps = pgsql_drv_caps;
|
||||
|
||||
/* Determine the server version */
|
||||
con = PQsetdbLogin(args.host,
|
||||
args.port,
|
||||
NULL,
|
||||
NULL,
|
||||
args.db,
|
||||
args.user,
|
||||
args.password);
|
||||
if (PQstatus(con) != CONNECTION_OK)
|
||||
{
|
||||
log_text(LOG_FATAL, "Connection to database failed: %s",
|
||||
PQerrorMessage(con));
|
||||
PQfinish(con);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Support for multi-row INSERTs is not available before 8.2 */
|
||||
if (PQserverVersion(con) < 80200)
|
||||
caps->multi_rows_insert = 0;
|
||||
|
||||
PQfinish(con);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -388,7 +411,7 @@ int pgsql_drv_bind_param(db_stmt_t *stmt, db_bind_t *params, unsigned int len)
|
||||
return 1;
|
||||
}
|
||||
|
||||
pgstmt->ptypes = (int *)malloc(len * sizeof(int));
|
||||
pgstmt->ptypes = (Oid *)malloc(len * sizeof(int));
|
||||
if (pgstmt->ptypes == NULL)
|
||||
return 1;
|
||||
|
||||
@ -692,6 +715,5 @@ int get_pgsql_bind_type(db_bind_type_t type)
|
||||
|
||||
int get_unique_stmt_name(char *name, int len)
|
||||
{
|
||||
return snprintf(name, len, "sbstmt%d%d", sb_rnd(), sb_rnd());
|
||||
return snprintf(name, len, "sbstmt%d%d", (int)sb_rnd(), (int)sb_rnd());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user