Database management changes

* Added in-base logging through a foreign data wrapper, which is only
possible using PostgreSQL 9.1
* Renamed database-related configuration files to indicate that they are
samples, and added the "real" names to the Git ignore list. Server
distribution modified accordingly.
* Removed PL/PgSQL registration (it was only necessary on 8.4)
* Added pgTAP SQL definitions and a script which will (hopefully) be
executed by the build system after the main Java build in order to
execute database unit tests. The script supports both admin- and user-
level testing. I also added a few tests to make sure the testing framework
actually runs them.
* Added documentation about the database definitions structure
This commit is contained in:
Emmanuel BENOîT 2011-12-15 15:38:46 +01:00
parent f682594cbd
commit be3106c463
18 changed files with 7669 additions and 47 deletions
legacyworlds-server-data/db-structure

View file

@ -12,7 +12,9 @@
-- Read configuration from file
\set pgadmin `grep ^admin= db-config.txt | sed -e s/.*=//`
\set dbname `grep ^db= db-config.txt | sed -e s/.*=//`
\set dbname_string '''':dbname''''
\set dbuser `grep ^user= db-config.txt | sed -e s/.*=//`
\set dbuser_string '''':dbuser''''
\set dbupass ''''`grep ^password= db-config.txt | sed -e s/.*=// -e "s/'/''/g"`''''
@ -34,8 +36,21 @@ GRANT CONNECT ON DATABASE :dbname TO :dbuser;
-- Connect to the LW database with the PostgreSQL admin user
\c :dbname :pgadmin
-- Register PL/PgSQL
CREATE TRUSTED PROCEDURAL LANGUAGE plpgsql;
-- Register the dblink extension
CREATE EXTENSION dblink;
-- Create foreign data wrapper and server used to write logs from within
-- transanctions
CREATE FOREIGN DATA WRAPPER pgsql
VALIDATOR postgresql_fdw_validator;
CREATE SERVER srv_logging
FOREIGN DATA WRAPPER pgsql
OPTIONS ( hostaddr '127.0.0.1' , dbname :dbname_string );
CREATE USER MAPPING FOR :dbuser
SERVER srv_logging
OPTIONS ( user :dbuser_string , password :dbupass );
GRANT USAGE ON FOREIGN SERVER srv_logging TO :dbuser;
BEGIN;