[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

trunk: load contrib functions cluster-wide or local to company database?



When running the requisite steps to add contrib functions to a
new-database company file for trunk (1.3):

  $ createdb -U postgres -O ledgersmb mycompany ; 
  $ createlang -U postgres plpgsql -d mycompany ; 
  $ psql -U postgres -d mycompany -f /usr/share/postgresql-8.3/contrib/tsearch2.sql
  $ psql -U postgres -d mycompany -f /usr/share/postgresql-8.3/contrib/tablefunc.sql
  $ psql -U postgres -d mycompany -f /usr/share/postgresql-8.3/contrib/pg_trgm.sql

It seems like the functions are being installed to a cluster-wide
namespace location. The following error messages are returned:

  psql:/usr/share/postgresql-8.3/contrib/tsearch2.sql:8: ERROR:  type "tsvector" already exists
  psql:/usr/share/postgresql-8.3/contrib/tsearch2.sql:9: ERROR:  type "tsquery" already exists
  psql:/usr/share/postgresql-8.3/contrib/tsearch2.sql:10: ERROR:  type "gtsvector" already exists
  psql:/usr/share/postgresql-8.3/contrib/tsearch2.sql:11: ERROR:  type "gtsq" already exists
  psql:/usr/share/postgresql-8.3/contrib/tsearch2.sql:18: ERROR:  function "lexize" already exists with same argument types
  psql:/usr/share/postgresql-8.3/contrib/tsearch2.sql:24: ERROR:  function "lexize" already exists with same argument types
  psql:/usr/share/postgresql-8.3/contrib/tsearch2.sql:30: ERROR:  function "lexize" already exists with same argument types
  ...

IIRC, and I can't find the conversation in the #ledgersmb logs to support
it, the recommendation was that the contrib functions were to be loaded
local to each company database, for isolation and re-deployment purposes.

Should psql be run with a different 'search_path', in order to install
these functions to the mycompany database only?

  /* $PostgreSQL: pgsql/contrib/tsearch2/tsearch2.sql.in,v 1.4 2007/11/28 19:33:04 tgl Exp $ */
  
  -- Adjust this setting to control where the objects get created.
  SET search_path = public;
  
  -- These domains are just to catch schema-qualified references to the
  -- old data types.
  CREATE DOMAIN tsvector AS pg_catalog.tsvector;
  CREATE DOMAIN tsquery AS pg_catalog.tsquery;
  CREATE DOMAIN gtsvector AS pg_catalog.gtsvector;
  CREATE DOMAIN gtsq AS pg_catalog.text;
  
  --dict interface
  CREATE FUNCTION lexize(oid, text) 
  	RETURNS _text
  	as 'ts_lexize'
  	LANGUAGE INTERNAL
  	RETURNS NULL ON NULL INPUT;
  ...

Thanks,
Jeff