Problems with PostgreSQL?
janeks - October 28, 2009 - 10:42
| Project: | Counter |
| Version: | 6.x-2.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I am getting this one:
* warning: pg_query() [function.pg-query]: Query failed: ERROR: operator does not exist: character varying + integer LINE 1: ...ATE counter_data SET counter_value = counter_value+1 WHERE c... ^ HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts. in /home/private/mysite/home/mysite/htdocs/includes/database.pgsql.inc on line 139.
* user warning: ERROR: operator does not exist: character varying + integer LINE 1: ...ATE counter_data SET counter_value = counter_value+1 WHERE c... ^ HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts. query: UPDATE counter_data SET counter_value = counter_value+1 WHERE counter_name='site_counter' in /home/private/mysite/home/mysite/htdocs/sites/all/modules/counter/counter.module on line 168.
#1
A quick solution is to change line 167
from
$sql = " UPDATE {counter_data} SET counter_value = counter_value+1 WHERE counter_name='site_counter'";
to
$sql = " UPDATE {counter_data} SET counter_value = counter_value::int+1 WHERE counter_name='site_counter'";
Not the best solution but it does it's work..
#2
Thank's!
It works now!
brgds
Janeks
#3
As counter_value is of varchar type then I guess lines 167-168:
$sql = " UPDATE {counter_data} SET counter_value = counter_value+1 WHERE counter_name='site_counter'";$results = db_query($sql);
should be changed to something like
$sql = " SELECT counter_value FROM {counter_data} WHERE counter_name='site_counter'";$res = db_result(db_query($sql));
$res++;
$sql = " UPDATE {counter_data} SET counter_value = '%s' WHERE counter_name='site_counter'";
$results = db_query($sql, $res);
And this is how it looks like in similar UPDATEs later in the code.
BTW what does exactly "Site Counter" value mean? It seems unclear to me.