FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=16017&edit=1

ID: 16017
Updated by: ifeghali@php.net
Reported By: simon dot jackson at carringbush dot net
-Summary: Issue with field validation length
+Summary: Postgres default field value metadata
Status: Open
Type: Bug
-Package: MDB2_Schema
+Package: MDB2
Package Version: 0.8.5
PHP Version: 5.2.5
Roadmap Versions:
New Comment:

-Summary: Issue with field validation length
+Summary: Postgres default field value metadata
-Package: MDB2_Schema
+Package: MDB2

Im looping this to the MDB2 guys so we can get their thoughts on it.

Best,
~IF.


Previous Comments:
------------------------------------------------------------------------

[2009-03-12 07:00:08] slj

This is with PostgreSQL 8.2.

I haven't tried this with any other versions of PostgreSQL or any
versions of MySQL yet.

A default value of a single space comes back as the rather long:

' '::character varying

Alternatively, it might be possible/better to persuade
MDB2_Driver_pgsql to just pass back the actual default value (i.e. the
single space) rather than the fully enquoted and cast value. This would
remove the need to modify MDB2_Schema. On the other hand if one is
reverse engineering the metadata, it would be best to know the full
defaults value.

I confess I'm not sure which is the best way to proceed.

------------------------------------------------------------------------

[2009-03-11 23:44:08] ifeghali

Hello Simon,

what RDBMS is that ? I am not sure putting database specific checks in
there is the best way to go. Let me think about that a bit more. Perhaps
you could create your own Validate class and pass it as a option ?

Regards,
Igor Feghali.

------------------------------------------------------------------------

[2009-03-11 08:59:50] slj

Changing the source as follows did solve the problem, but I'm not sure
that this is suitable as is for patching the source.

# diff /usr/local/horde/pear/MDB2/Schema/Validate.php
/usr/local/horde/pear/MDB2/Schema/Validate.php.orig
836,840c836
< if ( preg_match ( "/^'(.*)'::(.*)$/", $field_value, $parts
))
< $field_value_inner = $parts[1];
< else
< $field_value_inner = $field_value;
< if (!empty($field_def['length']) &&
strlen($field_value_inner) > $field_def['length']) {
---
if (!empty($field_def['length']) && strlen($field_value)
$field_def['length']) {
------------------------------------------------------------------------

[2009-03-11 08:37:49] slj

Description:
------------
In Validate.php the function validateDataFieldValue checks the length
of a $field_value against the size of the column. However, some field
values such as default values will include quotation characters and/or
some form of casting suffix eg:

' '::character varying

The actual length of the above is 1, not 21

The Horde 1.2.2 upgrade script crashes with the message:

Loading database module...
Updating database...
[ ERROR! ] Reading the existing table structure failed. Error
messages:
MDB2_Schema Error: schema validation error
default value of "pref_scope" is incorrect: "''::character varying" is
larger than "16"

------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedMay 24, '09 at 7:43p
activeMay 24, '09 at 7:43p
posts1
users1
websitepear.php.net

1 user in discussion

Ifeghali: 1 post

People

Translate

site design / logo © 2022 Grokbase