Commit 140d4ebc authored by Tom Lane's avatar Tom Lane

Tsearch2 functionality migrates to core. The bulk of this work is by

Oleg Bartunov and Teodor Sigaev, but I did a lot of editorializing,
so anything that's broken is probably my fault.

Documentation is nonexistent as yet, but let's land the patch so we can
get some portability testing done.
parent 4e94d1f9
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.206 2007/08/04 01:26:53 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.207 2007/08/21 01:11:11 tgl Exp $ -->
<chapter id="datatype"> <chapter id="datatype">
<title id="datatype-title">Data Types</title> <title id="datatype-title">Data Types</title>
...@@ -3484,6 +3484,14 @@ SET xmloption TO { DOCUMENT | CONTENT }; ...@@ -3484,6 +3484,14 @@ SET xmloption TO { DOCUMENT | CONTENT };
<primary>regtype</primary> <primary>regtype</primary>
</indexterm> </indexterm>
<indexterm zone="datatype-oid">
<primary>regconfig</primary>
</indexterm>
<indexterm zone="datatype-oid">
<primary>regdictionary</primary>
</indexterm>
<indexterm zone="datatype-oid"> <indexterm zone="datatype-oid">
<primary>xid</primary> <primary>xid</primary>
</indexterm> </indexterm>
...@@ -3505,9 +3513,9 @@ SET xmloption TO { DOCUMENT | CONTENT }; ...@@ -3505,9 +3513,9 @@ SET xmloption TO { DOCUMENT | CONTENT };
configuration variable is enabled. Type <type>oid</> represents configuration variable is enabled. Type <type>oid</> represents
an object identifier. There are also several alias types for an object identifier. There are also several alias types for
<type>oid</>: <type>regproc</>, <type>regprocedure</>, <type>oid</>: <type>regproc</>, <type>regprocedure</>,
<type>regoper</>, <type>regoperator</>, <type>regclass</>, and <type>regoper</>, <type>regoperator</>, <type>regclass</>,
<type>regtype</>. <xref linkend="datatype-oid-table"> shows an <type>regtype</>, <type>regconfig</>, and <type>regdictionary</>.
overview. <xref linkend="datatype-oid-table"> shows an overview.
</para> </para>
<para> <para>
...@@ -3614,6 +3622,20 @@ SELECT * FROM pg_attribute ...@@ -3614,6 +3622,20 @@ SELECT * FROM pg_attribute
<entry>data type name</entry> <entry>data type name</entry>
<entry><literal>integer</></entry> <entry><literal>integer</></entry>
</row> </row>
<row>
<entry><type>regconfig</></entry>
<entry><structname>pg_ts_config</></entry>
<entry>text search configuration</entry>
<entry><literal>english</></entry>
</row>
<row>
<entry><type>regdictionary</></entry>
<entry><structname>pg_ts_dict</></entry>
<entry>text search dictionary</entry>
<entry><literal>simple</></entry>
</row>
</tbody> </tbody>
</tgroup> </tgroup>
</table> </table>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.387 2007/08/19 03:23:30 adunstan Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.388 2007/08/21 01:11:11 tgl Exp $ -->
<chapter id="functions"> <chapter id="functions">
<title>Functions and Operators</title> <title>Functions and Operators</title>
...@@ -10794,7 +10794,9 @@ SELECT relname FROM pg_class WHERE pg_table_is_visible(oid); ...@@ -10794,7 +10794,9 @@ SELECT relname FROM pg_class WHERE pg_table_is_visible(oid);
All these functions require object OIDs to identify the object to be All these functions require object OIDs to identify the object to be
checked. If you want to test an object by name, it is convenient to use checked. If you want to test an object by name, it is convenient to use
the OID alias types (<type>regclass</>, <type>regtype</>, the OID alias types (<type>regclass</>, <type>regtype</>,
<type>regprocedure</>, or <type>regoperator</>), for example: <type>regprocedure</>, <type>regoperator</>, <type>regconfig</>,
or <type>regdictionary</>),
for example:
<programlisting> <programlisting>
SELECT pg_type_is_visible('myschema.widget'::regtype); SELECT pg_type_is_visible('myschema.widget'::regtype);
</programlisting> </programlisting>
...@@ -11255,8 +11257,8 @@ SELECT set_config('log_statement_stats', 'off', false); ...@@ -11255,8 +11257,8 @@ SELECT set_config('log_statement_stats', 'off', false);
<para> <para>
<function>pg_rotate_logfile</> signals the log-file manager to switch <function>pg_rotate_logfile</> signals the log-file manager to switch
to a new output file immediately. This works only when the built-in to a new output file immediately. This works only when the built-in
log collector is running, since otherwise there is no log-file manager log collector is running, since otherwise there is no log-file manager
subprocess. subprocess.
</para> </para>
<indexterm zone="functions-admin"> <indexterm zone="functions-admin">
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# $PostgreSQL: pgsql/src/Makefile,v 1.41 2007/01/20 17:16:09 petere Exp $ # $PostgreSQL: pgsql/src/Makefile,v 1.42 2007/08/21 01:11:12 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -18,6 +18,7 @@ all install installdirs uninstall distprep: ...@@ -18,6 +18,7 @@ all install installdirs uninstall distprep:
$(MAKE) -C timezone $@ $(MAKE) -C timezone $@
$(MAKE) -C backend $@ $(MAKE) -C backend $@
$(MAKE) -C backend/utils/mb/conversion_procs $@ $(MAKE) -C backend/utils/mb/conversion_procs $@
$(MAKE) -C backend/snowball $@
$(MAKE) -C include $@ $(MAKE) -C include $@
$(MAKE) -C interfaces $@ $(MAKE) -C interfaces $@
$(MAKE) -C bin $@ $(MAKE) -C bin $@
...@@ -47,6 +48,7 @@ clean: ...@@ -47,6 +48,7 @@ clean:
$(MAKE) -C port $@ $(MAKE) -C port $@
$(MAKE) -C timezone $@ $(MAKE) -C timezone $@
$(MAKE) -C backend $@ $(MAKE) -C backend $@
$(MAKE) -C backend/snowball $@
$(MAKE) -C include $@ $(MAKE) -C include $@
$(MAKE) -C interfaces $@ $(MAKE) -C interfaces $@
$(MAKE) -C bin $@ $(MAKE) -C bin $@
...@@ -60,6 +62,7 @@ distclean maintainer-clean: ...@@ -60,6 +62,7 @@ distclean maintainer-clean:
-$(MAKE) -C port $@ -$(MAKE) -C port $@
-$(MAKE) -C timezone $@ -$(MAKE) -C timezone $@
-$(MAKE) -C backend $@ -$(MAKE) -C backend $@
-$(MAKE) -C backend/snowball $@
-$(MAKE) -C include $@ -$(MAKE) -C include $@
-$(MAKE) -C interfaces $@ -$(MAKE) -C interfaces $@
-$(MAKE) -C bin $@ -$(MAKE) -C bin $@
......
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
# #
# Makefile for the postgres backend # Makefile for the postgres backend
# #
# Copyright (c) 1994, Regents of the University of California # Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
# #
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.123 2007/07/24 09:00:27 mha Exp $ # $PostgreSQL: pgsql/src/backend/Makefile,v 1.124 2007/08/21 01:11:12 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -15,7 +16,7 @@ include $(top_builddir)/src/Makefile.global ...@@ -15,7 +16,7 @@ include $(top_builddir)/src/Makefile.global
DIRS = access bootstrap catalog parser commands executor lib libpq \ DIRS = access bootstrap catalog parser commands executor lib libpq \
main nodes optimizer port postmaster regex rewrite \ main nodes optimizer port postmaster regex rewrite \
storage tcop utils $(top_builddir)/src/timezone storage tcop tsearch utils $(top_builddir)/src/timezone
SUBSYSOBJS = $(DIRS:%=%/SUBSYS.o) SUBSYSOBJS = $(DIRS:%=%/SUBSYS.o)
...@@ -166,6 +167,7 @@ ifeq ($(MAKE_DLL), true) ...@@ -166,6 +167,7 @@ ifeq ($(MAKE_DLL), true)
endif endif
endif endif
$(MAKE) -C catalog install-data $(MAKE) -C catalog install-data
$(MAKE) -C tsearch install-data
$(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample '$(DESTDIR)$(datadir)/pg_hba.conf.sample' $(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample '$(DESTDIR)$(datadir)/pg_hba.conf.sample'
$(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample '$(DESTDIR)$(datadir)/pg_ident.conf.sample' $(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample '$(DESTDIR)$(datadir)/pg_ident.conf.sample'
$(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample' $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample'
...@@ -220,6 +222,7 @@ ifeq ($(MAKE_DLL), true) ...@@ -220,6 +222,7 @@ ifeq ($(MAKE_DLL), true)
endif endif
endif endif
$(MAKE) -C catalog uninstall-data $(MAKE) -C catalog uninstall-data
$(MAKE) -C tsearch uninstall-data
rm -f '$(DESTDIR)$(datadir)/pg_hba.conf.sample' \ rm -f '$(DESTDIR)$(datadir)/pg_hba.conf.sample' \
'$(DESTDIR)$(datadir)/pg_ident.conf.sample' \ '$(DESTDIR)$(datadir)/pg_ident.conf.sample' \
'$(DESTDIR)$(datadir)/postgresql.conf.sample' \ '$(DESTDIR)$(datadir)/postgresql.conf.sample' \
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gin/ginarrayproc.c,v 1.9 2007/01/31 15:09:45 teodor Exp $ * $PostgreSQL: pgsql/src/backend/access/gin/ginarrayproc.c,v 1.10 2007/08/21 01:11:12 tgl Exp $
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -62,7 +62,7 @@ ginarrayextract(PG_FUNCTION_ARGS) ...@@ -62,7 +62,7 @@ ginarrayextract(PG_FUNCTION_ARGS)
if ( *nentries == 0 && PG_NARGS() == 3 ) if ( *nentries == 0 && PG_NARGS() == 3 )
{ {
switch( PG_GETARG_UINT16(2) ) switch( PG_GETARG_UINT16(2) ) /* StrategyNumber */
{ {
case GinOverlapStrategy: case GinOverlapStrategy:
*nentries = -1; /* nobody can be found */ *nentries = -1; /* nobody can be found */
...@@ -79,6 +79,15 @@ ginarrayextract(PG_FUNCTION_ARGS) ...@@ -79,6 +79,15 @@ ginarrayextract(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(entries); PG_RETURN_POINTER(entries);
} }
Datum
ginqueryarrayextract(PG_FUNCTION_ARGS)
{
PG_RETURN_DATUM(DirectFunctionCall3(ginarrayextract,
PG_GETARG_DATUM(0),
PG_GETARG_DATUM(1),
PG_GETARG_DATUM(2)));
}
Datum Datum
ginarrayconsistent(PG_FUNCTION_ARGS) ginarrayconsistent(PG_FUNCTION_ARGS)
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# #
# Makefile for backend/catalog # Makefile for backend/catalog
# #
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.64 2007/04/02 03:49:37 tgl Exp $ # $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.65 2007/08/21 01:11:13 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -35,6 +35,8 @@ POSTGRES_BKI_SRCS = $(addprefix $(top_srcdir)/src/include/catalog/,\ ...@@ -35,6 +35,8 @@ POSTGRES_BKI_SRCS = $(addprefix $(top_srcdir)/src/include/catalog/,\
pg_enum.h pg_namespace.h pg_conversion.h pg_depend.h \ pg_enum.h pg_namespace.h pg_conversion.h pg_depend.h \
pg_database.h pg_tablespace.h pg_pltemplate.h \ pg_database.h pg_tablespace.h pg_pltemplate.h \
pg_authid.h pg_auth_members.h pg_shdepend.h pg_shdescription.h \ pg_authid.h pg_auth_members.h pg_shdepend.h pg_shdescription.h \
pg_ts_config.h pg_ts_config_map.h pg_ts_dict.h \
pg_ts_parser.h pg_ts_template.h \
toasting.h indexing.h \ toasting.h indexing.h \
) )
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.139 2007/04/20 02:37:37 tgl Exp $ * $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.140 2007/08/21 01:11:13 tgl Exp $
* *
* NOTES * NOTES
* See acl.h. * See acl.h.
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include "catalog/pg_proc.h" #include "catalog/pg_proc.h"
#include "catalog/pg_tablespace.h" #include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h" #include "catalog/pg_type.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
#include "commands/dbcommands.h" #include "commands/dbcommands.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "parser/parse_func.h" #include "parser/parse_func.h"
...@@ -1416,7 +1418,11 @@ static const char *const no_priv_msg[MAX_ACL_KIND] = ...@@ -1416,7 +1418,11 @@ static const char *const no_priv_msg[MAX_ACL_KIND] =
/* ACL_KIND_CONVERSION */ /* ACL_KIND_CONVERSION */
gettext_noop("permission denied for conversion %s"), gettext_noop("permission denied for conversion %s"),
/* ACL_KIND_TABLESPACE */ /* ACL_KIND_TABLESPACE */
gettext_noop("permission denied for tablespace %s") gettext_noop("permission denied for tablespace %s"),
/* ACL_KIND_TSDICTIONARY */
gettext_noop("permission denied for text search dictionary %s"),
/* ACL_KIND_TSCONFIGURATION */
gettext_noop("permission denied for text search configuration %s")
}; };
static const char *const not_owner_msg[MAX_ACL_KIND] = static const char *const not_owner_msg[MAX_ACL_KIND] =
...@@ -1444,7 +1450,11 @@ static const char *const not_owner_msg[MAX_ACL_KIND] = ...@@ -1444,7 +1450,11 @@ static const char *const not_owner_msg[MAX_ACL_KIND] =
/* ACL_KIND_CONVERSION */ /* ACL_KIND_CONVERSION */
gettext_noop("must be owner of conversion %s"), gettext_noop("must be owner of conversion %s"),
/* ACL_KIND_TABLESPACE */ /* ACL_KIND_TABLESPACE */
gettext_noop("must be owner of tablespace %s") gettext_noop("must be owner of tablespace %s"),
/* ACL_KIND_TSDICTIONARY */
gettext_noop("must be owner of text search dictionary %s"),
/* ACL_KIND_TSCONFIGURATION */
gettext_noop("must be owner of text search configuration %s")
}; };
...@@ -2297,6 +2307,65 @@ pg_opfamily_ownercheck(Oid opf_oid, Oid roleid) ...@@ -2297,6 +2307,65 @@ pg_opfamily_ownercheck(Oid opf_oid, Oid roleid)
return has_privs_of_role(roleid, ownerId); return has_privs_of_role(roleid, ownerId);
} }
/*
* Ownership check for a text search dictionary (specified by OID).
*/
bool
pg_ts_dict_ownercheck(Oid dict_oid, Oid roleid)
{
HeapTuple tuple;
Oid ownerId;
/* Superusers bypass all permission checking. */
if (superuser_arg(roleid))
return true;
tuple = SearchSysCache(TSDICTOID,
ObjectIdGetDatum(dict_oid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("text search dictionary with OID %u does not exist",
dict_oid)));
ownerId = ((Form_pg_ts_dict) GETSTRUCT(tuple))->dictowner;
ReleaseSysCache(tuple);
return has_privs_of_role(roleid, ownerId);
}
/*
* Ownership check for a text search configuration (specified by OID).
*/
bool
pg_ts_config_ownercheck(Oid cfg_oid, Oid roleid)
{
HeapTuple tuple;
Oid ownerId;
/* Superusers bypass all permission checking. */
if (superuser_arg(roleid))
return true;
tuple = SearchSysCache(TSCONFIGOID,
ObjectIdGetDatum(cfg_oid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("text search configuration with OID %u does not exist",
cfg_oid)));
ownerId = ((Form_pg_ts_config) GETSTRUCT(tuple))->cfgowner;
ReleaseSysCache(tuple);
return has_privs_of_role(roleid, ownerId);
}
/* /*
* Ownership check for a database (specified by OID). * Ownership check for a database (specified by OID).
*/ */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.66 2007/06/05 21:31:04 tgl Exp $ * $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.67 2007/08/21 01:11:13 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -40,6 +40,10 @@ ...@@ -40,6 +40,10 @@
#include "catalog/pg_rewrite.h" #include "catalog/pg_rewrite.h"
#include "catalog/pg_tablespace.h" #include "catalog/pg_tablespace.h"
#include "catalog/pg_trigger.h" #include "catalog/pg_trigger.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
#include "catalog/pg_ts_parser.h"
#include "catalog/pg_ts_template.h"
#include "catalog/pg_type.h" #include "catalog/pg_type.h"
#include "commands/comment.h" #include "commands/comment.h"
#include "commands/dbcommands.h" #include "commands/dbcommands.h"
...@@ -97,6 +101,10 @@ static const Oid object_classes[MAX_OCLASS] = { ...@@ -97,6 +101,10 @@ static const Oid object_classes[MAX_OCLASS] = {
RewriteRelationId, /* OCLASS_REWRITE */ RewriteRelationId, /* OCLASS_REWRITE */
TriggerRelationId, /* OCLASS_TRIGGER */ TriggerRelationId, /* OCLASS_TRIGGER */
NamespaceRelationId, /* OCLASS_SCHEMA */ NamespaceRelationId, /* OCLASS_SCHEMA */
TSParserRelationId, /* OCLASS_TSPARSER */
TSDictionaryRelationId, /* OCLASS_TSDICT */
TSTemplateRelationId, /* OCLASS_TSTEMPLATE */
TSConfigRelationId, /* OCLASS_TSCONFIG */
AuthIdRelationId, /* OCLASS_ROLE */ AuthIdRelationId, /* OCLASS_ROLE */
DatabaseRelationId, /* OCLASS_DATABASE */ DatabaseRelationId, /* OCLASS_DATABASE */
TableSpaceRelationId /* OCLASS_TBLSPACE */ TableSpaceRelationId /* OCLASS_TBLSPACE */
...@@ -988,6 +996,22 @@ doDeletion(const ObjectAddress *object) ...@@ -988,6 +996,22 @@ doDeletion(const ObjectAddress *object)
RemoveSchemaById(object->objectId); RemoveSchemaById(object->objectId);
break; break;
case OCLASS_TSPARSER:
RemoveTSParserById(object->objectId);
break;
case OCLASS_TSDICT:
RemoveTSDictionaryById(object->objectId);
break;
case OCLASS_TSTEMPLATE:
RemoveTSTemplateById(object->objectId);
break;
case OCLASS_TSCONFIG:
RemoveTSConfigurationById(object->objectId);
break;
/* OCLASS_ROLE, OCLASS_DATABASE, OCLASS_TBLSPACE not handled */ /* OCLASS_ROLE, OCLASS_DATABASE, OCLASS_TBLSPACE not handled */
default: default:
...@@ -1201,8 +1225,8 @@ find_expr_references_walker(Node *node, ...@@ -1201,8 +1225,8 @@ find_expr_references_walker(Node *node,
/* /*
* If it's a regclass or similar literal referring to an existing * If it's a regclass or similar literal referring to an existing
* object, add a reference to that object. (Currently, only the * object, add a reference to that object. (Currently, only the
* regclass case has any likely use, but we may as well handle all the * regclass and regconfig cases have any likely use, but we may as
* OID-alias datatypes consistently.) * well handle all the OID-alias datatypes consistently.)
*/ */
if (!con->constisnull) if (!con->constisnull)
{ {
...@@ -1242,6 +1266,22 @@ find_expr_references_walker(Node *node, ...@@ -1242,6 +1266,22 @@ find_expr_references_walker(Node *node,
add_object_address(OCLASS_TYPE, objoid, 0, add_object_address(OCLASS_TYPE, objoid, 0,
context->addrs); context->addrs);
break; break;
case REGCONFIGOID:
objoid = DatumGetObjectId(con->constvalue);
if (SearchSysCacheExists(TSCONFIGOID,
ObjectIdGetDatum(objoid),
0, 0, 0))
add_object_address(OCLASS_TSCONFIG, objoid, 0,
context->addrs);
break;
case REGDICTIONARYOID:
objoid = DatumGetObjectId(con->constvalue);
if (SearchSysCacheExists(TSDICTOID,
ObjectIdGetDatum(objoid),
0, 0, 0))
add_object_address(OCLASS_TSDICT, objoid, 0,
context->addrs);
break;
} }
} }
return false; return false;
...@@ -1605,6 +1645,21 @@ object_address_present(const ObjectAddress *object, ...@@ -1605,6 +1645,21 @@ object_address_present(const ObjectAddress *object,
return false; return false;
} }
/*
* Record multiple dependencies from an ObjectAddresses array, after first
* removing any duplicates.
*/
void
record_object_address_dependencies(const ObjectAddress *depender,
ObjectAddresses *referenced,
DependencyType behavior)
{
eliminate_duplicate_dependencies(referenced);
recordMultipleDependencies(depender,
referenced->refs, referenced->numrefs,
behavior);
}
/* /*
* Clean up when done with an ObjectAddresses array. * Clean up when done with an ObjectAddresses array.
*/ */
...@@ -1690,6 +1745,22 @@ getObjectClass(const ObjectAddress *object) ...@@ -1690,6 +1745,22 @@ getObjectClass(const ObjectAddress *object)
Assert(object->objectSubId == 0); Assert(object->objectSubId == 0);
return OCLASS_SCHEMA; return OCLASS_SCHEMA;
case TSParserRelationId:
Assert(object->objectSubId == 0);
return OCLASS_TSPARSER;
case TSDictionaryRelationId:
Assert(object->objectSubId == 0);
return OCLASS_TSDICT;
case TSTemplateRelationId:
Assert(object->objectSubId == 0);
return OCLASS_TSTEMPLATE;
case TSConfigRelationId:
Assert(object->objectSubId == 0);
return OCLASS_TSCONFIG;
case AuthIdRelationId: case AuthIdRelationId:
Assert(object->objectSubId == 0); Assert(object->objectSubId == 0);
return OCLASS_ROLE; return OCLASS_ROLE;
...@@ -2080,6 +2151,70 @@ getObjectDescription(const ObjectAddress *object) ...@@ -2080,6 +2151,70 @@ getObjectDescription(const ObjectAddress *object)
break; break;
} }
case OCLASS_TSPARSER:
{
HeapTuple tup;
tup = SearchSysCache(TSPARSEROID,
ObjectIdGetDatum(object->objectId),
0, 0, 0);
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search parser %u",
object->objectId);
appendStringInfo(&buffer, _("text search parser %s"),
NameStr(((Form_pg_ts_parser) GETSTRUCT(tup))->prsname));
ReleaseSysCache(tup);
break;
}
case OCLASS_TSDICT:
{
HeapTuple tup;
tup = SearchSysCache(TSDICTOID,
ObjectIdGetDatum(object->objectId),
0, 0, 0);
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search dictionary %u",
object->objectId);
appendStringInfo(&buffer, _("text search dictionary %s"),
NameStr(((Form_pg_ts_dict) GETSTRUCT(tup))->dictname));
ReleaseSysCache(tup);
break;
}
case OCLASS_TSTEMPLATE:
{
HeapTuple tup;
tup = SearchSysCache(TSTEMPLATEOID,
ObjectIdGetDatum(object->objectId),
0, 0, 0);
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search template %u",
object->objectId);
appendStringInfo(&buffer, _("text search template %s"),
NameStr(((Form_pg_ts_template) GETSTRUCT(tup))->tmplname));
ReleaseSysCache(tup);
break;
}
case OCLASS_TSCONFIG:
{
HeapTuple tup;
tup = SearchSysCache(TSCONFIGOID,
ObjectIdGetDatum(object->objectId),
0, 0, 0);
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search configuration %u",
object->objectId);
appendStringInfo(&buffer, _("text search configuration %s"),
NameStr(((Form_pg_ts_config) GETSTRUCT(tup))->cfgname));
ReleaseSysCache(tup);
break;
}
case OCLASS_ROLE: case OCLASS_ROLE:
{ {
appendStringInfo(&buffer, _("role %s"), appendStringInfo(&buffer, _("role %s"),
......
This diff is collapsed.
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 1996-2007, PostgreSQL Global Development Group * Copyright (c) 1996-2007, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.39 2007/07/25 22:16:18 tgl Exp $ * $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.40 2007/08/21 01:11:13 tgl Exp $
*/ */
CREATE VIEW pg_roles AS CREATE VIEW pg_roles AS
...@@ -382,3 +382,74 @@ CREATE VIEW pg_stat_bgwriter AS ...@@ -382,3 +382,74 @@ CREATE VIEW pg_stat_bgwriter AS
pg_stat_get_bgwriter_buf_written_checkpoints() AS buffers_checkpoint, pg_stat_get_bgwriter_buf_written_checkpoints() AS buffers_checkpoint,
pg_stat_get_bgwriter_buf_written_clean() AS buffers_clean, pg_stat_get_bgwriter_buf_written_clean() AS buffers_clean,
pg_stat_get_bgwriter_maxwritten_clean() AS maxwritten_clean; pg_stat_get_bgwriter_maxwritten_clean() AS maxwritten_clean;
-- Tsearch debug function. Defined here because it'd be pretty unwieldy
-- to put it into pg_proc.h
CREATE TYPE ts_debug AS (
"Alias" text,
"Description" text,
"Token" text,
"Dictionaries" regdictionary[],
"Lexized token" text
);
COMMENT ON TYPE ts_debug IS 'returned type from ts_debug() function';
CREATE FUNCTION ts_debug(regconfig, text)
RETURNS SETOF ts_debug AS
$$
SELECT
(
SELECT
tt.alias
FROM
pg_catalog.ts_token_type(
(SELECT cfgparser FROM pg_catalog.pg_ts_config WHERE oid = $1 )
) AS tt
WHERE
tt.tokid = parse.tokid
) AS "Alias",
(
SELECT
tt.description
FROM
pg_catalog.ts_token_type(
(SELECT cfgparser FROM pg_catalog.pg_ts_config WHERE oid = $1 )
) AS tt
WHERE
tt.tokid = parse.tokid
) AS "Description",
parse.token AS "Token",
ARRAY ( SELECT m.mapdict::pg_catalog.regdictionary
FROM pg_catalog.pg_ts_config_map AS m
WHERE m.mapcfg = $1 AND m.maptokentype = parse.tokid
ORDER BY m.mapcfg, m.maptokentype, m.mapseqno )
AS "Dictionaries",
(
SELECT
dl.mapdict::pg_catalog.regdictionary || ': ' || dl.lex::pg_catalog.text
FROM
( SELECT mapdict, pg_catalog.ts_lexize(mapdict, parse.token) AS lex
FROM pg_catalog.pg_ts_config_map AS m
WHERE m.mapcfg = $1 AND m.maptokentype = parse.tokid
ORDER BY m.mapcfg, m.maptokentype, m.mapseqno ) dl
WHERE dl.lex IS NOT NULL
LIMIT 1
) AS "Lexized token"
FROM pg_catalog.ts_parse(
(SELECT cfgparser FROM pg_catalog.pg_ts_config WHERE oid = $1 ), $2
) AS parse;
$$
LANGUAGE SQL RETURNS NULL ON NULL INPUT;
COMMENT ON FUNCTION ts_debug(regconfig,text) IS 'debug function for text search configuration';
CREATE FUNCTION ts_debug(text)
RETURNS SETOF ts_debug AS
$$
SELECT * FROM pg_catalog.ts_debug( pg_catalog.get_current_ts_config(), $1 );
$$
LANGUAGE SQL RETURNS NULL ON NULL INPUT;
COMMENT ON FUNCTION ts_debug(text) IS 'debug function for current text search configuration';
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# Makefile for backend/commands # Makefile for backend/commands
# #
# IDENTIFICATION # IDENTIFICATION
# $PostgreSQL: pgsql/src/backend/commands/Makefile,v 1.36 2007/04/26 16:13:09 neilc Exp $ # $PostgreSQL: pgsql/src/backend/commands/Makefile,v 1.37 2007/08/21 01:11:14 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -18,7 +18,8 @@ OBJS = aggregatecmds.o alter.o analyze.o async.o cluster.o comment.o \ ...@@ -18,7 +18,8 @@ OBJS = aggregatecmds.o alter.o analyze.o async.o cluster.o comment.o \
indexcmds.o lockcmds.o operatorcmds.o opclasscmds.o \ indexcmds.o lockcmds.o operatorcmds.o opclasscmds.o \
portalcmds.o prepare.o proclang.o \ portalcmds.o prepare.o proclang.o \
schemacmds.o sequence.o tablecmds.o tablespace.o trigger.o \ schemacmds.o sequence.o tablecmds.o tablespace.o trigger.o \
typecmds.o user.o vacuum.o vacuumlazy.o variable.o view.o tsearchcmds.o typecmds.o user.o vacuum.o vacuumlazy.o \
variable.o view.o
all: SUBSYS.o all: SUBSYS.o
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.24 2007/07/03 01:30:36 neilc Exp $ * $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.25 2007/08/21 01:11:14 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -138,6 +138,22 @@ ExecRenameStmt(RenameStmt *stmt) ...@@ -138,6 +138,22 @@ ExecRenameStmt(RenameStmt *stmt)
break; break;
} }
case OBJECT_TSPARSER:
RenameTSParser(stmt->object, stmt->newname);
break;
case OBJECT_TSDICTIONARY:
RenameTSDictionary(stmt->object, stmt->newname);
break;
case OBJECT_TSTEMPLATE:
RenameTSTemplate(stmt->object, stmt->newname);
break;
case OBJECT_TSCONFIGURATION:
RenameTSConfiguration(stmt->object, stmt->newname);
break;
default: default:
elog(ERROR, "unrecognized rename stmt type: %d", elog(ERROR, "unrecognized rename stmt type: %d",
(int) stmt->renameType); (int) stmt->renameType);
...@@ -240,6 +256,14 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt) ...@@ -240,6 +256,14 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
AlterTypeOwner(stmt->object, newowner); AlterTypeOwner(stmt->object, newowner);
break; break;
case OBJECT_TSDICTIONARY:
AlterTSDictionaryOwner(stmt->object, newowner);
break;
case OBJECT_TSCONFIGURATION:
AlterTSConfigurationOwner(stmt->object, newowner);
break;
default: default:
elog(ERROR, "unrecognized AlterOwnerStmt type: %d", elog(ERROR, "unrecognized AlterOwnerStmt type: %d",
(int) stmt->objectType); (int) stmt->objectType);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Copyright (c) 1996-2007, PostgreSQL Global Development Group * Copyright (c) 1996-2007, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.96 2007/02/01 19:10:25 momjian Exp $ * $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.97 2007/08/21 01:11:14 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -34,6 +34,10 @@ ...@@ -34,6 +34,10 @@
#include "catalog/pg_shdescription.h" #include "catalog/pg_shdescription.h"
#include "catalog/pg_tablespace.h" #include "catalog/pg_tablespace.h"
#include "catalog/pg_trigger.h" #include "catalog/pg_trigger.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
#include "catalog/pg_ts_parser.h"
#include "catalog/pg_ts_template.h"
#include "catalog/pg_type.h" #include "catalog/pg_type.h"
#include "commands/comment.h" #include "commands/comment.h"
#include "commands/dbcommands.h" #include "commands/dbcommands.h"
...@@ -78,6 +82,10 @@ static void CommentLargeObject(List *qualname, char *comment); ...@@ -78,6 +82,10 @@ static void CommentLargeObject(List *qualname, char *comment);
static void CommentCast(List *qualname, List *arguments, char *comment); static void CommentCast(List *qualname, List *arguments, char *comment);
static void CommentTablespace(List *qualname, char *comment); static void CommentTablespace(List *qualname, char *comment);
static void CommentRole(List *qualname, char *comment); static void CommentRole(List *qualname, char *comment);
static void CommentTSParser(List *qualname, char *comment);
static void CommentTSDictionary(List *qualname, char *comment);
static void CommentTSTemplate(List *qualname, char *comment);
static void CommentTSConfiguration(List *qualname, char *comment);
/* /*
...@@ -151,6 +159,18 @@ CommentObject(CommentStmt *stmt) ...@@ -151,6 +159,18 @@ CommentObject(CommentStmt *stmt)
case OBJECT_ROLE: case OBJECT_ROLE:
CommentRole(stmt->objname, stmt->comment); CommentRole(stmt->objname, stmt->comment);
break; break;
case OBJECT_TSPARSER:
CommentTSParser(stmt->objname, stmt->comment);
break;
case OBJECT_TSDICTIONARY:
CommentTSDictionary(stmt->objname, stmt->comment);
break;
case OBJECT_TSTEMPLATE:
CommentTSTemplate(stmt->objname, stmt->comment);
break;
case OBJECT_TSCONFIGURATION:
CommentTSConfiguration(stmt->objname, stmt->comment);
break;
default: default:
elog(ERROR, "unrecognized object type: %d", elog(ERROR, "unrecognized object type: %d",
(int) stmt->objtype); (int) stmt->objtype);
...@@ -1462,3 +1482,61 @@ CommentCast(List *qualname, List *arguments, char *comment) ...@@ -1462,3 +1482,61 @@ CommentCast(List *qualname, List *arguments, char *comment)
/* Call CreateComments() to create/drop the comments */ /* Call CreateComments() to create/drop the comments */
CreateComments(castOid, CastRelationId, 0, comment); CreateComments(castOid, CastRelationId, 0, comment);
} }
static void
CommentTSParser(List *qualname, char *comment)
{
Oid prsId;
prsId = TSParserGetPrsid(qualname, false);
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to comment on text search parser")));
CreateComments(prsId, TSParserRelationId, 0, comment);
}
static void
CommentTSDictionary(List *qualname, char *comment)
{
Oid dictId;
dictId = TSDictionaryGetDictid(qualname, false);
if (!pg_ts_dict_ownercheck(dictId, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TSDICTIONARY,
NameListToString(qualname));
CreateComments(dictId, TSDictionaryRelationId, 0, comment);
}
static void
CommentTSTemplate(List *qualname, char *comment)
{
Oid tmplId;
tmplId = TSTemplateGetTmplid(qualname, false);
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to comment on text search template")));
CreateComments(tmplId, TSTemplateRelationId, 0, comment);
}
static void
CommentTSConfiguration(List *qualname, char *comment)
{
Oid cfgId;
cfgId = TSConfigGetCfgid(qualname, false);
if (!pg_ts_config_ownercheck(cfgId, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TSCONFIGURATION,
NameListToString(qualname));
CreateComments(cfgId, TSConfigRelationId, 0, comment);
}
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.230 2007/07/17 05:02:00 neilc Exp $ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.231 2007/08/21 01:11:14 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -5079,8 +5079,13 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, ...@@ -5079,8 +5079,13 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
case OCLASS_LANGUAGE: case OCLASS_LANGUAGE:
case OCLASS_OPERATOR: case OCLASS_OPERATOR:
case OCLASS_OPCLASS: case OCLASS_OPCLASS:
case OCLASS_OPFAMILY:
case OCLASS_TRIGGER: case OCLASS_TRIGGER:
case OCLASS_SCHEMA: case OCLASS_SCHEMA:
case OCLASS_TSPARSER:
case OCLASS_TSDICT:
case OCLASS_TSTEMPLATE:
case OCLASS_TSCONFIG:
/* /*
* We don't expect any of these sorts of objects to depend on * We don't expect any of these sorts of objects to depend on
......
This diff is collapsed.
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.189 2007/06/18 21:40:58 tgl Exp $ * $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.190 2007/08/21 01:11:15 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -87,6 +87,7 @@ static const ScanKeyword ScanKeywords[] = { ...@@ -87,6 +87,7 @@ static const ScanKeyword ScanKeywords[] = {
{"commit", COMMIT, UNRESERVED_KEYWORD}, {"commit", COMMIT, UNRESERVED_KEYWORD},
{"committed", COMMITTED, UNRESERVED_KEYWORD}, {"committed", COMMITTED, UNRESERVED_KEYWORD},
{"concurrently", CONCURRENTLY, UNRESERVED_KEYWORD}, {"concurrently", CONCURRENTLY, UNRESERVED_KEYWORD},
{"configuration", CONFIGURATION, UNRESERVED_KEYWORD},
{"connection", CONNECTION, UNRESERVED_KEYWORD}, {"connection", CONNECTION, UNRESERVED_KEYWORD},
{"constraint", CONSTRAINT, RESERVED_KEYWORD}, {"constraint", CONSTRAINT, RESERVED_KEYWORD},
{"constraints", CONSTRAINTS, UNRESERVED_KEYWORD}, {"constraints", CONSTRAINTS, UNRESERVED_KEYWORD},
...@@ -124,6 +125,7 @@ static const ScanKeyword ScanKeywords[] = { ...@@ -124,6 +125,7 @@ static const ScanKeyword ScanKeywords[] = {
{"delimiter", DELIMITER, UNRESERVED_KEYWORD}, {"delimiter", DELIMITER, UNRESERVED_KEYWORD},
{"delimiters", DELIMITERS, UNRESERVED_KEYWORD}, {"delimiters", DELIMITERS, UNRESERVED_KEYWORD},
{"desc", DESC, RESERVED_KEYWORD}, {"desc", DESC, RESERVED_KEYWORD},
{"dictionary", DICTIONARY, UNRESERVED_KEYWORD},
{"disable", DISABLE_P, UNRESERVED_KEYWORD}, {"disable", DISABLE_P, UNRESERVED_KEYWORD},
{"discard", DISCARD, UNRESERVED_KEYWORD}, {"discard", DISCARD, UNRESERVED_KEYWORD},
{"distinct", DISTINCT, RESERVED_KEYWORD}, {"distinct", DISTINCT, RESERVED_KEYWORD},
...@@ -219,6 +221,7 @@ static const ScanKeyword ScanKeywords[] = { ...@@ -219,6 +221,7 @@ static const ScanKeyword ScanKeywords[] = {
{"location", LOCATION, UNRESERVED_KEYWORD}, {"location", LOCATION, UNRESERVED_KEYWORD},
{"lock", LOCK_P, UNRESERVED_KEYWORD}, {"lock", LOCK_P, UNRESERVED_KEYWORD},
{"login", LOGIN_P, UNRESERVED_KEYWORD}, {"login", LOGIN_P, UNRESERVED_KEYWORD},
{"mapping", MAPPING, UNRESERVED_KEYWORD},
{"match", MATCH, UNRESERVED_KEYWORD}, {"match", MATCH, UNRESERVED_KEYWORD},
{"maxvalue", MAXVALUE, UNRESERVED_KEYWORD}, {"maxvalue", MAXVALUE, UNRESERVED_KEYWORD},
{"minute", MINUTE_P, UNRESERVED_KEYWORD}, {"minute", MINUTE_P, UNRESERVED_KEYWORD},
...@@ -268,6 +271,7 @@ static const ScanKeyword ScanKeywords[] = { ...@@ -268,6 +271,7 @@ static const ScanKeyword ScanKeywords[] = {
{"overlay", OVERLAY, COL_NAME_KEYWORD}, {"overlay", OVERLAY, COL_NAME_KEYWORD},
{"owned", OWNED, UNRESERVED_KEYWORD}, {"owned", OWNED, UNRESERVED_KEYWORD},
{"owner", OWNER, UNRESERVED_KEYWORD}, {"owner", OWNER, UNRESERVED_KEYWORD},
{"parser", PARSER, UNRESERVED_KEYWORD},
{"partial", PARTIAL, UNRESERVED_KEYWORD}, {"partial", PARTIAL, UNRESERVED_KEYWORD},
{"password", PASSWORD, UNRESERVED_KEYWORD}, {"password", PASSWORD, UNRESERVED_KEYWORD},
{"placing", PLACING, RESERVED_KEYWORD}, {"placing", PLACING, RESERVED_KEYWORD},
...@@ -310,6 +314,7 @@ static const ScanKeyword ScanKeywords[] = { ...@@ -310,6 +314,7 @@ static const ScanKeyword ScanKeywords[] = {
{"savepoint", SAVEPOINT, UNRESERVED_KEYWORD}, {"savepoint", SAVEPOINT, UNRESERVED_KEYWORD},
{"schema", SCHEMA, UNRESERVED_KEYWORD}, {"schema", SCHEMA, UNRESERVED_KEYWORD},
{"scroll", SCROLL, UNRESERVED_KEYWORD}, {"scroll", SCROLL, UNRESERVED_KEYWORD},
{"search", SEARCH, UNRESERVED_KEYWORD},
{"second", SECOND_P, UNRESERVED_KEYWORD}, {"second", SECOND_P, UNRESERVED_KEYWORD},
{"security", SECURITY, UNRESERVED_KEYWORD}, {"security", SECURITY, UNRESERVED_KEYWORD},
{"select", SELECT, RESERVED_KEYWORD}, {"select", SELECT, RESERVED_KEYWORD},
...@@ -345,6 +350,7 @@ static const ScanKeyword ScanKeywords[] = { ...@@ -345,6 +350,7 @@ static const ScanKeyword ScanKeywords[] = {
{"temp", TEMP, UNRESERVED_KEYWORD}, {"temp", TEMP, UNRESERVED_KEYWORD},
{"template", TEMPLATE, UNRESERVED_KEYWORD}, {"template", TEMPLATE, UNRESERVED_KEYWORD},
{"temporary", TEMPORARY, UNRESERVED_KEYWORD}, {"temporary", TEMPORARY, UNRESERVED_KEYWORD},
{"text", TEXT, UNRESERVED_KEYWORD},
{"then", THEN, RESERVED_KEYWORD}, {"then", THEN, RESERVED_KEYWORD},
{"time", TIME, COL_NAME_KEYWORD}, {"time", TIME, COL_NAME_KEYWORD},
{"timestamp", TIMESTAMP, COL_NAME_KEYWORD}, {"timestamp", TIMESTAMP, COL_NAME_KEYWORD},
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.155 2007/06/06 23:00:37 tgl Exp $ * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.156 2007/08/21 01:11:15 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1554,6 +1554,8 @@ TypeCategory(Oid inType) ...@@ -1554,6 +1554,8 @@ TypeCategory(Oid inType)
case (REGOPERATOROID): case (REGOPERATOROID):
case (REGCLASSOID): case (REGCLASSOID):
case (REGTYPEOID): case (REGTYPEOID):
case (REGCONFIGOID):
case (REGDICTIONARYOID):
case (INT2OID): case (INT2OID):
case (INT4OID): case (INT4OID):
case (INT8OID): case (INT8OID):
...@@ -1672,7 +1674,9 @@ IsPreferredType(CATEGORY category, Oid type) ...@@ -1672,7 +1674,9 @@ IsPreferredType(CATEGORY category, Oid type)
type == REGOPEROID || type == REGOPEROID ||
type == REGOPERATOROID || type == REGOPERATOROID ||
type == REGCLASSOID || type == REGCLASSOID ||
type == REGTYPEOID) type == REGTYPEOID ||
type == REGCONFIGOID ||
type == REGDICTIONARYOID)
preftype = OIDOID; preftype = OIDOID;
else else
preftype = FLOAT8OID; preftype = FLOAT8OID;
......
#-------------------------------------------------------------------------
#
# Makefile for src/backend/snowball
#
# $PostgreSQL: pgsql/src/backend/snowball/Makefile,v 1.1 2007/08/21 01:11:15 tgl Exp $
#
#-------------------------------------------------------------------------
subdir = src/backend/snowball
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -I$(top_srcdir)/src/include/snowball \
-I$(top_srcdir)/src/include/snowball/libstemmer $(CPPFLAGS)
OBJS= dict_snowball.o api.o utilities.o \
stem_ISO_8859_1_danish.o \
stem_ISO_8859_1_dutch.o \
stem_ISO_8859_1_english.o \
stem_ISO_8859_1_finnish.o \
stem_ISO_8859_1_french.o \
stem_ISO_8859_1_german.o \
stem_ISO_8859_1_hungarian.o \
stem_ISO_8859_1_italian.o \
stem_ISO_8859_1_norwegian.o \
stem_ISO_8859_1_porter.o \
stem_ISO_8859_1_portuguese.o \
stem_ISO_8859_1_spanish.o \
stem_ISO_8859_1_swedish.o \
stem_ISO_8859_2_romanian.o \
stem_KOI8_R_russian.o \
stem_UTF_8_danish.o \
stem_UTF_8_dutch.o \
stem_UTF_8_english.o \
stem_UTF_8_finnish.o \
stem_UTF_8_french.o \
stem_UTF_8_german.o \
stem_UTF_8_hungarian.o \
stem_UTF_8_italian.o \
stem_UTF_8_norwegian.o \
stem_UTF_8_porter.o \
stem_UTF_8_portuguese.o \
stem_UTF_8_romanian.o \
stem_UTF_8_russian.o \
stem_UTF_8_spanish.o \
stem_UTF_8_swedish.o \
stem_UTF_8_turkish.o
# second column is name of latin dictionary, if different
LANGUAGES= \
danish danish \
dutch dutch \
english english \
finnish finnish \
french french \
german german \
hungarian hungarian \
italian italian \
norwegian norwegian \
portuguese portuguese \
romanian romanian \
russian english \
spanish spanish \
swedish swedish \
turkish turkish \
SQLSCRIPT= snowball_create.sql
DICTDIR=tsearch_data
ifdef VPATH
override VPATH := $(srcdir)/libstemmer:$(VPATH)
else
VPATH = $(srcdir)/libstemmer
endif
SHLIB_LINK := $(BE_DLLLIBS)
NAME := dict_snowball
SO_MAJOR_VERSION := 0
SO_MINOR_VERSION := 0
rpath =
all: all-shared-lib $(SQLSCRIPT)
include $(top_srcdir)/src/Makefile.shlib
$(SQLSCRIPT): Makefile snowball_func.sql.in snowball.sql.in
ifeq ($(enable_shared), yes)
echo '-- Language-specific snowball dictionaries' > $@
cat $(srcdir)/snowball_func.sql.in >> $@
@set $(LANGUAGES) ; \
while [ "$$#" -gt 0 ] ; \
do \
lang=$$1; shift; \
if [ -s $(srcdir)/stopwords/$${lang}.stop ] ; then \
stop=", StopWords=$${lang}" ; \
else \
stop=""; \
fi; \
nonlatdictname=$$lang; \
latdictname=$$1; shift; \
cat $(srcdir)/snowball.sql.in | \
sed -e "s#_DICTNAME_#$$lang#g" | \
sed -e "s#_CFGNAME_#$$lang#g" | \
sed -e "s#_LATDICTNAME_#$$latdictname#g" | \
sed -e "s#_NONLATDICTNAME_#$$nonlatdictname#g" | \
sed -e "s#_STOPWORDS_#$$stop#g" ; \
done >> $@
else
echo "-- No language-specific snowball dictionaries, for lack of shared library support" > $@
endif
install: all installdirs
ifeq ($(enable_shared), yes)
$(INSTALL_SHLIB) $(shlib) '$(DESTDIR)$(pkglibdir)/$(NAME)$(DLSUFFIX)'
endif
$(INSTALL_DATA) $(SQLSCRIPT) '$(DESTDIR)$(datadir)'
@set $(LANGUAGES) ; \
while [ "$$#" -gt 0 ] ; \
do \
lang=$$1; shift; shift; \
if [ -s $(srcdir)/stopwords/$${lang}.stop ] ; then \
$(INSTALL_DATA) $(srcdir)/stopwords/$${lang}.stop '$(DESTDIR)$(datadir)/$(DICTDIR)' ; \
fi \
done
installdirs:
$(mkinstalldirs) '$(DESTDIR)$(pkglibdir)' '$(DESTDIR)$(datadir)' '$(DESTDIR)$(datadir)/$(DICTDIR)'
uninstall:
rm -f '$(DESTDIR)$(pkglibdir)/$(NAME)$(DLSUFFIX)'
rm -f '$(DESTDIR)$(datadir)/$(SQLSCRIPT)'
@set $(LANGUAGES) ; \
while [ "$$#" -gt 0 ] ; \
do \
lang=$$1; shift; shift; \
if [ -s $(srcdir)/stopwords/$${lang}.stop ] ; then \
rm -f '$(DESTDIR)$(datadir)/$(DICTDIR)/'$${lang}.stop ; \
fi \
done
clean distclean maintainer-clean: clean-lib
rm -f $(OBJS) $(SQLSCRIPT)
Snowball-based stemming
-----------------------
This module uses the word stemming code developed by the Snowball project,
http://snowball.tartarus.org/
which is released by them under a BSD-style license.
The files under src/backend/snowball/libstemmer/ and
src/include/snowball/libstemmer/ are taken directly from their libstemmer_c
distribution, with only some minor adjustments of file inclusions. Note
that most of these files are in fact derived files, not master source.
The master sources are in the Snowball language, and are available along
with the Snowball-to-C compiler from the Snowball project. We choose to
include the derived files in the PostgreSQL distribution because most
installations will not have the Snowball compiler available.
To update the PostgreSQL sources from a new Snowball libstemmer_c
distribution:
1. Copy the *.c files in libstemmer_c/src_c/ to src/backend/snowball/libstemmer
with replacement of "../runtime/header.h" by "header.h", for example
for f in libstemmer_c/src_c/*.c
do
sed 's|\.\./runtime/header\.h|header.h|' $f >libstemmer/`basename $f`
done
(Alternatively, if you rebuild the stemmer files from the master Snowball
sources, just omit "-r ../runtime" from the Snowball compiler switches.)
2. Copy the *.c files in libstemmer_c/runtime/ to
src/backend/snowball/libstemmer, and edit them to remove direct inclusions
of system headers such as <stdio.h> --- they should only include "header.h".
(This removal avoids portability problems on some platforms where <stdio.h>
is sensitive to largefile compilation options.)
3. Copy the *.h files in libstemmer_c/src_c/ and libstemmer_c/runtime/
to src/include/snowball/libstemmer. At this writing the header files
do not require any changes.
4. Check whether any stemmer modules have been added or removed. If so, edit
the OBJS list in Makefile, the list of #include's in dict_snowball.c, and the
stemmer_modules[] table in dict_snowball.c.
5. The various stopword files in stopwords/ must be downloaded
individually from pages on the snowball.tartarus.org website.
Be careful that these files must be stored in UTF-8 encoding.
This diff is collapsed.
#include "header.h"
extern struct SN_env * SN_create_env(int S_size, int I_size, int B_size)
{
struct SN_env * z = (struct SN_env *) calloc(1, sizeof(struct SN_env));
if (z == NULL) return NULL;
z->p = create_s();
if (z->p == NULL) goto error;
if (S_size)
{
int i;
z->S = (symbol * *) calloc(S_size, sizeof(symbol *));
if (z->S == NULL) goto error;
for (i = 0; i < S_size; i++)
{
z->S[i] = create_s();
if (z->S[i] == NULL) goto error;
}
}
if (I_size)
{
z->I = (int *) calloc(I_size, sizeof(int));
if (z->I == NULL) goto error;
}
if (B_size)
{
z->B = (unsigned char *) calloc(B_size, sizeof(unsigned char));
if (z->B == NULL) goto error;
}
return z;
error:
SN_close_env(z, S_size);
return NULL;
}
extern void SN_close_env(struct SN_env * z, int S_size)
{
if (z == NULL) return;
if (S_size)
{
int i;
for (i = 0; i < S_size; i++)
{
lose_s(z->S[i]);
}
free(z->S);
}
free(z->I);
free(z->B);
if (z->p) lose_s(z->p);
free(z);
}
extern int SN_set_current(struct SN_env * z, int size, const symbol * s)
{
int err = replace_s(z, 0, z->l, size, s, NULL);
z->c = 0;
return err;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
-- $PostgreSQL: pgsql/src/backend/snowball/snowball.sql.in,v 1.1 2007/08/21 01:11:16 tgl Exp $$
-- text search configuration for _CFGNAME_ language
CREATE TEXT SEARCH DICTIONARY _DICTNAME_
(TEMPLATE = snowball,
OPTION = 'Language=_DICTNAME__STOPWORDS_');
COMMENT ON TEXT SEARCH DICTIONARY _DICTNAME_ IS 'Snowball stemmer for _DICTNAME_ language';
CREATE TEXT SEARCH CONFIGURATION _CFGNAME_
(PARSER = default);
COMMENT ON TEXT SEARCH CONFIGURATION _CFGNAME_ IS 'Configuration for _CFGNAME_ language';
ALTER TEXT SEARCH CONFIGURATION _CFGNAME_ ADD MAPPING
FOR email, url, host, sfloat, version, uri, file, float, int, uint
WITH simple;
ALTER TEXT SEARCH CONFIGURATION _CFGNAME_ ADD MAPPING
FOR lhword, lpart_hword, lword
WITH _LATDICTNAME_;
ALTER TEXT SEARCH CONFIGURATION _CFGNAME_ ADD MAPPING
FOR hword, nlhword, nlpart_hword, nlword, word, part_hword
WITH _NONLATDICTNAME_;
-- $PostgreSQL: pgsql/src/backend/snowball/snowball_func.sql.in,v 1.1 2007/08/21 01:11:16 tgl Exp $$
SET search_path = pg_catalog;
CREATE FUNCTION dsnowball_init(INTERNAL)
RETURNS INTERNAL AS '$libdir/dict_snowball', 'dsnowball_init'
LANGUAGE C STRICT;
CREATE FUNCTION dsnowball_lexize(INTERNAL, INTERNAL, INTERNAL, INTERNAL)
RETURNS INTERNAL AS '$libdir/dict_snowball', 'dsnowball_lexize'
LANGUAGE C STRICT;
CREATE TEXT SEARCH TEMPLATE snowball
(INIT = dsnowball_init,
LEXIZE = dsnowball_lexize);
COMMENT ON TEXT SEARCH TEMPLATE snowball IS 'Snowball stemmer';
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
skies sky
booking book
bookings book
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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