From 5ae8d6d12b014802dbd85293eb039a34a35069e3 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Thu, 25 Aug 2016 14:29:11 +0300 Subject: [PATCH] Remove CaQL call from gphdfs. Use the get_type_name() lsyscache function directly. --- gpAux/extensions/gphdfs/gphdfsformatter.c | 30 ++++------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/gpAux/extensions/gphdfs/gphdfsformatter.c b/gpAux/extensions/gphdfs/gphdfsformatter.c index 1a44b74cfc..109db936c9 100644 --- a/gpAux/extensions/gphdfs/gphdfsformatter.c +++ b/gpAux/extensions/gphdfs/gphdfsformatter.c @@ -22,7 +22,6 @@ #include "funcapi.h" #include "access/formatter.h" -#include "catalog/catquery.h" #include "catalog/pg_proc.h" #include "utils/builtins.h" #include "utils/memutils.h" @@ -254,28 +253,6 @@ static void byteArrayToBoolArray(bits8* data, int len, bool** booldata, int bool } } -/** - * Get the name of the type, given the OID - */ -static void getTypeName(Oid typeid, char* data) -{ - char* name; - - /* XXX: would have been get_type_name() */ - name = caql_getcstring_plus( - NULL, - NULL, - NULL, - cql("SELECT typname FROM pg_type " - " WHERE oid = :1 ", - ObjectIdGetDatum(typeid))); - - Insist(name); - - strcpy(data, name); - pfree(name); -} - Datum gphdfsformatter_export(PG_FUNCTION_ARGS) { @@ -641,8 +618,11 @@ gphdfsformatter_import(PG_FUNCTION_ARGS) if ((isBinaryFormatType(defined_type) || isBinaryFormatType(input_type)) && input_type != defined_type) { - char intype[NAMEDATALEN]; - getTypeName(input_type, intype); + char *intype; + + intype = get_type_name(input_type); + Insist(intype); + ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION), errmsg("input data column %d of type \"%s\" did not match the external table definition", i+1, intype), -- GitLab