解决当数据库后台查询不到uint1、uint2、uint4、uint8类型的oid导致驱动挂掉问题
(cherry picked from commit de9de1acc92ea861875c96367132651c8420e26e) 静态检查 codecheck2
This commit is contained in:
@ -616,7 +616,7 @@ pq_get_pg_catalog_custom_type_oid(connectionObject *conn, const char *param, PyT
|
|||||||
char query[256];
|
char query[256];
|
||||||
int size;
|
int size;
|
||||||
unsigned int rv = 0;
|
unsigned int rv = 0;
|
||||||
|
char *temp_oid = NULL;
|
||||||
size = PyOS_snprintf(query, sizeof(query), "select oid from pg_type where typnamespace = 11 and typname= %s", param);
|
size = PyOS_snprintf(query, sizeof(query), "select oid from pg_type where typnamespace = 11 and typname= %s", param);
|
||||||
if (size < 0 || (size_t)size >= sizeof(query)) {
|
if (size < 0 || (size_t)size >= sizeof(query)) {
|
||||||
conn_set_error(conn, "query too large");
|
conn_set_error(conn, "query too large");
|
||||||
@ -645,8 +645,10 @@ pq_get_pg_catalog_custom_type_oid(connectionObject *conn, const char *param, PyT
|
|||||||
PQresStatus(PQresultStatus(conn->pgres)));
|
PQresStatus(PQresultStatus(conn->pgres)));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
temp_oid = PQgetvalue(conn->pgres, 0, 0);
|
||||||
rv = atoi(strdup(PQgetvalue(conn->pgres, 0, 0)));
|
if (temp_oid) {
|
||||||
|
rv = (unsigned int)atoi(temp_oid);
|
||||||
|
}
|
||||||
CLEARPGRES(conn->pgres);
|
CLEARPGRES(conn->pgres);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|||||||
Reference in New Issue
Block a user