未验证 提交 44c2bd81 编写于 作者: H Hubert Zhang 提交者: GitHub

Backport the fix to various coverity issues

* Coverity: Resource leak

Fix some resource leak.

(cherry picked from commit e27ec070)

* Coverity: Identical code for different branches

Clean identical code in heap.c and analyze.c

(cherry picked from commit f076205c)

* Coverity: Variable unused

Remove unused varaible.
For tuplesort.h, we doesn't support mksort based cluster,
so we should just set is_mk_tuplesortstate to false

(cherry picked from commit e5c86775)

* Coverity: Logically dead code

Remove dead code.
insertDesc is alwasy NULL in ao_vacuum_rel_compact()

(cherry picked from commit 38552bf7)

* Coverity: Sizeof not portable

sizeof(HeapTuple *) should be sizeof(HeapTuple)

(cherry picked from commit cf23db49)

* Coverity: Behave test misformat

conn = dbconn.connect() should be aligned with if statement, or it
will never be executed.

(cherry picked from commit 126ba1c6)

* Coverity: Check return value of strcmp

return value of strcmp is not checked in some branches.

(cherry picked from commit fd498cf9)
上级 4e4f6784
...@@ -1280,9 +1280,6 @@ class spawn(object): ...@@ -1280,9 +1280,6 @@ class spawn(object):
if pid == 0: if pid == 0:
return True return True
if pid == 0:
return True
if os.WIFEXITED(status): if os.WIFEXITED(status):
self.status = status self.status = status
self.exitstatus = os.WEXITSTATUS(status) self.exitstatus = os.WEXITSTATUS(status)
......
...@@ -158,9 +158,9 @@ Feature: Tests for gpaddmirrors ...@@ -158,9 +158,9 @@ Feature: Tests for gpaddmirrors
And the segments are synchronized And the segments are synchronized
When user stops all primary processes When user stops all primary processes
And user can start transactions And user can start transactions
Then verify that there is a "heap" table "public.heap_table" in "gptest" with "100" rows Then verify that there is a "heap" table "public.heap_table" in "gptest" with "202" rows
Then verify that there is a "ao" table "public.ao_table" in "gptest" with "100" rows Then verify that there is a "ao" table "public.ao_table" in "gptest" with "202" rows
Then verify that there is a "co" table "public.co_table" in "gptest" with "100" rows Then verify that there is a "co" table "public.co_table" in "gptest" with "202" rows
And the user runs "gpstop -aqM fast" And the user runs "gpstop -aqM fast"
@concourse_cluster @concourse_cluster
......
...@@ -545,10 +545,13 @@ def impl(context, table_type, tablename, dbname): ...@@ -545,10 +545,13 @@ def impl(context, table_type, tablename, dbname):
def impl(context, table_type, tablename, dbname, numrows): def impl(context, table_type, tablename, dbname, numrows):
if not check_table_exists(context, dbname=dbname, table_name=tablename, table_type=table_type): if not check_table_exists(context, dbname=dbname, table_name=tablename, table_type=table_type):
raise Exception("Table '%s' of type '%s' does not exist when expected" % (tablename, table_type)) raise Exception("Table '%s' of type '%s' does not exist when expected" % (tablename, table_type))
with dbconn.connect(dbconn.DbURL(dbname=dbname), unsetSearchPath=False) as conn: conn = dbconn.connect(dbconn.DbURL(dbname=dbname), unsetSearchPath=False)
rowcount = dbconn.execSQLForSingleton(conn, "SELECT count(*) FROM %s" % tablename) try:
if rowcount != numrows: rowcount = dbconn.execSQLForSingleton(conn, "SELECT count(*) FROM %s" % tablename)
raise Exception("Expected to find %d rows in table %s, found %d" % (numrows, tablename, rowcount)) if rowcount != int(numrows):
raise Exception("Expected to find %d rows in table %s, found %d" % (int(numrows), tablename, rowcount))
finally:
conn.close()
@then( @then(
'data for partition table "{table_name}" with partition level "{part_level}" is distributed across all segments on "{dbname}"') 'data for partition table "{table_name}" with partition level "{part_level}" is distributed across all segments on "{dbname}"')
......
...@@ -1498,12 +1498,7 @@ heap_create_with_catalog(const char *relname, ...@@ -1498,12 +1498,7 @@ heap_create_with_catalog(const char *relname,
* Allocate new OIDs here. * Allocate new OIDs here.
*/ */
if (!OidIsValid(relid) && Gp_role != GP_ROLE_EXECUTE) if (!OidIsValid(relid) && Gp_role != GP_ROLE_EXECUTE)
{ relid = GetNewOid(pg_class_desc);
if (IsBootstrapProcessingMode())
relid = GetNewOid(pg_class_desc);
else
relid = GetNewOid(pg_class_desc);
}
/* /*
* Determine the relation's initial permissions. * Determine the relation's initial permissions.
......
...@@ -622,6 +622,8 @@ cdbCopyEndInternal(CdbCopy *c, char *abort_msg, ...@@ -622,6 +622,8 @@ cdbCopyEndInternal(CdbCopy *c, char *abort_msg,
break; break;
} }
} }
if (buffer)
PQfreemem(buffer);
} }
/* in SREH mode, check if this seg rejected (how many) rows */ /* in SREH mode, check if this seg rejected (how many) rows */
......
...@@ -2749,7 +2749,7 @@ acquire_sample_rows_dispatcher(Relation onerel, bool inh, int elevel, ...@@ -2749,7 +2749,7 @@ acquire_sample_rows_dispatcher(Relation onerel, bool inh, int elevel,
* This result is for a segment that's not holding any data for this * This result is for a segment that's not holding any data for this
* table. Should get 0 rows. * table. Should get 0 rows.
*/ */
if (this_totalrows != 0 || this_totalrows != 0) if (this_totalrows != 0)
elog(WARNING, "table \"%s\" contains rows in segment %d, which is outside the # of segments for the table's policy (%d segments)", elog(WARNING, "table \"%s\" contains rows in segment %d, which is outside the # of segments for the table's policy (%d segments)",
RelationGetRelationName(onerel), resultno, onerel->rd_cdbpolicy->numsegments); RelationGetRelationName(onerel), resultno, onerel->rd_cdbpolicy->numsegments);
} }
...@@ -4180,7 +4180,7 @@ merge_leaf_stats(VacAttrStatsP stats, ...@@ -4180,7 +4180,7 @@ merge_leaf_stats(VacAttrStatsP stats,
MemoryContext old_context; MemoryContext old_context;
HeapTuple *heaptupleStats = HeapTuple *heaptupleStats =
(HeapTuple *) palloc(numPartitions * sizeof(HeapTuple *)); (HeapTuple *) palloc(numPartitions * sizeof(HeapTuple));
// NDV calculations // NDV calculations
float4 colAvgWidth = 0; float4 colAvgWidth = 0;
......
...@@ -74,7 +74,6 @@ DefineExternalRelation(CreateExternalStmt *createExtStmt) ...@@ -74,7 +74,6 @@ DefineExternalRelation(CreateExternalStmt *createExtStmt)
Datum locationUris = 0; Datum locationUris = 0;
Datum locationExec = 0; Datum locationExec = 0;
char *commandString = NULL; char *commandString = NULL;
char *customProtName = NULL;
char rejectlimittype = '\0'; char rejectlimittype = '\0';
char formattype; char formattype;
int rejectlimit = -1; int rejectlimit = -1;
...@@ -426,9 +425,6 @@ DefineExternalRelation(CreateExternalStmt *createExtStmt) ...@@ -426,9 +425,6 @@ DefineExternalRelation(CreateExternalStmt *createExtStmt)
GetAssignedOidsForDispatch(), GetAssignedOidsForDispatch(),
NULL); NULL);
} }
if (customProtName)
pfree(customProtName);
} }
......
...@@ -3377,8 +3377,8 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat ...@@ -3377,8 +3377,8 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
/* Set up OID mode too */ /* Set up OID mode too */
if (strcmp(te->desc, "TABLE") == 0 || if (strcmp(te->desc, "TABLE") == 0 ||
strcmp(te->desc, "EXTERNAL TABLE") || strcmp(te->desc, "EXTERNAL TABLE") == 0 ||
strcmp(te->desc, "FOREIGN TABLE")) strcmp(te->desc, "FOREIGN TABLE") == 0)
_setWithOids(AH, te); _setWithOids(AH, te);
/* Emit header comment for item */ /* Emit header comment for item */
......
...@@ -4264,6 +4264,7 @@ getTypeStorageOptions(Archive *fout, int *numTypes) ...@@ -4264,6 +4264,7 @@ getTypeStorageOptions(Archive *fout, int *numTypes)
{ {
numTypes = 0; numTypes = 0;
tstorageoptions = (TypeStorageOptions *) pg_malloc(0); tstorageoptions = (TypeStorageOptions *) pg_malloc(0);
destroyPQExpBuffer(query);
return tstorageoptions; return tstorageoptions;
} }
......
...@@ -301,7 +301,6 @@ switcheroo_tuplesort_begin_cluster(TupleDesc tupDesc, ...@@ -301,7 +301,6 @@ switcheroo_tuplesort_begin_cluster(TupleDesc tupDesc,
tuplesort_begin_cluster_pg(tupDesc, indexRel, tuplesort_begin_cluster_pg(tupDesc, indexRel,
workMem, randomAccess); workMem, randomAccess);
} }
state->is_mk_tuplesortstate = gp_enable_mk_sort;
state->is_mk_tuplesortstate = false; state->is_mk_tuplesortstate = false;
return state; return state;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册