Commit b822ae13 authored by Tomas Vondra's avatar Tomas Vondra

Use lfirst_int in cmp_list_len_contents_asc

The function added in be45be9c is comparing integer lists (IntList) by
length and contents, but there were two bugs.  Firstly, it used intVal()
to extract the value, but that's for Value nodes, not for extracting int
values from IntList.  Secondly, it called it directly on the ListCell,
without doing lfirst().  So just do lfirst_int() instead.

Interestingly enough, this did not cause any crashes on the buildfarm,
but valgrind rightfully complained about it.

Discussion: https://postgr.es/m/bf3805a8-d7d1-ae61-fece-761b7ff41ecc@postgresfriends.org
parent d00fbdc4
...@@ -1750,8 +1750,8 @@ cmp_list_len_contents_asc(const ListCell *a, const ListCell *b) ...@@ -1750,8 +1750,8 @@ cmp_list_len_contents_asc(const ListCell *a, const ListCell *b)
forboth(lca, la, lcb, lb) forboth(lca, la, lcb, lb)
{ {
int va = intVal(lca); int va = lfirst_int(lca);
int vb = intVal(lcb); int vb = lfirst_int(lcb);
if (va > vb) if (va > vb)
return 1; return 1;
if (va < vb) if (va < vb)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment