From edf322e4f0b968c15cbc6bac05484eb4add19cf5 Mon Sep 17 00:00:00 2001 From: Daria Lepikhova Date: Thu, 8 Oct 2020 13:00:49 +0500 Subject: [PATCH 1/6] Support 13 psql. Added returning type TSTernaryValue for checkcondition_HL() function. --- tsparser.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tsparser.c b/tsparser.c index 53ff6ac..78bf357 100644 --- a/tsparser.c +++ b/tsparser.c @@ -1973,7 +1973,11 @@ typedef struct #undef USE_PHRASE_SEARCH #endif +#if PG_VERSION_NUM >= 130000 +static TSTernaryValue +#else static bool +#endif #ifdef USE_PHRASE_SEARCH checkcondition_HL(void *opaque, QueryOperand *val, ExecPhraseData *data) #else @@ -1990,7 +1994,11 @@ checkcondition_HL(void *opaque, QueryOperand *val) { /* don't need to find all positions */ if (!data) +#if PG_VERSION_NUM >= 130000 + return TS_YES; +#else return true; +#endif if (!data->pos) { @@ -2005,17 +2013,29 @@ checkcondition_HL(void *opaque, QueryOperand *val) data->pos[data->npos++] = checkval->words[i].pos; } } +#else +#if PG_VERSION_NUM >= 130000 + return TS_YES; #else return true; +#endif #endif } #ifdef USE_PHRASE_SEARCH if (data && data->npos > 0) +#if PG_VERSION_NUM >= 130000 + return TS_YES; +#else return true; #endif +#endif +#if PG_VERSION_NUM >= 130000 + return TS_NO; +#else return false; +#endif } From ff61b616273e53c738c01ace6045e640f9a41cab Mon Sep 17 00:00:00 2001 From: Roman Zharkov Date: Thu, 20 May 2021 10:50:40 +0600 Subject: [PATCH 2/6] [refer #PGPRO-4978] Update the .gitignore file. tags: pg_tsparser --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8a9a6c9..1167d7c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.o *.so results +/log/ From ef4120fa145a0bc67eb77a833a1bfc9cf6519c8e Mon Sep 17 00:00:00 2001 From: Marina Polyakova Date: Wed, 29 Jun 2022 18:47:20 +0300 Subject: [PATCH 3/6] PGPRO-6866: do not use the function pg_atoi if possible In PostgreSQL version 12 or higher it's more effecient to use the function pg_strtoint32 instead (see the commit 86eaf208ea048936df6be77276a246d3f92e9620). And in PostgreSQL 15 the function pg_atoi was removed altogether (see the commit 73508475d69e90f98ebd9b7e1a5933a26a49c5e9). Therefore if possible use the function pg_strtoint32 instead. --- tsparser.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tsparser.c b/tsparser.c index 78bf357..0546e53 100644 --- a/tsparser.c +++ b/tsparser.c @@ -269,6 +269,10 @@ typedef struct TParser int type; } TParser; +#if PG_VERSION_NUM < 120000 +#define pg_strtoint32(value) pg_atoi((value), sizeof(int32), 0) +#endif + /* forward decls here */ static bool TParserGet(TParser *prs); @@ -2533,13 +2537,13 @@ tsparser_headline(PG_FUNCTION_ARGS) char *val = defGetString(defel); if (pg_strcasecmp(defel->defname, "MaxWords") == 0) - max_words = pg_atoi(val, sizeof(int32), 0); + max_words = pg_strtoint32(val); else if (pg_strcasecmp(defel->defname, "MinWords") == 0) - min_words = pg_atoi(val, sizeof(int32), 0); + min_words = pg_strtoint32(val); else if (pg_strcasecmp(defel->defname, "ShortWord") == 0) - shortword = pg_atoi(val, sizeof(int32), 0); + shortword = pg_strtoint32(val); else if (pg_strcasecmp(defel->defname, "MaxFragments") == 0) - max_fragments = pg_atoi(val, sizeof(int32), 0); + max_fragments = pg_strtoint32(val); else if (pg_strcasecmp(defel->defname, "StartSel") == 0) prs->startsel = pstrdup(val); else if (pg_strcasecmp(defel->defname, "StopSel") == 0) From 381bc16417009ae279e271c94e8c7e8f258e918f Mon Sep 17 00:00:00 2001 From: Marina Polyakova Date: Tue, 29 Aug 2023 17:12:48 +0300 Subject: [PATCH 4/6] PGPRO-8706: Fix t_isspace(), etc., when datlocprovider=i and datctype=C for 16+ See the commit f413941f41d370a7893caa3e6ed384b89a0577fd (Fix t_isspace(), etc., when datlocprovider=i and datctype=C.) in PostgreSQL 16+. A fix for previous major versions will be added later. --- tsparser.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tsparser.c b/tsparser.c index 0546e53..8d7f8f7 100644 --- a/tsparser.c +++ b/tsparser.c @@ -309,11 +309,14 @@ TParserInit(char *str, int len) */ if (prs->charmaxlen > 1) { - Oid collation = DEFAULT_COLLATION_OID; /* TODO */ pg_locale_t mylocale = 0; /* TODO */ prs->usewide = true; - if (lc_ctype_is_c(collation)) +#if PG_VERSION_NUM >= 160000 + if (database_ctype_is_c) +#else + if (lc_ctype_is_c(DEFAULT_COLLATION_OID)) +#endif { /* * char2wchar doesn't work for C-locale and sizeof(pg_wchar) could From 7f2b5600f5d298e76553ec4c0846c038890f9d1f Mon Sep 17 00:00:00 2001 From: CourteousSleet Date: Wed, 28 Aug 2024 14:44:46 +0300 Subject: [PATCH 5/6] [PGPRO-8706] Backport pg_tsparser fix Tags: icu, pg_tsparser --- tsparser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsparser.c b/tsparser.c index 8d7f8f7..e821dce 100644 --- a/tsparser.c +++ b/tsparser.c @@ -312,7 +312,7 @@ TParserInit(char *str, int len) pg_locale_t mylocale = 0; /* TODO */ prs->usewide = true; -#if PG_VERSION_NUM >= 160000 +#if PG_VERSION_NUM >= 150000 || (defined(PGPRO_STD) && PG_VERSION_NUM >= 120000) if (database_ctype_is_c) #else if (lc_ctype_is_c(DEFAULT_COLLATION_OID)) From f15c01d0151ea7ced8fe16f71f0db1c65d759bcb Mon Sep 17 00:00:00 2001 From: Zharkov Roman Date: Tue, 21 Jan 2025 16:04:49 +0300 Subject: [PATCH 6/6] Add meson.build file to support building from the contrib source tree. --- meson.build | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 meson.build diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..9dc5c8f --- /dev/null +++ b/meson.build @@ -0,0 +1,37 @@ +# Copyright (c) 2025, Postgres Professional + +# Does not support the PGXS infrastructure at this time. Please, compile as part +# of the contrib source tree. + +pg_tsparser_sources = files( + 'tsparser.c' +) + +if host_system == 'windows' + pg_tsparser_sources += rc_lib_gen.process(win32ver_rc, extra_args: [ + '--NAME', 'pg_tsparser', + '--FILEDESC', 'pg_tsparser - modifies the default text parsing strategy.',]) +endif + +pg_tsparser = shared_module('pg_tsparser', + pg_tsparser_sources, + kwargs: contrib_mod_args, +) +contrib_targets += pg_tsparser + +install_data( + 'pg_tsparser.control', + 'pg_tsparser--1.0.sql', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'pg_tsparser', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'pg_tsparser', + ], + }, +}