ããŒã¿ããŒã¹ãèšèšããŸããïŒ ããããæ°ããNoSQLã§ã¯ãªããå€ãè¯ããªã¬ãŒã·ã§ãã«SQLã§ããããŒã¿ãšããžãã¯ã«ã¢ã¯ã»ã¹ããããã®é¢ä¿ãšã¹ãã¢ãããã·ãŒãžã£ãèšè¿°ããããšãã§ããŸãã ãã¶ããããªãã¯PostgreSQLçšã®ããŒã¿ããŒã¹ãéçºããŠããŸããïŒ ãããããªããçŽ æŽããã-ãã®æçš¿ã¯ééããªãããªãã®ããã§ãã
PostgreSQLã®å©ç¹ã説æããããšã¯ãããããæå³ããããŸããã ç°¡åã«èšãã°ãããã¯è±å¯ãªæ©èœãåããææ°ã®é«éDBMSã§ãããåçšã®ããŒã¿ããŒã¹ç®¡çã·ã¹ãã ãšç«¶åã§ãããšããããšã§ãã PostgreSQLãBSD ã©ã€ã»ã³ã¹ãšåæ§ã®ç¡æã©ã€ã»ã³ã¹ã®äžã§é åžãããŠãããšããäºå®ïŒåçšãããžã§ã¯ãã§äœ¿çšæãªãã§äœ¿çšã§ããå€æŽã®éã«ç¬èªã®ã³ãŒããéããªããŠããœãŒã¹ã³ãŒããžã®ãã«ã¢ã¯ã»ã¹ãæäŸããŸãïŒã ã2016幎1æãããŒãžã§ã³9.5ããªãªãŒã¹ãããããã€ãã®éåžžã«åªããæ¹åãè¡ãããŸãã ïŒãPostgreSQLã¯ãããŸã§ã§æé«ã®DBMSã®1ã€ã§ãããšäž»åŒµã§ããŸãã ããããPostgreSQLéçºè ã®éã§äººæ°ãåŸãããšã劚ãããã®ã¯äœã§ããïŒ
ãããã®èŠå ã®1ã€ã¯ãããŒã¿ããŒã¹éçºãšãããªãã¡ã³ããã³ã¹ã®äž¡æ¹ã®ããã®ããªãå°æ°ã®ããŒã«ã§ãã ãã¡ãããPostgreSQLçšã®JDBCãã©ã€ããŒããããJDBCã䜿çšãããã¹ãŠã®ããŒã«ãåäœããŸããããããã®ããŒã«ã¯éåžžæ®éçã§ãããç¹å®ã®DBMSã®æ©èœãåžžã«äœ¿çšã§ããããã§ã¯ãããŸããã
ã©ã®éçºæ©èœã«ã€ããŠè©±ããŠããã®ã§ããïŒ ããšãã°ãæ¢åã®ããŒã¿ããŒã¹ãªããžã§ã¯ãïŒéåžžã¯ããŒãã«ãŸãã¯ãã¥ãŒïŒãå€æŽãããšãPostgreSQLããããèš±å¯ããªãããããªããžã§ã¯ãã®å€æŽäžã«ãšã©ãŒãçºçããããšããããããŸãã äŸåãªããžã§ã¯ãããããŸãã
ags=# create table t1 (f1 text); CREATE TABLE ags=# create view v1 as select * from t1; CREATE VIEW ags=# alter table t1 alter column f1 type char(5); ERROR: cannot alter type of a column used by a view or rule : rule _RETURN on view v1 depends on column "f1"
åæ§ã®æ©èœããã§ã«å€ãã®éçºè ãæ©ãŸããŠãããTODO wiki.postgresql.org/wiki/Todo#Views_and_Rulesã«èšé²ãããããã€ãã®å¯èœãªè§£æ±ºçããããŸãïŒäŸïŒ mwenus.blogspot.nl/2014/04/postgresql-how-to-handle-table-table and-view.html ïŒã
ãŸãã¯ãå¥ã®äŸã瀺ããŸãã ããã¯ããªãã«ã¯èµ·ãããŸããã§ãããã¹ãã¢ãããã·ãŒãžã£ãäœæãããããç©æ¥µçã«äœ¿çšãå§ãããã°ããããŠãããéåžžã¯ãããä¿®æ£ãããã£ãã®ã§ãã ãããŠãããžãã¯ãéšåçã«æ©èœããéšåçã«æ©èœããªãçç±ãç解ãå§ãããšãã«ã®ã¿ãå®éã«ã¯ã³ãŒãã®äžéšã§äœ¿çšãããæ°ãã眲åã䜿çšããŠè¿œå ã®ããã·ãŒãžã£ãäœæããã³ãŒãã®ä»ã®éšåã¯èª€ã£ãŠèª€ã£ãŠæ®ãããå€ãããã·ãŒãžã£ã䜿çšããããšã«æ°ä»ããŸããïŒ
ags=# \df f1 | | | | --------+-----+-----------------------+------------------------+--------- public | f1 | void | | public | f1 | void | p1 integer | (2 )
ãã®ç¶æ³ã«çŽé¢ããã®ã¯éåžžã«ç°¡åã§ããããã¯ãç§ã®æèŠã§ã¯ãã¹ãã¢ãããã·ãŒãžã£ãè«ççã«çµåããéåžžãå¿ããããããªããžã§ã¯ãã®å€èŠ³ãæé€ãã1ã€ã®ããã±ãŒãžã§ããŒã¿ããŒã¹ã«ããŒã«ããOracleããã±ãŒãžã®ãããªã°ã«ãŒãåãªããžã§ã¯ãããªãããšã«ãã£ãŠä¿é²ãããŸãã ã¯ãããã¡ãããã³ãŒãããã¹ãããŠããå Žåããã®ãããªãªããžã§ã¯ããæŠéã«å ¥ãå¯èœæ§ã¯å°ããã§ããããã®åäœã«ãã远跡ã®è€éããå¢ããŸãã
2ã€ã®ããŒã¿ããŒã¹ãæ¯èŒããäžæ¹ãä»æ¹ã«å€æããã¹ã¯ãªãããäœæããå Žåã¯ã©ãããã°ããã§ããïŒ ã»ãšãã©ã®å Žåã Liquibaseã䜿çšããããšããå§ãããŸãããLiquibaseãå°ãåã«è¿°ã¹ãäŸåé¢ä¿ã®åé¡ã解決ããæ¹æ³ã«ã€ããŠäœãç¥ããªãããšãç¥ã£ããšããããªãã¯äžæå¿«ã«è ¹ãç«ãŠãŸãã
3幎ã»ã©åã«MSSQLããPostgreSQLãžã®ç§»è¡ããã»ã¹ãéå§ãããšãã«ãåæ§ã®è³ªåã«çŽé¢ããŸããã åœæã Redgate SQL Source Controlã䜿çšããŠMSSQLãæäœããŠããŸããããPostgreSQLãæäœããããã®åæ§ã®ããŒã«ããªãããšã«éåžžã«æ©ãŸãããŠããŸããã 圌ãã¯éåžžã«æ©ãŸãããããŒã¿ããŒã¹ã®å€æŽã远跡ããéžæããããªããžã§ã¯ãã®ç§»è¡ã®ã¹ã¯ãªãããã€ã³ã¿ã©ã¯ãã£ãã¢ãŒããšèªåã¢ãŒãã®äž¡æ¹ã§äœæã§ããç¬èªã®ããŒã«ãäœæããããšã«ããŸããã
ç§ãã¡ã¯ã»ãšãã©ãJavaã§ããã°ã©ãã³ã°ããŠãããããéçºãã©ãããã©ãŒã ãéžæãã決å®ã¯ããã«åºãŸããã Eclipseã¢ããªã³ã®ã»ãããšããŠãè©Šè¡é¯èª€ãæ°åç¹°ãè¿ããåŸãã¢ããªã±ãŒã·ã§ã³ã®éçºãå§ãŸããŸããã
ãããããã°ããããŠã補åãçãŸããæ¹æ³ã§ã-pgCodeKeeperã
ã€ãŸãããã®æäœã¯æ¬¡ã®ããã«èª¬æã§ããŸããããŒã¿ããŒã¹ãªããžã§ã¯ãã¯ãEclipseãããžã§ã¯ãã®åœ¢åŒã§ãã£ã¹ã¯ã«ä¿åãããå°æ¥ïŒå¿ èŠã«å¿ããŠïŒããŒãžã§ã³ã¹ãã¬ãŒãžã·ã¹ãã ã«é 眮ã§ããŸãã ããŒã¿ããŒã¹ãšãããžã§ã¯ããŸãã¯ãããžã§ã¯ããã©ã³ãã®ãããããããã«æ¯èŒãããšãããŒã¿ããŒã¹ããïŒãããžã§ã¯ãããããŒã¿ããŒã¹ã«ãªããžã§ã¯ãã®ç¶æ ã転éããããã«ïŒå察æ¹åã«ç§»è¡ã¹ã¯ãªãããäœæã§ããŸãã ãããŠãç¬èªã®ANTLRææ³ã䜿çšããŠãªããžã§ã¯ãã解æãããšããäºå®ã«ãããããã«ããããªããžã§ã¯ãã®ããªãããçºéããäŸåé¢ä¿ã°ã©ããæ§ç¯ããããšãã§ããŸããããã«ãããé©åãªç§»è¡ã¹ã¯ãªããã®äœæã«ã€ãªãããŸãïŒäžèšã§è¡šæãããäŸåé¢ä¿ã®æ¢åã®åé¡ãèæ ®ã«å ¥ããŸãïŒã
pgCodeKeeperã䜿çšãããšãããŒã¿ããŒã¹ã«å€æŽãå ããã¯ãŒã¯ãããŒãæ§ç¯ã§ããŸãã ç§ãã¡ã¯èªå® ã§æ¬¡ã®ã¹ããŒã ã䜿çšããŠããŸãã
- éçºè
ã¯ãéçºããŒã¿ããŒã¹ã«å€æŽãå ããŸãïŒç§»è¡ããŒã¿ããŒã¹ã®äœææã«å¿
èŠã«ãªã移è¡ã¹ã¯ãªããã®äœæã«ã€ããŠã¯èæ
®ããŸããïŒã ãšããã§ãè€æ°ã®éçºè
éã§å
±æããã1ã€ã®éçºè
ããŒã¿ããŒã¹ãååšããå ŽåããããŸãã å€æŽãé©çšããå ŽåãpgCodeKeeperã§ã¯éžæãããªããžã§ã¯ãã®ã¿ã転éã§ããŸãã
- éçºè
ãpgCodeKeeperã䜿çšããŠè¡ã£ãå€æŽïŒå¿
èŠã«å¿ããŠããªããžã§ã¯ãã®äžéšã®ã¿ãžã®å€æŽïŒããããžã§ã¯ãã®éçºãã©ã³ãã«è»¢éãããã¡ã€ã³ãã©ã³ããšã®ããŒãžèŠæ±[ããŒãžèŠæ±]ãäœæãããŸãã
- é¢é£ä»ãèŠæ±ã¯ã責任è
ã«ãã£ãŠæ€èšŒãããåãå
¥ããããŸãã
- ããŒãžãªã¯ãšã¹ããåãå
¥ããåŸãpgCodeKeeperã¯ãã¡ã€ã³ãã©ã³ãããæŠéããŒã¿ããŒã¹ãžã®ç§»è¡ã¹ã¯ãªããïŒããŒã¿æ倱ã«ã€ãªããå¯èœæ§ã®ããåœä»€ãã¹ã¯ãªããã§çæããããšèŠåããŸãïŒãçæããŸãã
- äœæãããã¹ã¯ãªããã¯ãæŠéããŒã¿ããŒã¹ã«ããŒã«ãããŸãã
æåã®2ã€ã®ãã€ã³ãã¯éçºè ã«ãã£ãŠå®è¡ããã3çªç®ã¯ã€ã³ã¹ãã¯ã¿ãŒã«ãã£ãŠå®è¡ããã4çªç®ãš5çªç®ã¯ããŒã¿ããŒã¹ã«åè¡ãã人ã«ãã£ãŠå®è¡ãããŸãã 4çªç®ãš5çªç®ã®ãã€ã³ãã¯èªåã¢ãŒãã§ãå®è¡ã§ããŸããããã¯ãé£ç¶é ä¿¡ããã»ã¹[Continuous Delivery]ã®æ§ç¯ã«éåžžã«äŸ¿å©ã§ãããçŸåšã®èšäºã§ã¯ããã«ã€ããŠã¯èª¬æããŸããã
説æããã¯ãŒã¯ãããŒã§ã¯ããã¹ãŠã®ã¢ã¯ã·ã§ã³ãpgCodeKeeperãä»ããŠå®è¡ãããããã§ã¯ãããŸããã ããšãã°ãããŒãžã§ã³ç®¡çã·ã¹ãã ã§ã®æ°ãããã©ã³ãã®äœæã¯ãEclipseçšã®EGitã¢ããªã³ã«ãã£ãŠå®è¡ãããŸãã GitLabã®æ©èœã䜿çšããŠãããŒãžãªã¯ãšã¹ãã³ãŒãã¬ãã¥ãŒ[ããŒãžãªã¯ãšã¹ãã³ãŒãã¬ãã¥ãŒ]ã確èªããŸãã
ã€ãŸã pgCodeKeeperã®äž»ãªç®æšã¯ã以åã«äœæããããããžã§ã¯ããããŒã¿ããŒã¹ã€ã³ã¹ã¿ã³ã¹ãšæ¯èŒããå€æŽããããªããžã§ã¯ããå®çŸ©ããããŒã¿ããŒã¹ãããããžã§ã¯ãã«å€æŽïŒãããžã§ã¯ããã¡ã€ã«ã®å€æŽïŒãŸãã¯ãããžã§ã¯ãããããŒã¿ããŒã¹ã«å€æŽãé©çšããããšã§ãïŒç§»è¡ã¹ã¯ãªãããäœæããŸãïŒã
æéãçµã¡ããããžã§ã¯ããæ£åžžã«éçºãéå§ããç¹å®ã®ç¬éã«ã補åãå éšããŒã¿ããŒã¹ãç¶æããããã®çŸåšã®èŠä»¶ã«å¯Ÿå¿ããŠããããšã¯ééããããŸããã§ãããã補åã®ããã¯ãã°ã¯æ±ºããŠç©ºã§ã¯ãããŸããã ãŸããä»ã®éçºè ã®ããŒã¿ããŒã¹ã§çºçããå¯èœæ§ã®ããæ©èœããšã©ãŒã§æºããããŠããŸãã ãããžã§ã¯ãã¯ãäŒæ¥ãããžã§ã¯ãã®ãã¬ãŒã ã¯ãŒã¯å ã«ãšã©ãŸããïŒãããŠãçŸåšèŠæ±ãããŠããæ©èœãã»ãŒãã¹ãŠå®äºããŠãããããåæ»ã®æ®µéã«å ¥ãå¯èœæ§ããããŸãïŒããŸãã¯å ¬éåžå Žã«åå ¥ããŠããã£ãŒãããã¯ã䜿çšããŠæ¬¡ã®è³ªåãžã®åçãåãåãããšãæããã«ãªããŸããïŒ
- 補åã¯çŸåšããœãããŠã§ã¢åžå Žã§éèŠããããŸããïŒ
- éèŠãããå Žåã補åã®ã©ã®æµé/ã©ã€ã»ã³ã¹ã¢ãã«ããç§ãã¡ãšåžå Žã®äž¡æ¹ã«ãšã£ãŠæãé¢å¿ãããã®ã§ããããïŒ
ããã§ã䜿çšã®å¯äžã®æ¡ä»¶ã§ãããã£ãŒãããã¯ãæäŸãããããªãã¯ããŒã¿ãã¹ãã§pgCodeKeeperããªãªãŒã¹ããæºåãã§ããŸããã è·å Žã§è£œåãè©ŠããŠã¿ãã人ã¯ããŸããïŒ
ããžãã¹ã«ãã©ã€
ã§ãããããããŸã§èªãã§ããã ããã°ãå®éã«pgCodeKeeperãè©ŠããŠã¿ãã®ã«ååèå³ãããããšãé¡ã£ãŠããŸãã æºåã¯ããïŒ éããã
åã«æžããããã«ãpgCodeKeeperã¯ãã®é²åã®éã®çµããã«Eclipseãã©ãããã©ãŒã ã®ã¢ããªã³ã®ã»ããã«ãªãå§ããŸããã ãããŠããã¯ããã«ããã©ãããã©ãŒã ã§ã¯ãã¹ãŠã圌ãšäžç·ã«ããŸãããããšãæå³ãã圌ã¯LinuxãšWindowsã®äž¡æ¹ã§åããŠããŸãã åœç¶ãEclispeãã©ãããã©ãŒã ãèµ·åã§ããä»ã®ãã©ãããã©ãŒã ã§ãæ©èœããŸãããããã2ã€ã®ã¿ã䜿çšããŸãã
pgCodeKeeperãæ£åžžã«åäœããã«ã¯ãEclipseãã©ãããã©ãŒã ããŒãžã§ã³Juno以éãå¿ èŠã§ããããã®æ³šéã¯ãEclipseã®æ¢åã®ã€ã³ã¹ã¿ã³ã¹ã«ã€ã³ã¹ããŒã«ããå Žåã«é©çšãããŸãã æ°ããEclipseã€ã³ã¹ããŒã«ã®å Žåã eclipse.org / downloadsããææ°ããŒãžã§ã³ãå ¥æããŠãã ããã Javaéçºè åãã®Eclipse IDEãã€ã³ã¹ããŒã«ã§ããŸãïŒãšããããGitãšã®çµ±åã®ããã®ã¢ããªã³ãããããµã€ãºãæ¯èŒçå°ããããïŒããŸãã¯å¥œããªãã®ãéžæã§ããŸãïŒå¿ããªãã§ãã ããïŒEclipseã¯Javaã¢ããªã±ãŒã·ã§ã³ã§ãããããæ©èœããããã«ã¯ããŸãJRE / JDKãã€ã³ã¹ããŒã«ããå¿ èŠããããŸãïŒã
ã¡ãã¥ãŒé ç®[ãã«ã]-[æ°ãããœãããŠã§ã¢ã®ã€ã³ã¹ããŒã«]ãéžæããæŽæ°ãµã€ãã®URL pgcodekeeper.ru/update/releaseãå ¥åããŸãã
pgCodeKeeperã¢ããªã³ãéžæããŠã€ã³ã¹ããŒã«ããŸãã EclispeããªãŒããŒããŒãããæ°ãããããžã§ã¯ãã®ãŠã£ã¶ãŒãã®ãªã¹ãã«pgCodeKeeperãããžã§ã¯ãã衚瀺ãããå Žåãã€ã³ã¹ããŒã«ããã·ã§ã³ãå®äºãããšèŠãªããŸãã
pgCodeKeeperã®äœæ¥ã¯ããããžã§ã¯ãå ã®ãªããžã§ã¯ããšããŒã¿ããŒã¹ã®æ¯èŒã«åž°çããŸãããããžã§ã¯ãã®äœææã«ã¯ããããžã§ã¯ãã®æåã®ããã£ã¹ãããäœæããããŒã¿ããŒã¹ããã§ã«ããã¯ãã§ãã ããŒã¿ããŒã¹ãäœæããŠãããŒã¿ããŒã¹éçºããã»ã¹ãè©ŠããŠã¿ãŸãããã
DB圢æã¹ã¯ãªãã
$ psql -X <<SQL create database dev; \c dev create table t1 (f1 text); create view v1 as select * from t1; create view v2 as select * from v1; create function f1(p1 int) returns v2 as 'select * from v2 limit 1' language sql; SQL CREATE DATABASE "dev" "ags". CREATE TABLE CREATE VIEW CREATE VIEW CREATE FUNCTION $ psql dev psql (9.4.5, 9.3.10) "help", . (ags@10.84.0.6:5432) 15:11:08 [dev] =# \d \df ââââââââââ¬ââââââ¬ââââââââââââââââ¬âââââââââââ â â â â â ââââââââââŒââââââŒââââââââââââââââŒââââââââââ†â public â t1 â â ags â â public â v1 â â ags â â public â v2 â â ags â ââââââââââŽââââââŽââââââââââââââââŽâââââââââââ (3 ) ââââââââââ¬ââââââ¬ââââââââââââââââââââââââ¬âââââââââââââââââââââââââ¬ââââââââââ â â â â â â ââââââââââŒââââââŒââââââââââââââââââââââââŒâââââââââââââââââââââââââŒâââââââââ†â public â f1 â v2 â p1 integer â â ââââââââââŽââââââŽââââââââââââââââââââââââŽâââââââââââââââââââââââââŽââââââââââ (1 )
ããŠãç§ãã¡ã«ã¯ããŒã¿ããŒã¹ããããŸããããã§ã¯ãå°ã楜ããã§ãã³ãŒããæžããŸãããã ããŒãã«t1ãå€æŽããŸãã
(ags@10.84.0.6:5432) 15:12:28 [dev] =# alter table t1 alter column f1 type char(5); ERROR: cannot alter type of a column used by a view or rule : rule _RETURN on view v1 depends on column "f1" : 2,393
äºæ³ããã-èŠæ±ãããã¢ã¯ã·ã§ã³ãå®è¡ã§ããŸããã v1ã®è¡šç€ºã¯ããŒãã«t1ã«äŸåããŸãã ããã«ãv1ãåé€ããã«ã¯ãv2ãšf1ã®äž¡æ¹ãåé€ããå¿ èŠããããŸãã
(ags@10.84.0.6:5432) 15:16:05 [dev] * =# drop view v1; ERROR: cannot drop view v1 because other objects depend on it : view v2 depends on view v1 function f1(integer) depends on type v2 : Use DROP ... CASCADE to drop the dependent objects too. : 1,631
ã¯ã...ç§ãã¡ã¯å°ããªtrapã«ããããã§ããä»ç§ãã¡ã¯å¥è·¡ã®ã¹ã¯ãªããã®å©ãã«é Œããªããã°ãªããŸããïŒããšãã°ãäžã§æžãããã®ã«äŒŒãŠããŸã...ãããããããã¯äŸåã°ã©ãã«èœã¡ãå¯èœæ§ã®ãããã¹ãŠã®ãªããžã§ã¯ãã§åäœããŸããïŒããŸãã¯pgCodeKeeperïŒã«ã¹ã±ãŒãæ¹åŒã§ãã¥ãŒãšäŸåãªããžã§ã¯ããåé€ãã以åã«ä¿åãããã³ããã倱ããããªããžã§ã¯ãã埩å ããå¥ã®ãªãã·ã§ã³ããããŸããããã®ãæ©äŒãã¯äœ¿çšããŸããïŒã
ããŒã¿ããŒã¹ã管çãããããžã§ã¯ããäœæãããšããæ¥ãŸããã
æ°ãããããžã§ã¯ãã®ååãå ¥åããŸãã
ããŒã¿ããŒã¹ã®ãœãŒã¹ãèšå®ããŠããŸãïŒã¯ããæ°ãããœãŒã¹ãè¿œå ããå°ãäžæçãªç¬éã«ééãããããããŸããããèŸæ±åŒ·ããå°æ¥çã«ã¯ééããªãæ¹åããŸãïŒã ç§ã¯éåžžããã¹ã¯ãŒãã.pgpassã«ä¿åããpgCodeKeeperããã¹ã¯ãŒããååŸã§ããŸããã䜿çšããªãå Žåã¯ããŠã£ã¶ãŒãã®ãã¹ã¯ãŒããã£ãŒã«ãã«å ¥åããŸãã
ãããžã§ã¯ãã®äœæãå®äºãããããå®äºããã¿ã³ãã¯ãªãã¯ããŸãã ãã¹ãŠãæ£ããå®è¡ãããšãæ°ãããããžã§ã¯ããåæåãããããŒã¿ããŒã¹ãªããžã§ã¯ããå ¥åãããŸãã
ãããžã§ã¯ãå ã®ããŒã¿ããŒã¹ãªããžã§ã¯ãã¯ã人éãèªã¿åãããã¡ã€ã«ã§ãããç·šéããããšãã§ããŸãã
çŸåšãpgCodeKeeperã¯æ¬æ ŒçãªSQLãŸãã¯PL / pgSQLã³ãŒããšãã£ã¿ãšããŠäœçœ®ä»ããããŠããŸããããããšãã°ããã®å Žåã®ããã«ããšãã£ã¿ã§çŽæ¥ãã¡ã€ã«ãç·šéãããããåªããŠããå ŽåããããŸãã åäžãã£ãŒã«ãã®ã¿ã€ããããã¹ãããcharïŒ5ïŒã«å€æŽããŸãããã
ãããžã§ã¯ãã®ã¡ã€ã³ããã«ïŒäžéšã®ã¿ãã¯[ããŒã¿ããŒã¹ã®æŽæ°]ïŒã«ç§»åãã[å€æŽãååŸ]ãã¿ã³ãã¯ãªãã¯ããŸãã pgCodeKeeperã¯ãããŒã¿ããŒã¹ãšãããžã§ã¯ãã®äž¡æ¹ã§ç°ãªããªããžã§ã¯ãã®ãªã¹ãã衚瀺ããŸããã å·®åããã«ã«ã¯ãããŒã¿ããŒã¹ãªããžã§ã¯ãã®è©³çŽ°ãªå€æŽã衚瀺ãããŸãã
ããŠãããã§å°ãæ®ã£ãã®ã§ããããžã§ã¯ããªããžã§ã¯ããšåæããããããŒã¿ããŒã¹ãªããžã§ã¯ãã«ãã§ãã¯ãå ¥ãã[ã¹ã¯ãªããã®çæ]ãã¿ã³ãã¯ãªãã¯ããŸãã pgCodeKeeperã¯ãçæãããã¹ã¯ãªããã«ãããŒã¿ã®æ倱ã«ã€ãªããå¯èœæ§ã®ããå±éºãªæ瀺ãå«ãŸããŠããããšãæçã«å ±åãã次ã®ã¹ã¯ãªãããçæããŸãã
pgCodeKeeperã«ãã£ãŠçæããã移è¡ã¹ã¯ãªãã
SET TIMEZONE TO 'UTC'; SET check_function_bodies = false; -- DEPCY: This FUNCTION depends on the COLUMN: t1.f1 DROP FUNCTION f1(p1 integer); -- DEPCY: This VIEW depends on the COLUMN: t1.f1 DROP VIEW v2; -- DEPCY: This VIEW depends on the COLUMN: t1.f1 DROP VIEW v1; ALTER TABLE t1 ALTER COLUMN f1 TYPE char(5); /* - : t1 : text : char(5) */ -- DEPCY: This VIEW is a dependency of FUNCTION: f1(integer) CREATE VIEW v1 AS SELECT t1.f1 FROM t1; ALTER VIEW v1 OWNER TO ags; -- DEPCY: This VIEW is a dependency of FUNCTION: f1(integer) CREATE VIEW v2 AS SELECT v1.f1 FROM v1; ALTER VIEW v2 OWNER TO ags; CREATE OR REPLACE FUNCTION f1(p1 integer) RETURNS v2 LANGUAGE sql AS $$select * from v2 limit 1$$; ALTER FUNCTION f1(p1 integer) OWNER TO ags;
ãã£ããŒïŒ ããŠã¹ãæ°åã¯ãªãã¯ããã ãã§ïŒãããžã§ã¯ãã®åæåãé€ãïŒã移è¡ã¹ã¯ãªãããäœæã§ããŸãïŒ çµæã®ã¹ã¯ãªããã¯ãpgAdmin / psqlãšpgCodeKeeperã®äž¡æ¹ã§ç¬ç«ããŠããŒã«ã§ããŸãã PostgreSQLã§ã¯DDLåœä»€ããã©ã³ã¶ã¯ã·ã§ã³å¯Ÿå¿ã§ããããããã®ãããªã¹ã¯ãªãããããŒã«ãªãŒããŒããå Žåãã¹ã¯ãªããã®å®è¡äžã«ãšã©ãŒãçºçããå Žåã«ããŒã¿ããŒã¹ã®äžè²«æ§ã®ãªãç¶æ ãçºçããªãããã«ã1ã€ã®ãã©ã³ã¶ã¯ã·ã§ã³ïŒpsqlã§ã¯-1ããŒïŒã§ã¹ã¯ãªãããå®è¡ããå¿ èŠãããããšã瀺ããŸãã
ããã§ãããžã§ã¯ããšããŒã¿ããŒã¹ã®æ¯èŒãç¹°ãè¿ããšããããžã§ã¯ããšããŒã¿ããŒã¹ã®ãªããžã§ã¯ããç°ãªãããšãããããŸã...ïŒ
ãããã¯ãçºçããªãã®ã¯ããããžã§ã¯ãã«æåã§å€æŽãå ãããšãã«ãã¿ã€ãæåã®ç瞮圢ãcharãšããŠç€ºããããçŸåšã¯ããŒã¿ããŒã¹ã«å®å šãªåœ¢ã§è¡šç€ºãããŠããããã§ãã
ãããžã§ã¯ããæŽæ°ããã«ã¯ãäžéšã®ã¿ãããããžã§ã¯ãã®æŽæ°ãã«åãæ¿ãããå€æŽãååŸããã¯ãªãã¯ããå¿ èŠãªãªããžã§ã¯ããéžæããŠãéžæããå€æŽãé©çšããã¿ã³ãã¯ãªãã¯ããŸãã ãããã®ã¢ã¯ã·ã§ã³ãå®è¡ãããšãããŒã¿ããŒã¹ãšãããžã§ã¯ããªããžã§ã¯ãã¯åäžã«ãªããŸãã
æåãªè£œåã®ç¹åŸŽ
ãã®è£œåã¯å ã å éšããŒã¿ããŒã¹çšã«éçºãããããã䜿çšãããªããžã§ã¯ãã®ã¿ã€ãã®ã¿ãæåã«ãã¹ããããäžéšã¯ãŸã ãµããŒããããŠããŸããïŒããšãã°ãFOREIGN TABLEïŒã pgCodeKeeperã¯PostgreSQLã®ãã¹ãŠã®ããŒãžã§ã³ã§ã®åäœããµããŒãããŠããŸãããçŸåšãããŒãžã§ã³9.3以éã§åäœããããšãä¿èšŒãããŠããŸãïŒç¢ºèªããå¿ èŠããããŸã-9.1-9.2ã§ã¯åäœããŸããããã以åã§ã¯åäœããŸããïŒã
ãããã«
ä»æ¥ãPostgreSQLãšã®é£æºã容æã«ããæ°è£œåã«åºäŒãã次ã®ãããªãããã¯ã«è§Šããããšãªã補åã®äž»ãªæ©èœã«ã€ããŠè©±ããŸããïŒäŸåé¢ä¿ã®æåè¿œå ïŒããŒãµãŒã倱æããå Žåããã€ã§ãäŒããããšãã§ããŸãïŒãããŒãžã§ã³ç®¡çã·ã¹ãã ã®æäœãpgCodeKeeperã®åäœèªåã®é察話åã¢ãŒãã
ãã®èšäºã¯ãæ°èªãå°éçšèªããŸãã¯ããã€ãã®æ代é ãã®ã¹ããŒãã®ãã¬ãŒãºãªãã§ã¯å®çŸããŸããã§ããããã¹ãŠã®å ŽåãåèªãŸãã¯è¡šçŸã®æå³ããæåã®äœ¿çšæã«è±èªã§æãæ£ç¢ºã«å®çŸ©ããŸããã
çŸåšãpgCodeKeeperã¯ã2015幎11æ16æ¥ã®ãã·ã¢é£éŠæ¿åºä»€1236ãåœå®¶ããã³å°æ¹èªæ²»äœã®ããŒãºãæºããããã®èª¿éãç®çãšããå€åœããã®ãœãããŠã§ã¢ã®å ¥åœçŠæ¢ã®ç¢ºç«ã«ã€ããŠãã«åŸã£ãŠãåœå ãœãããŠã§ã¢ã®ã¬ãžã¹ããªã§ç»é²ããã»ã¹ãè¡ã£ãŠããŸãã garant.ru/hotlaw/federal/671898ããã¯ãè¿ãå°æ¥ãpgCodeKeeperãèŒžå ¥ä»£æ¿ããã°ã©ã ã«åå ã§ããããšãæå³ããŸãã
pgCodeKeeperã䜿çšãããšãPostgreSQLããŒã¿ããŒã¹ã®ã¡ã³ããã³ã¹ãå€§å¹ ã«å®¹æã«ãªããŸãïŒäžæ¯æ§ã®åœ±é¿ã確èªãããŠããŸãïŒã
pgCodeKeeperã¯ã©ã®ããã«ããããããšæããŸãããïŒ