Odd behavior with LIKE?

Поиск
Список
Период
Сортировка
От Tim Barnard
Тема Odd behavior with LIKE?
Дата
Msg-id 01eb01c0f2a0$6b2bdde0$a519af3f@hartcomm.com
обсуждение исходный текст
Ответы Re: Odd behavior with LIKE?  (GH <grasshacker@over-yonder.net>)
Список pgsql-general
I've noticed that if I don't preceed an underscore character ( _ )
with a double backslash ( \\ ), then a select using LIKE
ignores the underscore. For example, I have a couple of indexes
that end with "_ts" and a few tables that end in "ts":
 
From within psql:
 
select relname from pg_class;
 
  pg_type
  pg_attribute
  .
  .
  .
  raw_ts
  accts
  adjacents
  areacodes
  .
  .
  .
  and so on.
 
Now if I change the select to omit all tables/indexes
that begin with "pg_" or end with "_pkey":
 
select relname from pg_class where relname not like 'pg_%' and relname not like '%_pkey';
 
the "pg_" and "_pkey" files are correctly ommitted.
However, if I also want to omit all tables/indexes
ending with "_ts":
 
select relname from pg_class where relname not like 'pg_%' and relname not like '%_pkey' and relname not like '_ts';
 
then not only is "raw_ts" omitted (which is what I want),
but so are the tables "accts" and "adjacents". I can
correct this with:
 
select relname from pg_class where relname not like 'pg_%' and relname not like '%_pkey' and relname not like '\\_ts';
 
and probably whould do so for all conditions:
 
select relname from pg_class where relname not like 'pg\\_%' and relname not like '%\\_pkey' and relname not like '\\_ts';
 
Question is: Why must the underscore character
be prefixed with a double-backslash?
 
Tim
 

В списке pgsql-general по дате отправления:

Предыдущее
От: Jonathan Bartlett
Дата:
Сообщение: Re: Variables in Postgresql
Следующее
От: Farid Hajji
Дата:
Сообщение: numeric type in user-programs (needing numeric API?)