Microsoft SQL Support

vicente

Joined: 2006-03-15
Posts: 23
Posted: Wed, 2006-03-15 12:14

I want to develop a Microsoft SQL Server driver for Gallery. I see that there is an xsl file for each db gallery supports and a class file. Where can I get the source for this class file? I looked in cvs but cannot seem to find the source, only the class file. Can someone give me an idea of the layout of the xsl file? Also will I have to change/create any other files?
If someone with knowledge of the procedure to do a port of an existing driver can give me a step by step guide, I will write the code and get it done.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Wed, 2006-03-15 16:41

great! best of luck on this project, we'll gladly provide guidance.

this isn't java; *.class files in G2 are source files, just open it up :)

another thing you'll need to edit is lib/tools/bin/generate-sql.php (I don't think there are xsl files anymore.. are you looking at current CVS?)

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Thu, 2006-03-16 18:34

Hi, Vicente.

As I mentioned in response to your e-mail, I would suggest you look at the first few appends in the forum thread for the DB2 support (http://gallery.menalto.com/node/37648). The process will probably be much the same for SQL Server as it was with DB2.

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Fri, 2006-03-17 13:25

Hello

Thanks for the responses. I checked out the postings for the db2 port and they have helped.

I’ve got eclipse running with the php plugin and got all the code from CVS.

I’ve added the necessary code to generate-sql.php for mssql. I can compile it and can see the generated sql in schema.tpl

How does gallery 2 use this schema.tpl when running the sql against the db? How does it resolve dependencies in the file, I see that the sql is not ordered by dependency? E.g. an alter table exists for a table before the create table sql.

I’ve created a MsSqlStorage class and have modified it. I just need to understand what the following functions are used for
encodeBlob
decodeBlob
_getOptimizeStatement
convertIntToBits
convertBitsToInt

If I know what they are used for, I can check if they are necessary for MS SQL.

Once I’ve done those functions, I can start testing.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Fri, 2006-03-17 16:27

Wow, great progress already!

The schema.tpl file contains all new install and upgrade sql for all DBs.. the comments in the file are separators. Anything with # {tablename} is used for installing the module; lines with # A_{tablename}_{version} are used only for the appropriate upgrades.

Check the phpdoc in GalleryStorage.class for a brief description of each of those functions.. also look at the other DB classes for examples. Ask again if there are still questions..

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Mon, 2006-03-20 09:15

in the db2 port notes there is a step as follows:

in modules/core/classes/GalleryStorage.class
add after

case 'postgres':
case 'postgres7':
GalleryCoreApi::relativeRequireOnce(
'modules/core/classes' . $base . 'DatabaseStorage/PostgreSqlDatabaseStorage.class');
$this->_impl = new PostgreSqlDatabaseStorage($config);
break;

I cannot seem to find this, has this changed since the db2 port?

Vince

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Mon, 2006-03-20 09:28

I found it in Gallery.class :)

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Mon, 2006-03-20 13:26

Ah, I didn't realize this too had been moved after I implemented the DB2 change. :-)

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Wed, 2006-03-22 08:08

Hello

I need to know what to do now that the changes are complete; I have never done php development before, so please bear with me. Do I need to compile the code, or do I just copy it to my virtual directory on the web server and start testing it?

Thanks
Vince

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Wed, 2006-03-22 14:25

Hi Vince.

The only thing you need to 'build' is the 'gallery2/modules/core/classes/GalleryStorage/schema.tpl' file, which will contain the generated SQL based on your other changes.

To build this file, go to 'gallery2/modules/core/classes/GalleryStorage' and run 'gmake'.

lmenard@larryhome /cygdrive/c/temp/gallery2/modules/core/classes/GalleryStorage
$ gmake 2>&1 | tee gmake.out
perl ../../../../lib/tools/bin/extractClassXml.pl --dtd=../../../../lib/tools/dt
d/GalleryClass2.0.dtd --quiet --out-dir=tmp/classxml ../*.class
php -f ../../../../lib/tools/bin/generate-dbxml.php
php -f ../../../../lib/tools/bin/generate-sql.php

After this, you should have a new 'schema.tpl':

lmenard@larryhome /cygdrive/c/temp/gallery2/modules/core/classes/GalleryStorage
$ ls -l schema.tpl
-rw-r--r--  1 lmenard None 115269 Mar 22 09:24 schema.tpl

And it should contain a section for your MS SQL. (Look for '##', that's how the db platform sections are delimited.)

Then, just move your changed files into the 'gallery2' tree on your server, and fire up the installer by pointing your browser to 'http://localhost/gallery2/install/index.php' and see how it goes. :-)

Edit: I hope you have a Cygwin environment on your Windows system. If not, you'll need it for doing this build.

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Wed, 2006-03-22 15:07

thanks

Im running SUSE Linux in a virtual machine with samba, on my windows machine. I have compiled schema.tpl. I have gallery running on my windows machine, so I will use that to start testing.

thanks for the help...

 
doomdead

Joined: 2003-04-06
Posts: 174
Posted: Wed, 2006-03-22 21:48

this is GREAT. ive been waiting for sql support. I'd be more than happy to help test it. (hopefully we can move the gallery data from mysql to mssql without any problems)

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Thu, 2006-03-23 15:24

Hello

I have started testing, after the Database Setup Step of the installer I get the successful page, but the db only has 2 tables, I removed them and tried again but now no tables are created.

any ideas?

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Thu, 2006-03-23 15:40

I'm not 100% sure, but I think that's normal. The Database Setup Step only creates a couple of test tables, just as a 'sanity check'. The majority of the tables and other objects are created later during the Core Module Install step.

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Thu, 2006-03-23 15:52

you are right, when I get to the install core modules step the 2 tables mentioned are created.

the error I get now is as follows

Error (ERROR_STORAGE_FAILURE)
in modules\core\classes\GalleryStorage.class at line 476 (GalleryCoreApi::error)
in modules\core\classes\Gallery.class at line 223 (GalleryStorage::search)
in modules\core\classes\helpers\GalleryPluginHelper_simple.class at line 519 (Gallery::search)
in modules\core\classes\helpers\GalleryPluginHelper_simple.class at line 391 (GalleryPluginHelper_simple::fetchPluginList)
in modules\core\classes\GalleryCoreApi.class at line 292 (GalleryPluginHelper_simple::fetchPluginStatus)
in modules\core\classes\GalleryPlugin.class at line 182 (GalleryCoreApi::fetchPluginStatus)
in modules\core\classes\GalleryModule.class at line 343 (GalleryPlugin::activate)
in install\steps\InstallCoreModuleStep.class at line 146 (GalleryModule::activate)
in install\index.php at line 201 (InstallCoreModuleStep::processRequest)

is there a log file or something with a more detailed error message, also do you know if it is possible to debug the php code with the php eclipse module with php running in IIS?

Vince

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Thu, 2006-03-23 16:26

Yeah, now you're getting to the fun part. :-)

After the 'gallery2/config.php' file is created in Step 7, edit that file and enable debugging by changing line:

$gallery->setDebug(false);

to

$gallery->setDebug('buffered');

(Note that this file is recreated everytime you run Step 7, so you might have to re-enable debugging whenever you run Step 7.)

When debugging is enabled, look in your g2data directory for a file called 'install_*'. In that file, look for a few lines of version information being dumped. Ignore everything up to that point... the error you're looking for is somewhere below that.

Happy hunting.

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Thu, 2006-03-23 18:27

thanks

after fixing a few problems in the generate-sql file I now have 40 tables generated before the error

attached is the file, it seems to indicate that it was succesful, but I still get the error message...

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Thu, 2006-03-23 18:52

The last line in the trace very clearly says it was not succesful.

Quote:
Error: Failure during install core module step

I see one error in your trace...

b>Warning</b>:  mssql_query() [<a href='function.mssql-query'>function.mssql-query</a>]: message: Cannot insert the value NULL into column 'g_bits', table 'gallery3.dbo.g2_PermissionSetMap'; column does not allow nulls. INSERT fails. (severity 16) in <b>C:\Inetpub\wwwroot\gallerymssql\lib\adodb\drivers\adodb-mssql.inc.php</b> on line <b>690</b><br />
<br />
<b>Warning</b>:  mssql_query() [<a href='function.mssql-query'>function.mssql-query</a>]: Query failed in <b>C:\Inetpub\wwwroot\gallerymssql\lib\adodb\drivers\adodb-mssql.inc.php</b> on line <b>690</b><br />
515: The statement has been terminated.<br>

It says "Warning", but I don't trust that.

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Fri, 2006-03-24 09:37

ok...

I managed to get core modules to install succesfully and about 90% of the additional modules, but still have an
error, when going to the main page. I think I found the problem but now when I run the install again I get
an error on the database storage step. Before restarting the installation I deleted all the tables and all
files in the data directory, it seems as if gallery is trying to upgrade rather than do a fresh install, is
there a cache directory or file I need to delete to get gallery to do a fresh install...

Vince

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Fri, 2006-03-24 13:54

ok ... I figured there is "other" file needed to be deleted. I can now install all modules
succesfully but when I go to the main page I get the following...

Configuration Error: Missing Theme
Missing Theme
This album is configured to use the theme, but it is either inactive, not installed, or incompatible. To fix this problem you can login as a site administrator and then install or activate this theme or select another default theme

If I try logon as admin I get the following
Database Error
An error has occurred while interacting with the database.

Back to the Gallery

There is no debug output...

Any ideas?

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Fri, 2006-03-24 14:33

also...

do you have a makefile that will call gmake for all the modules that need it...I noticed there are
a few that need a schema.tpl, this will save me time, instead of me having to do each one manually...

maybe my problem is being caused by a tpl file that I missed...

Vince

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Fri, 2006-03-24 14:35

> existing database

In Installer Step 5 (Database Setup), if Gallery detects that there is an existing set of tables, there should be a button that gives you the option to remove and recreate those database objects. I forget the actual wording of this button, but the code that it fires is in the "GalleryStorage/mssqlDatabase.class" file you created, in a function called "cleanStore()". To be honest, that's the one thing i haven't tested really well yet in DB2.

It's very important that the database remains in sync with the contents of the g2data directory. I created a "recreate_db.bat" file that drops and recreates the database, and removes and recreates an empty "g2data". Before starting any Install, I run that script.

> Missing theme

Not sure how much I can help with this specific problem, but here's some general guidance based on my own experience:

1) Review the "install*.log" file to make sure there are no errors that were missed. If debug was not enabled, wipe the db and "g2data", re-run the Install with debug enabled.

2) You can enable debugging at any time, not just during the Install. For example, if you're having difficulty bringing up the main "gallery2/index.php" page, enable debugging and try it. You should see a lot of debug info. Note that the debug info is visible in your browser, it is not sent to a file. Again, there should be no errors in this debug output.

Note: When you enable debugging for runtime (non-Install) activity, it opens a separate browser running something called Smarty. I find it to be more annoying than useful. If you close that window, it just keeps coming back every time you refresh. So rather than close it, I minimize it, so at least it stays out of my way.

3) Look at the stack trace, and don't be afraid to put your own debug code into the source at those locations. For example, here's one I'm currently using:

printf("<br><br>In GalleryStorageExtras::_executeSql(), \$buffer = \"$buffer\".\n<br>");

4) When looking at the source code, watch for methods like "$this->_gs->_traceStart();" and "$this->_gs->_traceStop();" enclosing some execution statement. In non-Install cases, they have the effect of suppressing errors. You might find it helpful to temporarily comment them out.

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Fri, 2006-03-24 14:38

> makefile for modules

I'm afraid I have no idea why you'd need to do that. I never found any modules that needed any kind of 'build'... they all worked for me as-is.

Can you give me an example of such a module, and where is it looking for a 'schema.tpl' that does not exist?

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Fri, 2006-03-24 15:14

\gallery2\modules\comment\classes\GalleryStorage

has a tpl file, after I run gmake it has an entry for mssql

thanks for the other info, I will keep at it...

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Fri, 2006-03-24 15:24

ok... found the problem

gallery is generating sql like this

SELECT g2_AccessSubscriberMap.g_itemId, g2_AccessMap.g_permission | g2_AccessSubscriberMap.g_itemId
FROM g2_AccessMap, g2_AccessSubscriberMap
WHERE g2_AccessSubscriberMap.g_itemId IN (7)
AND g2_AccessSubscriberMap.g_accessListId = g2_AccessMap.g_accessListId
AND g2_AccessMap.g_userOrGroupId IN (5,4)
GROUP BY g2_AccessSubscriberMap.g_itemId

but mssql gives the error
Server: Msg 8120, Level 16, State 1, Line 1
Column 'g2_AccessMap.g_permission' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

The following sql works in mssql
SELECT g2_AccessSubscriberMap.g_itemId, g2_AccessMap.g_permission | g2_AccessSubscriberMap.g_itemId
FROM g2_AccessMap, g2_AccessSubscriberMap
WHERE g2_AccessSubscriberMap.g_itemId IN (7)
AND g2_AccessSubscriberMap.g_accessListId = g2_AccessMap.g_accessListId
AND g2_AccessMap.g_userOrGroupId IN (5,4)
GROUP BY g2_AccessSubscriberMap.g_itemId,g2_AccessMap.g_permission,g2_AccessSubscriberMap.g_itemId

Is there a way to specify the GROUP BY clause in generate-sql?

Vince

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Fri, 2006-03-24 15:48

> tpl file

Hmm, I wonder if that's because you're using code that was pulled directly from cvs, as opposed to from a nightly build? In my case (DB2), Valiant was checking in my changes frequently, so by the time I got to the additional modules, the base DB2 support was already there. Once your base changes go into cvs, you shouldn't have to do builds anywhere unless you change your SQL source.

> GROUP BY

See function getFunctionSql() in your "GalleryStorage/mssqlStorage.class". It is basically yours to do with as you please, though the lead developers are somewhat picky about what they allow for performance reasons. I think I had this same problem in DB2, so check out the getFunctionSql() in "GalleryStorage/Db2Storage.class".

You should also be able to modify the "MsSqlGenerator" block of code in "generate-sql.php" without impacting anyone else.

There is also SQL in "moodules/core/classes/helpers/*.class", but those are shared files, so changing those is not done easily.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Fri, 2006-03-24 17:36

The script that makes schema files for all modules: lib/tools/bin/rebuild-modules.pl

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Sat, 2006-03-25 09:48

where can I get more info on the structure of the arrays that are passed into
getfunctionsql() and generate-sql.php? None of the existing code generates the GROUP BY part of the
sql. I would imagine that the sql mentioned above is generated on the fly by gallery or is this
sql pre-generated and if so where is it?

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Sat, 2006-03-25 15:12

Could you please post the stack trace from the error, and I'll see if I can figure out where the GROUP BY is being added.

Generally speaking, to find out the contents of an array, I var_dump() it. Not the easiest thing to read, but it works. :-)

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Sat, 2006-03-25 15:34

Never mind the stack trace, using 'grep' commands I was able to find the code that I think is stopping you. It's in "GalleryPermissionHelper_Medium.class", function "fetchPermissionsForItems()".

The GROUP BY clause *is* there, so I don't understand what you mean by "None of the existing code generates the GROUP BY part of the sql". Here's the code:

	$query = '
	SELECT
	    [GalleryAccessSubscriberMap::itemId],
	    ' . $bitOr . '
	FROM
	    [GalleryAccessMap], [GalleryAccessSubscriberMap]
	WHERE
	    [GalleryAccessSubscriberMap::itemId] IN (' . $itemIdMarkers . ')
	    AND
	    [GalleryAccessSubscriberMap::accessListId] = [GalleryAccessMap::accessListId]
	    AND
	    [GalleryAccessMap::userOrGroupId] IN (' . $entityIdMarkers . ')
	GROUP BY
	    [GalleryAccessSubscriberMap::itemId]
	';

I think it would be safe to just add the required column(s) to the existing GROUP BY.

	GROUP BY
	    [GalleryAccessSubscriberMap::itemId],[GalleryAccessMap::permission],[GalleryAccessSubscriberMap::itemId]

Try it and see how it goes.

Mindless (or any other lead developers), any concern with that change?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sat, 2006-03-25 19:22

no, don't think that is right.. the error message was:
Column 'g2_AccessMap.g_permission' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

BIT_OR is an aggregate function, we don't want permissions in the GROUP BY.
so the problem is in the getFunctionSql generating the BIT_OR sql above.. it should OR'ing together all permissions values (aggregate), not OR'ing permissions with itemId.

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Sat, 2006-03-25 22:40

Ah, I'll bet Vicente copied the "Db2Storage.class" file. (In DB2, the 'G2_BIT_OR' aggregate function requires both columns to be passed into it. Chances are MS SQL's BIT_OR does not.)

Vicente, try copying a "case 'BIT_OR':" block from another database, e.g. PostGreSql.

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Sun, 2006-03-26 10:47

ok...great feedback...

I also found the code in GalleryPermissionHelper_medium.class and tried the change and it worked,
I still get the missing theme message but now I can log on as admin and browse through all admin menus with
no errors.

I am using sql servers bit or which is the | character
case 'BIT_OR':
$args = str_replace('?', '?', $args);
$sql = $args[0] . ' | ' . $args[1];
break;

The sql is ORing the permission values and not ORing them with itemid, but MS SQL is a bit strange with the
GROUP BY clause, it seems to want to have all items in the select list in the GROUP BY clause irrespective
of whether they are being ORed

so, the status is as follows

I was able to install successfully but when I went to the main page I got the following error
Configuration Error: Missing Theme
Missing Theme
This album is configured to use the theme, but it is either inactive, not installed, or incompatible. To fix this problem you can login as a site administrator and then install or activate this theme or select another default theme

I can now log in as admin. The theme seems to be active, so Im not sure what is causing the missing theme problem.

Also now I have a new problem, suddenly when I try to re-install, I get to the core install step and it
just seems to hang there, the install*.log file has the following

2006-03-26 12:31:48 [<no session id>]

--------------------------------------------------------
Prepare installation of the core module
--------------------------------------------------------

2006-03-26 12:31:48 [<no session id>] [1143365508] can't guarantee 120 -- extending!
2006-03-26 12:31:48 [<no session id>] Init first pass
2006-03-26 12:31:48 [<no session id>] file_exists(C:\Inetpub\wwwroot\gallerymssql\modules\core\classes\helpers/../../../../config.php)
2006-03-26 12:31:48 [<no session id>] file_exists(C:\Inetpub\wwwroot\gallerymssql\modules\core\classes\helpers/../../../../plugins/index.modules)

and thats it!!

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Sun, 2006-03-26 14:46

I think you have at least two separate issues here... the BIT_OR and the GROUP BY.

BIT_OR:

The additional passing of G_ITEMID into the BIT_OR is probably very specific to DB2. For now, forget you ever saw that. I suspect you don't need it.

The purpose of this BIT_OR is not to compare two columns. It is supposed to take the set of returned G_PERMISSIONS values and do bitwise ORing of those values against each other, then return the final BIT_ORed value.

For example, if the result set that satisfies the WHERE clause is:

G_ITEMID G_PERMISSIONS
-------- --------------------------------
1        00001110101001011000110101100111
1        00000001111100000101011111100000
1        10100000001000000000000000010000
2        00000001111011100000000001000000
2        01110000101000000000000000000101
2        00000000000000000000010000000000

Then what the query is supposed to do is return the BITOR of all the permissions for G_ITEMID "1", then the BITOR of all the permissions for G_ITEMID "2", etc. So, it should return:

G_ITEMID 2
-------- --------------------------------
1        10101111111101011101111111110111 // <- BITOR of all G_PERMISSION values where G_ITEMID = "1"
2        01110001111011100000000001000101 // <- BITOR of all G_PERMISSION values where G_ITEMID = "2"

DB2 unfortunately does not have built-in BIT functions, so I had to write my own (using a sample from the IBM DeveloperWorks site), but also unfortunately, aggregation using DB2 User-Defined Functions (UDFs) like that do not honour the GROUP BY clause in the original SQL, so the UDF needs to also know the G_ITEMID value for each row in order to do its own grouping. Otherwise it would just BITOR the entire set of G_PERMISSIONS values regardless of the G_ITEMID values. In the case of the above example, that would be:

G_ITEMID 2
-------- --------------------------------
1        11111111111111111101111111110111 // <- BITOR of *all* G_PERMISSION values
2        11111111111111111101111111110111 // <- BITOR of *all* G_PERMISSION values

GROUP BY:

So we might still need to add those columns to the GROUP BY clause from what I can see. It's Mindless that you need to convince. :-)

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Sun, 2006-03-26 14:55

As for the missing theme, I don't know offhand how to debug that, it might even be related to the BIT_ORing for all I know. But here's what I would suggest.

I would suggest that maybe it would be a good idea to get your current changes checked into CVS. That way, you can use nightly build snapshots (which are usually known to be good) instead of relying on an old extract from CVS (which I think you are doing).

Unfortunately, this is not a good time to do so, because the release of v2.1 is so imminent. But as soon as v2.1 is released, I would suggest getting your changes checked in. (The MS SQL support can be marked "In Development" or something in the Installer.)

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Sun, 2006-03-26 14:58

Sorry for the multiple postings, I keep noticing things I haven't addressed yet. :-)

For the hang... do you really mean "hang", or do you mean "exit"?

I've noticed that when I have a syntax error in a class file, the error might never be evident in the browser or the log file. Sometimes it just exits with no error msg.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sun, 2006-03-26 17:00

if you'd like to post what you have so far we can get it into CVS.. 2.1 was released a few days ago.

if you need permissions in the group by clause then I don't understand mssql syntax at all. group by itemId means larry's example above would form 2 groups (as there are 2 different itemIds) and each group would aggregate 3 permission values. if you add permission in the group by, every database i know of would then return 6 different groups in this example, as every pair of itemId,permission is different.. only rows with the same itemId AND permission value would be "grouped".

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Sun, 2006-03-26 17:35

I should also have mentioned... in DB2 I also wrap a MAX() around the BIT_OR, so it doesn't actually print the intermediate results, only the max. My exact query is:

SELECT g2_AccessSubscriberMap.g_itemId,
 MAX(G2_BIT_OR (g2_AccessSubscriberMap.g_itemId, g2_AccessMap.g_permission))
 FROM g2_AccessMap, g2_AccessSubscriberMap
 WHERE g2_AccessSubscriberMap.g_itemId IN (7, 12)
 AND g2_AccessSubscriberMap.g_accessListId = g2_AccessMap.g_accessListId
 AND g2_AccessMap.g_userOrGroupId IN (5,4)
 GROUP BY g2_AccessSubscriberMap.g_itemId

It returns:

G_ITEMID    2
----------- -------------------------------------------------------------------
          7 x'3030303030303030303030303030303030303030303030303030303030313131'
         12 x'3030303030303030303030303030303030303030303030303130303030313131'

  2 record(s) selected.

(Don't get hung up on the hex representation... that's just DB2's way of saying it is FOR BIT DATA.)

When I remove the MAX(), I get the same error as Vicente.

SQL0119N  An expression starting with "G_PERMISSION" specified in a SELECT
clause, HAVING clause, or ORDER BY clause is not specified in the GROUP BY
clause or it is in a SELECT clause, HAVING clause, or ORDER BY clause with a
column function and no GROUP BY clause is specified.  SQLSTATE=42803

Vicente, try wrapping a MAX() around your BITOR?

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Mon, 2006-03-27 14:50

-I started the day by fixing the "hang error". It was a error on my part in the mssqlstorage.class file.
-Using MAX() around the BITOR did work, thanks Larry.

I have spent the rest of the trying to figure out the

Configuration Error: Missing Theme
Missing Theme
This album is configured to use the theme, but it is either inactive, not installed, or incompatible. To fix this problem you can login as a site administrator and then install or activate this theme or select another default theme.

error. It should default to the default.theme.
My db does have a entry for default.theme, and it is even in the cache file in the data directory.
Does anyone have any idea of why this could be happenning, I have gone through the GalleryTheme.class
and put in printf statements, but cannot seem to figure out the problem.

Also, now and then I get
Notice: unserialize() [function.unserialize]: Error at offset 121 of 255 bytes in C:\Inetpub\wwwroot\gallerymssql2\modules\core\classes\GallerySession.class on line 935

Any ideas?

Vince

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Mon, 2006-03-27 15:32

Sorry, I have no idea why you're getting the "Missing Theme" error. I can't even find string "Missing Theme" in my entire Gallery2 tree, nor can I find any occurrence of "Missing" that looks like it might be followed by a variable that could be "Theme".

In "Site Admin -> Themes -> All Themes", what themes are installed (indicated by green circle)? On my system, "Matrix" is the only one installed, and it is therefore the default theme. Do you actually have a complete "gallery2/themes/matrix" directory? Mine is 99 files (172,022 bytes), in 206 directories.

I don't know anything about the session suport either. What is the value of $pSession[5] at that point when it fails?

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Mon, 2006-03-27 15:36

the matrix theme is installed. My matrix folder is 306 files, 137 folders (from CVS)

at this point Im stumped...

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2006-03-27 17:06

the error page is modules/core/templates/ShowItemError.tpl

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2006-03-27 17:11

it seems likely that getPluginParameter for default.theme is not returning a value.. can you add debug output to confirm this, any maybe dig into where it goes wrong?

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Mon, 2006-03-27 18:33
C:\MyServer\Gallery2\themes\matrix>dir /s | tail -n4

     Total Files Listed:
              99 File(s)        172,022 bytes
             206 Dir(s)   2,283,507,712 bytes free

If your matrix directory is 306 files then something is obviously very different between your setup and mine.

I still suggest checking your changes into CVS. That way your code is sure to go through a complete build process, and also then our two environments would be more comparable.

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Mon, 2006-03-27 18:42

Interesting... Windows' "find" completely fails to find this. :-)

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Mon, 2006-03-27 20:18

I have attached the debug file...

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Mon, 2006-03-27 20:23

In order to commit my changes, do I commit them to the head branch? This is where I got them (the original files) from.

 
Larry Menard
Larry Menard's picture

Joined: 2005-10-01
Posts: 757
Posted: Mon, 2006-03-27 20:55

Mindless may want to review your changes first. Wait for his advice. :-)

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2006-03-27 21:52

oh, that debug output never loads default.theme
in loads the root album (entity 7 I think) and thinks it has a particular theme.. ie, getTheme doesn't return an empty value so it doesn't load default.theme. check what value is in the db for this album, and in 7.inc!

to commit some code, post new files+diffs here.. I can review and commit.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2006-03-28 00:57

FYI, I have just upgraded CVS to use ADODB 4.80 and included the mssql files.

 
vicente

Joined: 2006-03-15
Posts: 23
Posted: Tue, 2006-03-28 07:45

I need to find out how to create diff files in eclipse,
in the mean time I have atached a zip file with the files I added or changed.
Please note that I changed generate-sql file to only generate mysql and mssql while I was testing.