Index: biblio.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/biblio/biblio.install,v
retrieving revision 1.58
diff -r1.58 biblio.install
1051a1052
>   global $db_type;
1057,1058c1058,1061
<   db_query("/*!40000 ALTER TABLE {biblio_field_type_data} DISABLE KEYS */;");
<   db_query("/*!40000 ALTER TABLE {biblio_fields} DISABLE KEYS */;");
---
>   if ($db_type == 'mysql' or $db_type == 'mysqli') {
>     db_query("/*!40000 ALTER TABLE {biblio_field_type_data} DISABLE KEYS */;");
>     db_query("/*!40000 ALTER TABLE {biblio_fields} DISABLE KEYS */;");
>   }
1134,1137c1137,1141
< 
<   db_query("/*!40000 ALTER TABLE {biblio_field_type_data} ENABLE KEYS */;");
<   db_query("/*!40000 ALTER TABLE {biblio_fields} ENABLE KEYS */;");
< 
---
>   if ($db_type == 'mysql' or $db_type == 'mysqli') {
>     db_query("/*!40000 ALTER TABLE {biblio_field_type_data} ENABLE KEYS */;");
>     db_query("/*!40000 ALTER TABLE {biblio_fields} ENABLE KEYS */;");
>   }
>   
1141a1146
>   global $db_type;
1146,1148c1151,1155
<   db_query("/*!40000 ALTER TABLE {biblio_field_type_data} DISABLE KEYS */;");
<   db_query("/*!40000 ALTER TABLE {biblio_fields} DISABLE KEYS */;");
< 
---
>   if ($db_type == 'mysql' or $db_type == 'mysqli') {
>     db_query("/*!40000 ALTER TABLE {biblio_field_type_data} DISABLE KEYS */;");
>     db_query("/*!40000 ALTER TABLE {biblio_fields} DISABLE KEYS */;");
>   }
>   
1183,1185c1190,1193
< 
<   db_query("/*!40000 ALTER TABLE {biblio_field_type_data} ENABLE KEYS */;");
<   db_query("/*!40000 ALTER TABLE {biblio_fields} ENABLE KEYS */;");
---
>   if ($db_type == 'mysql' or $db_type == 'mysqli') {
>     db_query("/*!40000 ALTER TABLE {biblio_field_type_data} ENABLE KEYS */;");
>     db_query("/*!40000 ALTER TABLE {biblio_fields} ENABLE KEYS */;");
>   }
1305a1314
>   global $db_type;
1307,1314c1316,1333
< 
<   $result[] = update_sql("alter table {biblio} modify `biblio_custom1` text ;");
<   $result[] = update_sql("alter table {biblio} modify `biblio_custom2` text ;");
<   $result[] = update_sql("alter table {biblio} modify `biblio_custom3` text ;");
<   $result[] = update_sql("alter table {biblio} modify `biblio_custom4` text ;");
<   $result[] = update_sql("alter table {biblio} modify `biblio_custom5` text ;");
<   $result[] = update_sql("alter table {biblio} modify `biblio_custom6` text ;");
<   $result[] = update_sql("alter table {biblio} modify `biblio_custom7` text ;");
---
>   if ($db_type == 'pgsql') {
>     $result[] = update_sql("alter table {biblio} alter column `biblio_custom1` type text ;");
>     $result[] = update_sql("alter table {biblio} alter column `biblio_custom2` type text ;");
>     $result[] = update_sql("alter table {biblio} alter column `biblio_custom3` type text ;");
>     $result[] = update_sql("alter table {biblio} alter column `biblio_custom4` type text ;");
>     $result[] = update_sql("alter table {biblio} alter column `biblio_custom5` type text ;");
>     $result[] = update_sql("alter table {biblio} alter column `biblio_custom6` type text ;");
>     $result[] = update_sql("alter table {biblio} alter column `biblio_custom7` type text ;");  
>   }
>   else {
>     $result[] = update_sql("alter table {biblio} modify `biblio_custom1` text ;");
>     $result[] = update_sql("alter table {biblio} modify `biblio_custom2` text ;");
>     $result[] = update_sql("alter table {biblio} modify `biblio_custom3` text ;");
>     $result[] = update_sql("alter table {biblio} modify `biblio_custom4` text ;");
>     $result[] = update_sql("alter table {biblio} modify `biblio_custom5` text ;");
>     $result[] = update_sql("alter table {biblio} modify `biblio_custom6` text ;");
>     $result[] = update_sql("alter table {biblio} modify `biblio_custom7` text ;");
>   }
1372a1392
>   global $db_type; 
1375,1376c1395,1401
<   $result[] = update_sql("ALTER TABLE {biblio_fields}  MODIFY hint varchar(255);");
< 
---
>   if ($db_type == 'pgsql') {
>     $result[] = update_sql("ALTER TABLE {biblio_fields}  ALTER COLUMN hint TYPE varchar(255);");  
>   }
>   else {
>     $result[] = update_sql("ALTER TABLE {biblio_fields}  MODIFY hint varchar(255);");
>   }
>   
1381c1406
< function _move_field_data(&$result)
---
> function _move_field_data(&$result) // NOT COMPATIBLE WITH POSTGRESQL
1487c1512
< function _move_authors(&$result)
---
> function _move_authors(&$result) // NOT COMPATIBLE WITH POSTGRESQL
1531a1557
>   global $db_type;
1537,1539c1563,1572
<   $result[] = update_sql("ALTER TABLE {biblio} MODIFY biblio_year int NOT NULL DEFAULT '9999' ");
<   $result[] = update_sql("ALTER TABLE {biblio}  MODIFY biblio_citekey varchar(255) ");
< 
---
>   if ($db_type == 'pgsql') {
>     $result[] = update_sql("ALTER TABLE {biblio} ALTER COLUMN biblio_year TYPE integer ");
>     $result[] = update_sql("ALTER TABLE {biblio} ALTER COLUMN biblio_year SET NOT NULL ");
>     $result[] = update_sql("ALTER TABLE {biblio} ALTER COLUMN biblio_year SET DEFAULT '9999' ");
>     $result[] = update_sql("ALTER TABLE {biblio} ALTER COLUMN biblio_citekey TYPE varchar(255) ");  
>   }
>   else {
>     $result[] = update_sql("ALTER TABLE {biblio} MODIFY biblio_year int NOT NULL DEFAULT '9999' ");
>     $result[] = update_sql("ALTER TABLE {biblio}  MODIFY biblio_citekey varchar(255) ");
>   }
1584a1618
>   global $db_type;
1589,1596c1623,1654
<     $result[] = update_sql("UPDATE {biblio} b
<                           INNER JOIN {biblio_contributor} bc on b.vid = bc.vid
<                           LEFT JOIN  {biblio_contributor_type} bct on b.biblio_type = bct.biblio_type and bct.auth_type = bc.auth_type
<                           SET bc.auth_category=bct.auth_catagory");
<     $result[] = update_sql("ALTER TABLE {biblio_contributor_type} CHANGE COLUMN auth_catagory auth_category INTEGER UNSIGNED NOT NULL DEFAULT 0,
<                           DROP PRIMARY KEY,
<                           ADD PRIMARY KEY USING BTREE(auth_category, biblio_type, auth_type)");
<   }
---
>     if ($db_type == 'pgsql') { // UNTESTED
>       $result[] = update_sql("UPDATE {biblio_contributor}
>                               SET  auth_catagory=bct.auth_catagory
>                               FROM {biblio_contributor_type} bct
>                               WHERE bct.auth_catagory in (
>                                 SELECT bct.auth_catagory 
>                                 FROM {biblio} b
>                                 INNER JOIN {biblio_contributor} bc on b.vid = bc.vid
>                                 LEFT JOIN  {biblio_contributor_type} bct on b.biblio_type = bct.biblio_type and bct.auth_type = bc.auth_type);");
>       $result[] = update_sql("ALTER TABLE {biblio_contributor_type}
>                               RENAME COLUMN auth_catagory TO auth_category");
>       $result[] = update_sql("ALTER TABLE {biblio_contributor_type}
>                               ALTER COLUMN auth_category TYPE INTEGER");
>       $result[] = update_sql("ALTER TABLE {biblio_contributor_type}
>                               ALTER COLUMN auth_category SET NOT NULL");
>       $result[] = update_sql("ALTER TABLE {biblio_contributor_type}
>                               ALTER COLUMN auth_category SET DEFAULT 0");
>       $result[] = update_sql("ALTER TABLE {biblio_contributor_type}
>                               DROP CONSTRAINT biblio_contributor_type_pkey");
>       $result[] = update_sql("ALTER TABLE {biblio_contributor_type} ADD
>                               PRIMARY KEY(auth_category, biblio_type, auth_type");
>     }
>     else {
>       $result[] = update_sql("UPDATE {biblio} b
>                             INNER JOIN {biblio_contributor} bc on b.vid = bc.vid
>                             LEFT JOIN  {biblio_contributor_type} bct on b.biblio_type = bct.biblio_type and bct.auth_type = bc.auth_type
>                             SET bc.auth_category=bct.auth_catagory");
>       $result[] = update_sql("ALTER TABLE {biblio_contributor_type} CHANGE COLUMN auth_catagory auth_category INTEGER UNSIGNED NOT NULL DEFAULT 0,
>                             DROP PRIMARY KEY,
>                             ADD PRIMARY KEY USING BTREE(auth_category, biblio_type, auth_type)");
>       }
>     }
1608c1666
<   if (db_result(db_query('SELECT COUNT(*) FROM biblio_fields WHERE type="contrib_widget"')) == 1) {
---
>   if (db_result(db_query("SELECT COUNT(*) FROM biblio_fields WHERE type='contrib_widget'")) == 1) {
1610c1668
<     $result[] = update_sql("UPDATE {biblio_fields} f SET fid=fid + 4 WHERE fid>1 ORDER BY fid DESC");
---
>     $result[] = update_sql("UPDATE {biblio_fields} f SET fid=fid + 4 WHERE fid>1");
1622c1680
<     $result[] = update_sql("UPDATE {biblio_field_type_data} f SET ftdid=ftdid + 4 WHERE ftdid>1 AND ftdid<100 ORDER BY ftdid DESC");
---
>     $result[] = update_sql("UPDATE {biblio_field_type_data} f SET ftdid=ftdid + 4 WHERE ftdid>1 AND ftdid<100");
1624c1682
<     $result[] = update_sql("INSERT INTO {biblio_field_type_data} 
---
>     $result[] = update_sql("INSERT INTO {biblio_field_type_data} (ftdid, title, hint)
1628c1686
<     $result[] = update_sql("UPDATE {biblio_field_type} ft SET fid=fid+4 WHERE fid>1 ORDER BY fid DESC");
---
>     $result[] = update_sql("UPDATE {biblio_field_type} ft SET fid=fid+4 WHERE fid>1");
1633c1691
<     $result[] = update_sql("INSERT INTO {biblio_field_type}
---
>     $result[] = update_sql("INSERT INTO {biblio_field_type} (tid,fid,ftdid,cust_tdid,common,autocomplete,required,weight,visible)
1638c1696
<     $result[] = update_sql("INSERT INTO {biblio_contributor_type}
---
>     $result[] = update_sql("INSERT INTO {biblio_contributor_type} (auth_category, biblio_type, auth_type)
1649a1708
>   global $db_type;
1657c1716,1727
<   $result[] = update_sql("ALTER TABLE {biblio_keyword_data} MODIFY COLUMN kid INTEGER UNSIGNED NOT NULL AUTO_INCREMENT");
---
>   if ($db_type == 'pgsql') { // UNTESTED
>     $result[] = update_sql("CREATE SEQUENCE {biblio_keyword_data_kid_seq}");
>     $result[] = update_sql("ALTER TABLE {biblio_keyword_data} ALTER COLUMN kid
>                             TYPE INTEGER");
>     $result[] = update_sql("ALTER TABLE {biblio_keyword_data} ALTER COLUMN kid
>                             SET NOT NULL");
>     $result[] = update_sql("ALTER TABLE {biblio_keyword_data} ALTER COLUMN kid
>                             SET DEFAULT nextval('biblio_keyword_data_kid_seq')");
>   }
>   else {
>     $result[] = update_sql("ALTER TABLE {biblio_keyword_data} MODIFY COLUMN kid INTEGER UNSIGNED NOT NULL AUTO_INCREMENT");
>   }
1666c1736
<   $db_result = db_query('SELECT nid,vid,biblio_keywords FROM {biblio} where biblio_keywords != "" ');
---
>   $db_result = db_query("SELECT nid,vid,biblio_keywords FROM {biblio} where biblio_keywords != '' ");
1674c1744
< }
\ No newline at end of file
---
> }
