Re: PostgreSQL 9.0.5 concat Issue

From: David Johnston <polobo(at)yahoo(dot)com>
To: "Keegan,Nate" <nate(dot)keegan(at)prescott-az(dot)gov>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL 9.0.5 concat Issue
Date: 2011-11-10 00:42:53
Message-ID: 294B2144-2217-4C25-B046-E8174141CF78@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Nov 9, 2011, at 18:00, "Keegan,Nate" <nate(dot)keegan(at)prescott-az(dot)gov> wrote:

> I'm using a Perl script to take SNMP traps and send them to Zabbix on FreeBSD 8.2-RELEASE amd64.
>
> The original Perl script can be found at http://www.zabbix.com/wiki/howto/monitor/snmp/snmp_traps_-_a_new_solution
>
> This script works just fine under PostgreSQL 9.0.4.
>
> I'm using the FreeBSD ports system to manage PostgreSQL and Zabbix and I noticed that a test upgrade to PostgreSQL server 9.0.5 causes the script to break in a predictable way.
>
> The script debug log is showing this:
>
> /usr/local/bin/zabbix_sender --zabbix-server 127.0.0.1 --port 10051 --host Template_Dell_OpenManage
>
> This is incorrect as 'host' should be an actual hostname and not the name of a Zabbix template (the Template_blah_blah part).
>
> /var/log/messages on my system has some output that takes me to the following line in the script:
>
> $dbh->selectrow_hashref("SELECT itemid,description,key_ FROM items where hostid='$hostid' and \
> '$keyoidvaluenum' like concat(key_,'%') order by length(key_) desc limit 1;");
>
> And here is the /var/log/messages output:
>
> ERROR: function concat(character varying, unknown) does not exist at character 98
> HINT: No function matches the given name and argument types. You might need to add explicit type casts.
> STATEMENT: SELECT itemid,description,key_ FROM items where hostid='10022' and '.1.3.6.1.4.1.318.0.77' like concat(key_,'%') order by length(key_) desc limit 1;
>
> There is only one line in the script which uses the concat function so I'm sure I'm in the right spot.
>
> I'm guessing that the concat function changed between PostgreSQL 9.0.4 and 9.0.5 in a subtle way that is breaking this script by causing the wrong information to be returned from the database.
>
> I can see the hint being offered but I'm unsure as to how to implement this in the given line of code exactly. I would be very grateful for any advice or direction as to how I might go about fixing this item.
>
>

Concat(key_,'%'::varchar) <-- explicit type cast from unknown to varchar

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Wes Cravens 2011-11-10 01:19:59 Returning a row from a function with an appended array field
Previous Message David Johnston 2011-11-10 00:40:49 Re: count (DISTINCT field) OVER ()