-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpg_multilingual_join.patch
760 lines (706 loc) · 23.7 KB
/
pg_multilingual_join.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c
index ac4c4ec..0b60f3f 100644
--- a/src/backend/commands/event_trigger.c
+++ b/src/backend/commands/event_trigger.c
@@ -1909,7 +1909,7 @@ EventTriggerCollectCreateOpClass(CreateOpClassStmt *stmt, Oid opcoid,
*/
void
EventTriggerCollectAlterTSConfig(AlterTSConfigurationStmt *stmt, Oid cfgId,
- Oid *dictIds, int ndicts)
+ Oid *dictIds, int32 *dictOptions, int ndicts)
{
MemoryContext oldcxt;
CollectedCommand *command;
@@ -1928,6 +1928,8 @@ EventTriggerCollectAlterTSConfig(AlterTSConfigurationStmt *stmt, Oid cfgId,
TSConfigRelationId, cfgId);
command->d.atscfg.dictIds = palloc(sizeof(Oid) * ndicts);
memcpy(command->d.atscfg.dictIds, dictIds, sizeof(Oid) * ndicts);
+ command->d.atscfg.dictOptions = palloc(sizeof(int32) * ndicts);
+ memcpy(command->d.atscfg.dictOptions, dictOptions, sizeof(Oid) * ndicts);
command->d.atscfg.ndicts = ndicts;
command->parsetree = copyObject(stmt);
diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c
index b240113..fd8523f 100644
--- a/src/backend/commands/tsearchcmds.c
+++ b/src/backend/commands/tsearchcmds.c
@@ -1103,6 +1103,7 @@ DefineTSConfiguration(List *names, List *parameters, ObjectAddress *copied)
mapvalues[Anum_pg_ts_config_map_maptokentype - 1] = cfgmap->maptokentype;
mapvalues[Anum_pg_ts_config_map_mapseqno - 1] = cfgmap->mapseqno;
mapvalues[Anum_pg_ts_config_map_mapdict - 1] = cfgmap->mapdict;
+ mapvalues[Anum_pg_ts_config_map_mapoptions - 1] = cfgmap->mapoptions;
newmaptup = heap_form_tuple(mapRel->rd_att, mapvalues, mapnulls);
@@ -1300,6 +1301,7 @@ MakeConfigurationMapping(AlterTSConfigurationStmt *stmt,
int *tokens,
ntoken;
Oid *dictIds;
+ int32 *dictOptions;
int ndict;
ListCell *c;
@@ -1341,12 +1343,23 @@ MakeConfigurationMapping(AlterTSConfigurationStmt *stmt,
*/
ndict = list_length(stmt->dicts);
dictIds = (Oid *) palloc(sizeof(Oid) * ndict);
+ dictOptions = (int32 *) palloc(sizeof(int32) * ndict);
i = 0;
foreach(c, stmt->dicts)
{
- List *names = (List *) lfirst(c);
+ Node *dict = (Node *) lfirst(c);
+
+ if (IsA(dict, DictElem))
+ {
+ DictElem *dictElem = (DictElem *) dict;
+
+ dictIds[i] = get_ts_dict_oid(dictElem->dictname, false);
+ dictOptions[i] = dictElem->options;
+ }
+ /* In case of REPLACE command */
+ else
+ dictIds[i] = get_ts_dict_oid((List *) dict, false);
- dictIds[i] = get_ts_dict_oid(names, false);
i++;
}
@@ -1434,6 +1447,7 @@ MakeConfigurationMapping(AlterTSConfigurationStmt *stmt,
values[Anum_pg_ts_config_map_maptokentype - 1] = Int32GetDatum(tokens[i]);
values[Anum_pg_ts_config_map_mapseqno - 1] = Int32GetDatum(j + 1);
values[Anum_pg_ts_config_map_mapdict - 1] = ObjectIdGetDatum(dictIds[j]);
+ values[Anum_pg_ts_config_map_mapoptions - 1] = Int32GetDatum(dictOptions[j]);
tup = heap_form_tuple(relMap->rd_att, values, nulls);
simple_heap_insert(relMap, tup);
@@ -1444,7 +1458,7 @@ MakeConfigurationMapping(AlterTSConfigurationStmt *stmt,
}
}
- EventTriggerCollectAlterTSConfig(stmt, cfgId, dictIds, ndict);
+ EventTriggerCollectAlterTSConfig(stmt, cfgId, dictIds, dictOptions, ndict);
}
/*
@@ -1513,7 +1527,7 @@ DropConfigurationMapping(AlterTSConfigurationStmt *stmt,
i++;
}
- EventTriggerCollectAlterTSConfig(stmt, cfgId, NULL, 0);
+ EventTriggerCollectAlterTSConfig(stmt, cfgId, NULL, NULL, 0);
}
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 71714bc..50ba9ae 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -4118,6 +4118,17 @@ _copyReassignOwnedStmt(const ReassignOwnedStmt *from)
return newnode;
}
+static DictElem *
+_copyDictElem(const DictElem *from)
+{
+ DictElem *newnode = makeNode(DictElem);
+
+ COPY_NODE_FIELD(dictname);
+ COPY_SCALAR_FIELD(options);
+
+ return newnode;
+}
+
static AlterTSDictionaryStmt *
_copyAlterTSDictionaryStmt(const AlterTSDictionaryStmt *from)
{
@@ -4956,6 +4967,9 @@ copyObject(const void *from)
case T_ReassignOwnedStmt:
retval = _copyReassignOwnedStmt(from);
break;
+ case T_DictElem:
+ retval = _copyDictElem(from);
+ break;
case T_AlterTSDictionaryStmt:
retval = _copyAlterTSDictionaryStmt(from);
break;
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index 29a090f..1578562 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -2095,6 +2095,15 @@ _equalReassignOwnedStmt(const ReassignOwnedStmt *a, const ReassignOwnedStmt *b)
}
static bool
+_equalDictElem(const DictElem *a, const DictElem *b)
+{
+ COMPARE_NODE_FIELD(dictname);
+ COMPARE_SCALAR_FIELD(options);
+
+ return true;
+}
+
+static bool
_equalAlterTSDictionaryStmt(const AlterTSDictionaryStmt *a, const AlterTSDictionaryStmt *b)
{
COMPARE_NODE_FIELD(dictname);
@@ -3255,6 +3264,9 @@ equal(const void *a, const void *b)
case T_ReassignOwnedStmt:
retval = _equalReassignOwnedStmt(a, b);
break;
+ case T_DictElem:
+ retval = _equalDictElem(a, b);
+ break;
case T_AlterTSDictionaryStmt:
retval = _equalAlterTSDictionaryStmt(a, b);
break;
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 5547fc8..6af84ab 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -53,6 +53,7 @@
#include "catalog/namespace.h"
#include "catalog/pg_am.h"
#include "catalog/pg_trigger.h"
+#include "catalog/pg_ts_config_map.h"
#include "commands/defrem.h"
#include "commands/trigger.h"
#include "nodes/makefuncs.h"
@@ -229,6 +230,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
struct ImportQual *importqual;
InsertStmt *istmt;
VariableSetStmt *vsetstmt;
+ DictElem *delem;
}
%type <node> stmt schema_stmt
@@ -374,6 +376,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
create_generic_options alter_generic_options
relation_expr_list dostmt_opt_list
transform_element_list transform_type_list
+ dict_list
%type <list> group_by_list
%type <node> group_by_item empty_grouping_set rollup_clause cube_clause
@@ -542,6 +545,9 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <str> opt_existing_window_name
%type <boolean> opt_if_not_exists
+%type <delem> dict_elem
+%type <ival> dict_option_list dict_option_elem
+
/*
* Non-keyword token types. These are hard-wired into the "flex" lexer.
* They must be listed first so that their numeric codes do not depend on
@@ -9181,7 +9187,7 @@ AlterTSDictionaryStmt:
;
AlterTSConfigurationStmt:
- ALTER TEXT_P SEARCH CONFIGURATION any_name ADD_P MAPPING FOR name_list any_with any_name_list
+ ALTER TEXT_P SEARCH CONFIGURATION any_name ADD_P MAPPING FOR name_list any_with dict_list
{
AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
n->kind = ALTER_TSCONFIG_ADD_MAPPING;
@@ -9192,7 +9198,7 @@ AlterTSConfigurationStmt:
n->replace = false;
$$ = (Node*)n;
}
- | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list any_with any_name_list
+ | ALTER TEXT_P SEARCH CONFIGURATION any_name ALTER MAPPING FOR name_list any_with dict_list
{
AlterTSConfigurationStmt *n = makeNode(AlterTSConfigurationStmt);
n->kind = ALTER_TSCONFIG_ALTER_MAPPING_FOR_TOKEN;
@@ -9250,6 +9256,33 @@ any_with: WITH {}
| WITH_LA {}
;
+dict_list: dict_elem { $$ = list_make1($1); }
+ | dict_list ',' dict_elem { $$ = lappend($1, $3); }
+ ;
+
+dict_elem: any_name
+ {
+ $$ = makeNode(DictElem);
+ $$->dictname = $1;
+ $$->options = 0;
+ }
+ | any_name '(' dict_option_list ')'
+ {
+ $$ = makeNode(DictElem);
+ $$->dictname = $1;
+ $$->options = $3;
+ }
+ ;
+
+dict_option_list:
+ dict_option_elem { $$ = $1; }
+ | dict_option_list ',' dict_option_elem { $$ = $1 | $3; }
+ ;
+
+dict_option_elem:
+ JOIN { $$ = DICTELEM_JOIN; }
+ ;
+
/*****************************************************************************
*
diff --git a/src/backend/tsearch/dict_simple.c b/src/backend/tsearch/dict_simple.c
index e3f06db..91bc109 100644
--- a/src/backend/tsearch/dict_simple.c
+++ b/src/backend/tsearch/dict_simple.c
@@ -62,7 +62,7 @@ dsimple_init(PG_FUNCTION_ARGS)
{
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("unrecognized simple dictionary parameter: \"%s\"",
+ errmsg("unrecognized simple dictionary parameter: \"%s\"",
defel->defname)));
}
}
diff --git a/src/backend/tsearch/ts_parse.c b/src/backend/tsearch/ts_parse.c
index f0e4269..8699914 100644
--- a/src/backend/tsearch/ts_parse.c
+++ b/src/backend/tsearch/ts_parse.c
@@ -14,6 +14,7 @@
#include "postgres.h"
+#include "catalog/pg_ts_config_map.h"
#include "tsearch/ts_cache.h"
#include "tsearch/ts_utils.h"
@@ -169,12 +170,66 @@ setNewTmpRes(LexizeData *ld, ParsedLex *lex, TSLexeme *res)
}
static TSLexeme *
+appendLexeme(TSLexeme *dst, TSLexeme *src, Size *pos, Size *size,
+ uint16 *nvariant)
+{
+ TSLexeme *res = dst,
+ *src_ptr = src;
+ Size len = *size,
+ cur = *pos;
+ uint16 maxvariant = *nvariant;
+
+ if (src == NULL)
+ return res;
+
+ if (!src->lexeme && !res)
+ {
+ *size = 2;
+ return (TSLexeme *) palloc0(sizeof(TSLexeme) * *size);
+ }
+
+ while (src_ptr->lexeme)
+ {
+ if (!res ||
+ cur == len - 1 /* for res[cur].lexeme = NULL */)
+ {
+ len = (len > 0) ? 2 * len : 8;
+ if (res)
+ res = (TSLexeme *) repalloc(res, sizeof(TSLexeme) * len);
+ else
+ res = (TSLexeme *) palloc(sizeof(TSLexeme) * len);
+ }
+
+ res[cur].nvariant = src_ptr->nvariant + *nvariant;
+ res[cur].flags = src_ptr->flags;
+ res[cur].lexeme = src_ptr->lexeme;
+
+ maxvariant = Max(maxvariant, res[cur].nvariant);
+
+ cur++;
+ src_ptr++;
+ }
+
+ *pos = cur;
+ *size = len;
+ *nvariant = maxvariant;
+ /* Mark end of array */
+ res[cur].lexeme = NULL;
+
+ return res;
+}
+
+static TSLexeme *
LexizeExec(LexizeData *ld, ParsedLex **correspondLexem)
{
int i;
ListDictionary *map;
TSDictionaryCacheEntry *dict;
- TSLexeme *res;
+ TSLexeme *res = NULL,
+ *dict_res;
+ Size len = 0,
+ cur = 0;
+ uint16 nvariant = 0;
if (ld->curDictId == InvalidOid)
{
@@ -204,7 +259,7 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem)
ld->dictState.isend = ld->dictState.getnext = false;
ld->dictState.private_state = NULL;
- res = (TSLexeme *) DatumGetPointer(FunctionCall4(
+ dict_res = (TSLexeme *) DatumGetPointer(FunctionCall4(
&(dict->lexize),
PointerGetDatum(dict->dictData),
PointerGetDatum(curValLemm),
@@ -222,24 +277,53 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem)
ld->curDictId = DatumGetObjectId(map->dictIds[i]);
ld->posDict = i + 1;
ld->curSub = curVal->next;
- if (res)
- setNewTmpRes(ld, curVal, res);
- return LexizeExec(ld, correspondLexem);
- }
+ if (dict_res)
+ setNewTmpRes(ld, curVal, dict_res);
- if (!res) /* dictionary doesn't know this lexeme */
- continue;
+ dict_res = LexizeExec(ld, correspondLexem);
+ }
+ else
+ {
+ /* Dictionary doesn't know this lexeme. */
+ if (!dict_res &&
+ /*
+ * But if we have result from other dictionaries, we
+ * could return this results.
+ */
+ !res)
+ continue;
+
+ if (dict_res && dict_res->flags & TSL_FILTER)
+ {
+ curValLemm = dict_res->lexeme;
+ curValLenLemm = strlen(dict_res->lexeme);
+ continue;
+ }
+ }
- if (res->flags & TSL_FILTER)
+ /*
+ * Collect lexems from previous dictionary
+ * and pass them to next step.
+ */
+ if (res != NULL || (map->dictOptions[i] & DICTELEM_JOIN) != 0)
{
- curValLemm = res->lexeme;
- curValLenLemm = strlen(res->lexeme);
- continue;
+ res = appendLexeme(res, dict_res, &cur, &len, &nvariant);
+
+ if (dict_res)
+ {
+ pfree(dict_res);
+ dict_res = NULL;
+ }
}
- RemoveHead(ld);
- setCorrLex(ld, correspondLexem);
- return res;
+ /* But if we reach non-join dictionary mapping, then end work */
+ if ((map->dictOptions[i] & DICTELEM_JOIN) == 0)
+ {
+ RemoveHead(ld);
+ setCorrLex(ld, correspondLexem);
+
+ return (res != NULL) ? res : dict_res;
+ }
}
RemoveHead(ld);
@@ -293,7 +377,7 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem)
ld->dictState.isend = (curVal->type == 0) ? true : false;
ld->dictState.getnext = false;
- res = (TSLexeme *) DatumGetPointer(FunctionCall4(
+ dict_res = (TSLexeme *) DatumGetPointer(FunctionCall4(
&(dict->lexize),
PointerGetDatum(dict->dictData),
PointerGetDatum(curVal->lemm),
@@ -305,25 +389,25 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem)
{
/* Dictionary wants one more */
ld->curSub = curVal->next;
- if (res)
- setNewTmpRes(ld, curVal, res);
+ if (dict_res)
+ setNewTmpRes(ld, curVal, dict_res);
continue;
}
- if (res || ld->tmpRes)
+ if (dict_res || ld->tmpRes)
{
/*
* Dictionary normalizes lexemes, so we remove from stack all
* used lexemes, return to basic mode and redo end of stack
* (if it exists)
*/
- if (res)
+ if (dict_res)
{
moveToWaste(ld, ld->curSub);
}
else
{
- res = ld->tmpRes;
+ dict_res = ld->tmpRes;
moveToWaste(ld, ld->lastRes);
}
@@ -333,7 +417,7 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem)
ld->lastRes = NULL;
ld->tmpRes = NULL;
setCorrLex(ld, correspondLexem);
- return res;
+ return dict_res;
}
/*
@@ -346,7 +430,7 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem)
}
setCorrLex(ld, correspondLexem);
- return NULL;
+ return res;
}
/*
diff --git a/src/backend/utils/cache/ts_cache.c b/src/backend/utils/cache/ts_cache.c
index 50f1743..92e2aba 100644
--- a/src/backend/utils/cache/ts_cache.c
+++ b/src/backend/utils/cache/ts_cache.c
@@ -415,6 +415,7 @@ lookup_ts_config_cache(Oid cfgId)
HeapTuple maptup;
ListDictionary maplists[MAXTOKENTYPE + 1];
Oid mapdicts[MAXDICTSPERTT];
+ int32 mapoptions[MAXDICTSPERTT];
int maxtokentype;
int ndicts;
int i;
@@ -501,9 +502,15 @@ lookup_ts_config_cache(Oid cfgId)
sizeof(Oid) * ndicts);
memcpy(maplists[maxtokentype].dictIds, mapdicts,
sizeof(Oid) * ndicts);
+ maplists[maxtokentype].dictOptions = (int32 *)
+ MemoryContextAlloc(CacheMemoryContext,
+ sizeof(int32) * ndicts);
+ memcpy(maplists[maxtokentype].dictOptions, mapoptions,
+ sizeof(int32) * ndicts);
}
maxtokentype = toktype;
mapdicts[0] = cfgmap->mapdict;
+ mapoptions[0] = cfgmap->mapoptions;
ndicts = 1;
}
else
@@ -511,7 +518,9 @@ lookup_ts_config_cache(Oid cfgId)
/* continuing data for current token type */
if (ndicts >= MAXDICTSPERTT)
elog(ERROR, "too many pg_ts_config_map entries for one token type");
- mapdicts[ndicts++] = cfgmap->mapdict;
+ mapdicts[ndicts] = cfgmap->mapdict;
+ mapoptions[ndicts] = cfgmap->mapoptions;
+ ndicts++;
}
}
@@ -528,6 +537,10 @@ lookup_ts_config_cache(Oid cfgId)
sizeof(Oid) * ndicts);
memcpy(maplists[maxtokentype].dictIds, mapdicts,
sizeof(Oid) * ndicts);
+ maplists[maxtokentype].dictOptions = (int32 *)
+ MemoryContextAlloc(CacheMemoryContext, sizeof(int32) * ndicts);
+ memcpy(maplists[maxtokentype].dictOptions, mapoptions,
+ sizeof(int32) * ndicts);
/* and save the overall map */
entry->lenmap = maxtokentype + 1;
entry->map = (ListDictionary *)
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 4da297f..4ef5255 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -53,6 +53,7 @@
#include "catalog/pg_largeobject_metadata.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_trigger.h"
+#include "catalog/pg_ts_config_map.h"
#include "catalog/pg_type.h"
#include "libpq/libpq-fs.h"
@@ -12938,6 +12939,7 @@ dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo)
i;
int i_tokenname;
int i_dictname;
+ int i_options;
/* Skip if not to be dumped */
if (!cfginfo->dobj.dump || dopt->dataOnly)
@@ -12976,7 +12978,8 @@ dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo)
"SELECT \n"
" ( SELECT alias FROM pg_catalog.ts_token_type('%u'::pg_catalog.oid) AS t \n"
" WHERE t.tokid = m.maptokentype ) AS tokenname, \n"
- " m.mapdict::pg_catalog.regdictionary AS dictname \n"
+ " m.mapdict::pg_catalog.regdictionary AS dictname, \n"
+ " m.mapoptions AS options \n"
"FROM pg_catalog.pg_ts_config_map AS m \n"
"WHERE m.mapcfg = '%u' \n"
"ORDER BY m.mapcfg, m.maptokentype, m.mapseqno",
@@ -12987,11 +12990,13 @@ dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo)
i_tokenname = PQfnumber(res, "tokenname");
i_dictname = PQfnumber(res, "dictname");
+ i_options = PQfnumber(res, "options");
for (i = 0; i < ntups; i++)
{
char *tokenname = PQgetvalue(res, i, i_tokenname);
char *dictname = PQgetvalue(res, i, i_dictname);
+ int options = atoi(PQgetvalue(res, i, i_options));
if (i == 0 ||
strcmp(tokenname, PQgetvalue(res, i - 1, i_tokenname)) != 0)
@@ -13007,6 +13012,10 @@ dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo)
}
else
appendPQExpBuffer(q, ", %s", dictname);
+
+ /* append mapping options */
+ if (options & DICTELEM_JOIN)
+ appendPQExpBuffer(q, " (JOIN)");
}
if (ntups > 0)
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index bfa6b87..d9f408c 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 201610121
+#define CATALOG_VERSION_NO 201610191
#endif
diff --git a/src/include/catalog/pg_ts_config_map.h b/src/include/catalog/pg_ts_config_map.h
index c1753a3..a32c934 100644
--- a/src/include/catalog/pg_ts_config_map.h
+++ b/src/include/catalog/pg_ts_config_map.h
@@ -36,6 +36,7 @@ CATALOG(pg_ts_config_map,3603) BKI_WITHOUT_OIDS
int32 maptokentype; /* token type from parser */
int32 mapseqno; /* order in which to consult dictionaries */
Oid mapdict; /* dictionary to consult */
+ int32 mapoptions; /* dictionary options in mapping */
} FormData_pg_ts_config_map;
typedef FormData_pg_ts_config_map *Form_pg_ts_config_map;
@@ -44,35 +45,42 @@ typedef FormData_pg_ts_config_map *Form_pg_ts_config_map;
* compiler constants for pg_ts_config_map
* ----------------
*/
-#define Natts_pg_ts_config_map 4
+#define Natts_pg_ts_config_map 5
#define Anum_pg_ts_config_map_mapcfg 1
#define Anum_pg_ts_config_map_maptokentype 2
#define Anum_pg_ts_config_map_mapseqno 3
#define Anum_pg_ts_config_map_mapdict 4
+#define Anum_pg_ts_config_map_mapoptions 5
+
+/* ----------------
+ * compiler constant for mapoptions
+ * ----------------
+ */
+#define DICTELEM_JOIN 1 << 0 /* join mapping */
/* ----------------
* initial contents of pg_ts_config_map
* ----------------
*/
-DATA(insert ( 3748 1 1 3765 ));
-DATA(insert ( 3748 2 1 3765 ));
-DATA(insert ( 3748 3 1 3765 ));
-DATA(insert ( 3748 4 1 3765 ));
-DATA(insert ( 3748 5 1 3765 ));
-DATA(insert ( 3748 6 1 3765 ));
-DATA(insert ( 3748 7 1 3765 ));
-DATA(insert ( 3748 8 1 3765 ));
-DATA(insert ( 3748 9 1 3765 ));
-DATA(insert ( 3748 10 1 3765 ));
-DATA(insert ( 3748 11 1 3765 ));
-DATA(insert ( 3748 15 1 3765 ));
-DATA(insert ( 3748 16 1 3765 ));
-DATA(insert ( 3748 17 1 3765 ));
-DATA(insert ( 3748 18 1 3765 ));
-DATA(insert ( 3748 19 1 3765 ));
-DATA(insert ( 3748 20 1 3765 ));
-DATA(insert ( 3748 21 1 3765 ));
-DATA(insert ( 3748 22 1 3765 ));
+DATA(insert ( 3748 1 1 3765 0 ));
+DATA(insert ( 3748 2 1 3765 0 ));
+DATA(insert ( 3748 3 1 3765 0 ));
+DATA(insert ( 3748 4 1 3765 0 ));
+DATA(insert ( 3748 5 1 3765 0 ));
+DATA(insert ( 3748 6 1 3765 0 ));
+DATA(insert ( 3748 7 1 3765 0 ));
+DATA(insert ( 3748 8 1 3765 0 ));
+DATA(insert ( 3748 9 1 3765 0 ));
+DATA(insert ( 3748 10 1 3765 0 ));
+DATA(insert ( 3748 11 1 3765 0 ));
+DATA(insert ( 3748 15 1 3765 0 ));
+DATA(insert ( 3748 16 1 3765 0 ));
+DATA(insert ( 3748 17 1 3765 0 ));
+DATA(insert ( 3748 18 1 3765 0 ));
+DATA(insert ( 3748 19 1 3765 0 ));
+DATA(insert ( 3748 20 1 3765 0 ));
+DATA(insert ( 3748 21 1 3765 0 ));
+DATA(insert ( 3748 22 1 3765 0 ));
#endif /* PG_TS_CONFIG_MAP_H */
diff --git a/src/include/commands/event_trigger.h b/src/include/commands/event_trigger.h
index 0e91bf6..41f6c1a 100644
--- a/src/include/commands/event_trigger.h
+++ b/src/include/commands/event_trigger.h
@@ -83,7 +83,8 @@ extern void EventTriggerCollectCreateOpClass(CreateOpClassStmt *stmt,
Oid opcoid, List *operators,
List *procedures);
extern void EventTriggerCollectAlterTSConfig(AlterTSConfigurationStmt *stmt,
- Oid cfgId, Oid *dictIds, int ndicts);
+ Oid cfgId, Oid *dictIds, int32 *dictOptions,
+ int ndicts);
extern void EventTriggerCollectAlterDefPrivs(AlterDefaultPrivilegesStmt *stmt);
#endif /* EVENT_TRIGGER_H */
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index 88297bb..2df89e2 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -380,6 +380,7 @@ typedef enum NodeTag
T_CreateEnumStmt,
T_CreateRangeStmt,
T_AlterEnumStmt,
+ T_DictElem,
T_AlterTSDictionaryStmt,
T_AlterTSConfigurationStmt,
T_CreateFdwStmt,
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 6de2cab..42b5f53 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -3087,6 +3087,16 @@ typedef enum AlterTSConfigType
ALTER_TSCONFIG_DROP_MAPPING
} AlterTSConfigType;
+/*
+ * DictElem - dictionary parameters
+ */
+typedef struct DictElem
+{
+ NodeTag type;
+ List *dictname; /* name of dictionary */
+ int32 options; /* OR of DictElemOption flags */
+} DictElem;
+
typedef struct AlterTSConfigurationStmt
{
NodeTag type;
@@ -3098,7 +3108,7 @@ typedef struct AlterTSConfigurationStmt
* NIL, but tokentype isn't, DROP MAPPING was specified.
*/
List *tokentype; /* list of Value strings */
- List *dicts; /* list of list of Value strings */
+ List *dicts; /* list of DictElem */
bool override; /* if true - remove old variant */
bool replace; /* if true - replace dictionary by another */
bool missing_ok; /* for DROP - skip error if missing? */
diff --git a/src/include/tcop/deparse_utility.h b/src/include/tcop/deparse_utility.h
index 046184d..6705f97 100644
--- a/src/include/tcop/deparse_utility.h
+++ b/src/include/tcop/deparse_utility.h
@@ -91,6 +91,7 @@ typedef struct CollectedCommand
{
ObjectAddress address;
Oid *dictIds;
+ int32 *dictOptions;
int ndicts;
} atscfg;
diff --git a/src/include/tsearch/ts_cache.h b/src/include/tsearch/ts_cache.h
index 3798933..cba41d4 100644
--- a/src/include/tsearch/ts_cache.h
+++ b/src/include/tsearch/ts_cache.h
@@ -66,6 +66,7 @@ typedef struct
{
int len;
Oid *dictIds;
+ int32 *dictOptions;
} ListDictionary;
typedef struct
diff --git a/src/test/regress/expected/tsearch.out b/src/test/regress/expected/tsearch.out
index 129d06e..c95aed3 100644
--- a/src/test/regress/expected/tsearch.out
+++ b/src/test/regress/expected/tsearch.out
@@ -51,8 +51,8 @@ RIGHT JOIN pg_ts_config_map AS m
ON (tt.cfgid=m.mapcfg AND tt.tokid=m.maptokentype)
WHERE
tt.cfgid IS NULL OR tt.tokid IS NULL;
- cfgid | tokid | mapcfg | maptokentype | mapseqno | mapdict
--------+-------+--------+--------------+----------+---------
+ cfgid | tokid | mapcfg | maptokentype | mapseqno | mapdict | mapoptions
+-------+-------+--------+--------------+----------+---------+------------
(0 rows)
-- test basic text search behavior without indexes, then with