mirror of https://github.com/citusdata/citus.git
Allow all possible option types for text search objects (#5838)
parent
6c05e4b35c
commit
9f204600af
|
@ -12,6 +12,7 @@
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
|
#include "commands/defrem.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
|
|
||||||
#include "distributed/citus_ruleutils.h"
|
#include "distributed/citus_ruleutils.h"
|
||||||
|
@ -78,8 +79,6 @@ DeparseCreateTextSearchDictionaryStmt(Node *node)
|
||||||
* AppendDefElemList is a helper to append a comma separated list of definitions to a
|
* AppendDefElemList is a helper to append a comma separated list of definitions to a
|
||||||
* define statement.
|
* define statement.
|
||||||
*
|
*
|
||||||
* Currently only supports String and TypeName entries. Will error on others.
|
|
||||||
*
|
|
||||||
* The extra objectName parameter is used to create meaningful error messages.
|
* The extra objectName parameter is used to create meaningful error messages.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
|
@ -109,32 +108,11 @@ AppendDefElemList(StringInfo buf, List *defelems, char *objectName)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* extract identifier from defelem */
|
/* extract value from defelem */
|
||||||
const char *identifier = NULL;
|
const char *value = defGetString(defelem);
|
||||||
switch (nodeTag(defelem->arg))
|
|
||||||
{
|
|
||||||
case T_String:
|
|
||||||
{
|
|
||||||
identifier = quote_identifier(strVal(defelem->arg));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case T_TypeName:
|
|
||||||
{
|
|
||||||
TypeName *typeName = castNode(TypeName, defelem->arg);
|
|
||||||
identifier = NameListToQuotedString(typeName->names);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
ereport(ERROR, (errmsg("unexpected argument during deparsing of "
|
|
||||||
"TEXT SEARCH %s definition", objectName)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* stringify */
|
/* stringify */
|
||||||
appendStringInfo(buf, "%s = %s", defelem->defname, identifier);
|
appendStringInfo(buf, "%s = %s", defelem->defname, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -619,6 +619,83 @@ $$);
|
||||||
ERROR: text search dictionary "my_turkish_dict" does not exist
|
ERROR: text search dictionary "my_turkish_dict" does not exist
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
|
-- test different templates that are used in dictionaries
|
||||||
|
CREATE TEXT SEARCH DICTIONARY simple_dict (
|
||||||
|
TEMPLATE = pg_catalog.simple,
|
||||||
|
STOPWORDS = english,
|
||||||
|
accept = false
|
||||||
|
);
|
||||||
|
SELECT COUNT(DISTINCT result)=1 FROM run_command_on_all_nodes($$
|
||||||
|
SELECT ROW(dictname, dictnamespace::regnamespace, dictowner::regrole, tmplname, dictinitoption)
|
||||||
|
FROM pg_ts_dict d JOIN pg_ts_template t ON ( d.dicttemplate = t.oid )
|
||||||
|
WHERE dictname = 'simple_dict';
|
||||||
|
$$);
|
||||||
|
?column?
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
CREATE TEXT SEARCH DICTIONARY synonym_dict (
|
||||||
|
template=synonym,
|
||||||
|
synonyms='synonym_sample',
|
||||||
|
casesensitive=1
|
||||||
|
);
|
||||||
|
SELECT COUNT(DISTINCT result)=1 FROM run_command_on_all_nodes($$
|
||||||
|
SELECT ROW(dictname, dictnamespace::regnamespace, dictowner::regrole, tmplname, dictinitoption)
|
||||||
|
FROM pg_ts_dict d JOIN pg_ts_template t ON ( d.dicttemplate = t.oid )
|
||||||
|
WHERE dictname = 'synonym_dict';
|
||||||
|
$$);
|
||||||
|
?column?
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
CREATE TEXT SEARCH DICTIONARY thesaurus_dict (
|
||||||
|
TEMPLATE = thesaurus,
|
||||||
|
DictFile = thesaurus_sample,
|
||||||
|
Dictionary = pg_catalog.english_stem
|
||||||
|
);
|
||||||
|
SELECT COUNT(DISTINCT result)=1 FROM run_command_on_all_nodes($$
|
||||||
|
SELECT ROW(dictname, dictnamespace::regnamespace, dictowner::regrole, tmplname, dictinitoption)
|
||||||
|
FROM pg_ts_dict d JOIN pg_ts_template t ON ( d.dicttemplate = t.oid )
|
||||||
|
WHERE dictname = 'thesaurus_dict';
|
||||||
|
$$);
|
||||||
|
?column?
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
CREATE TEXT SEARCH DICTIONARY ispell_dict (
|
||||||
|
TEMPLATE = ispell,
|
||||||
|
DictFile = ispell_sample,
|
||||||
|
AffFile = ispell_sample,
|
||||||
|
Stopwords = english
|
||||||
|
);
|
||||||
|
SELECT COUNT(DISTINCT result)=1 FROM run_command_on_all_nodes($$
|
||||||
|
SELECT ROW(dictname, dictnamespace::regnamespace, dictowner::regrole, tmplname, dictinitoption)
|
||||||
|
FROM pg_ts_dict d JOIN pg_ts_template t ON ( d.dicttemplate = t.oid )
|
||||||
|
WHERE dictname = 'ispell_dict';
|
||||||
|
$$);
|
||||||
|
?column?
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
CREATE TEXT SEARCH DICTIONARY snowball_dict (
|
||||||
|
TEMPLATE = snowball,
|
||||||
|
Language = english,
|
||||||
|
StopWords = english
|
||||||
|
);
|
||||||
|
SELECT COUNT(DISTINCT result)=1 FROM run_command_on_all_nodes($$
|
||||||
|
SELECT ROW(dictname, dictnamespace::regnamespace, dictowner::regrole, tmplname, dictinitoption)
|
||||||
|
FROM pg_ts_dict d JOIN pg_ts_template t ON ( d.dicttemplate = t.oid )
|
||||||
|
WHERE dictname = 'snowball_dict';
|
||||||
|
$$);
|
||||||
|
?column?
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
SET client_min_messages TO 'warning';
|
SET client_min_messages TO 'warning';
|
||||||
DROP SCHEMA text_search, text_search2, "Text Search Requiring Quote's" CASCADE;
|
DROP SCHEMA text_search, text_search2, "Text Search Requiring Quote's" CASCADE;
|
||||||
DROP ROLE text_search_owner;
|
DROP ROLE text_search_owner;
|
||||||
|
|
|
@ -345,6 +345,62 @@ SELECT result FROM run_command_on_all_nodes($$
|
||||||
SELECT 'my_turkish_dict'::regdictionary;
|
SELECT 'my_turkish_dict'::regdictionary;
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
|
-- test different templates that are used in dictionaries
|
||||||
|
CREATE TEXT SEARCH DICTIONARY simple_dict (
|
||||||
|
TEMPLATE = pg_catalog.simple,
|
||||||
|
STOPWORDS = english,
|
||||||
|
accept = false
|
||||||
|
);
|
||||||
|
SELECT COUNT(DISTINCT result)=1 FROM run_command_on_all_nodes($$
|
||||||
|
SELECT ROW(dictname, dictnamespace::regnamespace, dictowner::regrole, tmplname, dictinitoption)
|
||||||
|
FROM pg_ts_dict d JOIN pg_ts_template t ON ( d.dicttemplate = t.oid )
|
||||||
|
WHERE dictname = 'simple_dict';
|
||||||
|
$$);
|
||||||
|
|
||||||
|
CREATE TEXT SEARCH DICTIONARY synonym_dict (
|
||||||
|
template=synonym,
|
||||||
|
synonyms='synonym_sample',
|
||||||
|
casesensitive=1
|
||||||
|
);
|
||||||
|
SELECT COUNT(DISTINCT result)=1 FROM run_command_on_all_nodes($$
|
||||||
|
SELECT ROW(dictname, dictnamespace::regnamespace, dictowner::regrole, tmplname, dictinitoption)
|
||||||
|
FROM pg_ts_dict d JOIN pg_ts_template t ON ( d.dicttemplate = t.oid )
|
||||||
|
WHERE dictname = 'synonym_dict';
|
||||||
|
$$);
|
||||||
|
|
||||||
|
CREATE TEXT SEARCH DICTIONARY thesaurus_dict (
|
||||||
|
TEMPLATE = thesaurus,
|
||||||
|
DictFile = thesaurus_sample,
|
||||||
|
Dictionary = pg_catalog.english_stem
|
||||||
|
);
|
||||||
|
SELECT COUNT(DISTINCT result)=1 FROM run_command_on_all_nodes($$
|
||||||
|
SELECT ROW(dictname, dictnamespace::regnamespace, dictowner::regrole, tmplname, dictinitoption)
|
||||||
|
FROM pg_ts_dict d JOIN pg_ts_template t ON ( d.dicttemplate = t.oid )
|
||||||
|
WHERE dictname = 'thesaurus_dict';
|
||||||
|
$$);
|
||||||
|
|
||||||
|
CREATE TEXT SEARCH DICTIONARY ispell_dict (
|
||||||
|
TEMPLATE = ispell,
|
||||||
|
DictFile = ispell_sample,
|
||||||
|
AffFile = ispell_sample,
|
||||||
|
Stopwords = english
|
||||||
|
);
|
||||||
|
SELECT COUNT(DISTINCT result)=1 FROM run_command_on_all_nodes($$
|
||||||
|
SELECT ROW(dictname, dictnamespace::regnamespace, dictowner::regrole, tmplname, dictinitoption)
|
||||||
|
FROM pg_ts_dict d JOIN pg_ts_template t ON ( d.dicttemplate = t.oid )
|
||||||
|
WHERE dictname = 'ispell_dict';
|
||||||
|
$$);
|
||||||
|
|
||||||
|
CREATE TEXT SEARCH DICTIONARY snowball_dict (
|
||||||
|
TEMPLATE = snowball,
|
||||||
|
Language = english,
|
||||||
|
StopWords = english
|
||||||
|
);
|
||||||
|
SELECT COUNT(DISTINCT result)=1 FROM run_command_on_all_nodes($$
|
||||||
|
SELECT ROW(dictname, dictnamespace::regnamespace, dictowner::regrole, tmplname, dictinitoption)
|
||||||
|
FROM pg_ts_dict d JOIN pg_ts_template t ON ( d.dicttemplate = t.oid )
|
||||||
|
WHERE dictname = 'snowball_dict';
|
||||||
|
$$);
|
||||||
|
|
||||||
SET client_min_messages TO 'warning';
|
SET client_min_messages TO 'warning';
|
||||||
DROP SCHEMA text_search, text_search2, "Text Search Requiring Quote's" CASCADE;
|
DROP SCHEMA text_search, text_search2, "Text Search Requiring Quote's" CASCADE;
|
||||||
|
|
Loading…
Reference in New Issue