Skip to content

Commit e9e5808

Browse files
authored
Merge pull request #917 from NotHimmel/master-latest-nested_subfunc
refactor subproc_function
2 parents 8c6f9ef + 3c9c891 commit e9e5808

36 files changed

Lines changed: 3139 additions & 3061 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Furthermore, for more detailed installation instructions, please refer to the [I
3333

3434
## Developer Formatting hooks and CI:
3535
- A pre-commit formatting hook is provided at `.githooks/pre-commit`. Enable it with `git config core.hooksPath .githooks`, or run `make enable-git-hooks` (equivalently `bash tools/enable-git-hooks.sh`).
36-
- The hook depends only on in-tree tools `src/tools/pgindent` and `src/tools/pg_bsd_indent`. On commit it formats staged C/C++ files with pgindent and re-adds them to the index.
36+
- The hook depends only on in-tree tools `src/tools/pgindent` and `src/tools/pg_bsd_indent`. On commit it formats staged C/C++ files with pgindent and re-adds them to the staged area.
3737
- A Cirrus workflow `FormatCheck` runs `pgindent --check` on files changed in a PR.
3838

3939
## Contributing to the IvorySQL

contrib/postgres_fdw/deparse.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* well as functions to construct the query text to be sent. The latter
99
* functionality is annoyingly duplicative of ruleutils.c, but there are
1010
* enough special considerations that it seems best to keep this separate.
11-
* One saving grace is that we only need deparse logic for node types that
12-
* we consider safe to send.
11+
* One saving grace is that deparse logic is required only for node types
12+
* considered safe to send.
1313
*
1414
* We assume that the remote session's search_path is exactly "pg_catalog",
1515
* and thus we need schema-qualify all and only names outside pg_catalog.
@@ -2976,7 +2976,7 @@ deparseVar(Var *node, deparse_expr_cxt *context)
29762976
qualify_col);
29772977
else
29782978
{
2979-
/* Treat like a Param */
2979+
/* Treat as a Param */
29802980
if (context->params_list)
29812981
{
29822982
int pindex = 0;
@@ -3409,7 +3409,7 @@ deparseOperatorName(StringInfo buf, Form_pg_operator opform)
34093409
{
34103410
char *opname;
34113411

3412-
/* opname is not a SQL identifier, so we should not quote it. */
3412+
/* opname is not a SQL identifier, so do not quote it. */
34133413
opname = NameStr(opform->oprname);
34143414

34153415
/* Print schema name only if it's not pg_catalog */

src/backend/catalog/dependency.c

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static void reportDependentObjects(const ObjectAddresses *targetObjects,
165165
DropBehavior behavior,
166166
int flags,
167167
const ObjectAddress *origObject,
168-
bool *refinddepobjects);
168+
bool *refinddepobjects);
169169
static void deleteOneObject(const ObjectAddress *object,
170170
Relation *depRel, int32 flags);
171171
static void doDeletion(const ObjectAddress *object, int flags);
@@ -287,7 +287,7 @@ performDeletion(const ObjectAddress *object,
287287
{
288288
Relation depRel;
289289
ObjectAddresses *targetObjects;
290-
bool need_refinddepobj = false;
290+
bool need_refinddepobj = false;
291291

292292
/*
293293
* We save some cycles by opening pg_depend just once and passing the
@@ -363,7 +363,7 @@ performMultipleDeletions(const ObjectAddresses *objects,
363363
Relation depRel;
364364
ObjectAddresses *targetObjects;
365365
int i;
366-
bool need_refinddepobj = false;
366+
bool need_refinddepobj = false;
367367

368368
/* No work if no objects... */
369369
if (objects->numrefs <= 0)
@@ -427,7 +427,9 @@ performMultipleDeletions(const ObjectAddresses *objects,
427427
const ObjectAddress *thisobj = objects->refs + i;
428428

429429
/*
430-
* Obtain a deletion lock for every target object. (Preferably, this should have been handled by the caller, but in reality, many callers neglect to do so.)
430+
* Obtain a deletion lock for every target object. (Preferably,
431+
* this should have been handled by the caller, but in reality,
432+
* many callers neglect to do so.)
431433
*/
432434
AcquireDeletionLock(thisobj, flags);
433435

@@ -504,7 +506,7 @@ findDependentObjects(const ObjectAddress *object,
504506
int maxDependentObjects;
505507
ObjectAddressStack mystack;
506508
ObjectAddressExtra extra;
507-
ObjectFunOrPkg *dependentFuncPkgOids;
509+
ObjectFunOrPkg *dependentFuncPkgOids;
508510
int numDependentFuncPkgOids;
509511
int maxDependentFuncPkgOids;
510512

@@ -968,7 +970,7 @@ findDependentObjects(const ObjectAddress *object,
968970
if (foundDep->deptype == DEPENDENCY_TYPE &&
969971
(object->classId == RelationRelationId ||
970972
object->classId == PackageRelationId ||
971-
object->classId == PackageBodyRelationId ))
973+
object->classId == PackageBodyRelationId))
972974
{
973975
if (foundDep->classid == 0)
974976
continue;
@@ -1106,17 +1108,17 @@ findDependentObjects(const ObjectAddress *object,
11061108
pg_qsort(dependentFuncPkgOids, numDependentFuncPkgOids,
11071109
sizeof(ObjectFunOrPkg), object_funpkgoid_comparator);
11081110

1109-
numDependentFuncPkgOids = qunique((void *)dependentFuncPkgOids, numDependentFuncPkgOids,
1110-
sizeof(ObjectFunOrPkg), object_funpkgoid_comparator);
1111+
numDependentFuncPkgOids = qunique((void *) dependentFuncPkgOids, numDependentFuncPkgOids,
1112+
sizeof(ObjectFunOrPkg), object_funpkgoid_comparator);
11111113
}
11121114

11131115
/*
1114-
* Find out the dependent funciton which uses %TYPE or %ROWTYPE
1115-
* in parameters datatype or return datatype.
1116+
* Find out the dependent funciton which uses %TYPE or %ROWTYPE in
1117+
* parameters datatype or return datatype.
11161118
*/
11171119
for (int i = 0; i < numDependentFuncPkgOids; i++)
11181120
{
1119-
Oid objectId = dependentFuncPkgOids[i].objectId;
1121+
Oid objectId = dependentFuncPkgOids[i].objectId;
11201122

11211123
switch (dependentFuncPkgOids[i].flags)
11221124
{
@@ -1150,7 +1152,7 @@ findDependentObjects(const ObjectAddress *object,
11501152
{
11511153
PackageCacheKey pkey;
11521154
PackageCacheItem *item;
1153-
HeapTuple pkgbodyTup;
1155+
HeapTuple pkgbodyTup;
11541156
Form_pg_package_body pkgbodyStruct;
11551157

11561158
/*
@@ -1269,7 +1271,7 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
12691271
if (ORA_PARSER == compatible_db && behavior == DROP_RESTRICT)
12701272
{
12711273
/* Check if all dependencies that require CASCADE are views */
1272-
bool all_cascade_dep_is_view = true;
1274+
bool all_cascade_dep_is_view = true;
12731275
ObjectAddresses *viewObjects;
12741276

12751277
viewObjects = new_object_addresses();
@@ -1295,8 +1297,9 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
12951297
continue;
12961298

12971299
/*
1298-
* If the object was found via an automatic, internal, partition, or extension dependency,
1299-
* it is permitted to be removed even with RESTRICT.
1300+
* If the object was found via an automatic, internal, partition,
1301+
* or extension dependency, it is permitted to be removed even
1302+
* with RESTRICT.
13001303
*/
13011304
if (extra->flags & (DEPFLAG_AUTO |
13021305
DEPFLAG_INTERNAL |
@@ -1317,7 +1320,10 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
13171320
}
13181321
else
13191322
{
1320-
/* If any dependent object is not a view, set flag and exit loop */
1323+
/*
1324+
* If any dependent object is not a view, set flag and exit
1325+
* loop
1326+
*/
13211327
if (get_rel_relkind(obj->objectId) != RELKIND_VIEW)
13221328
{
13231329
all_cascade_dep_is_view = false;
@@ -1330,7 +1336,10 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
13301336
pfree(objDesc);
13311337
}
13321338

1333-
/* If all dependencies are views, mark them as invalid and trigger a recheck */
1339+
/*
1340+
* If all dependencies are views, mark them as invalid and trigger a
1341+
* recheck
1342+
*/
13341343
if (all_cascade_dep_is_view && viewObjects->numrefs > 0)
13351344
{
13361345
for (i = viewObjects->numrefs - 1; i >= 0; i--)
@@ -1339,7 +1348,8 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
13391348
}
13401349

13411350
/*
1342-
* After invalidating views, re-evaluate dependencies to ensure consistency.
1351+
* After invalidating views, re-evaluate dependencies to ensure
1352+
* consistency.
13431353
*/
13441354
if (refinddepobj)
13451355
*refinddepobj = true;
@@ -1709,7 +1719,7 @@ doDeletion(const ObjectAddress *object, int flags)
17091719
DeleteSequenceTuple(object->objectId);
17101720

17111721
if (ORA_PARSER == compatible_db && relKind == RELKIND_VIEW)
1712-
DeleteForceView(object->objectId);
1722+
DeleteForceView(object->objectId);
17131723

17141724
break;
17151725
}
@@ -1851,7 +1861,7 @@ AcquireDeletionLock(const ObjectAddress *object, int flags)
18511861
AccessExclusiveLock);
18521862
else
18531863
{
1854-
/* assume we should lock the whole object not a sub-object */
1864+
/* Assume we lock the whole object, not a sub-object */
18551865
LockDatabaseObject(object->classId, object->objectId, 0,
18561866
AccessExclusiveLock);
18571867
}
@@ -1868,7 +1878,7 @@ ReleaseDeletionLock(const ObjectAddress *object)
18681878
if (object->classId == RelationRelationId)
18691879
UnlockRelationOid(object->objectId, AccessExclusiveLock);
18701880
else
1871-
/* assume we should lock the whole object not a sub-object */
1881+
/* Assume we lock the whole object, not a sub-object */
18721882
UnlockDatabaseObject(object->classId, object->objectId, 0,
18731883
AccessExclusiveLock);
18741884
}
@@ -2211,21 +2221,21 @@ find_expr_references_walker(Node *node,
22112221

22122222
if (FUNC_EXPR_FROM_PG_PROC(funcexpr->function_from))
22132223
add_object_address(ProcedureRelationId, funcexpr->funcid, 0,
2214-
context->addrs);
2224+
context->addrs);
22152225
else
22162226
{
22172227
Oid funcoid = InvalidOid;
2218-
bool is_package = false;
2228+
bool is_package = false;
22192229

22202230
funcoid = get_top_function_info(funcexpr, &is_package);
22212231
if (OidIsValid(funcoid))
22222232
{
22232233
if (is_package)
22242234
add_object_address(PackageRelationId, funcoid, 0,
2225-
context->addrs);
2235+
context->addrs);
22262236
else
22272237
add_object_address(ProcedureRelationId, funcoid, 0,
2228-
context->addrs);
2238+
context->addrs);
22292239
}
22302240
}
22312241

@@ -2857,8 +2867,8 @@ object_address_comparator(const void *a, const void *b)
28572867
int
28582868
object_funpkgoid_comparator(const void *a, const void *b)
28592869
{
2860-
const ObjectFunOrPkg *obja = (const ObjectFunOrPkg *) a;
2861-
const ObjectFunOrPkg *objb = (const ObjectFunOrPkg *) b;
2870+
const ObjectFunOrPkg *obja = (const ObjectFunOrPkg *) a;
2871+
const ObjectFunOrPkg *objb = (const ObjectFunOrPkg *) b;
28622872

28632873
if (obja->objectId > objb->objectId)
28642874
return -1;

src/backend/commands/explain.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ ExplainPrintSerialize(ExplainState *es, SerializeMetrics *metrics)
10021002
{
10031003
const char *format;
10041004

1005-
/* We shouldn't get called for EXPLAIN_SERIALIZE_NONE */
1005+
/* Must not be called for EXPLAIN_SERIALIZE_NONE */
10061006
if (es->serialize == EXPLAIN_SERIALIZE_TEXT)
10071007
format = "text";
10081008
else
@@ -1343,7 +1343,7 @@ plan_is_disabled(Plan *plan)
13431343
* (eg, "Outer", "Inner"); it can be null at top level. plan_name is an
13441344
* optional name to be attached to the node.
13451345
*
1346-
* In text format, es->indent is controlled in this function since we only
1346+
* In text format, es->indent is controlled here since we only
13471347
* want it to change at plan-node boundaries (but a few subroutines will
13481348
* transiently increment it). In non-text formats, es->indent corresponds
13491349
* to the nesting depth of logical output groups, and therefore is controlled
@@ -1699,7 +1699,7 @@ ExplainNode(PlanState *planstate, List *ancestors,
16991699
{
17001700
BitmapIndexScan *bitmapindexscan = (BitmapIndexScan *) plan;
17011701
const char *indexname =
1702-
explain_get_index_name(bitmapindexscan->indexid);
1702+
explain_get_index_name(bitmapindexscan->indexid);
17031703

17041704
if (es->format == EXPLAIN_FORMAT_TEXT)
17051705
appendStringInfo(es->str, " on %s",
@@ -3116,13 +3116,12 @@ show_sort_info(SortState *sortstate, ExplainState *es)
31163116
}
31173117

31183118
/*
3119-
* You might think we should just skip this stanza entirely when
3120-
* es->hide_workers is true, but then we'd get no sort-method output at
3121-
* all. We have to make it look like worker 0's data is top-level data.
3122-
* This is easily done by just skipping the OpenWorker/CloseWorker calls.
3123-
* Currently, we don't worry about the possibility that there are multiple
3124-
* workers in such a case; if there are, duplicate output fields will be
3125-
* emitted.
3119+
* It might seem better to skip this stanza entirely when es->hide_workers
3120+
* is true, but then we'd get no sort-method output at all. We have to
3121+
* make it look like worker 0's data is top-level data. This is easily
3122+
* done by just skipping the OpenWorker/CloseWorker calls. Currently, we
3123+
* don't worry about the possibility that there are multiple workers in
3124+
* such a case; if there are, duplicate output fields will be emitted.
31263125
*/
31273126
if (sortstate->shared_info != NULL)
31283127
{
@@ -3330,7 +3329,7 @@ show_incremental_sort_info(IncrementalSortState *incrsortstate,
33303329
for (n = 0; n < incrsortstate->shared_info->num_workers; n++)
33313330
{
33323331
IncrementalSortInfo *incsort_info =
3333-
&incrsortstate->shared_info->sinfo[n];
3332+
&incrsortstate->shared_info->sinfo[n];
33343333

33353334
/*
33363335
* If a worker hasn't processed any sort groups at all, then
@@ -4831,7 +4830,7 @@ ExplainCustomChildren(CustomScanState *css, List *ancestors, ExplainState *es)
48314830
{
48324831
ListCell *cell;
48334832
const char *label =
4834-
(list_length(css->custom_ps) != 1 ? "children" : "child");
4833+
(list_length(css->custom_ps) != 1 ? "children" : "child");
48354834

48364835
foreach(cell, css->custom_ps)
48374836
ExplainNode((PlanState *) lfirst(cell), ancestors, label, NULL, es);

0 commit comments

Comments
 (0)