Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d3a3831

Browse files
committed
Rename OverrideSearchPath to SearchPathMatcher.
The previous commit removed the "override" APIs. Surviving APIs facilitate plancache.c to snapshot search_path and test whether the current value equals a remembered snapshot. Aleksander Alekseev. Reported by Alexander Lakhin and Noah Misch. Discussion: https://postgr.es/m/8ffb4650-52c4-6a81-38fc-8f99be981130@gmail.com
1 parent 7c5c4e1 commit d3a3831

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

src/backend/catalog/namespace.c

+12-12
Original file line numberDiff line numberDiff line change
@@ -3374,24 +3374,24 @@ SetTempNamespaceState(Oid tempNamespaceId, Oid tempToastNamespaceId)
33743374

33753375

33763376
/*
3377-
* GetOverrideSearchPath - fetch current search path definition.
3377+
* GetSearchPathMatcher - fetch current search path definition.
33783378
*
33793379
* The result structure is allocated in the specified memory context
33803380
* (which might or might not be equal to CurrentMemoryContext); but any
33813381
* junk created by revalidation calculations will be in CurrentMemoryContext.
33823382
*/
3383-
OverrideSearchPath *
3384-
GetOverrideSearchPath(MemoryContext context)
3383+
SearchPathMatcher *
3384+
GetSearchPathMatcher(MemoryContext context)
33853385
{
3386-
OverrideSearchPath *result;
3386+
SearchPathMatcher *result;
33873387
List *schemas;
33883388
MemoryContext oldcxt;
33893389

33903390
recomputeNamespacePath();
33913391

33923392
oldcxt = MemoryContextSwitchTo(context);
33933393

3394-
result = (OverrideSearchPath *) palloc0(sizeof(OverrideSearchPath));
3394+
result = (SearchPathMatcher *) palloc0(sizeof(SearchPathMatcher));
33953395
schemas = list_copy(activeSearchPath);
33963396
while (schemas && linitial_oid(schemas) != activeCreationNamespace)
33973397
{
@@ -3413,16 +3413,16 @@ GetOverrideSearchPath(MemoryContext context)
34133413
}
34143414

34153415
/*
3416-
* CopyOverrideSearchPath - copy the specified OverrideSearchPath.
3416+
* CopySearchPathMatcher - copy the specified SearchPathMatcher.
34173417
*
34183418
* The result structure is allocated in CurrentMemoryContext.
34193419
*/
3420-
OverrideSearchPath *
3421-
CopyOverrideSearchPath(OverrideSearchPath *path)
3420+
SearchPathMatcher *
3421+
CopySearchPathMatcher(SearchPathMatcher *path)
34223422
{
3423-
OverrideSearchPath *result;
3423+
SearchPathMatcher *result;
34243424

3425-
result = (OverrideSearchPath *) palloc(sizeof(OverrideSearchPath));
3425+
result = (SearchPathMatcher *) palloc(sizeof(SearchPathMatcher));
34263426
result->schemas = list_copy(path->schemas);
34273427
result->addCatalog = path->addCatalog;
34283428
result->addTemp = path->addTemp;
@@ -3432,15 +3432,15 @@ CopyOverrideSearchPath(OverrideSearchPath *path)
34323432
}
34333433

34343434
/*
3435-
* OverrideSearchPathMatchesCurrent - does path match current setting?
3435+
* SearchPathMatchesCurrentEnvironment - does path match current environment?
34363436
*
34373437
* This is tested over and over in some common code paths, and in the typical
34383438
* scenario where the active search path seldom changes, it'll always succeed.
34393439
* We make that case fast by keeping a generation counter that is advanced
34403440
* whenever the active search path changes.
34413441
*/
34423442
bool
3443-
OverrideSearchPathMatchesCurrent(OverrideSearchPath *path)
3443+
SearchPathMatchesCurrentEnvironment(SearchPathMatcher *path)
34443444
{
34453445
ListCell *lc,
34463446
*lcp;

src/backend/utils/cache/plancache.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ CompleteCachedPlan(CachedPlanSource *plansource,
407407
* one-shot plans; and we *must* skip this for transaction control
408408
* commands, because this could result in catalog accesses.
409409
*/
410-
plansource->search_path = GetOverrideSearchPath(querytree_context);
410+
plansource->search_path = GetSearchPathMatcher(querytree_context);
411411
}
412412

413413
/*
@@ -586,7 +586,7 @@ RevalidateCachedQuery(CachedPlanSource *plansource,
586586
if (plansource->is_valid)
587587
{
588588
Assert(plansource->search_path != NULL);
589-
if (!OverrideSearchPathMatchesCurrent(plansource->search_path))
589+
if (!SearchPathMatchesCurrentEnvironment(plansource->search_path))
590590
{
591591
/* Invalidate the querytree and generic plan */
592592
plansource->is_valid = false;
@@ -759,7 +759,7 @@ RevalidateCachedQuery(CachedPlanSource *plansource,
759759
* not generate much extra cruft either, since almost certainly the path
760760
* is already valid.)
761761
*/
762-
plansource->search_path = GetOverrideSearchPath(querytree_context);
762+
plansource->search_path = GetSearchPathMatcher(querytree_context);
763763

764764
MemoryContextSwitchTo(oldcxt);
765765

@@ -1326,7 +1326,7 @@ CachedPlanAllowsSimpleValidityCheck(CachedPlanSource *plansource,
13261326
Assert(plan->is_valid);
13271327
Assert(plan == plansource->gplan);
13281328
Assert(plansource->search_path != NULL);
1329-
Assert(OverrideSearchPathMatchesCurrent(plansource->search_path));
1329+
Assert(SearchPathMatchesCurrentEnvironment(plansource->search_path));
13301330

13311331
/* We don't support oneshot plans here. */
13321332
if (plansource->is_oneshot)
@@ -1449,7 +1449,7 @@ CachedPlanIsSimplyValid(CachedPlanSource *plansource, CachedPlan *plan,
14491449

14501450
/* Is the search_path still the same as when we made it? */
14511451
Assert(plansource->search_path != NULL);
1452-
if (!OverrideSearchPathMatchesCurrent(plansource->search_path))
1452+
if (!SearchPathMatchesCurrentEnvironment(plansource->search_path))
14531453
return false;
14541454

14551455
/* It's still good. Bump refcount if requested. */
@@ -1565,7 +1565,7 @@ CopyCachedPlan(CachedPlanSource *plansource)
15651565
newsource->relationOids = copyObject(plansource->relationOids);
15661566
newsource->invalItems = copyObject(plansource->invalItems);
15671567
if (plansource->search_path)
1568-
newsource->search_path = CopyOverrideSearchPath(plansource->search_path);
1568+
newsource->search_path = CopySearchPathMatcher(plansource->search_path);
15691569
newsource->query_context = querytree_context;
15701570
newsource->rewriteRoleId = plansource->rewriteRoleId;
15711571
newsource->rewriteRowSecurity = plansource->rewriteRowSecurity;

src/include/catalog/namespace.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@ typedef enum TempNamespaceStatus
4949
} TempNamespaceStatus;
5050

5151
/*
52-
* Structure for xxxOverrideSearchPath functions
52+
* Structure for xxxSearchPathMatcher functions
5353
*
5454
* The generation counter is private to namespace.c and shouldn't be touched
5555
* by other code. It can be initialized to zero if necessary (that means
5656
* "not known equal to the current active path").
5757
*/
58-
typedef struct OverrideSearchPath
58+
typedef struct SearchPathMatcher
5959
{
6060
List *schemas; /* OIDs of explicitly named schemas */
6161
bool addCatalog; /* implicitly prepend pg_catalog? */
6262
bool addTemp; /* implicitly prepend temp schema? */
6363
uint64 generation; /* for quick detection of equality to active */
64-
} OverrideSearchPath;
64+
} SearchPathMatcher;
6565

6666
/*
6767
* Option flag bits for RangeVarGetRelidExtended().
@@ -164,9 +164,9 @@ extern void SetTempNamespaceState(Oid tempNamespaceId,
164164
Oid tempToastNamespaceId);
165165
extern void ResetTempTableNamespace(void);
166166

167-
extern OverrideSearchPath *GetOverrideSearchPath(MemoryContext context);
168-
extern OverrideSearchPath *CopyOverrideSearchPath(OverrideSearchPath *path);
169-
extern bool OverrideSearchPathMatchesCurrent(OverrideSearchPath *path);
167+
extern SearchPathMatcher *GetSearchPathMatcher(MemoryContext context);
168+
extern SearchPathMatcher *CopySearchPathMatcher(SearchPathMatcher *path);
169+
extern bool SearchPathMatchesCurrentEnvironment(SearchPathMatcher *path);
170170

171171
extern Oid get_collation_oid(List *collname, bool missing_ok);
172172
extern Oid get_conversion_oid(List *conname, bool missing_ok);

src/include/utils/plancache.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ typedef struct CachedPlanSource
111111
List *query_list; /* list of Query nodes, or NIL if not valid */
112112
List *relationOids; /* OIDs of relations the queries depend on */
113113
List *invalItems; /* other dependencies, as PlanInvalItems */
114-
struct OverrideSearchPath *search_path; /* search_path used for parsing
114+
struct SearchPathMatcher *search_path; /* search_path used for parsing
115115
* and planning */
116116
MemoryContext query_context; /* context holding the above, or NULL */
117117
Oid rewriteRoleId; /* Role ID we did rewriting for */

src/tools/pgindent/typedefs.list

+1-1
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,6 @@ OuterJoinClauseInfo
16861686
OutputPluginCallbacks
16871687
OutputPluginOptions
16881688
OutputPluginOutputType
1689-
OverrideSearchPath
16901689
OverridingKind
16911690
PACE_HEADER
16921691
PACL
@@ -2463,6 +2462,7 @@ ScanState
24632462
ScanTypeControl
24642463
ScannerCallbackState
24652464
SchemaQuery
2465+
SearchPathMatcher
24662466
SecBuffer
24672467
SecBufferDesc
24682468
SecLabelItem

0 commit comments

Comments
 (0)