{"id":285290,"date":"2017-04-20T16:00:02","date_gmt":"2017-04-20T12:00:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=285290"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=285290","title":{"rendered":"\u041b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0432 PostgreSQL 10"},"content":{"rendered":"<p><img decoding=\"async\" align=\"left\" width=\"350\" src=\"https:\/\/habrastorage.org\/files\/e50\/460\/ba7\/e50460ba7f0b49e1bf79f0b2618cc9b4.jpg\"\/>PG Day\u201917 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0440\u0430\u0434\u043e\u0432\u0430\u0442\u044c \u0432\u0430\u0441 \u0430\u0432\u0442\u043e\u0440\u0441\u043a\u0438\u043c\u0438 \u0441\u0442\u0430\u0442\u044c\u044f\u043c\u0438. \u0421\u0435\u0433\u043e\u0434\u043d\u044f, \u043d\u0430\u0448 \u0441\u0442\u0430\u0440\u044b\u0439 \u0434\u0440\u0443\u0433 \u0438 \u0431\u0435\u0441\u0441\u043c\u0435\u043d\u043d\u044b\u0439 \u0430\u0432\u0442\u043e\u0440 \u043f\u0440\u043e\u0432\u043e\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u043e Web-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 <a href=\"https:\/\/habrahabr.ru\/users\/varanio\/\" class=\"user_link\">varanio<\/a> \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u0442 \u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438.*<\/p>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0445\u043e\u0442\u0435\u043b \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e \u00ab\u0413\u0430\u0440\u0440\u0438 \u041f\u043e\u0442\u0442\u0435\u0440 \u0438 \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0441\u043a\u0438\u0439 \u043a\u0430\u043c\u0435\u043d\u044c\u00bb, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u043e \u043b\u0435\u0442 \u043f\u0440\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 PostgreSQL \u0441 MySQL \u043a\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u044f\u0432\u043b\u044f\u043b\u0441\u044f \u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u043b, \u0447\u0442\u043e \u0432 \u041f\u043e\u0441\u0433\u0440\u0435\u0441\u0435 \u043d\u0435\u0442 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 (\u043c\u043e\u0436\u043d\u043e \u0440\u0435\u043f\u043b\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u044e \u0431\u0430\u0437\u0443 \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u043f\u0440\u0438\u0447\u0435\u043c \u0440\u0435\u043f\u043b\u0438\u043a\u0430 read only), \u0430 \u0432 MySQL \u0438\u0445 \u0446\u0435\u043b\u044b\u0445 \u0434\u0432\u0430 \u0432\u0438\u0434\u0430: statement based \u0438 row based.<\/p>\n<p>  \u0418 \u0435\u0441\u043b\u0438 statement based \u2014 \u044d\u0442\u043e \u0431\u043e\u043c\u0431\u0430 \u0437\u0430\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043b\u0430\u0437\u0435\u0440\u043d\u044b\u043c \u043f\u0440\u0438\u0446\u0435\u043b\u043e\u043c \u0432 \u043d\u043e\u0433\u0443, \u0442\u043e row based \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u043b\u043e \u0432 PG. \u0422.\u0435. \u0432\u043e\u043f\u0440\u043e\u0441 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u2014 \u043a\u0430\u043a \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0441\u043a\u0438\u0439 \u043a\u0430\u043c\u0435\u043d\u044c \u0443 \u043b\u044e\u0431\u0438\u0442\u0435\u043b\u0435\u0439 \u0431\u0430\u0437.<\/p>\n<p>  \u0422\u043e\u0447\u043d\u0435\u0435, \u0432 \u043f\u043e\u0441\u0433\u0440\u0435\u0441\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c [slony](http:\/\/www.slony.info\/) \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0435\u043f\u043b\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443-\u0434\u0432\u0435 \u043d\u0443\u0436\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041d\u043e slony \u2014 \u044d\u0442\u043e \u0445\u0438\u0442\u0440\u043e\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0435 \u043d\u0430 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443: \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u2014 \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0439. \u0422.\u0435. \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0437\u044f\u0442\u044c \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c ALTER TABLE ADD COLUMN, \u044d\u0442\u043e \u043d\u0430\u0434\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u043a\u0442\u043e-\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b, \u0430 \u043f\u043e\u0442\u043e\u043c, \u0447\u0442\u043e \u0435\u0449\u0435 \u0445\u0443\u0436\u0435, \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0432 \u043f\u0430\u043d\u0438\u043a\u0435 \u0432\u0435\u0440\u043d\u0443\u043b \u043a\u0430\u043a \u0431\u044b\u043b\u043e, \u0442\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0440\u0430\u0437\u0440\u0443\u043b\u0438\u0442\u044c \u044d\u0442\u0443 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0451\u0440\u043d\u044b\u0439 \u043c\u0430\u0433 80lvl. \u041f\u043e\u043c\u0438\u043c\u043e slony, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 9.4 \u0441\u0442\u0430\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 wal, \u0432\u0440\u043e\u0434\u0435 \u0431\u044b, \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u2014 pglogical.<\/p>\n<p>  **\u041d\u043e \u044d\u0442\u043e \u0432\u0441\u0451 \u043d\u0435 \u0442\u043e!**<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u044f \u0443\u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u0432 dev-\u0432\u0435\u0442\u043a\u0443 PostgreSQL 10 \u0443\u043f\u0430\u043b \u043a\u043e\u043c\u043c\u0438\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438, \u0431\u0435\u0437 \u044d\u043a\u0441\u0442\u0435\u043d\u0448\u0435\u043d\u043e\u0432 \u0438 \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432, \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u0440\u0435\u043f\u043b\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0430 \u043a\u0430\u043a \u043e\u043d\u043e \u0442\u0430\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0421\u0442\u0430\u0432\u0438\u043c PostgreSQL \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 \u043d\u0430 \u0443\u0431\u0443\u043d\u0442\u0443<br \/>  ==============================<\/p>\n<p>  \u042d\u0442\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e. \u0421\u0442\u0430\u0432\u0438\u043c \u0432\u0441\u044f\u043a\u0438\u0435 \u043f\u043e\u043b\u0443\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435 \u0441\u043b\u043e\u0432\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438:<\/p>\n<p>  ~~sudo apt-get install avada kedavra expelliarmus~~<br \/>  &#171;`sudo apt-get install -y build-essential libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev&#171;`<\/p>\n<p>  \u041a\u0430\u0447\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438: <\/p>\n<p>  &#171;`git clone git:\/\/git.postgresql.org\/git\/postgresql.git&#171;`<\/p>\n<p>  \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0435 \u044d\u0442\u043e \u0434\u0435\u043b\u043e:<br \/>  &#171;`<br \/>  cd postgresql<br \/>  .\/configure <br \/>  make <br \/>  make install <br \/>  &#171;`<\/p>\n<p>  \u042f \u043d\u0430\u043f\u0438\u0441\u0430\u043b make install, \u044d\u0442\u043e \u0431\u0435\u0437\u0432\u043e\u0437\u0432\u0440\u0430\u0442\u043d\u043e \u0437\u0430\u0433\u0430\u0434\u0438\u0442 \u0432\u0430\u0448 \/usr\/local, \u0442\u0430\u043a \u0447\u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0432 \u0432\u0438\u0440\u0443\u0430\u043b\u043a\u0435 \u0438\u043b\u0438 \u0434\u043e\u043a\u0435\u0440-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435, \u0438\u043b\u0438 \u0436\u0435 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0433\u043e \u0441\u0432\u0430\u0440\u0449\u0438\u043a\u0430, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e. \u042f \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435 \u0430\u0434\u043c\u0438\u043d, \u0442\u0430\u043a \u0447\u0442\u043e \u0438\u0437\u0432\u0438\u043d\u0438\u0442\u0435.<\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0435\u043c\u043e\u043d\u044b<br \/>  ======================<br \/>  \u0417\u0430\u0439\u0434\u0435\u043c \u043f\u043e\u0434 \u044e\u0437\u0435\u0440\u043e\u043c postgres. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0433\u043e \u0435\u0449\u0435 \u043d\u0435\u0442, \u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c, \u043d\u043e \u043d\u0435 \u0437\u0430\u043b\u043e\u0433\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u0434 \u043d\u0438\u043c, \u0442\u043e \u043d\u0430\u0432\u0435\u0440\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0437\u0430\u0434\u0430\u043d \u043f\u0430\u0440\u043e\u043b\u044c, \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u0434\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c sudo passwd postgres. \u0418\u0442\u0430\u043a, \u0437\u0430\u0439\u0434\u0435\u043c \u043f\u043e\u0434 \u044e\u0437\u0435\u0440\u043e\u043c postgres:<\/p>\n<p>  &#171;`su \u2014 postgres&#171;`<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0433\u0434\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0430\u043f\u043a\u0438 master \u0438 slave \u0438 \u043f\u0440\u043e\u0438\u043d\u0438\u0442\u0438\u043c \u0442\u0430\u043c \u0431\u0434:<\/p>\n<p>  &#171;`<br \/>  \/usr\/local\/pgsql\/bin\/initdb -D ~\/master<br \/>  \/usr\/local\/pgsql\/bin\/initdb -D ~\/slave<br \/>  &#171;`<\/p>\n<p>  \u0422.\u0435. \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0434\u0432\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0435\u043c\u043e\u043d\u0430 pg, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0443 \u0440\u0435\u043f\u043b\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041f\u0443\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u043f\u043e\u0440\u0442\u0443 5433, \u0434\u0440\u0443\u0433\u043e\u0439 \u2014 \u043d\u0430 5434.<\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u0432\u043f\u0438\u0441\u0430\u0442\u044c \u0432 `~\/master\/postgresql.conf` \u0441\u0442\u0440\u043e\u043a\u0443 `port = 5433`, \u0432 `~\/slave\/postgresql.conf` \u2014 \u0441\u0442\u0440\u043e\u043a\u0443 `port = 5434`, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>  \u0412 \u043e\u0431\u043e\u0438\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0430\u0445 `postgresql.conf` \u043d\u0430\u0434\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c:<br \/>  &#171;`<br \/>  wal_level = logical <br \/>  &#171;`<\/p>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430, \u043d\u0430\u0434\u043e \u0440\u0430\u0441\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0432 `pg_hba.conf`:<br \/>  &#171;`<br \/>  local replication postgres trust<br \/>  &#171;`<\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043e\u0431\u0430 \u0434\u0435\u043c\u043e\u043d\u0430:<br \/>  &#171;`<br \/>  \/usr\/local\/pgsql\/bin\/pg_ctl start -D ~\/master -l ~\/master.log<br \/>  \/usr\/local\/pgsql\/bin\/pg_ctl start -D ~\/slave -l ~\/slave.log<br \/>  &#171;`<\/p>\n<p>  \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044e<br \/>  ===================<br \/>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0438\u043a\u0430\u043a\u043e\u0439 (\u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0438\u043a\u0430\u043a\u043e\u0439) \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u0435\u0449\u0435 \u043d\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0448\u0435\u0440\u0441\u0442\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443, \u0447\u0442\u043e\u0431\u044b \u0445\u043e\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0443\u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u0438\u043c \u0432\u0438\u0434\u043e\u043c \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438. <\/p>\n<p>  \u0412\u0441\u0451 \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0432\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 postgres, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0445\u043b\u0430\u043c\u043b\u044f\u0442\u044c \u0434\u0435\u0442\u0430\u043b\u044f\u043c\u0438. \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043c\u0430\u0441\u0442\u0435\u0440:<br \/>  &#171;`<br \/>  \/usr\/local\/pgsql\/bin\/psql -p 5433<br \/>  &#171;`<\/p>\n<p>  C\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u00ab\u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e\u00bb:<br \/>  &#171;`sql<br \/>  CREATE TABLE repl (<br \/>   id int, <br \/>   name text, <br \/>   primary key(id)<br \/>  );<br \/>  CREATE PUBLICATION testpub;<br \/>  &#171;`<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 \u043e\u0434\u043d\u0443):<br \/>  &#171;`sql<br \/>  ALTER PUBLICATION testpub ADD TABLE repl;<br \/>  &#171;`<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u043b\u0435\u0439\u0432\u0430:<br \/>  &#171;`<br \/>  \/usr\/local\/pgsql\/bin\/psql -p 5434<br \/>  &#171;`<\/p>\n<p>  \u0422\u043e\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<br \/>  &#171;`sql<br \/>  CREATE TABLE repl (<br \/>   id int, <br \/>   name text, <br \/>   primary key(id)<br \/>  );<br \/>  &#171;`<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443 \u043d\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u0430 \u0434\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u0431\u0430\u0437\u044b \u0438 \u0438\u043c\u044f PUBLICATION:<br \/>  &#171;`sql<br \/>  CREATE SUBSCRIPTION testsub CONNECTION &#8216;port=5433 dbname=postgres&#8217; PUBLICATION testpub;<br \/>  &#171;`<\/p>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c<br \/>  ===============<br \/>  \u0412\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430 \u043c\u0430\u0441\u0442\u0435\u0440\u0435:<br \/>  &#171;`sql<br \/>  INSERT INTO repl (id, name) VALUES (1, &#8216;\u0412\u0430\u0441\u044f&#8217;);<br \/>  &#171;`<\/p>\n<p>  \u0427\u0438\u0442\u0430\u0435\u043c \u043d\u0430 \u0440\u0435\u043f\u043b\u0438\u043a\u0435:<br \/>  &#171;`sql<br \/>  postgres=# select * from repl;<br \/>   id | name <br \/>  &#8212;-+&#8212;&#8212;<br \/>   1 | \u0412\u0430\u0441\u044f<br \/>  (1 row)<br \/>  &#171;`<\/p>\n<p>  It works!<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0440\u0435\u043f\u043b\u0438\u043a\u0443:<br \/>  &#171;`<br \/>  \/usr\/local\/pgsql\/bin\/pg_ctl stop -D ~\/slave<br \/>  &#171;`<\/p>\n<p>  \u041d\u0430 \u043c\u0430\u0441\u0442\u0435\u0440\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c:<br \/>  &#171;`sql<br \/>  delete from repl;<br \/>   insert into repl (id, name) values (10, &#8216;test&#8217;);<br \/>  &#171;`<\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u043b\u0435\u0439\u0432 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c:<br \/>  &#171;`<br \/>  \/usr\/local\/pgsql\/bin\/pg_ctl start -D ~\/slave -l ~\/slave.log<br \/>  &#171;`<\/p>\n<p>  &#171;`sql<br \/>  postgres=# select * from repl;<br \/>   id | name <br \/>  &#8212;-+&#8212;&#8212;<br \/>   10 | test<br \/>  (1 row)<br \/>  &#171;`<\/p>\n<p>  \u0412\u0441\u0451 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e.<\/p>\n<p>  \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043d\u043e\u0432\u0443\u044e \u043a\u043e\u043b\u043e\u043d\u043a\u0443 \u043d\u0430 \u043c\u0430\u0441\u0442\u0435\u0440 \u0438 \u043d\u0430 \u0441\u043b\u0435\u0439\u0432, \u0432\u0441\u0442\u0430\u0432\u0438\u043b \u0437\u0430\u043f\u0438\u0441\u0438, \u0438 \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e. <\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0437\u043d\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u0445 \u0444\u0430\u0439\u043b `src\/test\/subscription\/t\/001_rep_changes.pl`. \u041e\u043d \u043d\u0430 \u043f\u0435\u0440\u043b\u0435, \u043d\u043e \u0442\u0430\u043c \u0432\u0441\u0451 \u043f\u043e\u043d\u044f\u0442\u043d\u043e. <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">src\/test\/subscription\/t\/001_rep_changes.pl<\/b><\/p>\n<div class=\"spoiler_text\">&#171;`perl<br \/>  # Basic logical replication test<br \/>  use strict;<br \/>  use warnings;<br \/>  use PostgresNode;<br \/>  use TestLib;<br \/>  use Test::More tests =&gt; 11;<\/p>\n<p>  # Initialize publisher node<br \/>  my $node_publisher = get_new_node(&#8216;publisher&#8217;);<br \/>  $node_publisher-&gt;init(allows_streaming =&gt; &#8216;logical&#8217;);<br \/>  $node_publisher-&gt;start;<\/p>\n<p>  # Create subscriber node<br \/>  my $node_subscriber = get_new_node(&#8216;subscriber&#8217;);<br \/>  $node_subscriber-&gt;init(allows_streaming =&gt; &#8216;logical&#8217;);<br \/>  $node_subscriber-&gt;start;<\/p>\n<p>  # Create some preexisting content on publisher<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abCREATE TABLE tab_notrep AS SELECT generate_series(1,10) AS a\u00bb);<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abCREATE TABLE tab_ins (a int)\u00bb);<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abCREATE TABLE tab_full AS SELECT generate_series(1,10) AS a\u00bb);<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abCREATE TABLE tab_rep (a int primary key)\u00bb);<\/p>\n<p>  # Setup structure on subscriber<br \/>  $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abCREATE TABLE tab_notrep (a int)\u00bb);<br \/>  $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abCREATE TABLE tab_ins (a int)\u00bb);<br \/>  $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abCREATE TABLE tab_full (a int)\u00bb);<br \/>  $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abCREATE TABLE tab_rep (a int primary key)\u00bb);<\/p>\n<p>  # Setup logical replication<br \/>  my $publisher_connstr = $node_publisher-&gt;connstr. &#8216; dbname=postgres&#8217;;<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abCREATE PUBLICATION tap_pub\u00bb);<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abCREATE PUBLICATION tap_pub_ins_only WITH (nopublish delete, nopublish update)\u00bb);<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abALTER PUBLICATION tap_pub ADD TABLE tab_rep, tab_full\u00bb);<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abALTER PUBLICATION tap_pub_ins_only ADD TABLE tab_ins\u00bb);<\/p>\n<p>  my $appname = &#8216;tap_sub&#8217;;<br \/>  $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abCREATE SUBSCRIPTION tap_sub CONNECTION &#8216;$publisher_connstr application_name=$appname&#8217; PUBLICATION tap_pub, tap_pub_ins_only\u00bb);<\/p>\n<p>  # Wait for subscriber to finish initialization<br \/>  my $caughtup_query =<br \/>  \u00abSELECT pg_current_xlog_location() &lt;= replay_location FROM pg_stat_replication WHERE application_name = &#8216;$appname&#8217;;\u00bb;<br \/>  $node_publisher-&gt;poll_query_until(&#8216;postgres&#8217;, $caughtup_query)<br \/>   or die \u00abTimed out while waiting for subscriber to catch up\u00bb;<\/p>\n<p>  my $result =<br \/>   $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;, \u00abSELECT count(*) FROM tab_notrep\u00bb);<br \/>  is($result, qq(0), &#8216;check non-replicated table is empty on subscriber&#8217;);<\/p>\n<p>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abINSERT INTO tab_ins SELECT generate_series(1,50)\u00bb);<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abDELETE FROM tab_ins WHERE a &gt; 20\u00bb);<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abUPDATE tab_ins SET a = -a\u00bb);<\/p>\n<p>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abINSERT INTO tab_rep SELECT generate_series(1,50)\u00bb);<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abDELETE FROM tab_rep WHERE a &gt; 20\u00bb);<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abUPDATE tab_rep SET a = -a\u00bb);<\/p>\n<p>  $node_publisher-&gt;poll_query_until(&#8216;postgres&#8217;, $caughtup_query)<br \/>   or die \u00abTimed out while waiting for subscriber to catch up\u00bb;<\/p>\n<p>  $result =<br \/>   $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;, \u00abSELECT count(*), min(a), max(a) FROM tab_ins\u00bb);<br \/>  is($result, qq(50|1|50), &#8216;check replicated inserts on subscriber&#8217;);<\/p>\n<p>  $result =<br \/>   $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;, \u00abSELECT count(*), min(a), max(a) FROM tab_rep\u00bb);<br \/>  is($result, qq(20|-20|-1), &#8216;check replicated changes on subscriber&#8217;);<\/p>\n<p>  # insert some duplicate rows<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abINSERT INTO tab_full SELECT generate_series(1,10)\u00bb);<\/p>\n<p>  # add REPLICA IDENTITY FULL so we can update<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abALTER TABLE tab_full REPLICA IDENTITY FULL\u00bb);<br \/>  $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abALTER TABLE tab_full REPLICA IDENTITY FULL\u00bb);<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abALTER TABLE tab_ins REPLICA IDENTITY FULL\u00bb);<br \/>  $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abALTER TABLE tab_ins REPLICA IDENTITY FULL\u00bb);<\/p>\n<p>  # and do the update<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abUPDATE tab_full SET a = a * a\u00bb);<\/p>\n<p>  # Wait for subscription to catch up<br \/>  $node_publisher-&gt;poll_query_until(&#8216;postgres&#8217;, $caughtup_query)<br \/>   or die \u00abTimed out while waiting for subscriber to catch up\u00bb;<\/p>\n<p>  $result =<br \/>   $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;, \u00abSELECT count(*), min(a), max(a) FROM tab_full\u00bb);<br \/>  is($result, qq(10|1|100), &#8216;update works with REPLICA IDENTITY FULL and duplicate tuples&#8217;);<\/p>\n<p>  # check that change of connection string and\/or publication list causes<br \/>  # restart of subscription workers. Not all of these are registered as tests<br \/>  # as we need to poll for a change but the test suite will fail none the less<br \/>  # when something goes wrong.<br \/>  my $oldpid = $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abSELECT pid FROM pg_stat_replication WHERE application_name = &#8216;$appname&#8217;;\u00bb);<br \/>  $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abALTER SUBSCRIPTION tap_sub CONNECTION &#8216;application_name=$appname $publisher_connstr&#8217;\u00bb);<br \/>  $node_publisher-&gt;poll_query_until(&#8216;postgres&#8217;,<br \/>   \u00abSELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = &#8216;$appname&#8217;;\u00bb)<br \/>   or die \u00abTimed out while waiting for apply to restart\u00bb;<\/p>\n<p>  $oldpid = $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abSELECT pid FROM pg_stat_replication WHERE application_name = &#8216;$appname&#8217;;\u00bb);<br \/>  $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abALTER SUBSCRIPTION tap_sub SET PUBLICATION tap_pub_ins_only\u00bb);<br \/>  $node_publisher-&gt;poll_query_until(&#8216;postgres&#8217;,<br \/>   \u00abSELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = &#8216;$appname&#8217;;\u00bb)<br \/>   or die \u00abTimed out while waiting for apply to restart\u00bb;<\/p>\n<p>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abINSERT INTO tab_ins SELECT generate_series(1001,1100)\u00bb);<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abDELETE FROM tab_rep\u00bb);<\/p>\n<p>  $node_publisher-&gt;poll_query_until(&#8216;postgres&#8217;, $caughtup_query)<br \/>   or die \u00abTimed out while waiting for subscriber to catch up\u00bb;<\/p>\n<p>  $result =<br \/>   $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;, \u00abSELECT count(*), min(a), max(a) FROM tab_ins\u00bb);<br \/>  is($result, qq(150|1|1100), &#8216;check replicated inserts after subscription publication change&#8217;);<\/p>\n<p>  $result =<br \/>   $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;, \u00abSELECT count(*), min(a), max(a) FROM tab_rep\u00bb);<br \/>  is($result, qq(20|-20|-1), &#8216;check changes skipped after subscription publication change&#8217;);<\/p>\n<p>  # check alter publication (relcache invalidation etc)<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abALTER PUBLICATION tap_pub_ins_only WITH (publish delete)\u00bb);<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abALTER PUBLICATION tap_pub_ins_only ADD TABLE tab_full\u00bb);<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abDELETE FROM tab_ins WHERE a &gt; 0\u00bb);<br \/>  $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;,<br \/>   \u00abINSERT INTO tab_full VALUES(0)\u00bb);<\/p>\n<p>  $node_publisher-&gt;poll_query_until(&#8216;postgres&#8217;, $caughtup_query)<br \/>   or die \u00abTimed out while waiting for subscriber to catch up\u00bb;<\/p>\n<p>  # note that data are different on provider and subscriber<br \/>  $result =<br \/>   $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;, \u00abSELECT count(*), min(a), max(a) FROM tab_ins\u00bb);<br \/>  is($result, qq(50|1|50), &#8216;check replicated deletes after alter publication&#8217;);<\/p>\n<p>  $result =<br \/>   $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;, \u00abSELECT count(*), min(a), max(a) FROM tab_full\u00bb);<br \/>  is($result, qq(11|0|100), &#8216;check replicated insert after alter publication&#8217;);<\/p>\n<p>  # check all the cleanup<br \/>  $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;, \u00abDROP SUBSCRIPTION tap_sub\u00bb);<\/p>\n<p>  $result =<br \/>   $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;, \u00abSELECT count(*) FROM pg_subscription\u00bb);<br \/>  is($result, qq(0), &#8216;check subscription was dropped on subscriber&#8217;);<\/p>\n<p>  $result =<br \/>   $node_publisher-&gt;safe_psql(&#8216;postgres&#8217;, \u00abSELECT count(*) FROM pg_replication_slots\u00bb);<br \/>  is($result, qq(0), &#8216;check replication slot was dropped on publisher&#8217;);<\/p>\n<p>  $result =<br \/>   $node_subscriber-&gt;safe_psql(&#8216;postgres&#8217;, \u00abSELECT count(*) FROM pg_replication_origin\u00bb);<br \/>  is($result, qq(0), &#8216;check replication origin was dropped on subscriber&#8217;);<\/p>\n<p>  $node_subscriber-&gt;stop(&#8216;fast&#8217;);<br \/>  $node_publisher-&gt;stop(&#8216;fast&#8217;);<br \/>  &#171;`  <\/div>\n<\/div>\n<p>  \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0435\u0441\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0431\u0435\u0437 primary key, \u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0438\u0437 \u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043d\u0430\u0434\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c:<br \/>  &#171;`sql<br \/>  ALTER TABLE tablename REPLICA IDENTITY FULL<br \/>  &#171;`<br \/>  \u042f \u043d\u0435 \u0437\u043d\u0430\u044e, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0432\u0438\u0434\u0438\u043c\u043e \u0433\u0435\u043d\u0435\u0440\u044f\u0442\u0441\u044f \u043a\u0430\u043a\u0438\u0435-\u0442\u043e id \u043d\u0430 \u043b\u0435\u0442\u0443. \u0415\u0441\u043b\u0438 \u0443 \u043a\u043e\u0433\u043e-\u0442\u043e \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438, \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c \u043f\u043b\u0438\u0437 \u0432 \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0445.<\/p>\n<p>  \u0412\u044b\u0432\u043e\u0434\u044b<br \/>  ==========<br \/>  \u0412\u044b\u0432\u043e\u0434 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442: \u044f \u043e\u0447\u0435\u043d\u044c \u0436\u0434\u0443 PostgreSQL 10 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 production-ready, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0435\u0448\u0438\u0442 \u0446\u0435\u043b\u044b\u0439 \u043f\u043b\u0430\u0441\u0442 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c (\u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043a\u0438\u043d\u0443\u0442\u044c slony). \u0414\u043b\u044f \u043a\u043e\u0433\u043e-\u0442\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043a\u0430\u043f\u043b\u0435\u0439 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0441 MySQL \u043d\u0430 Postgres.<\/p>\n<p>  \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442. \u0411\u0443\u0434\u0435\u0442 \u043b\u0438 \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e, \u0443\u0434\u043e\u0431\u043d\u043e \u0432 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u043d\u0438\u0438 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0415\u0441\u043b\u0438 \u0443 \u043a\u043e\u0433\u043e-\u0442\u043e \u0435\u0441\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u0442\u0435\u043c\u0435, \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c \u043f\u043b\u0438\u0437 \u0432 \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0445.<\/p>\n<p>  \u0410 \u043f\u043e\u043a\u0430 \u043c\u044b \u0436\u0434\u0435\u043c PostgreSQL 10, \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430, \u0443 \u0432\u0430\u0441 \u043c\u043d\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e \u0434\u0440\u0435\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0435 \u0442\u0435\u043a\u0443\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438. \u041d\u0430 [**PG Day&#8217;17**](https:\/\/pgday.ru\/ru\/2017\/request\/registration?utm_source=habrahabr&#038;utm_medium=blog&#038;utm_campaign=varanio2) \u0432\u0430\u0441 \u0436\u0434\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0434\u043e\u043a\u043b\u0430\u0434\u043e\u0432 \u0438 \u043c\u0430\u0441\u0442\u0435\u0440-\u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043f\u043e PostgreSQL. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, **\u0418\u043b\u044c\u044f \u041a\u043e\u0441\u043c\u043e\u0434\u0435\u043c\u044c\u044f\u043d\u0441\u043a\u0438\u0439** \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u0442 \u0432\u0441\u0435 \u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u041f\u0413, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439, \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c\u0435 \u0438, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u043e\u0434\u0441\u043a\u0430\u0436\u0435\u0442, \u043a\u0430\u043a \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a. \u0421\u043f\u0435\u0448\u0438\u0442\u0435 [**\u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f**](https:\/\/pgday.ru\/ru\/2017\/request\/registration?utm_source=habrahabr&#038;utm_medium=blog&#038;utm_campaign=varanio2)!<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/326996\/\"> https:\/\/habrahabr.ru\/post\/326996\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" align=\"left\" width=\"350\" src=\"https:\/\/habrastorage.org\/files\/e50\/460\/ba7\/e50460ba7f0b49e1bf79f0b2618cc9b4.jpg\"\/>PG Day\u201917 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0440\u0430\u0434\u043e\u0432\u0430\u0442\u044c \u0432\u0430\u0441 \u0430\u0432\u0442\u043e\u0440\u0441\u043a\u0438\u043c\u0438 \u0441\u0442\u0430\u0442\u044c\u044f\u043c\u0438. \u0421\u0435\u0433\u043e\u0434\u043d\u044f, \u043d\u0430\u0448 \u0441\u0442\u0430\u0440\u044b\u0439 \u0434\u0440\u0443\u0433 \u0438 \u0431\u0435\u0441\u0441\u043c\u0435\u043d\u043d\u044b\u0439 \u0430\u0432\u0442\u043e\u0440 \u043f\u0440\u043e\u0432\u043e\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u043e Web-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 <a href=\"https:\/\/habrahabr.ru\/users\/varanio\/\" class=\"user_link\">varanio<\/a> \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u0442 \u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438.*<\/p>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0445\u043e\u0442\u0435\u043b \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e \u00ab\u0413\u0430\u0440\u0440\u0438 \u041f\u043e\u0442\u0442\u0435\u0440 \u0438 \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0441\u043a\u0438\u0439 \u043a\u0430\u043c\u0435\u043d\u044c\u00bb, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u043e \u043b\u0435\u0442 \u043f\u0440\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 PostgreSQL \u0441 MySQL \u043a\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u044f\u0432\u043b\u044f\u043b\u0441\u044f \u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u043b, \u0447\u0442\u043e \u0432 \u041f\u043e\u0441\u0433\u0440\u0435\u0441\u0435 \u043d\u0435\u0442 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 (\u043c\u043e\u0436\u043d\u043e \u0440\u0435\u043f\u043b\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u044e \u0431\u0430\u0437\u0443 \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u043f\u0440\u0438\u0447\u0435\u043c \u0440\u0435\u043f\u043b\u0438\u043a\u0430 read only), \u0430 \u0432 MySQL \u0438\u0445 \u0446\u0435\u043b\u044b\u0445 \u0434\u0432\u0430 \u0432\u0438\u0434\u0430: statement based \u0438 row based.<\/p>\n<p>  \u0418 \u0435\u0441\u043b\u0438 statement based \u2014 \u044d\u0442\u043e \u0431\u043e\u043c\u0431\u0430 \u0437\u0430\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043b\u0430\u0437\u0435\u0440\u043d\u044b\u043c \u043f\u0440\u0438\u0446\u0435\u043b\u043e\u043c \u0432 \u043d\u043e\u0433\u0443, \u0442\u043e row based \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u043b\u043e \u0432 PG. \u0422.\u0435. \u0432\u043e\u043f\u0440\u043e\u0441 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u2014 \u043a\u0430\u043a \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0441\u043a\u0438\u0439 \u043a\u0430\u043c\u0435\u043d\u044c \u0443 \u043b\u044e\u0431\u0438\u0442\u0435\u043b\u0435\u0439 \u0431\u0430\u0437.<\/p>\n<p>  \u0422\u043e\u0447\u043d\u0435\u0435, \u0432 \u043f\u043e\u0441\u0433\u0440\u0435\u0441\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c [slony](http:\/\/www.slony.info\/) \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0435\u043f\u043b\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443-\u0434\u0432\u0435 \u043d\u0443\u0436\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041d\u043e slony \u2014 \u044d\u0442\u043e \u0445\u0438\u0442\u0440\u043e\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0435 \u043d\u0430 \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443: \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u2014 \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0439. \u0422.\u0435. \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0437\u044f\u0442\u044c \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c ALTER TABLE ADD COLUMN, \u044d\u0442\u043e \u043d\u0430\u0434\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u043a\u0442\u043e-\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b, \u0430 \u043f\u043e\u0442\u043e\u043c, \u0447\u0442\u043e \u0435\u0449\u0435 \u0445\u0443\u0436\u0435, \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0432 \u043f\u0430\u043d\u0438\u043a\u0435 \u0432\u0435\u0440\u043d\u0443\u043b \u043a\u0430\u043a \u0431\u044b\u043b\u043e, \u0442\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0440\u0430\u0437\u0440\u0443\u043b\u0438\u0442\u044c \u044d\u0442\u0443 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0451\u0440\u043d\u044b\u0439 \u043c\u0430\u0433 80lvl. \u041f\u043e\u043c\u0438\u043c\u043e slony, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 9.4 \u0441\u0442\u0430\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 wal, \u0432\u0440\u043e\u0434\u0435 \u0431\u044b, \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u2014 pglogical.<\/p>\n<p>  **\u041d\u043e \u044d\u0442\u043e \u0432\u0441\u0451 \u043d\u0435 \u0442\u043e!**<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u044f \u0443\u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u0432 dev-\u0432\u0435\u0442\u043a\u0443 PostgreSQL 10 \u0443\u043f\u0430\u043b \u043a\u043e\u043c\u043c\u0438\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438, \u0431\u0435\u0437 \u044d\u043a\u0441\u0442\u0435\u043d\u0448\u0435\u043d\u043e\u0432 \u0438 \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432, \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u0440\u0435\u043f\u043b\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0430 \u043a\u0430\u043a \u043e\u043d\u043e \u0442\u0430\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-285290","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/285290","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=285290"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/285290\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=285290"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=285290"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=285290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}