Skip to content

Commit 140d4eb

Browse files
committed
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.
1 parent 4e94d1f commit 140d4eb

File tree

200 files changed

+54388
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+54388
-147
lines changed

doc/src/sgml/datatype.sgml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.206 2007/08/04 01:26:53 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.207 2007/08/21 01:11:11 tgl Exp $ -->
22

33
<chapter id="datatype">
44
<title id="datatype-title">Data Types</title>
@@ -3484,6 +3484,14 @@ SET xmloption TO { DOCUMENT | CONTENT };
34843484
<primary>regtype</primary>
34853485
</indexterm>
34863486

3487+
<indexterm zone="datatype-oid">
3488+
<primary>regconfig</primary>
3489+
</indexterm>
3490+
3491+
<indexterm zone="datatype-oid">
3492+
<primary>regdictionary</primary>
3493+
</indexterm>
3494+
34873495
<indexterm zone="datatype-oid">
34883496
<primary>xid</primary>
34893497
</indexterm>
@@ -3505,9 +3513,9 @@ SET xmloption TO { DOCUMENT | CONTENT };
35053513
configuration variable is enabled. Type <type>oid</> represents
35063514
an object identifier. There are also several alias types for
35073515
<type>oid</>: <type>regproc</>, <type>regprocedure</>,
3508-
<type>regoper</>, <type>regoperator</>, <type>regclass</>, and
3509-
<type>regtype</>. <xref linkend="datatype-oid-table"> shows an
3510-
overview.
3516+
<type>regoper</>, <type>regoperator</>, <type>regclass</>,
3517+
<type>regtype</>, <type>regconfig</>, and <type>regdictionary</>.
3518+
<xref linkend="datatype-oid-table"> shows an overview.
35113519
</para>
35123520

35133521
<para>
@@ -3614,6 +3622,20 @@ SELECT * FROM pg_attribute
36143622
<entry>data type name</entry>
36153623
<entry><literal>integer</></entry>
36163624
</row>
3625+
3626+
<row>
3627+
<entry><type>regconfig</></entry>
3628+
<entry><structname>pg_ts_config</></entry>
3629+
<entry>text search configuration</entry>
3630+
<entry><literal>english</></entry>
3631+
</row>
3632+
3633+
<row>
3634+
<entry><type>regdictionary</></entry>
3635+
<entry><structname>pg_ts_dict</></entry>
3636+
<entry>text search dictionary</entry>
3637+
<entry><literal>simple</></entry>
3638+
</row>
36173639
</tbody>
36183640
</tgroup>
36193641
</table>

doc/src/sgml/func.sgml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.387 2007/08/19 03:23:30 adunstan Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.388 2007/08/21 01:11:11 tgl Exp $ -->
22

33
<chapter id="functions">
44
<title>Functions and Operators</title>
@@ -10794,7 +10794,9 @@ SELECT relname FROM pg_class WHERE pg_table_is_visible(oid);
1079410794
All these functions require object OIDs to identify the object to be
1079510795
checked. If you want to test an object by name, it is convenient to use
1079610796
the OID alias types (<type>regclass</>, <type>regtype</>,
10797-
<type>regprocedure</>, or <type>regoperator</>), for example:
10797+
<type>regprocedure</>, <type>regoperator</>, <type>regconfig</>,
10798+
or <type>regdictionary</>),
10799+
for example:
1079810800
<programlisting>
1079910801
SELECT pg_type_is_visible('myschema.widget'::regtype);
1080010802
</programlisting>
@@ -11255,8 +11257,8 @@ SELECT set_config('log_statement_stats', 'off', false);
1125511257
<para>
1125611258
<function>pg_rotate_logfile</> signals the log-file manager to switch
1125711259
to a new output file immediately. This works only when the built-in
11258-
log collector is running, since otherwise there is no log-file manager
11259-
subprocess.
11260+
log collector is running, since otherwise there is no log-file manager
11261+
subprocess.
1126011262
</para>
1126111263

1126211264
<indexterm zone="functions-admin">

src/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $PostgreSQL: pgsql/src/Makefile,v 1.41 2007/01/20 17:16:09 petere Exp $
7+
# $PostgreSQL: pgsql/src/Makefile,v 1.42 2007/08/21 01:11:12 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -18,6 +18,7 @@ all install installdirs uninstall distprep:
1818
$(MAKE) -C timezone $@
1919
$(MAKE) -C backend $@
2020
$(MAKE) -C backend/utils/mb/conversion_procs $@
21+
$(MAKE) -C backend/snowball $@
2122
$(MAKE) -C include $@
2223
$(MAKE) -C interfaces $@
2324
$(MAKE) -C bin $@
@@ -47,6 +48,7 @@ clean:
4748
$(MAKE) -C port $@
4849
$(MAKE) -C timezone $@
4950
$(MAKE) -C backend $@
51+
$(MAKE) -C backend/snowball $@
5052
$(MAKE) -C include $@
5153
$(MAKE) -C interfaces $@
5254
$(MAKE) -C bin $@
@@ -60,6 +62,7 @@ distclean maintainer-clean:
6062
-$(MAKE) -C port $@
6163
-$(MAKE) -C timezone $@
6264
-$(MAKE) -C backend $@
65+
-$(MAKE) -C backend/snowball $@
6366
-$(MAKE) -C include $@
6467
-$(MAKE) -C interfaces $@
6568
-$(MAKE) -C bin $@

src/backend/Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
#
33
# Makefile for the postgres backend
44
#
5-
# Copyright (c) 1994, Regents of the University of California
5+
# Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
6+
# Portions Copyright (c) 1994, Regents of the University of California
67
#
7-
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.123 2007/07/24 09:00:27 mha Exp $
8+
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.124 2007/08/21 01:11:12 tgl Exp $
89
#
910
#-------------------------------------------------------------------------
1011

@@ -15,7 +16,7 @@ include $(top_builddir)/src/Makefile.global
1516

1617
DIRS = access bootstrap catalog parser commands executor lib libpq \
1718
main nodes optimizer port postmaster regex rewrite \
18-
storage tcop utils $(top_builddir)/src/timezone
19+
storage tcop tsearch utils $(top_builddir)/src/timezone
1920

2021
SUBSYSOBJS = $(DIRS:%=%/SUBSYS.o)
2122

@@ -166,6 +167,7 @@ ifeq ($(MAKE_DLL), true)
166167
endif
167168
endif
168169
$(MAKE) -C catalog install-data
170+
$(MAKE) -C tsearch install-data
169171
$(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample '$(DESTDIR)$(datadir)/pg_hba.conf.sample'
170172
$(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample '$(DESTDIR)$(datadir)/pg_ident.conf.sample'
171173
$(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample'
@@ -220,6 +222,7 @@ ifeq ($(MAKE_DLL), true)
220222
endif
221223
endif
222224
$(MAKE) -C catalog uninstall-data
225+
$(MAKE) -C tsearch uninstall-data
223226
rm -f '$(DESTDIR)$(datadir)/pg_hba.conf.sample' \
224227
'$(DESTDIR)$(datadir)/pg_ident.conf.sample' \
225228
'$(DESTDIR)$(datadir)/postgresql.conf.sample' \

src/backend/access/gin/ginarrayproc.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gin/ginarrayproc.c,v 1.9 2007/01/31 15:09:45 teodor Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gin/ginarrayproc.c,v 1.10 2007/08/21 01:11:12 tgl Exp $
1212
*-------------------------------------------------------------------------
1313
*/
1414
#include "postgres.h"
@@ -62,7 +62,7 @@ ginarrayextract(PG_FUNCTION_ARGS)
6262

6363
if ( *nentries == 0 && PG_NARGS() == 3 )
6464
{
65-
switch( PG_GETARG_UINT16(2) )
65+
switch( PG_GETARG_UINT16(2) ) /* StrategyNumber */
6666
{
6767
case GinOverlapStrategy:
6868
*nentries = -1; /* nobody can be found */
@@ -79,6 +79,15 @@ ginarrayextract(PG_FUNCTION_ARGS)
7979
PG_RETURN_POINTER(entries);
8080
}
8181

82+
Datum
83+
ginqueryarrayextract(PG_FUNCTION_ARGS)
84+
{
85+
PG_RETURN_DATUM(DirectFunctionCall3(ginarrayextract,
86+
PG_GETARG_DATUM(0),
87+
PG_GETARG_DATUM(1),
88+
PG_GETARG_DATUM(2)));
89+
}
90+
8291
Datum
8392
ginarrayconsistent(PG_FUNCTION_ARGS)
8493
{

src/backend/catalog/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Makefile for backend/catalog
44
#
5-
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.64 2007/04/02 03:49:37 tgl Exp $
5+
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.65 2007/08/21 01:11:13 tgl Exp $
66
#
77
#-------------------------------------------------------------------------
88

@@ -35,6 +35,8 @@ POSTGRES_BKI_SRCS = $(addprefix $(top_srcdir)/src/include/catalog/,\
3535
pg_enum.h pg_namespace.h pg_conversion.h pg_depend.h \
3636
pg_database.h pg_tablespace.h pg_pltemplate.h \
3737
pg_authid.h pg_auth_members.h pg_shdepend.h pg_shdescription.h \
38+
pg_ts_config.h pg_ts_config_map.h pg_ts_dict.h \
39+
pg_ts_parser.h pg_ts_template.h \
3840
toasting.h indexing.h \
3941
)
4042

src/backend/catalog/aclchk.c

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.139 2007/04/20 02:37:37 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.140 2007/08/21 01:11:13 tgl Exp $
1212
*
1313
* NOTES
1414
* See acl.h.
@@ -34,6 +34,8 @@
3434
#include "catalog/pg_proc.h"
3535
#include "catalog/pg_tablespace.h"
3636
#include "catalog/pg_type.h"
37+
#include "catalog/pg_ts_config.h"
38+
#include "catalog/pg_ts_dict.h"
3739
#include "commands/dbcommands.h"
3840
#include "miscadmin.h"
3941
#include "parser/parse_func.h"
@@ -1416,7 +1418,11 @@ static const char *const no_priv_msg[MAX_ACL_KIND] =
14161418
/* ACL_KIND_CONVERSION */
14171419
gettext_noop("permission denied for conversion %s"),
14181420
/* ACL_KIND_TABLESPACE */
1419-
gettext_noop("permission denied for tablespace %s")
1421+
gettext_noop("permission denied for tablespace %s"),
1422+
/* ACL_KIND_TSDICTIONARY */
1423+
gettext_noop("permission denied for text search dictionary %s"),
1424+
/* ACL_KIND_TSCONFIGURATION */
1425+
gettext_noop("permission denied for text search configuration %s")
14201426
};
14211427

14221428
static const char *const not_owner_msg[MAX_ACL_KIND] =
@@ -1444,7 +1450,11 @@ static const char *const not_owner_msg[MAX_ACL_KIND] =
14441450
/* ACL_KIND_CONVERSION */
14451451
gettext_noop("must be owner of conversion %s"),
14461452
/* ACL_KIND_TABLESPACE */
1447-
gettext_noop("must be owner of tablespace %s")
1453+
gettext_noop("must be owner of tablespace %s"),
1454+
/* ACL_KIND_TSDICTIONARY */
1455+
gettext_noop("must be owner of text search dictionary %s"),
1456+
/* ACL_KIND_TSCONFIGURATION */
1457+
gettext_noop("must be owner of text search configuration %s")
14481458
};
14491459

14501460

@@ -2297,6 +2307,65 @@ pg_opfamily_ownercheck(Oid opf_oid, Oid roleid)
22972307
return has_privs_of_role(roleid, ownerId);
22982308
}
22992309

2310+
/*
2311+
* Ownership check for a text search dictionary (specified by OID).
2312+
*/
2313+
bool
2314+
pg_ts_dict_ownercheck(Oid dict_oid, Oid roleid)
2315+
{
2316+
HeapTuple tuple;
2317+
Oid ownerId;
2318+
2319+
/* Superusers bypass all permission checking. */
2320+
if (superuser_arg(roleid))
2321+
return true;
2322+
2323+
tuple = SearchSysCache(TSDICTOID,
2324+
ObjectIdGetDatum(dict_oid),
2325+
0, 0, 0);
2326+
if (!HeapTupleIsValid(tuple))
2327+
ereport(ERROR,
2328+
(errcode(ERRCODE_UNDEFINED_OBJECT),
2329+
errmsg("text search dictionary with OID %u does not exist",
2330+
dict_oid)));
2331+
2332+
ownerId = ((Form_pg_ts_dict) GETSTRUCT(tuple))->dictowner;
2333+
2334+
ReleaseSysCache(tuple);
2335+
2336+
return has_privs_of_role(roleid, ownerId);
2337+
}
2338+
2339+
/*
2340+
* Ownership check for a text search configuration (specified by OID).
2341+
*/
2342+
bool
2343+
pg_ts_config_ownercheck(Oid cfg_oid, Oid roleid)
2344+
{
2345+
HeapTuple tuple;
2346+
Oid ownerId;
2347+
2348+
/* Superusers bypass all permission checking. */
2349+
if (superuser_arg(roleid))
2350+
return true;
2351+
2352+
tuple = SearchSysCache(TSCONFIGOID,
2353+
ObjectIdGetDatum(cfg_oid),
2354+
0, 0, 0);
2355+
if (!HeapTupleIsValid(tuple))
2356+
ereport(ERROR,
2357+
(errcode(ERRCODE_UNDEFINED_OBJECT),
2358+
errmsg("text search configuration with OID %u does not exist",
2359+
cfg_oid)));
2360+
2361+
ownerId = ((Form_pg_ts_config) GETSTRUCT(tuple))->cfgowner;
2362+
2363+
ReleaseSysCache(tuple);
2364+
2365+
return has_privs_of_role(roleid, ownerId);
2366+
}
2367+
2368+
23002369
/*
23012370
* Ownership check for a database (specified by OID).
23022371
*/

0 commit comments

Comments
 (0)