Postgres + realtime

Hi all. I have a problem with realtime usage in asterisk 15.1.2.
And i want to save my config in postgres DB
I have install odbc driver and postgres DB, configure files
/etc/odbc.ini,

[Pg-aster-conf]
Description         = PostgreSQL connection to 'asterisk' database
Driver              = PostgreSQL
Database            = asterisk
Servername          = localhost
Port                = 5432
Protocol            = 9.2
ReadOnly            = No
RowVersioning       = No
ShowSystemTables    = No
ShowOidColumn       = No
FakeOidIndex        = No
ConnSettings        =

/etc/asterisk/res_odbc.conf,

[asterisk-conf]
enabled         => yes		
dsn             => Pg-aster-conf
username        => asterisk
password        => asterisk
pre-connect     => yes
max_connections => 100

/etc/asterisk/extconfig.conf

[settings]
sipusers        => odbc,asterisk-conf,sippeers
sippeers        => odbc,asterisk-conf,sippeers
sipregs         => odbc,asterisk-conf,sippeers
extensions      => odbc,asterisk-conf,extensions

/etc/asterisk/extensions.conf

[outcoling]
exten => _XXXX,1,Dial(SIP/${EXTEN},,m)
switch => Realtime/sipusers@sippeers
switch => Realtime/sippeers@sippeers
switch => Realtime/sipregs@sippeers
switch => Realtime/extensions@extensions

I have created DB tables from src script contrib/realtime/postgresql/postgresql_config.sql
Insert data into tables sippeers and extensions.
And when i try to call, in postgres log i see, that asterisk try to select exten and primary column from table sippeers and then from extension. In sippeers table there is no such column, and they are situated in table extension.
How can i make to use extension table ?

asterisk=> SELECT * FROM extensions;
 id |  context  | exten |       priority       | app  |      appdata
----+-----------+-------+----------------------+------+-------------------
  3 | outcoling | _XXXX | 1                    | Dial | (SIP/${EXTEN},,m)
asterisk=> SELECT name, host,type,context,nat,callgroup,disallow,allow,callerid FROM sippeers;
  name  |  host   |  type  |  context  | nat | callgroup | disallow |   allow   |   callerid
--------+---------+--------+-----------+-----+-----------+----------+-----------+---------------
 agent3 | dynamic | friend | outcoling | no  | 1         | all      | alaw,ulaw | "1003" <1003>
 agent1 | dynamic | friend | outcoling | no  | 1         | all      | alaw,ulaw | "1001" <1001>
 agent2 | dynamic | friend | outcoling | no  | 1         | all      | alaw,ulaw | "1002" <1002>
(3 строки)

From postgresql log

СООБЩЕНИЕ:  оператор: PREPARE "_PLAN0x7fb4a8007480"(char, char, char) as SELECT * FROM sippeers WHERE exten = $1 AND priority = $2 AND context = $3;EXECUTE "_PLAN0x7fb4a8007480"('h','1','sipusers')
ОШИБКА:  колонка "exten" не существует (символ 81)
ОПЕРАТОР:  PREPARE "_PLAN0x7fb4a8007480"(char, char, char) as SELECT * FROM sippeers WHERE exten = $1 AND priority = $2 AND context = $3;EXECUTE "_PLAN0x7fb4a8007480"('h','1','sipusers')
СООБЩЕНИЕ:  оператор: PREPARE "_PLAN0x7fb4a8003310"(char, char, char) as SELECT * FROM sippeers WHERE exten LIKE $1 AND priority = $2 AND context = $3 ORDER BY exten;EXECUTE "_PLAN0x7fb4a8003310"('\\_%','1','sipusers')
ОШИБКА:  колонка "exten" не существует (символ 81)
ОПЕРАТОР:  PREPARE "_PLAN0x7fb4a8003310"(char, char, char) as SELECT * FROM sippeers WHERE exten LIKE $1 AND priority = $2 AND context = $3 ORDER BY exten;EXECUTE "_PLAN0x7fb4a8003310"('\\_%','1','sipusers')
СООБЩЕНИЕ:  оператор: PREPARE "_PLAN0x7fb4a8002660"(char, char, char) as SELECT * FROM sippeers WHERE exten = $1 AND priority = $2 AND context = $3;EXECUTE "_PLAN0x7fb4a8002660"('h','1','sippeers')
ОШИБКА:  колонка "exten" не существует (символ 81)
ОПЕРАТОР:  PREPARE "_PLAN0x7fb4a8002660"(char, char, char) as SELECT * FROM sippeers WHERE exten = $1 AND priority = $2 AND context = $3;EXECUTE "_PLAN0x7fb4a8002660"('h','1','sippeers')
СООБЩЕНИЕ:  оператор: PREPARE "_PLAN0x7fb4a8002660"(char, char, char) as SELECT * FROM sippeers WHERE exten LIKE $1 AND priority = $2 AND context = $3 ORDER BY exten;EXECUTE "_PLAN0x7fb4a8002660"('\\_%','1','sippeers')
ОШИБКА:  колонка "exten" не существует (символ 81)
ОПЕРАТОР:  PREPARE "_PLAN0x7fb4a8002660"(char, char, char) as SELECT * FROM sippeers WHERE exten LIKE $1 AND priority = $2 AND context = $3 ORDER BY exten;EXECUTE "_PLAN0x7fb4a8002660"('\\_%','1','sippeers')
СООБЩЕНИЕ:  оператор: PREPARE "_PLAN0x7fb4a8004dd0"(char, char, char) as SELECT * FROM sippeers WHERE exten = $1 AND priority = $2 AND context = $3;EXECUTE "_PLAN0x7fb4a8004dd0"('h','1','sipregs')
ОШИБКА:  колонка "exten" не существует (символ 81)
ОПЕРАТОР:  PREPARE "_PLAN0x7fb4a8004dd0"(char, char, char) as SELECT * FROM sippeers WHERE exten = $1 AND priority = $2 AND context = $3;EXECUTE "_PLAN0x7fb4a8004dd0"('h','1','sipregs')
СООБЩЕНИЕ:  оператор: PREPARE "_PLAN0x7fb4a8002660"(char, char, char) as SELECT * FROM sippeers WHERE exten LIKE $1 AND priority = $2 AND context = $3 ORDER BY exten;EXECUTE "_PLAN0x7fb4a8002660"('\\_%','1','sipregs')
ОШИБКА:  колонка "exten" не существует (символ 81)
ОПЕРАТОР:  PREPARE "_PLAN0x7fb4a8002660"(char, char, char) as SELECT * FROM sippeers WHERE exten LIKE $1 AND priority = $2 AND context = $3 ORDER BY exten;EXECUTE "_PLAN0x7fb4a8002660"('\\_%','1','sipregs')
СООБЩЕНИЕ:  оператор: PREPARE "_PLAN0x7fb4a8002660"(char, char, char) as SELECT * FROM extensions WHERE exten = $1 AND priority = $2 AND context = $3;EXECUTE "_PLAN0x7fb4a8002660"('h','1','extensions')
СООБЩЕНИЕ:  продолжительность: 0.275 мс
СООБЩЕНИЕ:  оператор: DEALLOCATE "_PLAN0x7fb4a8002660"
СООБЩЕНИЕ:  продолжительность: 0.066 мс
СООБЩЕНИЕ:  оператор: PREPARE "_PLAN0x7fb4a8002660"(char, char, char) as SELECT * FROM extensions WHERE exten LIKE $1 AND priority = $2 AND context = $3 ORDER BY exten;EXECUTE "_PLAN0x7fb4a8002660"('\\_%','1','extensions')

*CLI> sip show peers
Name/username             Host                                    Dyn Forcerport Comedia    ACL Port     Status      Description                      Realtime
agent1/agent1             192.168.161.12                           D  No         No             22869    OK (5 ms)                                    Cached RT
agent2/agent2             192.168.134.93                           D  No         No             43835    OK (52 ms)                                   Cached RT
agent3/agent3             192.168.156.30                           D  No         No             65072    OK (5 ms)                                    Cached RT
3 sip peers [Monitored: 3 online, 0 offline Unmonitored: 0 online, 0 offline]

Remove the following from your extensions.conf:

switch => Realtime/sipusers@sippeers
switch => Realtime/sippeers@sippeers
switch => Realtime/sipregs@sippeers

These instruct the PBX to query each of these for dialplan extensions. Since they don’t contain dialplan extensions… they shouldn’t be queried.

I leave only this string in /etc/asterisk/extensions.conf

[outcoling]
exten => _XXXX,1,Dial(SIP/${EXTEN},,m)
;switch => Realtime/sipusers@sippeers
;switch => Realtime/sippeers@sippeers
;switch => Realtime/sipregs@sippeers
switch => Realtime/extensions@extensions

And in postgres log

СООБЩЕНИЕ:  оператор: PREPARE "_PLAN0x7fc690005e80"(char, char) as SELECT * FROM sippeers WHERE name = $1 AND host = $2;EXECUTE "_PLAN0x7fc690005e80"('1002','dynamic')
СООБЩЕНИЕ:  продолжительность: 0.795 мс
СООБЩЕНИЕ:  оператор: DEALLOCATE "_PLAN0x7fc690005e80"
СООБЩЕНИЕ:  продолжительность: 0.050 мс
СООБЩЕНИЕ:  оператор: PREPARE "_PLAN0x7fc690003010"(char) as SELECT * FROM sippeers WHERE name = $1;EXECUTE "_PLAN0x7fc690003010"('1002')
СООБЩЕНИЕ:  продолжительность: 0.457 мс
СООБЩЕНИЕ:  оператор: DEALLOCATE "_PLAN0x7fc690003010"
СООБЩЕНИЕ:  продолжительность: 0.041 мс
СООБЩЕНИЕ:  оператор: PREPARE "_PLAN0x7fc6900086a0"(char, char, char) as SELECT * FROM extensions WHERE exten = $1 AND priority = $2 AND context = $3;EXECUTE "_PLAN0x7fc6900086a0"('1002','2','extensions')
СООБЩЕНИЕ:  продолжительность: 0.226 мс
СООБЩЕНИЕ:  оператор: DEALLOCATE "_PLAN0x7fc6900086a0"
СООБЩЕНИЕ:  продолжительность: 0.041 мс
СООБЩЕНИЕ:  оператор: PREPARE "_PLAN0x7fc690003010"(char, char, char) as SELECT * FROM extensions WHERE exten LIKE $1 AND priority = $2 AND context = $3 ORDER BY exten;EXECUTE "_PLAN0x7fc690003010"('\\_%','2','extensions')
СООБЩЕНИЕ:  продолжительность: 0.268 мс
СООБЩЕНИЕ:  оператор: DEALLOCATE "_PLAN0x7fc690003010"
СООБЩЕНИЕ:  продолжительность: 0.044 мс
СООБЩЕНИЕ:  оператор: PREPARE "_PLAN0x7fc690006d20"(char, char, char) as SELECT * FROM extensions WHERE exten = $1 AND priority = $2 AND context = $3;EXECUTE "_PLAN0x7fc690006d20"('h','1','extensions')
СООБЩЕНИЕ:  продолжительность: 0.215 мс
СООБЩЕНИЕ:  оператор: DEALLOCATE "_PLAN0x7fc690006d20"
СООБЩЕНИЕ:  продолжительность: 0.042 мс
СООБЩЕНИЕ:  оператор: PREPARE "_PLAN0x7fc690001880"(char, char, char) as SELECT * FROM extensions WHERE exten LIKE $1 AND priority = $2 AND context = $3 ORDER BY exten;EXECUTE "_PLAN0x7fc690001880"('\\_%','1','extensions')
СООБЩЕНИЕ:  продолжительность: 0.240 мс
СООБЩЕНИЕ:  оператор: DEALLOCATE "_PLAN0x7fc690001880"
СООБЩЕНИЕ:  продолжительность: 0.049 мс
 sip show peers
Name/username             Host                                    Dyn Forcerport Comedia    ACL Port     Status      Description                      Realtime
agent1/agent1             192.168.161.12                           D  No         No             22869    OK (4 ms)                                    Cached RT
agent2/agent2             192.168.134.93                           D  No         No             43835    OK (31 ms)                                   Cached RT
agent3/agent3             192.168.156.30                           D  No         No             65072    OK (5 ms)                                    Cached RT
3 sip peers [Monitored: 3 online, 0 offline Unmonitored: 0 online, 0 offline]

and in CLI i see

[Nov 24 15:09:20] NOTICE[2732]: app_queue.c:8989 reload_queue_rules: queuerules.conf has not changed since it was last loaded. Not taking any action.
[Nov 24 15:09:23] WARNING[3365][C-00000042]: chan_sip.c:6280 create_addr: Purely numeric hostname (1002), and not a peer--rejecting!
[Nov 24 15:09:23] WARNING[3365][C-00000042]: app_dial.c:2510 dial_exec_full: Unable to create channel of type 'SIP' (cause 20 - Subscriber absent)