Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd52072b

Browse files
author
Aleksandr Parfenov
committed
Fix pg_upgrade and psql output in case of connect to old PostgreSQL instance. Fix typos and add comments
1 parentacafc53 commitd52072b

File tree

13 files changed

+257
-57
lines changed

13 files changed

+257
-57
lines changed

‎doc/src/sgml/ref/alter_tsconfig.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ ALTER TEXT SEARCH CONFIGURATION <replaceable>name</replaceable> SET SCHEMA <repl
170170
</refsect1>
171171

172172
<refsect1>
173-
<title>Dictionaries MapConfig</title>
173+
<title>Dictionaries MapConfiguration</title>
174174

175175
<refsect2>
176176
<title>Format</title>

‎src/backend/commands/tsearchcmds.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,10 @@ getTokenTypes(Oid prsId, List *tokennames)
12841284
returnres;
12851285
}
12861286

1287+
/*
1288+
* Parse parse node extracted from dictionary mapping and transform it into
1289+
* internal representation of dictionary mapping.
1290+
*/
12871291
staticTSMapElement*
12881292
ParseTSMapConfig(DictMapElem*elem)
12891293
{

‎src/backend/parser/gram.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,8 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
398398
relation_expr_listdostmt_opt_list
399399
transform_element_listtransform_type_list
400400
TriggerTransitionsTriggerReferencing
401-
vacuum_relation_listopt_vacuum_relation_list
402401
publication_name_list
402+
vacuum_relation_listopt_vacuum_relation_list
403403

404404
%type<list>group_by_list
405405
%type<node>group_by_itemempty_grouping_setrollup_clausecube_clause

‎src/backend/tsearch/ts_configmap.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* ts_configmap.c
44
*internal representation of text search configuration and utilities for it
55
*
6-
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
6+
* Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
77
*
88
*
99
* IDENTIFICATION
@@ -55,15 +55,15 @@ typedef enum TSMapParseState
5555
}TSMapParseState;
5656

5757
/*
58-
* Context used duringJsonb parsing to construct a TSMap
58+
* Context used duringJSONB parsing to construct a TSMap
5959
*/
6060
typedefstructTSMapJsonbParseData
6161
{
6262
TSMapParseStatestates[JSONB_PARSE_STATE_STACK_SIZE];/* Stack of states of
6363
* JSONB parsing
6464
* automaton */
6565
intstatesIndex;/* Index of current stack frame */
66-
TSMapElement*element;/* Element that is incnstruction now */
66+
TSMapElement*element;/* Element that is inconstruction now */
6767
}TSMapJsonbParseData;
6868

6969
staticJsonbValue*TSMapElementToJsonbValue(TSMapElement*element,JsonbParseState*jsonbState);
@@ -82,6 +82,9 @@ TSMapPrintDictName(Oid dictId, StringInfo result)
8282
HeapTuplemaptup;
8383
Form_pg_ts_dictdict;
8484

85+
if (false)
86+
return;
87+
8588
maprel=heap_open(TSDictionaryRelationId,AccessShareLock);
8689
mapidx=index_open(TSDictionaryOidIndexId,AccessShareLock);
8790

@@ -223,7 +226,7 @@ dictionary_mapping_to_text(PG_FUNCTION_ARGS)
223226
}
224227

225228
/* ----------------
226-
* Functions used to convert TSMap structure intoJsonb representation
229+
* Functions used to convert TSMap structure intoJSONB representation
227230
* ----------------
228231
*/
229232

@@ -399,7 +402,7 @@ TSMapElementToJsonbValue(TSMapElement *element, JsonbParseState *jsonbState)
399402
}
400403

401404
/*
402-
* Convert a FTS configuration intoJsonb
405+
* Convert a FTS configuration intoJSONB
403406
*/
404407
Jsonb*
405408
TSMapToJsonb(TSMapElement*element)
@@ -415,7 +418,7 @@ TSMapToJsonb(TSMapElement *element)
415418
}
416419

417420
/* ----------------
418-
* Functions used to get TSMap structure fromJsonb representation
421+
* Functions used to get TSMap structure fromJSONB representation
419422
* ----------------
420423
*/
421424

@@ -438,7 +441,7 @@ static bool
438441
IsTSMapCaseKey(JsonbValue*value)
439442
{
440443
/*
441-
* JsonbValue string may be not null-terminated. Convert it forapropriate
444+
* JsonbValue string may be not null-terminated. Convert it forappropriate
442445
* behavior of strcmp function.
443446
*/
444447
char*key=palloc0(sizeof(char)* (value->val.string.len+1));
@@ -455,7 +458,7 @@ static bool
455458
IsTSMapExpressionKey(JsonbValue*value)
456459
{
457460
/*
458-
* JsonbValue string may be not null-terminated. Convert it forapropriate
461+
* JsonbValue string may be not null-terminated. Convert it forappropriate
459462
* behavior of strcmp function.
460463
*/
461464
char*key=palloc0(sizeof(char)* (value->val.string.len+1));
@@ -498,7 +501,7 @@ static void
498501
JsonbKeyExpressionProcessing(JsonbValuevalue,TSMapJsonbParseData*parseData)
499502
{
500503
/*
501-
* JsonbValue string may be not null-terminated. Convert it forapropriate
504+
* JsonbValue string may be not null-terminated. Convert it forappropriate
502505
* behavior of strcmp function.
503506
*/
504507
char*key=palloc0(sizeof(char)* (value.val.string.len+1));
@@ -528,7 +531,7 @@ static void
528531
JsonbKeyCaseProcessing(JsonbValuevalue,TSMapJsonbParseData*parseData)
529532
{
530533
/*
531-
* JsonbValue string may be not null-terminated. Convert it forapropriate
534+
* JsonbValue string may be not null-terminated. Convert it forappropriate
532535
* behavior of strcmp function.
533536
*/
534537
char*key=palloc0(sizeof(char)* (value.val.string.len+1));
@@ -602,7 +605,7 @@ JsonbProcessElement(JsonbIteratorToken r, JsonbValue value, TSMapJsonbParseData
602605
caseWJB_KEY:
603606

604607
/*
605-
* Construct an TSMapElement object. At first key insideJsonb
608+
* Construct an TSMapElement object. At first key insideJSONB
606609
* object a type is selected based on key.
607610
*/
608611
if (parseData->states[parseData->statesIndex]==TSMPS_READ_COMPLEX_OBJ)
@@ -696,7 +699,7 @@ JsonbProcessElement(JsonbIteratorToken r, JsonbValue value, TSMapJsonbParseData
696699
}
697700
break;
698701
default:
699-
/* Ignore unusedJsonb tokens */
702+
/* Ignore unusedJSONB tokens */
700703
break;
701704
}
702705
}
@@ -725,7 +728,7 @@ JsonbToTSMapElement(JsonbContainer *root)
725728
}
726729

727730
/*
728-
* Convert aJsonb into TSMapElement
731+
* Convert aJSONB into TSMapElement
729732
*/
730733
TSMapElement*
731734
JsonbToTSMap(Jsonb*json)
@@ -741,7 +744,7 @@ JsonbToTSMap(Jsonb *json)
741744
*/
742745

743746
/*
744-
*Dynamicly extendable list of OIDs
747+
*Dynamically extendable list of OIDs
745748
*/
746749
typedefstructOidList
747750
{

‎src/backend/tsearch/ts_parse.c

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
*-------------------
2828
*/
2929

30+
/*
31+
* Representation of token produced by FTS parser. It contains intermediate
32+
* lexemes in case of phrase dictionary processing.
33+
*/
3034
typedefstructParsedLex
3135
{
3236
inttype;/* Token type */
@@ -42,12 +46,18 @@ typedef struct ParsedLex
4246
* the token */
4347
}ParsedLex;
4448

49+
/*
50+
* List of tokens produced by FTS parser.
51+
*/
4552
typedefstructListParsedLex
4653
{
4754
ParsedLex*head;
4855
ParsedLex*tail;
4956
}ListParsedLex;
5057

58+
/*
59+
* Dictionary state shared between processing of different tokens
60+
*/
5161
typedefstructDictState
5262
{
5363
OidrelatedDictionary;/* DictState contains state of dictionary
@@ -64,38 +74,52 @@ typedef struct DictState
6474
* accepted or intermediate tokens */
6575
boolprocessed;/* Is the dictionary take control during
6676
* current token processing */
67-
TSLexeme*tmpResult;/* Last resultretued by thesaurus-like
77+
TSLexeme*tmpResult;/* Last resultreturned by thesaurus-like
6878
* dictionary, if dictionary still waiting for
6979
* more lexemes */
7080
}DictState;
7181

82+
/*
83+
* List of dictionary states
84+
*/
7285
typedefstructDictStateList
7386
{
7487
intlistLength;
7588
DictState*states;
7689
}DictStateList;
7790

91+
/*
92+
* Buffer entry with lexemes produced from current token
93+
*/
7894
typedefstructLexemesBufferEntry
7995
{
80-
OiddictId;
81-
TSMapElement*key;
82-
ParsedLex*token;
83-
TSLexeme*data;
96+
TSMapElement*key;/* Element of the mapping configuration produced the entry */
97+
ParsedLex*token;/* Token used for production of the lexemes */
98+
TSLexeme*data;/* Lexemes produced from current token */
8499
}LexemesBufferEntry;
85100

101+
/*
102+
* Buffer with lexemes produced from current token
103+
*/
86104
typedefstructLexemesBuffer
87105
{
88106
intsize;
89107
LexemesBufferEntry*data;
90108
}LexemesBuffer;
91109

110+
/*
111+
* Storage for accepted and possible accepted lexemes
112+
*/
92113
typedefstructResultStorage
93114
{
94115
TSLexeme*lexemes;/* Processed lexemes, which is not yet
95116
* accepted */
96-
TSLexeme*accepted;
117+
TSLexeme*accepted;/* Already accepted lexemes */
97118
}ResultStorage;
98119

120+
/*
121+
* FTS processing context
122+
*/
99123
typedefstructLexizeData
100124
{
101125
TSConfigCacheEntry*cfg;/* Text search configuration mappings for
@@ -115,6 +139,9 @@ typedef struct LexizeData
115139
booldebugContext;/* If true, relatedRule attribute is filled */
116140
}LexizeData;
117141

142+
/*
143+
* FTS processing debug context. Used during ts_debug calls.
144+
*/
118145
typedefstructTSDebugContext
119146
{
120147
TSConfigCacheEntry*cfg;/* Text search configuration mappings for
@@ -279,7 +306,7 @@ setCorrLex(LexizeData *ld, ParsedLex **correspondLexem)
279306
*/
280307

281308
/*
282-
* Get a state of dictionary based on itsoid
309+
* Get a state of dictionary based on itsOID
283310
*/
284311
staticDictState*
285312
DictStateListGet(DictStateList*list,OiddictId)
@@ -295,7 +322,7 @@ DictStateListGet(DictStateList *list, Oid dictId)
295322
}
296323

297324
/*
298-
* Remove a state of dictionary based on itsoid
325+
* Remove a state of dictionary based on itsOID
299326
*/
300327
staticvoid
301328
DictStateListRemove(DictStateList*list,OiddictId)
@@ -318,7 +345,7 @@ DictStateListRemove(DictStateList *list, Oid dictId)
318345
}
319346

320347
/*
321-
* Insert a state of dictionary with specifiedoid
348+
* Insert a state of dictionary with specifiedOID
322349
*/
323350
staticDictState*
324351
DictStateListAdd(DictStateList*list,DictState*state)
@@ -1391,7 +1418,7 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem)
13911418

13921419
/*
13931420
* Add accepted delayed results to the output of the parsing. All
1394-
* lexemes returned during thesauruspharse processing should be
1421+
* lexemes returned during thesaurusphrase processing should be
13951422
* returned simultaneously, since all phrase tokens are processed as
13961423
* one.
13971424
*/

‎src/backend/utils/cache/ts_cache.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,8 @@ lookup_ts_config_cache(Oid cfgId)
449449
if (entry->map)
450450
{
451451
for (i=0;i<entry->lenmap;i++)
452-
{
453452
if (entry->map[i])
454453
TSMapElementFree(entry->map[i]);
455-
}
456454
pfree(entry->map);
457455
}
458456
}

‎src/bin/pg_dump/pg_dump.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14204,16 +14204,29 @@ dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo)
1420414204
PQclear(res);
1420514205

1420614206
resetPQExpBuffer(query);
14207-
appendPQExpBuffer(query,
14208-
"SELECT\n"
14209-
" ( SELECT alias FROM pg_catalog.ts_token_type('%u'::pg_catalog.oid) AS t\n"
14210-
" WHERE t.tokid = m.maptokentype ) AS tokenname,\n"
14211-
" dictionary_mapping_to_text(m.mapcfg, m.maptokentype) AS dictname\n"
14212-
"FROM pg_catalog.pg_ts_config_map AS m\n"
14213-
"WHERE m.mapcfg = '%u'\n"
14214-
"GROUP BY m.mapcfg, m.maptokentype\n"
14215-
"ORDER BY m.mapcfg, m.maptokentype",
14216-
cfginfo->cfgparser, cfginfo->dobj.catId.oid);
14207+
14208+
if (fout->remoteVersion >= 110000)
14209+
appendPQExpBuffer(query,
14210+
"SELECT\n"
14211+
" ( SELECT alias FROM pg_catalog.ts_token_type('%u'::pg_catalog.oid) AS t\n"
14212+
" WHERE t.tokid = m.maptokentype ) AS tokenname,\n"
14213+
" dictionary_mapping_to_text(m.mapcfg, m.maptokentype) AS dictname\n"
14214+
"FROM pg_catalog.pg_ts_config_map AS m\n"
14215+
"WHERE m.mapcfg = '%u'\n"
14216+
"GROUP BY m.mapcfg, m.maptokentype\n"
14217+
"ORDER BY m.mapcfg, m.maptokentype",
14218+
cfginfo->cfgparser, cfginfo->dobj.catId.oid);
14219+
else
14220+
appendPQExpBuffer(query,
14221+
"SELECT\n"
14222+
" ( SELECT alias FROM pg_catalog.ts_token_type('%u'::pg_catalog.oid) AS t\n"
14223+
" WHERE t.tokid = m.maptokentype ) AS tokenname,\n"
14224+
" m.mapdict::pg_catalog.regdictionary AS dictname\n"
14225+
"FROM pg_catalog.pg_ts_config_map AS m\n"
14226+
"WHERE m.mapcfg = '%u'\n"
14227+
"GROUP BY m.mapcfg, m.maptokentype, m.mapseqno\n"
14228+
"ORDER BY m.mapcfg, m.maptokentype",
14229+
cfginfo->cfgparser, cfginfo->dobj.catId.oid);
1421714230

1421814231
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
1421914232
ntups = PQntuples(res);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp