<p></p>
<p><b>@pnorman</b> approved this pull request.</p>

<p dir="auto">It looks like what's happening is the VALUES has types of <code class="notranslate">(text, int)</code> or <code class="notranslate">(text, bigint)</code>, and because the join condition could be done as <code class="notranslate">p.foo::text = t.osm_type</code> or <code class="notranslate">p.foo = t.osm_type::char(1)</code> it picks the former because the latter would involve potential data loss.</p>
<p dir="auto">There are three ways to resolve this</p>
<ol dir="auto">
<li>coerce the first (or all?) the values as documented for <a href="https://www.postgresql.org/docs/current/sql-values.html" rel="nofollow">quoted literal constants</a></li>
<li>use a temporary table, which will automatically coerce to the type of the columns when VALUES is used in the insert statement. This would also avoid potential out-of-memory failures for very large numbers of rows</li>
<li>coerce the type, as done in this PR</li>
</ol>
<p dir="auto">I'm somewhat inclined towards the third one, but would prefer to also coerce <code class="notranslate">t.osm_id</code> to bigint at the same time. This is only to be explicit about the type conversion, as if the values contains only numbers that can be represented as a normal integer it will get coerced into a bigint anyways when comparing to the p table, which has type bigint.</p>
<p dir="auto">So I'm okay with the PR as-is, but some food for thought and other options.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/osm2pgsql/pull/2007#pullrequestreview-1540011745">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AA6353RPASWF5PSC55NBQKDXRGGSVANCNFSM6AAAAAA2RJ5NAQ">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AA6353XRVFDQHCBMAGEW6QTXRGGSVA5CNFSM6AAAAAA2RJ5NASWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTS3ZK3OC.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/osm2pgsql/pull/2007/review/1540011745</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/osm2pgsql/pull/2007#pullrequestreview-1540011745",
"url": "https://github.com/openstreetmap/osm2pgsql/pull/2007#pullrequestreview-1540011745",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>