The OG module contains some SQL that is not supported by PostgreSQL, specifically the REPLACE INTO command and the use of ORDER BY [column] when [column] is not present in the SELECT list. I've attached a modified version of og.module based on the 1.1.2.8 release that putatively ammends the problem, but requires some verification, since I'm a newbie and don't really know what I'm doing.
| Comment | File | Size | Author |
|---|---|---|---|
| #31 | og_2006-07-25_postgres.patch | 14.44 KB | dww |
| #27 | og_20060724.postgresql.patch | 9.58 KB | PMunn |
| #24 | og-4.7.0.20060718.pgsql_support.patch | 9.41 KB | PMunn |
| #22 | og-4.7.0.20060630.pgsql_support.patch | 32.99 KB | PMunn |
| #21 | og-4.7.0-postgresqlsupport.patch | 14.6 KB | PMunn |
Comments
Comment #1
ken-ichi commentedScratch that. Having some problems with UPDATE and primary keys. Thinking of dropping UPDATE in favor of DELETE and INSERT.
Comment #2
blazerw commentedAttached is the sql script to create the tables. Not perfect, tho. The sequences created for the primary keys are not named correctly. You'll have to experience the errors and change the sequence names appropriately. I used pgadmin to change the names, so no SQL for you.
Comment #3
aabill commentedThe functionality of this module exactly matches my needs, so I was very pleased to find it. I've taken the PG version ken-ichi did and fixed the problems he refers to (that claim is of course suspect until thorough testing is completed). I'm using it with CVS version of Drupal with no apparent problems so far. Please find it attached.
And yes - I do know what day it is, but my wife's asleep on the floor and I'm stuffed full of Xmas lunch and bored out of my skull, so I'm working. OK?!!
Comment #4
lyk0s commentedThis thread seemed to be the best place for me to try and get some answers.
I'm new to Drupal, but not new to Unix or programming (25+ years).
What I want to do is as follows:
I want members to be able to set access privs on their content based on the roles
of the users. For instance Unauthenticated users would be able to read blogs that
some users would like them to see but not able to read forums period. The basic idea is that some content is open to members only and some content is only open to particular roles (or particular users in particular roles). It seems that the Organic Groups Module is what I need. Now...
Is it best for me to attempt this with Drupal-current (from the CVS tree?
Reading the install instructions, installing the module is obvious to me but not installing
the og.mysql. I am running mySQL (sorry I know this is a Postgres thread), do I merge this code into database/database.mysql?
Any other tips would help or If you think there is a better module for my needs let me know.
Comment #5
moshe weitzman commentedthe most recent patch is empty. if a pgsql schema and patch are supplied, I will accept them. Please do some testing before marking this as 'patch'. I don't plan to do any pgsql testing.
Comment #6
(not verified) commentedI've now tested this thoroughly, fixed one or two bugs, and have it in production use on a company Intranet. *Very* useful module - congrats to Ken. Ideally, before considering it complete, someone should check that in making it postgres compatible I haven't broken MySQL compatibility . Also, I'm using cvs from December 20th, so probably someone should make sure it's ok with 4.5.2 stable, although I will be upgrading to that or latest cvs here soon and will contribute any further changes that might be necessary.
Cheers
Bill A.
Comment #7
aabill commentedOops - sorry - should have included schema for postgres version. Here it is:
CREATE TABLE og (
nid int NOT NULL default '0',
selective int NOT NULL default '0',
PRIMARY KEY (nid)
)
Comment #8
ken-ichi commentedThanks Bill. I've done some nominal testing in both PGSQL (7.4.6) and MySQL (4.1.8), and it seems to work fine in both. Nice work!
-Ken-ichi
Comment #9
moshe weitzman commentedthanks. would be especially nice if someone could condense the changes into a patch file. i intend to support postgres so this issue is getting us close but not quite there yet.
Comment #10
ken-ichi commentedI ran diff -u og.module og_pg.module > og_pg.patch and got this. I hope this is what you're after, Moshe. I also removed the commented out REPLACE statements from the new code.
Comment #11
moshe weitzman commentedthanks ken. sorry took me so long to review this:
is this needed? seems like the old way was just as valid:
$nodes .= node_view(node_load($onenode), TRUE, FALSE);
+ $conditions = array('nid' => $onenode['nid']);
+ $nodes .= node_view(node_load($conditions), FALSE, FALSE);
also, id like for the new setting about 'age' to be either removed or to be placed in the new section for block specific settings which is availablew in HEAD
Comment #12
ken-ichi commentedHeh, sorry it took me so long to get back. I think you should talk to aabill about issues with the code. All I did was make a diff file of his changes.
Comment #13
qjb commentedI tried my best to implement the (query) changes submitted in on this page to the 4.6.0 version of the og.module file. Can anyone make a patch and test/review the code?
Comment #14
qjb commentedAnd the database tables for psql...
Comment #15
moshe weitzman commentedI would appreciate if people could test and refine these patches if needed.
Comment #16
intel352 commentedworks great for me so far
Comment #17
dwwsometime this week i hope to have a postgres test machine up and running. once i do, i'll try to update these patches, test on postgres + mysql, and report my findings. just posting here so i don't forget. ;)
Comment #18
Hangya commentedI hope there will be also a patch for OG 4.7 like this!!
Comment #19
dwwdefinitely. if we're going to support it, it'll be for 4.7 and HEAD, too.
Comment #20
PMunn commentedI've coded a working og module for postgresql, being careful to keep the mysql code intact. This includes a working og.install for setting it up. I've configured it but haven't started making groups for it yet. You can get it from here.
http://download.farbot.com/index.php?path=php%2FDrupal/
I haven't tested mysql with it since my modifications, and if I find problems with it going forward I will post the updates at that location.
Comment #21
PMunn commentedHere's a patch to the og directory that patches the current release on the main page to get postgresql support working.
Comment #22
PMunn commentedI've fixed a couple of bugs in the postgresql patch, and recreated it from the module's .tar.gz file.
Comment #23
moshe weitzman commentedlooks like you were working with an older version of og when you generated this. it reverts some wanted improvements. please reroll against latest HEAD and assure that only the minimum required are shown as changed.
Comment #24
PMunn commentedI've recreated the patch with the latest CVS code from today. This includes new logic and SQL to add the two new columns to a postgresql database.
Comment #25
dwwi'll take a look at this and test on both pgsql and mysql, but it won't happen for a few days. we're about to do a major stable release at my day job.
setting the version to "cvs" to reflect what this is targetted for. however, moshe, can we please backport this to 4.7? i'd be willing to work on that if necessary...
Comment #26
moshe weitzman commentedsure. i'm planning to keep 4.7 and HEAD identical until feature freeze ... thanks for testing this, derek.
Comment #27
PMunn commentedHere's an updated patch to go against yesterday's cvs version of og.
Comment #28
moshe weitzman commentedThanks much
1. there is 1 REPLACE INTO statement in _og_update_db(). This needs changing, right?
2. delete if present seems a bit cumbersome since it will often generate 3 queries (select, delete, insert). a ebtter algorithm does either 2 queries (select => update or insert depending on presence of that record) or even 1 query (Update, and if that fails to affect anything do an insert). i recognize that these might be hard to implement in a function though. i think it is OK if we don't convert the old updates to pgsql compatible.
lets talk this through and then i will commit.
Comment #29
dww- the change to add the notification field to the {og} table is ported in og_update_11(), but not created in the initial install hook
- the patch adds a ton of ^M characters
maybe more, this is just the first i've found. i'll keep testing right now, and roll a new patch.
Comment #30
dwwand when i try the same patched workspace on my MySQL test site, i get this:
not sure i'll be able to solve everything tonight... i can't really stay up much later tonight. i'll see what i can do in the next 1/2 hour or so. maybe i can get it most of the way there. ;)
Comment #31
dwwok, turns out #30 is just a bug in OG if you don't enable OG access control. i get the same stuff with or without the patch...
however, both of the cases for _og_update_db() are broken on pgsql...
AND ISNULL(na.gid)is wrong. it works asAND na.gid IS NULLon both mysql and pgsqlREPLACE INFOis indeed unavailable in pgsql.furthermore, the "Group authors" block is broken on pgsql. mysql is forgiving, and allows you to SELECT a bunch of stuff you don't include in a GROUP BY clause, and just throws it out for you. pgsql, considers this an error. this is kind of tricky, since we're currently using the
og_get_home_nodes_sql()method to SELECT a ton of fields, but we then ignore everything excetp the fields from {users}. to make this work right in pgsql, we'd probably need to add a 3rd optional argument toog_get_home_nodes_sql(), the columns to SELECT, and then in the case of og_block_subscribers() (kind of a poorly named function, IMHO, if it's displaying recent authors in the current group) where we're specifying a GROUP BY, we'd also specify SELECT. i'm not even sure this would work, to be honest, since pgsql also doesn't like it when you do ORDER BY on something that's not in the SELECT. :(i almost think that since the needs of the (fairly unimportant) OG authors block are such a tiny subset of the complex query we need for the group home page itself, perhaps we should just resign ourselves to having a separate query directly in the block. yes, some of the query would be duplicated logic, and if we ever change it, we'd have to remember to change it in both places. but i think trying to make
og_get_home_nodes_sql()generic enough to work for both cases might make things even more complicated and confusing than just having a separate query.that said, the attached patch does the following:
_og_update_db()as described abovei can't promise i tested everything, but this is a lot closer. every change i made i tried on both pgsql and mysql (it's nice to have 2 sites running on my machine, pointing to the same set of scripts, but different DB backends), so i know this patch doesn't break mysql at all, at least. it still needs work (Group authors block), and there might be a few other rare cases that aren't right, but i'd almost be willing to just commit this as-is, and then work on these other, more minor issues down the road.
moshe, can you please take a look, comment on the whole GROUP BY mess, and set to 'needs work' or RTBC? thanks,
-derek
Comment #32
moshe weitzman commentedplease add a condition around the 'view' op in og_block() also - just worried about any existing sites that switch to postgres. you may commit this to 4.7 and HEAD (currently identical - please keep it that way for now)
also, please watch this queue for any issues that arise from these changes.
Comment #33
dwwi ran the simpletests under my patched workspace (on both pgsql and mysql) and only 1 test failed (but that failed on mysql w/o the patch, too). see http://drupal.org/node/75692 for more on this.
therefore, w/ moshe's slight modification to conditionally not try to *display* the OG authors block under pgsql, either, i committed to HEAD and 4.7.
webchick and i briefly discussed a backport to 4.6 on IRC, but we both agree it's not worth doing, especially since pgsql support in 4.6 core isn't all that great to begin with.
Comment #34
(not verified) commented