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

Commit3808cf2

Browse files
committed
Fix infelicities in describeOneTableDetails' partitioned-table handling.
describeOneTableDetails issued a partition-constraint-fetching queryfor every table, even ones it knows perfectly well are not partitions.To add insult to injury, it then proceeded to leak the empty PGresultif the table wasn't a partition. Doing that a lot of times mightamount to a meaningful leak, so this seems like a back-patchable bug.Fix that, and also fix a related PGresult leak in the partition-parentcase (though that leak would occur only if we got no row, which isunexpected).Minor code beautification too, to make this code look more like thepre-existing code around it.Back-patch the whole change into v12. However, the fact that we alreadyknow whether the table is a partition dates only to commit1af25ca;back-patching the relevant changes from that is probably more churnthan is justified in released branches. Hence, in v11 and v10, justdo the minimum to fix the PGresult leaks.Noted while messing around with adjacent code for yesterday's \dimprovements.
1 parentba7359d commit3808cf2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

‎src/bin/psql/describe.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,9 +1989,8 @@ describeOneTableDetails(const char *schemaname,
19891989
partconstraintdef);
19901990
printTableAddFooter(&cont,tmpbuf.data);
19911991
}
1992-
1993-
PQclear(result);
19941992
}
1993+
PQclear(result);
19951994
}
19961995

19971996
if (tableinfo.relkind==RELKIND_PARTITIONED_TABLE)
@@ -2004,12 +2003,15 @@ describeOneTableDetails(const char *schemaname,
20042003
"SELECT pg_catalog.pg_get_partkeydef('%s'::pg_catalog.oid);",
20052004
oid);
20062005
result=PSQLexec(buf.data);
2007-
if (!result||PQntuples(result)!=1)
2006+
if (!result)
20082007
gotoerror_return;
20092008

2010-
partkeydef=PQgetvalue(result,0,0);
2011-
printfPQExpBuffer(&tmpbuf,_("Partition key: %s"),partkeydef);
2012-
printTableAddFooter(&cont,tmpbuf.data);
2009+
if (PQntuples(result)==1)
2010+
{
2011+
partkeydef=PQgetvalue(result,0,0);
2012+
printfPQExpBuffer(&tmpbuf,_("Partition key: %s"),partkeydef);
2013+
printTableAddFooter(&cont,tmpbuf.data);
2014+
}
20132015
PQclear(result);
20142016
}
20152017

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp