Postponed
Project:
Localization server
Version:
7.x-1.x-dev
Component:
Database
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
22 Nov 2008 at 08:32 UTC
Updated:
9 Oct 2013 at 14:58 UTC
Jump to comment: Most recent file
Comments
Comment #1
gábor hojtsyLooks good, will commit when I have a chance. Although it sounds a bit optimistic that this would fix PostgreSQL compatibility altogether.
Comment #2
grub3 commentedDear Gábor,
I am using the same thread to report problems, to avoid filling list.
When clicking on:
Localization server › Connector for drupal.org
Connector for drupal.org
* Configurer
* Scan
Contents of /tmp/drupal-6.6.tar.gz have been scanned.
warning: pg_fetch_object() expects parameter 1 to be resource, array given in /home/jmpoure/bulle-immobiliere.org/trunk/drupal/includes/database.pgsql.inc on line 175.
Any idea?
Comment #3
grub3 commentedI am testing further and there is a problem running DELETE queries in :
l10n_community.admin.inc
In PostgreSQL, you cannot use LEFT AND RIGHT JOINS directly in DELETE clauses.
You need to use a nested query.
Example: line 233
Should be written:
This kind of query will run anywhere on any database.
I admit this is more heavy.
Could you confirm this query runs without problem under MySQL?
Should I submit a patch for DELETE clauses?
Comment #4
grub3 commentedThere are other minor problems in pages.inc, line 485:
fails to run under PostgreSQL.
It should be:
When GROUP BY is present, it is not valid for the SELECT list expressions to refer to ungrouped columns except within aggregate functions, since there would be more than one possible value to return for an ungrouped column.
Could you confirm that the modified query runs smoothy under MySQL?
Then i will submit a patch.
For the same reasons:
$result = db_query("SELECT COUNT(DISTINCT s.sid) AS string_count, p.pid, p.title, p.uri FROM {l10n_community_project} p INNER JOIN {l10n_community_release} r ON p.pid = r.pid INNER JOIN {l10n_community_file} f ON r.rid = f.rid INNER JOIN {l10n_community_line} l ON f.fid = l.fid INNER JOIN {l10n_community_string} s ON l.sid = s.sid GROUP BY p.pid, p.title, p.uri;");Also notice the "AS" when counting.
Don't blame me. This is probably SQL99 and running the code under PostgreSQL ensures that the SQL will run anywhere.
Comment #5
grub3 commentedHere is a patch for the page.inc SQL code.
As it is quite straightforward, it should work.
Comment #6
grub3 commentedNow, please inform me if
DELETE FROM {l10n_community_error}
WHERE eid IN
(SELECT e.eid FROM {l10n_community_error} e
LEFT JOIN {l10n_community_release} r ON e.rid = r.rid
WHERE r.pid = %d)
runs smothly under MySQL so that i can generate another patch.
Kind regards, JMP
Comment #7
grub3 commentedOkay, now I have a real problem.
PostgreSQL does not allow to delete ROWs in several tables simultaneously.
So this query fails (line 260):
I will ask for advice at PostgreSQL.org and report back.
Kind regards, JMP
Comment #8
gábor hojtsyRe: the DELETE, I was about to say that. The "DELETE FROM ... LEFT JOIN ..." statements do delete from multiple tables, so they are not equal to using a subselect, which would not delete from the subtable.
Comment #9
grub3 commentedExactly, this is why this multiple delete is problematic.
I plan to ask support to core PostgreSQL hackers at PostgreSQL to ask information. At first I would like to know if this is SQL99 compliant and what PostgreSQL plans to do. In the past, I asked for features and they were sometimes added in PostgreSQL. PostgreSQL hackers have the goal to develop a reference database and they wron't move in any direction when a feature is not SQL99 compliant. Based on their analysis, we can decide to write a specific PostgreSQL code or transform the delete query into two queries. Or whatever you decide. I will be back soon, being very motivated by your module.
I am also part of kdenlive projects, which is a video editor for GNU/Linux. We plan to use Drupal to internationalize our PO files. So I will be looking for a hack to load and update ou POTs into the database. I am really motivated !!! And I will stay active on the module to help supporing it.
Comment #10
gábor hojtsyCommitted this patch which fixes all the "SELECT ... AS" omissions I could find (before you find more). This folds in the original patch, and some part of #5 *except* the GROUP BY changes. Looking forward for more patches. Thanks for your investigations so far!
Comment #11
gábor hojtsyDo you have any other improvements?
Comment #12
grub3 commentedI will test and report shortly. Thanks.
Comment #13
grub3 commentedSorry, I was busy and I am back. There is a small problem :
Patch attached.
Comment #14
grub3 commentedAlso, BINARY is not SQL92 compliant. It is an extension from MySQL:
I guess it should be : SELECT s.sid FROM l10n_community_string s LEFT JOIN l10n_community_translation t ON s.sid = t.sid WHERE t.translation = 'Nombre de projets à parcourir simultanément' AND t.is_active = 1 AND t.language = 'fr' AND s.sid = 1
No ? Anyway, this kind of optimization is done by the parser. Why do you cast to BINARY. I don't understand the logic.
Comment #15
grub3 commentedPatch attached. Please review this patch, as I don't understand the logic behind this choice of "BINARY". Bye.
Comment #16
grub3 commentedI added three translations to the local testing database. Project displays:
Progress status
Status overview
* 0 contributors
* 438 strings to translate
* 0 translations recorded
* 0 suggestions awaiting approval
Top contributors
People with most approved translations
* admin - 3 translations
Is this normal that 0 translations are recorded when admin has 3? Do I miss something.
Anyway, congrats, it seems to work perfectly excepte a few hints.
Comment #17
grub3 commentedAnother small issue:
Patch attached.
Comment #18
grub3 commentedBy the way, the explore project page is empty. Explore languages works. So there should be something in explore projects.
This query is empty:
SELECT COUNT(DISTINCT s.sid) AS string_count, p.pid, p.title, p.uri
FROM l10n_community_project p INNER JOIN l10n_community_release r ON p.pid = r.pid
INNER JOIN l10n_community_file f ON r.rid = f.rid
INNER JOIN l10n_community_line l ON f.fid = l.fid
INNER JOIN l10n_community_string s ON l.sid = s.sid
GROUP BY p.pid, p.title, p.uri
Comment #19
grub3 commentedAnother problem in admin:
user warning: query: SELECT p.pid, p.title project_title, r.rid, r.title release_title, COUNT(l.lineno) as occurance_count FROM l10n_community_project p INNER JOIN l10n_community_release r ON p.pid = r.pid INNER JOIN l10n_community_file f ON r.rid = f.rid INNER JOIN l10n_community_line l ON f.fid = l.fid INNER JOIN l10n_community_string s ON l.sid = s.sid WHERE s.sid = 1 GROUP BY r.rid ORDER by p.pid, r.rid in /home/html/drupal/sites/all/modules/l10n_server/l10n_community/ajax.inc on line 26.Patch attached.
By the way, this query is empty on my test server.
Comment #20
grub3 commentedThis nested deletion on INNER JOINS is not permitted in PostgreSQL
Could you write seperate SQL queries for each table and run them simultaneously in one query with ;
Comment #21
grub3 commentedAlso here:
* warning: pg_query() [function.pg-query]: Query failed: ERREUR: erreur de syntaxe sur ou près de « s » LINE 1: DELETE s, t FROM l10n_community_string s ^ in /home/html/drupal/includes/database.pgsql.inc on line 139.
* user warning: query: DELETE s, t FROM l10n_community_string s LEFT JOIN l10n_community_translation t ON t.sid = s.sid WHERE s.sid NOT IN (SELECT sid FROM l10n_community_line) in /home/html/drupal/sites/all/modules/l10n_server/l10n_community/l10n_community.admin.inc on line 263.
We need two seperate queries.
Comment #22
grub3 commentedSetting status to needs review.
Comment #23
gábor hojtsyI've reviewed your latest patches and notes, and here is some feedback:
- it would be great to roll them into one patch, because reviewing / committing them one-by-one can be hard
- the use of BINARY was recently eliminated with introduction of a hashkey column to speed up our lookups
- the use of cascading deletes was removed previously due to the denormalization of our data storage (also to speed up some queries by avoiding joins)
So looks like your patches need some revisits, merging and then we can look at the remaining issues. Thanks for your continued efforts.
Comment #24
SebCorbin commentedMoved this to D7 branch as PostgreSQL is much more optimized and could speed up the queries.
Comment #25
SebCorbin commentedLet's postpone until we have a stable release