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

Commitcff13ef

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 parent1357181 commitcff13ef

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
@@ -2083,9 +2083,8 @@ describeOneTableDetails(const char *schemaname,
20832083
partconstraintdef);
20842084
printTableAddFooter(&cont,tmpbuf.data);
20852085
}
2086-
2087-
PQclear(result);
20882086
}
2087+
PQclear(result);
20892088
}
20902089

20912090
if (tableinfo.relkind==RELKIND_PARTITIONED_TABLE)
@@ -2098,12 +2097,15 @@ describeOneTableDetails(const char *schemaname,
20982097
"SELECT pg_catalog.pg_get_partkeydef('%s'::pg_catalog.oid);",
20992098
oid);
21002099
result=PSQLexec(buf.data);
2101-
if (!result||PQntuples(result)!=1)
2100+
if (!result)
21022101
gotoerror_return;
21032102

2104-
partkeydef=PQgetvalue(result,0,0);
2105-
printfPQExpBuffer(&tmpbuf,_("Partition key: %s"),partkeydef);
2106-
printTableAddFooter(&cont,tmpbuf.data);
2103+
if (PQntuples(result)==1)
2104+
{
2105+
partkeydef=PQgetvalue(result,0,0);
2106+
printfPQExpBuffer(&tmpbuf,_("Partition key: %s"),partkeydef);
2107+
printTableAddFooter(&cont,tmpbuf.data);
2108+
}
21072109
PQclear(result);
21082110
}
21092111

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp