{"action":"created","issue":{"url":"https://api.github.com/repos/npgsql/npgsql/issues/641","labels_url":"https://api.github.com/repos/npgsql/npgsql/issues/641/labels{/name}","comments_url":"https://api.github.com/repos/npgsql/npgsql/issues/641/comments","events_url":"https://api.github.com/repos/npgsql/npgsql/issues/641/events","html_url":"https://github.com/npgsql/npgsql/issues/641","id":86883397,"number":641,"title":"create and execute function in same sql text throws exception","user":{"login":"Yarith","id":7803088,"avatar_url":"https://avatars.githubusercontent.com/u/7803088?v=3","gravatar_id":"","url":"https://api.github.com/users/Yarith","html_url":"https://github.com/Yarith","followers_url":"https://api.github.com/users/Yarith/followers","following_url":"https://api.github.com/users/Yarith/following{/other_user}","gists_url":"https://api.github.com/users/Yarith/gists{/gist_id}","starred_url":"https://api.github.com/users/Yarith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yarith/subscriptions","organizations_url":"https://api.github.com/users/Yarith/orgs","repos_url":"https://api.github.com/users/Yarith/repos","events_url":"https://api.github.com/users/Yarith/events{/privacy}","received_events_url":"https://api.github.com/users/Yarith/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-10T08:11:53Z","updated_at":"2015-06-11T06:40:44Z","closed_at":"2015-06-11T06:40:44Z","body":"I got another issue with the new 3.0 version (changeset 9a8980077f6348f082e46cb78663eef2fee1e215).\r\nI have a sql text which creates a function and then executes it. Npgsql throws a NpgsqlException\r\nwhich contains a \"function does not exist\" message. The function was not created. If i remove the\r\nfunction call then the function gets created.\r\n\r\nhere is the code for a test which throws the exception with the current version:\r\n```csharp\r\n[Test]\r\npublic void CreateAndExecuteFunction()\r\n{\r\n    const string query =\r\n@\"CREATE FUNCTION pg_temp.createandexecute() \r\n  RETURNS boolean AS \r\n$BODY$DECLARE\r\nBEGIN \r\n  RETURN TRUE;\r\nEND;$BODY$\r\n  LANGUAGE 'plpgsql';\r\n\r\nSELECT pg_temp.createandexecute();\";\r\n    object result = ExecuteScalar(query);\r\n    Assert.AreEqual(true, result);\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/npgsql/npgsql/issues/comments/111014339","html_url":"https://github.com/npgsql/npgsql/issues/641#issuecomment-111014339","issue_url":"https://api.github.com/repos/npgsql/npgsql/issues/641","id":111014339,"user":{"login":"roji","id":1862641,"avatar_url":"https://avatars.githubusercontent.com/u/1862641?v=3","gravatar_id":"","url":"https://api.github.com/users/roji","html_url":"https://github.com/roji","followers_url":"https://api.github.com/users/roji/followers","following_url":"https://api.github.com/users/roji/following{/other_user}","gists_url":"https://api.github.com/users/roji/gists{/gist_id}","starred_url":"https://api.github.com/users/roji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roji/subscriptions","organizations_url":"https://api.github.com/users/roji/orgs","repos_url":"https://api.github.com/users/roji/repos","events_url":"https://api.github.com/users/roji/events{/privacy}","received_events_url":"https://api.github.com/users/roji/received_events","type":"User","site_admin":false},"created_at":"2015-06-11T06:40:44Z","updated_at":"2015-06-11T06:40:44Z","body":"Thanks for reporting @Yarith.\r\n\r\nConfirmed. if the function creation is split into a different command then everything is fine.\r\n\r\nUnfortunately this seems to be a result of Npgsql's switching to using the PostgreSQL extended protocol, rather than the previously-used simple protocol. The same thing occurs when creating a table and selecting from it in the same command. I'm not sure why the extended protocol makes this impossible.\r\n\r\nI've updated our in-progress 3.0 [migration guide](http://npgsql.github.io/npgsql/doc/migration-3.0.html) to let people know about this.\r\n\r\nFor anyone wondering about the switch to extended, it allows us to do things like parameters in multiple-query commands, binary encoding, etc."}}