Add collation when comparing versions

When comparing versions in the telemetry module when processing the
HTTP response, a direct call of `texteq` is made, but without using a
collation. This generate unnecessary errors in the log and also cause
the telemetry job to abort.

This commit fixes that by using the "C" collation when comparing the
version strings.
This commit is contained in:
Mats Kindahl 2020-03-27 14:16:21 +01:00 committed by Erik Nordström
parent e2da5606cf
commit d0cde563c5
2 changed files with 11 additions and 7 deletions

View File

@ -19,6 +19,7 @@
#include <storage/proc.h> #include <storage/proc.h>
#include <storage/procarray.h> #include <storage/procarray.h>
#include <storage/sinvaladt.h> #include <storage/sinvaladt.h>
#include <utils/elog.h>
#include "job.h" #include "job.h"
#include "scanner.h" #include "scanner.h"

View File

@ -8,6 +8,7 @@
#include <fmgr.h> #include <fmgr.h>
#include <miscadmin.h> #include <miscadmin.h>
#include <commands/extension.h> #include <commands/extension.h>
#include <catalog/pg_collation.h>
#include <utils/builtins.h> #include <utils/builtins.h>
#include <utils/json.h> #include <utils/json.h>
#include <utils/jsonb.h> #include <utils/jsonb.h>
@ -146,13 +147,15 @@ static void
process_response(const char *json) process_response(const char *json)
{ {
VersionResult result; VersionResult result;
bool is_uptodate = bool is_uptodate = DatumGetBool(
DatumGetBool(DirectFunctionCall2(texteq, DirectFunctionCall2Coll(texteq,
DirectFunctionCall2(json_object_field_text, C_COLLATION_OID,
CStringGetTextDatum(json), DirectFunctionCall2Coll(json_object_field_text,
PointerGetDatum(cstring_to_text( C_COLLATION_OID,
TS_IS_UPTODATE_JSON_FIELD))), CStringGetTextDatum(json),
PointerGetDatum(cstring_to_text("true")))); PointerGetDatum(cstring_to_text(
TS_IS_UPTODATE_JSON_FIELD))),
PointerGetDatum(cstring_to_text("true"))));
if (is_uptodate) if (is_uptodate)
elog(NOTICE, "the \"%s\" extension is up-to-date", EXTENSION_NAME); elog(NOTICE, "the \"%s\" extension is up-to-date", EXTENSION_NAME);