Posted by janeks on October 28, 2009 at 10:42am
| Project: | Counter |
| Version: | 6.x-2.6 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
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.
Comments
#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.
#4
I think counter_value should be defined as integer in the database table.
Attached my install script which works well with PostgreSQL 8.4.
Greetings
Conni
#5
Fixed. Thanks all for patching and review.
6.x-2.4: Bug fix: PostgreSQL can not accept "counter_data.counter_value + 1" since it is varchar
#6
Resolved!
#7
It results in errors like
query: INSERT IGNORE INTO counter (counter_ip,counter_date,counter_page) VALUES ('192.168.0.1','2010-04-14 14:15:14','/admin/settings/date-time') in /home/www/sites/all/modules/counter/counter.module on line 177.So 'IGNORE' should appear only in mysql/mysqli case.
#8
Please don't change the TITLE. The integer issue has been fixed in 6.x-2.4.
6.x-2.4: Bug fix: PostgreSQL can not accept "counter_data.counter_value + 1" since it is varchar
For IGNORE clause problem in PostgreSQL follow this thread http://drupal.org/node/782088