Some Oracle Fixes

Craig Sprout
Joined: 22 Oct 2007

Some Oracle Fixes

Posted:06 Nov 2007 (21:10 UTC)
I've been going through R2 and finding a lot of SQL that is broken in Oracle, and trying to fix it.

I will say that I am not a very good PHP programmer, nor a very good SQL programmer, so if these fixes break everything, you can, as they say, keep both halves.

There are still some modules I have yet to go through, but the big problem I have found is in subselects that contain tables with the same column name. Most of them involve columns named "content_id".

For the most part, if the SQL contained a "SELECT *" from a field, I just expanded the statement to select everything except a content_id field. For the liberty_content table, though, I left it as "SELECT *".

Here are some of the changes I've made:

Pigeonhole.php
==============
150c150
<                       SELECT pigm.*
---
>                       SELECT pigm.`parent_id`,

BitBlogPost.php
===============
822c822,823
<                               bp.*, lc.*, lcds.`data` AS `summary`, COALESCE( bp.`publish_date`, lc.`last_modified` ) AS sort_date,
---
>                               bp.`post_id`, bp.`publish_date`, bp.`expire_date`, bp.`trackbacks_to`, bp.`trackbacks_from`,
>                               lc.*, lcds.`data` AS `summary`, COALESCE( bp.`publish_date`, lc.`last_modified` ) AS sort_date,

FisheyeGallery.php
==================
636c636,637
<               $query = "SELECT fg.`gallery_id` AS `hash_key`, fg.*,
---
>               $query = "SELECT fg.`gallery_id` AS `hash_key`,
>                                       fg.`rows_per_page`, fg.`cols_per_page`,fg.`thumbnail_size`, fg.`preview_content_id`, fg.`image_comment`,


These seem to be working so far.

I've done a workaround for the boards module which is very, very ugly, and I need to fix it to make better use of AdoDB. If you want it let me know.

Right now, I'm tracking down problems in the Events and File gallery modules. I'll keep you posted as I make progress.
Craig Sprout
Joined: 22 Oct 2007

Re: Some Oracle Fixes

Posted:20 Nov 2007 (15:10 UTC)
Here are some more patches to get things functional in Oracle.

I haven't been able to test my changes against other DB's, so I'm not sure if the changes to BitDbBase.php will foul everything else up. The random part should be OK, but the SUBSTR part is worrisome to me. You have to make the BitDbBase patch for the BitBoardTopic patch to work correctly.

As always, if you have any questions or suggestions or better fixes, just holler.

BitDbBase.php
=============
91a92,95
>       * Substring Operator
>       */
>       var $mSubString = "SUBSTRING";
>       /**
118a123,127
> 
>                               case "oci8":
>                               case "oci8po":
>                               $this->mSubString = "SUBSTR";
>                               break;
239a249
> 
765c775,776
<                                       //"oci8"     => "",
---
>                                       "oci8"     => "dbms_random.value()",
>                                       "oci8po"   => "dbms_random.value()",


BitBoardTopic.php
=================
322,326c323
<               if ( $this->mDb->mType == 'firebird' ) {
<                       $substrSql =
"SUBSTRING(s_lcom.`thread_forward_sequence` FROM 1 FOR 10) LIKE
SUBSTRING(lcom.`thread_forward_sequence` FROM 1 FOR 10)";
<               } else {
<                       $substrSql =
"SUBSTRING(s_lcom.`thread_forward_sequence`, 1, 10) LIKE
SUBSTRING(lcom.`thread_forward_sequence`, 1, 10)";
<               }
---
>               $substrSql = $this->mDb->mSubString .
>               "(s_lcom.`thread_forward_sequence`, 1, 10) LIKE " .
>               $this->mDb->mSubString . "(thread_forward_sequence`, 1, 10)";
421,425c418,419
<               if ( $this->mDb->mType == 'firebird' ) {
<                       $substrSql = "SUBSTRING(lcom.`thread_forward_sequence`
FROM 1 FOR 10)";
<               } else {
<                       $substrSql =
"SUBSTRING(lcom.`thread_forward_sequence`, 1, 10)";
<               }
---
> 
>               $substrSql = $this->mDb->mSubString .
>               "(lcom.`thread_forward_sequence`, 1, 10) ";


TreasuryGallery.php
===================
72,73c72,73
<                       $query = "SELECT trg.*, ls.`root_structure_id`,
ls.`parent_id`,
<                               lc.`title`, lc.`format_guid`, lc.`data`,
lc.`user_id`, lc.`content_type_guid`,
---
>                       $query = "SELECT trg.`structure_id`, trg.`is_private`,
>                       ls.`root_structure_id`, ls.`parent_id`,
>                               lc.`title`, lc.`format_guid`, lc.`data`,
>                               lc.`user_id`, lc.`content_type_guid`,
>                               lc.`content_id`,
197,198c197,198
<                       SELECT trg.*, ls.`root_structure_id`, ls.`parent_id`,
<                       lc.`title`, lc.`data`, lc.`user_id`,
lc.`content_type_guid`, lc.`created`, lch.`hits`,
---
>                       SELECT trg.`structure_id`, trg.`is_private` as
>                       trg_ispriv, ls.`root_structure_id`, ls.`parent_id`,
>                       lc.`title`, lc.`data`, lc.`user_id`,
>                       lc.`content_type_guid`, lc.`created`, lch.`hits`,
>                       lc.`content_id`,


BitEvents.php
=============
72c72,74
<                       $query = "SELECT e.*, lc.*, " .
---
>                       $query = "SELECT e.`events_id`, e.`end_time`,
>                       e.`description`, e.`cost`, e.`type_id`,
>                       e.`location_id`, 
>                                        e.`frequency`, e.`event_interval`,
>                                        e.`r_count`, e.`end_date`,
>                                        e.`bylists`, 
>                               lc.`content_id`, lc.`data`, lc.`format_guid`,
>                               " .
433c435,437
<               $query = "SELECT e.*, lc.`content_id`, lc.`title`, lc.`data`,
lc.`modifier_user_id` AS `modifier_user_id`, lc.`user_id` AS`creator_user_id`,
---
>               $query = "SELECT e.`events_id`, e.`end_time`, e.`description`,
>               e.`cost`, e.`type_id`, e.`location_id`, 
>                                e.`frequency`, e.`event_interval`,
>                                e.`r_count`, e.`end_date`, e.`bylists`,
>                       lc.`content_id`, lc.`title`, lc.`data`,
>                       lc.`modifier_user_id` AS `modifier_user_id`,
>                       lc.`user_id` AS`creator_user_id`,
435d438
<                       $selectSql

  Page 1 of 1  1