The current definition of IP field in history table is IP VARCHAR(15)
(from upgrade_1.6.2.php if i am correct)
which is fine for IPv4 but IPv6 are 39 characters longs and cannot be stored
The current definition of IP field in history table is
`IP` VARCHAR(15)
(from upgrade_1.6.2.php if i am correct)
which is fine for IPv4 but IPv6 are 39 characters longs and cannot be stored
<!-- github-sync-id:376374003 -->
Extending the size of the IP column probably fixes the problem.
The following query changes the size of the IP field to 39 characters:
ALTER TABLE `piwigo_history`
CHANGE COLUMN `IP` `IP` VARCHAR(39) NOT NULL DEFAULT '' AFTER `user_id`;
However for more efficient storage it may be better to change the type of the column to VARBINARY(16), so the storage requirement is at most 16 bytes (instead of 39 bytes with the previous solution).
Then use INET6_ATON() when storing an IP in the table, and use INET6_NTOA() when retrieving an IP from the table.
Note: INET6_ATON and INET6_NTOA functions were introduced in MySQL 5.6
What is the lowest MySQL version supported by Piwigo?
Extending the size of the `IP` column probably fixes the problem.
The following query changes the size of the `IP` field to 39 characters:
```
ALTER TABLE `piwigo_history`
CHANGE COLUMN `IP` `IP` VARCHAR(39) NOT NULL DEFAULT '' AFTER `user_id`;
```
However for more efficient storage it may be better to change the type of the column to `VARBINARY(16)`, so the storage requirement is at most **16** bytes (instead of **39** bytes with the previous solution).
Then use `INET6_ATON()` when storing an IP in the table, and use `INET6_NTOA()` when retrieving an IP from the table.
Note: `INET6_ATON` and `INET6_NTOA` functions were introduced in MySQL 5.6
What is the lowest MySQL version supported by Piwigo?
More information:
https://dev.mysql.com/doc/refman/5.6/en/miscellaneous-functions.html#function_inet6-aton
https://dev.mysql.com/doc/refman/5.6/en/miscellaneous-functions.html#function_inet6-ntoa
<!-- github-comment-id:468921404 -->
In old versions of MySQL/MariaDB, when inserting "abcd" into a varchar(3) field, it would silently insert "abc" (auto-truncate). In recent version of MySQL/MariaDB, you get an error. I've experienced it a lot lately. Not with IPv6 in piwigo_history but that is the same problem.
Maybe CHAR(39) would be better than VARCHAR(39). To be decided.
In old versions of MySQL/MariaDB, when inserting "abcd" into a varchar(3) field, it would silently insert "abc" (auto-truncate). In recent version of MySQL/MariaDB, you get an error. I've experienced it a lot lately. Not with IPv6 in `piwigo_history` but that is the same problem.
Maybe `CHAR(39)` would be better than `VARCHAR(39)`. To be decided.
<!-- github-comment-id:2205958719 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
The current definition of IP field in history table is
IPVARCHAR(15)(from upgrade_1.6.2.php if i am correct)
which is fine for IPv4 but IPv6 are 39 characters longs and cannot be stored
Extending the size of the
IPcolumn probably fixes the problem.The following query changes the size of the
IPfield to 39 characters:However for more efficient storage it may be better to change the type of the column to
VARBINARY(16), so the storage requirement is at most 16 bytes (instead of 39 bytes with the previous solution).Then use
INET6_ATON()when storing an IP in the table, and useINET6_NTOA()when retrieving an IP from the table.Note:
INET6_ATONandINET6_NTOAfunctions were introduced in MySQL 5.6What is the lowest MySQL version supported by Piwigo?
More information:
https://dev.mysql.com/doc/refman/5.6/en/miscellaneous-functions.html#function_inet6-aton
https://dev.mysql.com/doc/refman/5.6/en/miscellaneous-functions.html#function_inet6-ntoa
In old versions of MySQL/MariaDB, when inserting "abcd" into a varchar(3) field, it would silently insert "abc" (auto-truncate). In recent version of MySQL/MariaDB, you get an error. I've experienced it a lot lately. Not with IPv6 in
piwigo_historybut that is the same problem.Maybe
CHAR(39)would be better thanVARCHAR(39). To be decided.