From 830f2a29e6d5724bfd68e904d87587d4b54875be Mon Sep 17 00:00:00 2001 From: Hiroshi Inoue Date: Thu, 26 Sep 2019 20:58:28 +0900 Subject: [PATCH] Fix a crash bug when SQLProcedureColumns() handles satisfies_hash_partition(). The proargmodes column of satisfies_hash_partition()'s pg_proc entry is not null but the proallargtypes column is null. Per report from James.wang . --- info.c | 16 ++++++++-------- pgtypes.c | 8 ++++++++ pgtypes.h | 1 + 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/info.c b/info.c index 307e2dd..f190321 100644 --- a/info.c +++ b/info.c @@ -5111,33 +5111,33 @@ MYLOG(0, "atttypid=%s\n", atttypid ? atttypid : "(null)"); set_tuplefield_int4(&tuple[PROCOLS_ORDINAL_POSITION], 0); set_tuplefield_string(&tuple[PROCOLS_IS_NULLABLE], NULL_STRING); } + paramcount = 0; + params = NULL; if (proargmodes) { const char *p; - paramcount = 0; for (p = proargmodes; *p; p++) { if (',' == (*p)) paramcount++; } paramcount++; - params = QR_get_value_backend_text(tres, i, ext_pos + 2); + params = QR_get_value_backend_text(tres, i, ext_pos + 2); // proallargtypes - oidarray if ('{' == *proargmodes) proargmodes++; - if ('{' == *params) - params++; } - else - { + if (0 == paramcount) paramcount = QR_get_value_backend_int(tres, i, 3, NULL); - params = QR_get_value_backend_text(tres, i, 4); - } + if (0 < paramcount && NULL == params) + params = QR_get_value_backend_text(tres, i, 4); // proargtypes - oidvector if (proargnames) { if ('{' == *proargnames) proargnames++; } + if (params && '{' == *params) + params++; /* PARAMETERS info */ for (j = 0; j < paramcount; j++) { diff --git a/pgtypes.c b/pgtypes.c index 5f49137..bee10ec 100644 --- a/pgtypes.c +++ b/pgtypes.c @@ -840,6 +840,14 @@ MYLOG(DETAIL_LOG_LEVEL, "pgtype_to_name int4\n"); return "cidr"; case PG_TYPE_UUID: return "uuid"; + case PG_TYPE_VOID: + return "void"; + case PG_TYPE_INT2VECTOR: + return "int2vector"; + case PG_TYPE_OIDVECTOR: + return "oidvector"; + case PG_TYPE_ANY: + return "any"; case PG_TYPE_INTERVAL: get_interval_type(atttypmod, &tname); return tname; diff --git a/pgtypes.h b/pgtypes.h index 2b120bd..894b6d6 100644 --- a/pgtypes.h +++ b/pgtypes.h @@ -61,6 +61,7 @@ #define PG_TYPE_NUMERIC 1700 #define PG_TYPE_REFCURSOR 1790 #define PG_TYPE_RECORD 2249 +#define PG_TYPE_ANY 2276 #define PG_TYPE_VOID 2278 #define PG_TYPE_UUID 2950 #define INTERNAL_ASIS_TYPE (-9999) -- 2.39.5