Commit 7ada2d31 authored by Robert Haas's avatar Robert Haas

Remove contrib/tsearch2.

This module was intended to ease migrations of applications that used
the pre-8.3 version of text search to the in-core version introduced
in that release.  However, since all pre-8.3 releases of the database
have been out of support for more than 5 years at this point, we
expect that few people are depending on it at this point.  If some
people still need it, nothing prevents it from being maintained as a
separate extension, outside of core.

Discussion: http://postgr.es/m/CA+Tgmob5R8aDHiFRTQsSJbT1oreKg2FOSBrC=2f4tqEH3dOMAg@mail.gmail.com
parent ae0e550c
......@@ -13,7 +13,6 @@ README.* conflict-marker-size=32
# Certain data files that contain special whitespace, and other special cases
*.data -whitespace
contrib/tsearch2/sql/tsearch2.sql whitespace=space-before-tab,blank-at-eof,-blank-at-eol
contrib/pgcrypto/sql/pgp-armor.sql whitespace=-blank-at-eol
doc/bug.template whitespace=space-before-tab,-blank-at-eof,blank-at-eol
src/backend/catalog/sql_features.txt whitespace=space-before-tab,blank-at-eof,-blank-at-eol
......
......@@ -47,7 +47,6 @@ SUBDIRS = \
test_decoding \
tsm_system_rows \
tsm_system_time \
tsearch2 \
unaccent \
vacuumlo
......
# Generated subdirectories
/log/
/results/
/tmp_check/
# contrib/tsearch2/Makefile
MODULES = tsearch2
EXTENSION = tsearch2
DATA = tsearch2--1.0.sql tsearch2--unpackaged--1.0.sql
PGFILEDESC = "tsearch2 - backward-compatible text search functionality"
REGRESS = tsearch2
ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
else
subdir = contrib/tsearch2
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
/* contrib/tsearch2/tsearch2--unpackaged--1.0.sql */
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION tsearch2 FROM unpackaged" to load this file. \quit
ALTER EXTENSION tsearch2 ADD type @extschema@.tsvector;
ALTER EXTENSION tsearch2 ADD type @extschema@.tsquery;
ALTER EXTENSION tsearch2 ADD type @extschema@.gtsvector;
ALTER EXTENSION tsearch2 ADD type gtsq;
ALTER EXTENSION tsearch2 ADD function lexize(oid,text);
ALTER EXTENSION tsearch2 ADD function lexize(text,text);
ALTER EXTENSION tsearch2 ADD function lexize(text);
ALTER EXTENSION tsearch2 ADD function set_curdict(integer);
ALTER EXTENSION tsearch2 ADD function set_curdict(text);
ALTER EXTENSION tsearch2 ADD function dex_init(internal);
ALTER EXTENSION tsearch2 ADD function dex_lexize(internal,internal,integer);
ALTER EXTENSION tsearch2 ADD function snb_en_init(internal);
ALTER EXTENSION tsearch2 ADD function snb_lexize(internal,internal,integer);
ALTER EXTENSION tsearch2 ADD function snb_ru_init_koi8(internal);
ALTER EXTENSION tsearch2 ADD function snb_ru_init_utf8(internal);
ALTER EXTENSION tsearch2 ADD function snb_ru_init(internal);
ALTER EXTENSION tsearch2 ADD function spell_init(internal);
ALTER EXTENSION tsearch2 ADD function spell_lexize(internal,internal,integer);
ALTER EXTENSION tsearch2 ADD function syn_init(internal);
ALTER EXTENSION tsearch2 ADD function syn_lexize(internal,internal,integer);
ALTER EXTENSION tsearch2 ADD function @extschema@.thesaurus_init(internal);
ALTER EXTENSION tsearch2 ADD function thesaurus_lexize(internal,internal,integer,internal);
ALTER EXTENSION tsearch2 ADD type tokentype;
ALTER EXTENSION tsearch2 ADD function token_type(integer);
ALTER EXTENSION tsearch2 ADD function token_type(text);
ALTER EXTENSION tsearch2 ADD function token_type();
ALTER EXTENSION tsearch2 ADD function set_curprs(integer);
ALTER EXTENSION tsearch2 ADD function set_curprs(text);
ALTER EXTENSION tsearch2 ADD type tokenout;
ALTER EXTENSION tsearch2 ADD function parse(oid,text);
ALTER EXTENSION tsearch2 ADD function parse(text,text);
ALTER EXTENSION tsearch2 ADD function parse(text);
ALTER EXTENSION tsearch2 ADD function @extschema@.prsd_start(internal,integer);
ALTER EXTENSION tsearch2 ADD function prsd_getlexeme(internal,internal,internal);
ALTER EXTENSION tsearch2 ADD function @extschema@.prsd_end(internal);
ALTER EXTENSION tsearch2 ADD function @extschema@.prsd_lextype(internal);
ALTER EXTENSION tsearch2 ADD function prsd_headline(internal,internal,internal);
ALTER EXTENSION tsearch2 ADD function set_curcfg(integer);
ALTER EXTENSION tsearch2 ADD function set_curcfg(text);
ALTER EXTENSION tsearch2 ADD function show_curcfg();
ALTER EXTENSION tsearch2 ADD function @extschema@.length(tsvector);
ALTER EXTENSION tsearch2 ADD function to_tsvector(oid,text);
ALTER EXTENSION tsearch2 ADD function to_tsvector(text,text);
ALTER EXTENSION tsearch2 ADD function @extschema@.to_tsvector(text);
ALTER EXTENSION tsearch2 ADD function @extschema@.strip(tsvector);
ALTER EXTENSION tsearch2 ADD function @extschema@.setweight(tsvector,"char");
ALTER EXTENSION tsearch2 ADD function concat(tsvector,tsvector);
ALTER EXTENSION tsearch2 ADD function @extschema@.querytree(tsquery);
ALTER EXTENSION tsearch2 ADD function to_tsquery(oid,text);
ALTER EXTENSION tsearch2 ADD function to_tsquery(text,text);
ALTER EXTENSION tsearch2 ADD function @extschema@.to_tsquery(text);
ALTER EXTENSION tsearch2 ADD function plainto_tsquery(oid,text);
ALTER EXTENSION tsearch2 ADD function plainto_tsquery(text,text);
ALTER EXTENSION tsearch2 ADD function @extschema@.plainto_tsquery(text);
ALTER EXTENSION tsearch2 ADD function tsearch2();
ALTER EXTENSION tsearch2 ADD function rank(real[],tsvector,tsquery);
ALTER EXTENSION tsearch2 ADD function rank(real[],tsvector,tsquery,integer);
ALTER EXTENSION tsearch2 ADD function rank(tsvector,tsquery);
ALTER EXTENSION tsearch2 ADD function rank(tsvector,tsquery,integer);
ALTER EXTENSION tsearch2 ADD function rank_cd(real[],tsvector,tsquery);
ALTER EXTENSION tsearch2 ADD function rank_cd(real[],tsvector,tsquery,integer);
ALTER EXTENSION tsearch2 ADD function rank_cd(tsvector,tsquery);
ALTER EXTENSION tsearch2 ADD function rank_cd(tsvector,tsquery,integer);
ALTER EXTENSION tsearch2 ADD function headline(oid,text,tsquery,text);
ALTER EXTENSION tsearch2 ADD function headline(oid,text,tsquery);
ALTER EXTENSION tsearch2 ADD function headline(text,text,tsquery,text);
ALTER EXTENSION tsearch2 ADD function headline(text,text,tsquery);
ALTER EXTENSION tsearch2 ADD function headline(text,tsquery,text);
ALTER EXTENSION tsearch2 ADD function headline(text,tsquery);
ALTER EXTENSION tsearch2 ADD operator family gist_tsvector_ops using gist;
ALTER EXTENSION tsearch2 ADD operator class gist_tsvector_ops using gist;
ALTER EXTENSION tsearch2 ADD type statinfo;
ALTER EXTENSION tsearch2 ADD function stat(text);
ALTER EXTENSION tsearch2 ADD function stat(text,text);
ALTER EXTENSION tsearch2 ADD function reset_tsearch();
ALTER EXTENSION tsearch2 ADD function get_covers(tsvector,tsquery);
ALTER EXTENSION tsearch2 ADD type tsdebug;
ALTER EXTENSION tsearch2 ADD function _get_parser_from_curcfg();
ALTER EXTENSION tsearch2 ADD function @extschema@.ts_debug(text);
ALTER EXTENSION tsearch2 ADD function @extschema@.numnode(tsquery);
ALTER EXTENSION tsearch2 ADD function @extschema@.tsquery_and(tsquery,tsquery);
ALTER EXTENSION tsearch2 ADD function @extschema@.tsquery_or(tsquery,tsquery);
ALTER EXTENSION tsearch2 ADD function @extschema@.tsquery_not(tsquery);
ALTER EXTENSION tsearch2 ADD function rewrite(tsquery,text);
ALTER EXTENSION tsearch2 ADD function rewrite(tsquery,tsquery,tsquery);
ALTER EXTENSION tsearch2 ADD function rewrite_accum(tsquery,tsquery[]);
ALTER EXTENSION tsearch2 ADD function rewrite_finish(tsquery);
ALTER EXTENSION tsearch2 ADD function rewrite(tsquery[]);
ALTER EXTENSION tsearch2 ADD function @extschema@.tsq_mcontains(tsquery,tsquery);
ALTER EXTENSION tsearch2 ADD function @extschema@.tsq_mcontained(tsquery,tsquery);
ALTER EXTENSION tsearch2 ADD operator family gist_tp_tsquery_ops using gist;
ALTER EXTENSION tsearch2 ADD operator class gist_tp_tsquery_ops using gist;
ALTER EXTENSION tsearch2 ADD operator family gin_tsvector_ops using gin;
ALTER EXTENSION tsearch2 ADD operator class gin_tsvector_ops using gin;
ALTER EXTENSION tsearch2 ADD operator family @extschema@.tsvector_ops using btree;
ALTER EXTENSION tsearch2 ADD operator class @extschema@.tsvector_ops using btree;
ALTER EXTENSION tsearch2 ADD operator family @extschema@.tsquery_ops using btree;
ALTER EXTENSION tsearch2 ADD operator class @extschema@.tsquery_ops using btree;
-- tsearch2 relies on the core functions gin_extract_tsvector,
-- gin_extract_tsquery, and gin_tsquery_consistent, which changed signature in
-- 9.1. To support upgrading, pg_catalog contains entries for these functions
-- with both the old and new signatures, and the former is what would have
-- been added to our opclass during initial restore of a 9.0 dump script.
-- Avert your eyes while we hack the pg_amproc entries to make them link to
-- the new forms ...
UPDATE pg_catalog.pg_amproc
SET amproc = 'pg_catalog.gin_extract_tsvector(pg_catalog.tsvector,internal,internal)'::pg_catalog.regprocedure
WHERE amprocfamily =
(SELECT oid FROM pg_catalog.pg_opfamily WHERE opfname = 'gin_tsvector_ops' AND
opfnamespace = (SELECT oid FROM pg_catalog.pg_namespace
WHERE nspname = '@extschema@'))
AND amproclefttype = 'pg_catalog.tsvector'::pg_catalog.regtype
AND amprocrighttype = 'pg_catalog.tsvector'::pg_catalog.regtype
AND amprocnum = 2
AND amproc = 'pg_catalog.gin_extract_tsvector(pg_catalog.tsvector,internal)'::pg_catalog.regprocedure;
UPDATE pg_catalog.pg_amproc
SET amproc = 'pg_catalog.gin_extract_tsquery(pg_catalog.tsquery,internal,smallint,internal,internal,internal,internal)'::pg_catalog.regprocedure
WHERE amprocfamily =
(SELECT oid FROM pg_catalog.pg_opfamily WHERE opfname = 'gin_tsvector_ops' AND
opfnamespace = (SELECT oid FROM pg_catalog.pg_namespace
WHERE nspname = '@extschema@'))
AND amproclefttype = 'pg_catalog.tsvector'::pg_catalog.regtype
AND amprocrighttype = 'pg_catalog.tsvector'::pg_catalog.regtype
AND amprocnum = 3
AND amproc = 'pg_catalog.gin_extract_tsquery(pg_catalog.tsquery,internal,smallint,internal,internal)'::pg_catalog.regprocedure;
UPDATE pg_catalog.pg_amproc
SET amproc = 'pg_catalog.gin_tsquery_consistent(internal,smallint,pg_catalog.tsquery,integer,internal,internal,internal,internal)'::pg_catalog.regprocedure
WHERE amprocfamily =
(SELECT oid FROM pg_catalog.pg_opfamily WHERE opfname = 'gin_tsvector_ops' AND
opfnamespace = (SELECT oid FROM pg_catalog.pg_namespace
WHERE nspname = '@extschema@'))
AND amproclefttype = 'pg_catalog.tsvector'::pg_catalog.regtype
AND amprocrighttype = 'pg_catalog.tsvector'::pg_catalog.regtype
AND amprocnum = 4
AND amproc = 'pg_catalog.gin_tsquery_consistent(internal,smallint,pg_catalog.tsquery,integer,internal,internal)'::pg_catalog.regprocedure;
This diff is collapsed.
# tsearch2 extension
comment = 'compatibility package for pre-8.3 text search functions'
default_version = '1.0'
module_pathname = '$libdir/tsearch2'
# this is not relocatable because the tsearch2--unpackaged--1.0.sql script
# has to use @extschema@ to avoid conflict with items in pg_catalog
relocatable = false
......@@ -142,7 +142,6 @@ CREATE EXTENSION <replaceable>module_name</> FROM unpackaged;
&tablefunc;
&tcn;
&test-decoding;
&tsearch2;
&tsm-system-rows;
&tsm-system-time;
&unaccent;
......
......@@ -151,7 +151,6 @@
<!ENTITY test-decoding SYSTEM "test-decoding.sgml">
<!ENTITY test-parser SYSTEM "test-parser.sgml">
<!ENTITY test-shm-mq SYSTEM "test-shm-mq.sgml">
<!ENTITY tsearch2 SYSTEM "tsearch2.sgml">
<!ENTITY tsm-system-rows SYSTEM "tsm-system-rows.sgml">
<!ENTITY tsm-system-time SYSTEM "tsm-system-time.sgml">
<!ENTITY unaccent SYSTEM "unaccent.sgml">
......
......@@ -3864,87 +3864,4 @@ Parser: "pg_catalog.default"
</sect1>
<sect1 id="textsearch-migration">
<title>Migration from Pre-8.3 Text Search</title>
<para>
Applications that use the <xref linkend="tsearch2">
module for text searching will need some adjustments to work
with the
built-in features:
</para>
<itemizedlist>
<listitem>
<para>
Some functions have been renamed or had small adjustments in their
argument lists, and all of them are now in the <literal>pg_catalog</>
schema, whereas in a previous installation they would have been in
<literal>public</> or another non-system schema. There is a new
version of <application>tsearch2</>
that provides a compatibility layer to solve most problems in this
area.
</para>
</listitem>
<listitem>
<para>
The old <application>tsearch2</> functions and other objects
<emphasis>must</> be suppressed when loading <application>pg_dump</>
output from a pre-8.3 database. While many of them won't load anyway,
a few will and then cause problems. One simple way to deal with this
is to load the new <application>tsearch2</> module before restoring
the dump; then it will block the old objects from being loaded.
</para>
</listitem>
<listitem>
<para>
Text search configuration setup is completely different now.
Instead of manually inserting rows into configuration tables,
search is configured through the specialized SQL commands shown
earlier in this chapter. There is no automated
support for converting an existing custom configuration for 8.3;
you're on your own here.
</para>
</listitem>
<listitem>
<para>
Most types of dictionaries rely on some outside-the-database
configuration files. These are largely compatible with pre-8.3
usage, but note the following differences:
<itemizedlist spacing="compact" mark="bullet">
<listitem>
<para>
Configuration files now must be placed in a single specified
directory (<filename>$SHAREDIR/tsearch_data</>), and must have
a specific extension depending on the type of file, as noted
previously in the descriptions of the various dictionary types.
This restriction was added to forestall security problems.
</para>
</listitem>
<listitem>
<para>
Configuration files must be encoded in UTF-8 encoding,
regardless of what database encoding is used.
</para>
</listitem>
<listitem>
<para>
In thesaurus configuration files, stop words must be marked with
<literal>?</>.
</para>
</listitem>
</itemizedlist>
</para>
</listitem>
</itemizedlist>
</sect1>
</chapter>
<!-- doc/src/sgml/tsearch2.sgml -->
<sect1 id="tsearch2" xreflabel="tsearch2">
<title>tsearch2</title>
<indexterm zone="tsearch2">
<primary>tsearch2</primary>
</indexterm>
<para>
The <application>tsearch2</> module provides backwards-compatible
text search functionality for applications that used
<application>tsearch2</> before text searching was integrated
into core <productname>PostgreSQL</productname> in release 8.3.
</para>
<sect2>
<title>Portability Issues</title>
<para>
Although the built-in text search features were based on
<application>tsearch2</> and are largely similar to it,
there are numerous small differences that will create portability
issues for existing applications:
</para>
<itemizedlist mark="bullet">
<listitem>
<para>
Some functions' names were changed, for example <function>rank</>
to <function>ts_rank</>.
The replacement <literal>tsearch2</literal> module
provides aliases having the old names.
</para>
</listitem>
<listitem>
<para>
The built-in text search data types and functions all exist within
the system schema <literal>pg_catalog</>. In an installation using
<application>tsearch2</>, these objects would usually have been in
the <literal>public</> schema, though some users chose to place them
in a separate schema of their own. Explicitly schema-qualified
references to the objects will therefore fail in either case.
The replacement <literal>tsearch2</literal> module
provides alias objects that are stored in <literal>public</>
(or another schema if necessary) so that such references will still work.
</para>
</listitem>
<listitem>
<para>
There is no concept of a <quote>current parser</> or <quote>current
dictionary</> in the built-in text search features, only of a current
search configuration (set by the <varname>default_text_search_config</>
parameter). While the current parser and current dictionary were used
only by functions intended for debugging, this might still pose
a porting obstacle in some cases.
The replacement <literal>tsearch2</literal> module emulates these
additional state variables and provides backwards-compatible functions
for setting and retrieving them.
</para>
</listitem>
</itemizedlist>
<para>
There are some issues that are not addressed by the replacement
<literal>tsearch2</literal> module, and will therefore require
application code changes in any case:
</para>
<itemizedlist mark="bullet">
<listitem>
<para>
The old <function>tsearch2</> trigger function allowed items in its
argument list to be names of functions to be invoked on the text data
before it was converted to <type>tsvector</> format. This was removed
as being a security hole, since it was not possible to guarantee that
the function invoked was the one intended. The recommended approach
if the data must be massaged before being indexed is to write a custom
trigger that does the work for itself.
</para>
</listitem>
<listitem>
<para>
Text search configuration information has been moved into core
system catalogs that are noticeably different from the tables used
by <application>tsearch2</>. Any applications that examined
or modified those tables will need adjustment.
</para>
</listitem>
<listitem>
<para>
If an application used any custom text search configurations,
those will need to be set up in the core
catalogs using the new text search configuration SQL commands.
The replacement <literal>tsearch2</literal> module offers a little
bit of support for this by making it possible to load an old set
of <application>tsearch2</> configuration tables into
<productname>PostgreSQL</productname> 8.3. (Without the module,
it is not possible to load the configuration data because values in the
<type>regprocedure</> columns cannot be resolved to functions.)
While those configuration tables won't actually <emphasis>do</>
anything, at least their contents will be available to be consulted
while setting up an equivalent custom configuration in 8.3.
</para>
</listitem>
<listitem>
<para>
The old <function>reset_tsearch()</> and <function>get_covers()</>
functions are not supported.
</para>
</listitem>
<listitem>
<para>
The replacement <literal>tsearch2</literal> module does not define
any alias operators, relying entirely on the built-in ones.
This would only pose an issue if an application used explicitly
schema-qualified operator names, which is very uncommon.
</para>
</listitem>
</itemizedlist>
</sect2>
<sect2>
<title>Converting a pre-8.3 Installation</title>
<para>
The recommended way to update a pre-8.3 installation that uses
<application>tsearch2</> is:
</para>
<procedure>
<step>
<para>
Make a dump from the old installation in the usual way,
but be sure not to use <literal>-c</> (<literal>--clean</>)
option of <application>pg_dump</> or <application>pg_dumpall</>.
</para>
</step>
<step>
<para>
In the new installation, create empty database(s) and install
the replacement <literal>tsearch2</literal> module into each
database that will use text search. This must be done
<emphasis>before</> loading the dump data! If your old installation
had the <application>tsearch2</> objects in a schema other
than <literal>public</>, be sure to adjust the
<command>CREATE EXTENSION</> command so that the replacement
objects are created in that same schema.
</para>
</step>
<step>
<para>
Load the dump data. There will be quite a few errors reported
due to failure to recreate the original <application>tsearch2</>
objects. These errors can be ignored, but this means you cannot
restore the dump in a single transaction (eg, you cannot use
<application>pg_restore</>'s <option>-1</> switch).
</para>
</step>
<step>
<para>
Examine the contents of the restored <application>tsearch2</>
configuration tables (<structname>pg_ts_cfg</> and so on), and
create equivalent built-in text search configurations as needed.
You may drop the old configuration tables once you've extracted
all the useful information from them.
</para>
</step>
<step>
<para>
Test your application.
</para>
</step>
</procedure>
<para>
At a later time you may wish to rename application references
to the alias text search objects, so that you can eventually
uninstall the replacement <literal>tsearch2</literal> module.
</para>
</sect2>
<sect2>
<title>References</title>
<para>
Tsearch2 Development Site
<ulink url="http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/"></ulink>
</para>
</sect2>
</sect1>
......@@ -28,7 +28,6 @@ typedef struct
int pos; /* position of the parser */
} ParserState;
/* copy-paste from wparser.h of tsearch2 */
typedef struct
{
int lexid;
......
......@@ -36,7 +36,7 @@ my @contrib_uselibpgport = ('oid2name', 'pg_standby', 'vacuumlo');
my @contrib_uselibpgcommon = ('oid2name', 'pg_standby', 'vacuumlo');
my $contrib_extralibs = undef;
my $contrib_extraincludes =
{ 'tsearch2' => ['contrib/tsearch2'], 'dblink' => ['src/backend'] };
{ 'dblink' => ['src/backend'] };
my $contrib_extrasource = {
'cube' => [ 'contrib/cube/cubescan.l', 'contrib/cube/cubeparse.y' ],
'seg' => [ 'contrib/seg/segscan.l', 'contrib/seg/segparse.y' ], };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment