Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have a precedence issue. This:</p> <pre><code>d.context-&gt;'hostname' ~ r.context-&gt;'Name' </code></pre> <p>is being parsed like this:</p> <pre><code>d.context -&gt; ('hostname' ~ r.context) -&gt; 'Name' </code></pre> <p>so the <code>~</code> is trying to match the <code>'hostname'</code> TEXT value with the <code>r.context</code> HSTORE. Add some parentheses to force the issue:</p> <pre><code>(d.context-&gt;'hostname') ~ (r.context-&gt;'Name') </code></pre> <p>If we have a look at the <a href="http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-PRECEDENCE" rel="nofollow">operator precedence table</a>, you'll see this:</p> <blockquote> <ul> <li>stuff that doesn't contain <code>~</code> or <code>-&gt;</code></li> <li><code>(any other)</code>: all other native and user-defined operators</li> <li>more stuff that doesn't contain <code>~</code> or <code>-&gt;</code></li> </ul> </blockquote> <p>So both <code>~</code> and <code>-&gt;</code> fall into the "other" category. I'd guess that <code>~</code> is added to the operator list before <code>-&gt;</code> since <code>~</code> is a native operator whereas <code>-&gt;</code> is added by the hstore extension.</p> <hr> <p>Interestingly enough, the <em>more stuff that doesn't contain <code>~</code> or <code>-&gt;</code></em> list does contain LIKE and this:</p> <pre><code>hstore1 -&gt; k1 like hstore2 -&gt; k2 </code></pre> <p>works as expected so in here:</p> <pre><code>select 'a=&gt;b'::hstore -&gt; 'a' like 'a=&gt;b'::hstore -&gt; 'a'; select 'a=&gt;b'::hstore -&gt; 'a' ~ 'a=&gt;b'::hstore -&gt; 'a'; </code></pre> <p>the first query will be <code>'t'</code> whereas the second will produce your "operator does not exist" error. I only mention this because I would have expected the <code>LIKE</code>, <code>SIMILAR</code>, and <code>~</code> operators to have the same precedence since they're all variations on the same theme.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload