{"action":"opened","issue":{"url":"https://api.github.com/repos/postgres-x2/postgres-x2/issues/45","labels_url":"https://api.github.com/repos/postgres-x2/postgres-x2/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/postgres-x2/postgres-x2/issues/45/comments","events_url":"https://api.github.com/repos/postgres-x2/postgres-x2/issues/45/events","html_url":"https://github.com/postgres-x2/postgres-x2/issues/45","id":74549837,"number":45,"title":" WITH queries return \"input of anonymous composite ty....\"","user":{"login":"koichi-szk","id":985469,"avatar_url":"https://avatars.githubusercontent.com/u/985469?v=3","gravatar_id":"","url":"https://api.github.com/users/koichi-szk","html_url":"https://github.com/koichi-szk","followers_url":"https://api.github.com/users/koichi-szk/followers","following_url":"https://api.github.com/users/koichi-szk/following{/other_user}","gists_url":"https://api.github.com/users/koichi-szk/gists{/gist_id}","starred_url":"https://api.github.com/users/koichi-szk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koichi-szk/subscriptions","organizations_url":"https://api.github.com/users/koichi-szk/orgs","repos_url":"https://api.github.com/users/koichi-szk/repos","events_url":"https://api.github.com/users/koichi-szk/events{/privacy}","received_events_url":"https://api.github.com/users/koichi-szk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-09T01:19:07Z","updated_at":"2015-05-09T01:19:07Z","closed_at":null,"body":"This was submitted by Amit Khandekar, 2013-04-18.\r\n\r\nSee [sourceforge bug tracker](http://sourceforge.net/p/postgres-xc/bugs/410/) for details.\r\n\r\nA query like :\r\n\r\n```\r\nWITH rcte AS ( SELECT sum(id) AS totalid FROM tab1 )\r\npostgres-# UPDATE tab1 SET id = id + totalid FROM rcte\r\n```\r\n\r\nhas some existing issue due to which it gives:\r\n\r\n```\r\n-ERROR: input of anonymous composite types is not implemented\r\n```\r\n\r\nBut after trigger implementation, it would not error out, but in some cases it give wrong results like the e.g. shown below.\r\n\r\n```\r\npostgres=# \\set REP 'distribute by hash(val) '\r\npostgres=# CREATE TABLE tab1 ( id int, val text ) :REP ;\r\nCREATE TABLE\r\npostgres=# INSERT INTO tab1 VALUES ( 1, 'p1' );\r\nINSERT 0 1\r\npostgres=# INSERT INTO tab1 VALUES ( 11, 'c11' ),( 12, 'c12' );\r\nINSERT 0 2\r\npostgres=# INSERT INTO tab1 VALUES ( 23, 'c21' ),( 24, 'c22' );\r\nINSERT 0 2\r\npostgres=# WITH rcte AS ( SELECT sum(id) AS totalid FROM tab1 )\r\npostgres-# UPDATE tab1 SET id = id + totalid FROM rcte;\r\nUPDATE 5\r\npostgres=# SELECT * FROM tab1 ORDER BY id;\r\nid | val\r\n----+-----\r\n72 | p1\r\n82 | c11\r\n83 | c12\r\n94 | c21\r\n95 | c22\r\n(5 rows)\r\npostgres=# WITH wcte AS ( INSERT INTO tab1 VALUES ( 42, 'new' ) RETURNING id AS newid )\r\npostgres-# UPDATE tab1 SET id = id + newid FROM wcte;\r\nUPDATE 6\r\npostgres=# SELECT * FROM tab1 ORDER BY id;\r\nid | val\r\n-----+-----\r\n84 | new <---- This PG shows: 48 | new, not 84 | new.\r\n114 | p1\r\n124 | c11\r\n125 | c12\r\n136 | c21\r\n137 | c22\r\n(6 rows)\r\n```\r\n\r\nAbove, the UPDATE also updates the latest inserted value 42 and sets its value to 42+newid = 84. While in PG, it does not update the inserted value.\r\nAfter the trigger work, I am keeping this incorrect output in with_1.out. Currently there is no with_1.out; with_1.out itself had incorrect results."}}