Skip to content

Commit

Permalink
Tsearch2 functionality migrates to core. The bulk of this work is by
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tglsfdc committed Aug 21, 2007
1 parent 4e94d1f commit 140d4eb
Show file tree
Hide file tree
Showing 200 changed files with 54,388 additions and 147 deletions.
30 changes: 26 additions & 4 deletions doc/src/sgml/datatype.sgml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- $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">
<title id="datatype-title">Data Types</title>
Expand Down Expand Up @@ -3484,6 +3484,14 @@ SET xmloption TO { DOCUMENT | CONTENT };
<primary>regtype</primary>
</indexterm>

<indexterm zone="datatype-oid">
<primary>regconfig</primary>
</indexterm>

<indexterm zone="datatype-oid">
<primary>regdictionary</primary>
</indexterm>

<indexterm zone="datatype-oid">
<primary>xid</primary>
</indexterm>
Expand All @@ -3505,9 +3513,9 @@ SET xmloption TO { DOCUMENT | CONTENT };
configuration variable is enabled. Type <type>oid</> represents
an object identifier. There are also several alias types for
<type>oid</>: <type>regproc</>, <type>regprocedure</>,
<type>regoper</>, <type>regoperator</>, <type>regclass</>, and
<type>regtype</>. <xref linkend="datatype-oid-table"> shows an
overview.
<type>regoper</>, <type>regoperator</>, <type>regclass</>,
<type>regtype</>, <type>regconfig</>, and <type>regdictionary</>.
<xref linkend="datatype-oid-table"> shows an overview.
</para>

<para>
Expand Down Expand Up @@ -3614,6 +3622,20 @@ SELECT * FROM pg_attribute
<entry>data type name</entry>
<entry><literal>integer</></entry>
</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>
</tgroup>
</table>
Expand Down
10 changes: 6 additions & 4 deletions doc/src/sgml/func.sgml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- $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">
<title>Functions and Operators</title>
Expand Down Expand Up @@ -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
checked. If you want to test an object by name, it is convenient to use
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>
SELECT pg_type_is_visible('myschema.widget'::regtype);
</programlisting>
Expand Down Expand Up @@ -11255,8 +11257,8 @@ SELECT set_config('log_statement_stats', 'off', false);
<para>
<function>pg_rotate_logfile</> signals the log-file manager to switch
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
subprocess.
log collector is running, since otherwise there is no log-file manager
subprocess.
</para>

<indexterm zone="functions-admin">
Expand Down
5 changes: 4 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# 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 $
#
#-------------------------------------------------------------------------

Expand All @@ -18,6 +18,7 @@ all install installdirs uninstall distprep:
$(MAKE) -C timezone $@
$(MAKE) -C backend $@
$(MAKE) -C backend/utils/mb/conversion_procs $@
$(MAKE) -C backend/snowball $@
$(MAKE) -C include $@
$(MAKE) -C interfaces $@
$(MAKE) -C bin $@
Expand Down Expand Up @@ -47,6 +48,7 @@ clean:
$(MAKE) -C port $@
$(MAKE) -C timezone $@
$(MAKE) -C backend $@
$(MAKE) -C backend/snowball $@
$(MAKE) -C include $@
$(MAKE) -C interfaces $@
$(MAKE) -C bin $@
Expand All @@ -60,6 +62,7 @@ distclean maintainer-clean:
-$(MAKE) -C port $@
-$(MAKE) -C timezone $@
-$(MAKE) -C backend $@
-$(MAKE) -C backend/snowball $@
-$(MAKE) -C include $@
-$(MAKE) -C interfaces $@
-$(MAKE) -C bin $@
Expand Down
9 changes: 6 additions & 3 deletions src/backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#
# 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 $
#
#-------------------------------------------------------------------------

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

DIRS = access bootstrap catalog parser commands executor lib libpq \
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)

Expand Down Expand Up @@ -166,6 +167,7 @@ ifeq ($(MAKE_DLL), true)
endif
endif
$(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_ident.conf.sample '$(DESTDIR)$(datadir)/pg_ident.conf.sample'
$(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample'
Expand Down Expand Up @@ -220,6 +222,7 @@ ifeq ($(MAKE_DLL), true)
endif
endif
$(MAKE) -C catalog uninstall-data
$(MAKE) -C tsearch uninstall-data
rm -f '$(DESTDIR)$(datadir)/pg_hba.conf.sample' \
'$(DESTDIR)$(datadir)/pg_ident.conf.sample' \
'$(DESTDIR)$(datadir)/postgresql.conf.sample' \
Expand Down
13 changes: 11 additions & 2 deletions src/backend/access/gin/ginarrayproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* 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"
Expand Down Expand Up @@ -62,7 +62,7 @@ ginarrayextract(PG_FUNCTION_ARGS)

if ( *nentries == 0 && PG_NARGS() == 3 )
{
switch( PG_GETARG_UINT16(2) )
switch( PG_GETARG_UINT16(2) ) /* StrategyNumber */
{
case GinOverlapStrategy:
*nentries = -1; /* nobody can be found */
Expand All @@ -79,6 +79,15 @@ ginarrayextract(PG_FUNCTION_ARGS)
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
ginarrayconsistent(PG_FUNCTION_ARGS)
{
Expand Down
4 changes: 3 additions & 1 deletion src/backend/catalog/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# 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 $
#
#-------------------------------------------------------------------------

Expand Down Expand Up @@ -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_database.h pg_tablespace.h pg_pltemplate.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 \
)

Expand Down
75 changes: 72 additions & 3 deletions src/backend/catalog/aclchk.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
*
* 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
* See acl.h.
Expand All @@ -34,6 +34,8 @@
#include "catalog/pg_proc.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
#include "commands/dbcommands.h"
#include "miscadmin.h"
#include "parser/parse_func.h"
Expand Down Expand Up @@ -1416,7 +1418,11 @@ static const char *const no_priv_msg[MAX_ACL_KIND] =
/* ACL_KIND_CONVERSION */
gettext_noop("permission denied for conversion %s"),
/* 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] =
Expand Down Expand Up @@ -1444,7 +1450,11 @@ static const char *const not_owner_msg[MAX_ACL_KIND] =
/* ACL_KIND_CONVERSION */
gettext_noop("must be owner of conversion %s"),
/* 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")
};


Expand Down Expand Up @@ -2297,6 +2307,65 @@ pg_opfamily_ownercheck(Oid opf_oid, Oid roleid)
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).
*/
Expand Down
Loading

0 comments on commit 140d4eb

Please sign in to comment.