解决当数据库后台查询不到uint1、uint2、uint4、uint8类型的oid导致驱动挂掉问题

(cherry picked from commit de9de1acc92ea861875c96367132651c8420e26e)

静态检查

codecheck2
This commit is contained in:
zcl
2024-07-18 15:55:24 +08:00
parent 77d04c9e82
commit 48e24e8b76

View File

@ -616,7 +616,7 @@ pq_get_pg_catalog_custom_type_oid(connectionObject *conn, const char *param, PyT
char query[256];
int size;
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);
if (size < 0 || (size_t)size >= sizeof(query)) {
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)));
goto cleanup;
}
rv = atoi(strdup(PQgetvalue(conn->pgres, 0, 0)));
temp_oid = PQgetvalue(conn->pgres, 0, 0);
if (temp_oid) {
rv = (unsigned int)atoi(temp_oid);
}
CLEARPGRES(conn->pgres);
cleanup: