增加注释和修改函数名称
修改查询oid的值的sql语句
This commit is contained in:
@ -1332,7 +1332,7 @@ register_type_uint(connectionObject *self, PyThreadState **tstate)
|
||||
_typecast_INTEGER_types = (long int*)malloc((size+1)*sizeof(long int));
|
||||
|
||||
for (int i=0; i< size; i++) {
|
||||
unsigned int uint_val = pq_get_custom_type_oid(self, uint_arr[i], tstate);
|
||||
unsigned int uint_val = pq_get_pg_catalog_custom_type_oid(self, uint_arr[i], tstate);
|
||||
_typecast_INTEGER_types[i] = (long int)uint_val;
|
||||
}
|
||||
typecastObject_initlist _typecast_builtins[] = {
|
||||
|
||||
@ -608,15 +608,16 @@ cleanup:
|
||||
}
|
||||
|
||||
|
||||
/* Get the oid of uint type created by the dolphin plugin, which is only in the pg_catalog by default */
|
||||
|
||||
unsigned int
|
||||
pq_get_custom_type_oid(connectionObject *conn, const char *param, PyThreadState **tstate)
|
||||
pq_get_pg_catalog_custom_type_oid(connectionObject *conn, const char *param, PyThreadState **tstate)
|
||||
{
|
||||
char query[256];
|
||||
int size;
|
||||
unsigned int rv = 0;
|
||||
|
||||
size = PyOS_snprintf(query, sizeof(query), "select oid from pg_type where 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)) {
|
||||
conn_set_error(conn, "query too large");
|
||||
goto cleanup;
|
||||
@ -631,7 +632,7 @@ pq_get_custom_type_oid(connectionObject *conn, const char *param, PyThreadState
|
||||
}
|
||||
|
||||
if (!conn->pgres) {
|
||||
Dprintf("pq_get_custom_type_oid: PQexec returned NULL");
|
||||
Dprintf("pq_get_pg_catalog_custom_type_oid: PQexec returned NULL");
|
||||
PyEval_RestoreThread(*tstate);
|
||||
if (!PyErr_Occurred()) {
|
||||
conn_set_error(conn, PQerrorMessage(conn->pgconn));
|
||||
@ -640,7 +641,7 @@ pq_get_custom_type_oid(connectionObject *conn, const char *param, PyThreadState
|
||||
goto cleanup;
|
||||
}
|
||||
if (PQresultStatus(conn->pgres) != PGRES_TUPLES_OK) {
|
||||
Dprintf("pq_get_custom_type_oid: result was not TUPLES_OK (%s)",
|
||||
Dprintf("pq_get_pg_catalog_custom_type_oid: result was not TUPLES_OK (%s)",
|
||||
PQresStatus(PQresultStatus(conn->pgres)));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user