phpLens
 home  products examples manual  faq support forum  contact news  login store

Forums: phplens   adodb
Forums:   ADOdb Help & Dev:   Replies 
New ReplySearch
Topic: PostgreSQL MetaType() questions...
author: Eloy Lafuente (stronk7)   created: 03-05-2009 07:00:41 PM
Hi,

when working with the PostrgreSQL (postgres64) driver, we have found two "annoyances" in the MetaType() function:

1) Any varchar > $this->blobSize is returned as Text (X) by the function.
2) Any integer (int2, int4...) is returned as 'R' when it's part of primary key or part of unique key. While it's not a problem for us for PKs (all our PKs are really SERIALs)... it's causing us problems for columns belonging to unique keys.

Why are these "customisations" in the MetaType() present? Shouldn't be better to return "C" (char data) for any varchar, no matter of its length?

And, integer columns, isn't better to return the proper type (I), ignoring if they belong to one unique key? After all, the primary_key and the unique attributes in the Adodb field object already have that info. Why to modify the "meta type" based on them?

Both transformations are causing problems here, where we generate different code to alter DB structure based in those meta types (in fact, re-calculating them, because we cannot rely on the types returned by the PG driver, being inconsistent with the values returned by other drivers).

Ciao, stronk7 :-)
Topic: Re:PostgreSQL MetaType() questions...
author: John Lim   created: 06-05-2009 10:30:28 AM
Hi Eloy,

1. Just set blobSize to whatever makes sense to you.

2. I don't understand. The code for 'R' is:


case 'OID':
case 'SERIAL':
return 'R';
Topic: Re:PostgreSQL MetaType() questions...
author: John Lim   created: 06-05-2009 10:38:38 AM
You're right about 2 on closer look. However when i implemented this, I needed this feature.

I will add a new property to the connection driver class:

var uniqueIisR = true;

Then after you init the driver set:

$db = ADONewConnection('postgres8');
$db->uniqueIisR = false;
$db->blobSize = $someLargeNumber;

Also change MetaType() to:

if (isset($fieldobj) && empty($fieldobj->primary_key) && empty($fieldobj->unique)) return 'I';

to

if (isset($fieldobj) && empty($fieldobj->primary_key) && (!$this->uniqueIisR || empty($fieldobj->unique))) return 'I';

This will be in next version of adodb.
Topic: Re:PostgreSQL MetaType() questions...
author: Eloy Lafuente (stronk7)   created: 07-05-2009 05:59:44 AM
Perfect solution John. Thanks!
Page 1
New ReplySearch

View Source

email: contact#phplens.com (change # to @)     telephone (malaysia): 60-3-7947 2888     fax (malaysia): 60-3-7947 2800