Last modified: 2014-09-07 20:59:00 UTC
VoteNY not working with Postgresql. The vote.sql I have convert to pgsql, now it looks like -- Postgres Version -- author: basti -- set Schemata SET search_path = mediawiki; CREATE TABLE vote ( -- Internal ID to identify between different vote tags on different pages vote_id SERIAL NOT NULL PRIMARY KEY, -- Username (if any) of the person who voted username varchar(255) NOT NULL default '0', -- User ID of the person who voted vote_user_id integer NOT NULL default '0', -- ID of the page where the vote tag is in vote_page_id integer NOT NULL default '0', -- Value of the vote (ranging from 1 to 5) vote_value char(1) NOT NULL default '', -- Timestamp when the vote was cast vote_date timestamp without time zone NOT NULL, -- IP address of the user who voted vote_ip varchar(45) NOT NULL default '' ) /*$wgDBTableOptions*/; CREATE INDEX vote_page_id_index ON vote (vote_page_id); CREATE INDEX valueidx ON vote (vote_value); CREATE INDEX usernameidx ON vote (username); CREATE INDEX vote_date ON vote (vote_date); Next I try to create a BlogPost by calling Spezial:CreateBlogPost but this returns SELECT vote_value FROM "Vote" WHERE vote_page_id = '0' AND username = 'Admin' LIMIT 1 The " are too mutch, you can found the code in VoteClass.php line 182 ff. Then I run SET search_path=mediawiki; SELECT vote_value FROM Vote WHERE vote_page_id = '0' AND username = 'Admin' LIMIT 1 in PgAdmin all works fine. "SET search_path" is normally done by includes/db/DatabasePostgres.php How can I fix this? Regards, Basti
I have found the error, but I don't know how to solve it. There is a Problem with the Postgres "serach Path" in the plugin. On the database site there is only one schema "mediawiki". The $wgDBuser has the default schema "mediawiki" on server site. (Use "SHOW search_path;" in SQL console to check this.) $wgDBmwschema = "mediawiki"; and $wgDBtype = "postgres"; are also set in LocalSettings.php The Wiki-DEBUG output say "Schema "mediawiki" already in the search path". There is always the same Error on Database site: SELECT COUNT(*) AS VoteCount FROM "Vote" WHERE vote_page_id = '0' Postgres log: FEHLER: Relation »Vote« existiert nicht LINE 1: ...Vote::count Admin */ COUNT(*) AS VoteCount FROM "Vote" WH... ^ “. (in english: Relation »Vote« does not exist) When i change in VoteNY/VoteClass.php it runs. function UserAlreadyVoted() { $dbr = wfGetDB( DB_SLAVE ); $s = $dbr->selectRow( # Here add Postgres schema 'mediawiki.vote', array( 'vote_value' ), array( 'vote_page_id' => $this->PageID, 'username' => $this->Username ), __METHOD__ ); # Exit for debug exit("UserAlreadyVoted() done"); if( $s === false ) { return false; } else { return $s->vote_value; } } I have done also some changes in VoteNY/Hooks.php public static function addTable( $updater ) { $dir = dirname( __FILE__ ); /** change to use Postgres **/ $dbr = wfGetDB( DB_SLAVE ); if ($dbr->getType() == "postgres") { $file = "$dir/vote.postgres.sql"; } else { $file = "$dir/vote.sql"; } /** check if table exists, else the update.php won't run because Postgres exit with Error **/ if (!$dbr->tableExists('vote')) { $updater->addExtensionUpdate( array( 'addTable', 'Vote', $file, true ) ); } /** end of changes **/ return true; } vote.postgres.sql -- Postgres Version -- set Schemata for debug, normally done by includes/db/DatabasePostgres.sql ? SET search_path = mediawiki; CREATE TABLE vote ( -- Internal ID to identify between different vote tags on different pages vote_id SERIAL NOT NULL PRIMARY KEY, -- Username (if any) of the person who voted username varchar(255) NOT NULL default '0', -- User ID of the person who voted vote_user_id integer NOT NULL default '0', -- ID of the page where the vote tag is in vote_page_id integer NOT NULL default '0', -- Value of the vote (ranging from 1 to 5) vote_value char(1) NOT NULL default '', -- Timestamp when the vote was cast vote_date timestamp without time zone NOT NULL, -- IP address of the user who voted vote_ip varchar(45) NOT NULL default '' ) /*$wgDBTableOptions*/; CREATE INDEX vote_page_id_index ON vote (vote_page_id); CREATE INDEX valueidx ON vote (vote_value); CREATE INDEX usernameidx ON vote (username); CREATE INDEX vote_date ON vote (vote_date); --EOF So it seems that includes/db/DatabasePostgres.sql isn't use by this Plugin or something else is goning wrong that the database connection don't know anything about the schema. Regards, basti
You need not normally to deal with PostgreSQL schema at all, it will be set automatically. Isn't the problem because the table is called "Vote" (capital "V") and not "vote"? Can you change your sql to use CREATE TABLE "Vote" and not CREATE TABLE vote and see if it works?
Created attachment 13938 [details] SQL file for Postgresql
basti, unfortunately more changes are needed - avg() function for example does not work on characters in PostgreSQL. I have pushed an improved patch (ready to include in the extension) to Gerrit.
Gerrit change #98353 pushed and tested on both MySQL and PostgreSQL.
This bug seems to be "resolved fixed". Is there anything else to be done?
Good catch. Setting status.