Fix citus_executor_name mapping by reimplementing it in C

pull/2812/head
Marco Slot 2019-06-29 22:38:29 +02:00
parent 70c0d96507
commit d6c667946c
5 changed files with 83 additions and 1 deletions

View File

@ -0,0 +1,8 @@
/* citus--8.2-3--8.2-4 */
CREATE OR REPLACE FUNCTION pg_catalog.citus_executor_name(executor_type int)
RETURNS text
LANGUAGE C STRICT
AS 'MODULE_PATHNAME', $$citus_executor_name$$;
COMMENT ON FUNCTION pg_catalog.citus_executor_name(int)
IS 'return the name of the external based for the value in citus_stat_statements() output';

View File

@ -1,6 +1,6 @@
# Citus extension
comment = 'Citus distributed database'
default_version = '8.2-3'
default_version = '8.2-4'
module_pathname = '$libdir/citus'
relocatable = false
schema = pg_catalog

View File

@ -12,9 +12,14 @@
#include "fmgr.h"
#include "distributed/query_stats.h"
#include "utils/builtins.h"
PG_FUNCTION_INFO_V1(citus_stat_statements_reset);
PG_FUNCTION_INFO_V1(citus_query_stats);
PG_FUNCTION_INFO_V1(citus_executor_name);
static char * CitusExecutorName(MultiExecutorType executorType);
/* placeholder for InitializeCitusQueryStats */
@ -58,3 +63,60 @@ citus_query_stats(PG_FUNCTION_ARGS)
"Citus Enterprise")));
PG_RETURN_VOID();
}
/*
* citus_executor_name is a UDF that returns the name of the executor
* given the internal enum value.
*/
Datum
citus_executor_name(PG_FUNCTION_ARGS)
{
MultiExecutorType executorType = PG_GETARG_UINT32(0);
char *executorName = CitusExecutorName(executorType);
PG_RETURN_TEXT_P(cstring_to_text(executorName));
}
/*
* CitusExecutorName returns the name of the executor given the internal
* enum value.
*/
static char *
CitusExecutorName(MultiExecutorType executorType)
{
switch (executorType)
{
case MULTI_EXECUTOR_ADAPTIVE:
{
return "adaptive";
}
case MULTI_EXECUTOR_REAL_TIME:
{
return "real-time";
}
case MULTI_EXECUTOR_TASK_TRACKER:
{
return "task-tracker";
}
case MULTI_EXECUTOR_ROUTER:
{
return "router";
}
case MULTI_EXECUTOR_COORDINATOR_INSERT_SELECT:
{
return "insert-select";
}
default:
{
return "unknown";
}
}
}

View File

@ -155,6 +155,12 @@ ALTER EXTENSION citus UPDATE TO '8.0-9';
ALTER EXTENSION citus UPDATE TO '8.0-10';
ALTER EXTENSION citus UPDATE TO '8.0-11';
ALTER EXTENSION citus UPDATE TO '8.0-12';
ALTER EXTENSION citus UPDATE TO '8.0-13';
ALTER EXTENSION citus UPDATE TO '8.1-1';
ALTER EXTENSION citus UPDATE TO '8.2-1';
ALTER EXTENSION citus UPDATE TO '8.2-2';
ALTER EXTENSION citus UPDATE TO '8.2-3';
ALTER EXTENSION citus UPDATE TO '8.2-4';
-- show running version
SHOW citus.version;
citus.version

View File

@ -155,6 +155,12 @@ ALTER EXTENSION citus UPDATE TO '8.0-9';
ALTER EXTENSION citus UPDATE TO '8.0-10';
ALTER EXTENSION citus UPDATE TO '8.0-11';
ALTER EXTENSION citus UPDATE TO '8.0-12';
ALTER EXTENSION citus UPDATE TO '8.0-13';
ALTER EXTENSION citus UPDATE TO '8.1-1';
ALTER EXTENSION citus UPDATE TO '8.2-1';
ALTER EXTENSION citus UPDATE TO '8.2-2';
ALTER EXTENSION citus UPDATE TO '8.2-3';
ALTER EXTENSION citus UPDATE TO '8.2-4';
-- show running version
SHOW citus.version;