Search Postgresql Archives

Why does this SQL work?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I have the following setup :

manualscan=> set search_path=ver736,public;
SET
manualscan=> \d courier;
                                      Table "ver736.courier"
    Column     |          Type          |                        Modifiers
---------------+------------------------+----------------------------------------------------------
 org_id        | smallint               | not null default nextval('courier_org_id_seq'::regclass)
 courier_name  | character varying(500) | not null
 courier_code  | character varying(50)  |
 is_valid      | boolean                |
 universe_id   | character varying(50)  |
 courier_image | bytea                  |
Indexes:
    "courier_pk" PRIMARY KEY, btree (org_id)
    "courier_code_un" UNIQUE CONSTRAINT, btree (courier_code)
    "courier_name_un" UNIQUE CONSTRAINT, btree (courier_name)
    "courier_code_idx" btree (courier_code)
Referenced by:
xxx...xxx...(a few tables)


manualscan=> \d msgtxt;
                                         Table "public.msgtxt"
      Column       |           Type           |                       Modifiers
-------------------+--------------------------+--------------------------------------------------------
 msgid             | integer                  | not null default nextval('msgtxt_msgid_seq'::regclass)
 msgval            | text                     |
 transaction_stamp | timestamp with time zone | default now()
 corelationid      | text                     |
 deviverymode      | integer                  |
 destination       | text                     |
 expiration        | integer                  |
 messageid         | text                     |
 priority          | integer                  |
 redelivered       | boolean                  |
 replyto           | text                     |
 timestamp         | bigint                   |
 msgtype           | text                     |
 senderid          | text                     |
Indexes:
    "msgtxt_pkey" PRIMARY KEY, btree (msgid)
Triggers:
    manual_scan_tx_tr AFTER INSERT ON msgtxt FOR EACH ROW EXECUTE PROCEDURE process_manual_scan_tx()

manualscan=> select count(*) From msgtxt where msgid in (
manualscan(>         select msgid From courier where org_id=3
manualscan(>         )
manualscan->  ;
 count
-------
 10225
(1 row)
manualscan=> select count(*) From public.msgtxt where msgid in (select msgid From ver736.courier where org_id=3);
 count
-------
 10225
(1 row)

Please note, there is no msgid col in courier table. Which brings the question why does this SQL work? An "select msgid From courier where org_id=3" by itself gives error column "msgid" does not exist.

OS Version : Centos 7
PG Version : PostgreSQL 9.4.1 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-16), 64-bit

Regards
AK

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux