G'day all,
Playing with 2.2.0RC3, using PostgreSQL and noticed the following error message:
Warning: pg_query(): Query failed: ERROR: value too long for type character varying(15) in /var/www/gallery.screamingroot.org/include/dblayer/functions_pgsql.inc.php on line 122 INSERT INTO piwigo_history ( date, time, user_id, IP, section, category_id, image_id, image_type, tag_ids ) VALUES ( CURRENT_DATE, CURRENT_TIME, 2, '2002:cabc:9436:6120:22f:16ef:fe46:53f1', 'categories', NULL, NULL, NULL, NULL ) ;
ERROR: value too long for type character varying(15)
The quick fix is:
ALTER TABLE piwigo_history DROP ip;
ALTER TABLE piwigo_history ADD ip inet;
The inet data type is able to store both IPv4 and IPv6 addresses and removes the error message.
I'll produce a quick patch against 2.2.0RC3, although this issue may be present in previous versions and on other databases.
Cheers,
Adrian
Update:
This will affect MySQL and SQLite as well. Neither of these databases have specific inet/cidr data types, so the easy fix is to increase the varchar size to 39;
ALTER TABLE piwigo_history ALTER ip TYPE varchar(39);
(note; not actually tested as I don't have a MySQL DB handy).
Last edited by Nack (2011-03-01 04:31:37)
Offline
Patch
diff -ruN a/install/piwigo_structure-mysql.sql b/install/piwigo_structure-mysql.sql
--- a/install/piwigo_structure-mysql.sql 2011-03-01 11:34:11.735657137 +0800
+++ b/install/piwigo_structure-mysql.sql 2011-03-01 11:35:11.879649161 +0800
@@ -117,7 +117,7 @@
`date` date NOT NULL default '0000-00-00',
`time` time NOT NULL default '00:00:00',
`user_id` smallint(5) NOT NULL default '0',
- `IP` varchar(15) NOT NULL default '',
+ `IP` varchar(39) NOT NULL default '',
`section` enum('categories','tags','search','list','favorites','most_visited','best_rated','recent_pics','recent_cats') default NULL,
`category_id` smallint(5) default NULL,
`tag_ids` varchar(50) default NULL,
diff -ruN a/install/piwigo_structure-pdo-sqlite.sql b/install/piwigo_structure-pdo-sqlite.sql
--- a/install/piwigo_structure-pdo-sqlite.sql 2011-03-01 11:34:11.735657137 +0800
+++ b/install/piwigo_structure-pdo-sqlite.sql 2011-03-01 11:35:26.559684780 +0800
@@ -101,7 +101,7 @@
"date" DATE NOT NULL,
"time" TIME NOT NULL,
"user_id" INTEGER default 0 NOT NULL,
- "ip" VARCHAR(15) default '' NOT NULL,
+ "ip" VARCHAR(39) default '' NOT NULL,
"section" VARCHAR(50) default NULL,
"category_id" INTEGER,
"tag_ids" VARCHAR(50),
diff -ruN a/install/piwigo_structure-pgsql.sql b/install/piwigo_structure-pgsql.sql
--- a/install/piwigo_structure-pgsql.sql 2011-03-01 11:34:11.735657137 +0800
+++ b/install/piwigo_structure-pgsql.sql 2011-03-01 11:36:13.179695164 +0800
@@ -132,7 +132,7 @@
"date" DATE NOT NULL,
"time" TIME NOT NULL,
"user_id" INTEGER default 0 NOT NULL,
- "ip" VARCHAR(15) default '' NOT NULL,
+ "ip" INET default '' NOT NULL,
"section" HISTORY_SECTION default NULL,
"category_id" INTEGER,
"tag_ids" VARCHAR(50),
diff -ruN a/install/piwigo_structure-sqlite.sql b/install/piwigo_structure-sqlite.sql
--- a/install/piwigo_structure-sqlite.sql 2011-03-01 11:34:11.739654642 +0800
+++ b/install/piwigo_structure-sqlite.sql 2011-03-01 11:35:40.811668674 +0800
@@ -101,7 +101,7 @@
"date" DATE NOT NULL,
"time" TIME NOT NULL,
"user_id" INTEGER default 0 NOT NULL,
- "ip" VARCHAR(15) default '' NOT NULL,
+ "ip" VARCHAR(39) default '' NOT NULL,
"section" VARCHAR(50) default NULL,
"category_id" INTEGER,
"tag_ids" VARCHAR(50),
Offline