{"action":"created","issue":{"url":"https://api.github.com/repos/lib/pq/issues/372","labels_url":"https://api.github.com/repos/lib/pq/issues/372/labels{/name}","comments_url":"https://api.github.com/repos/lib/pq/issues/372/comments","events_url":"https://api.github.com/repos/lib/pq/issues/372/events","html_url":"https://github.com/lib/pq/issues/372","id":85729502,"number":372,"title":"invalid parameter warning","user":{"login":"tp","id":52437,"avatar_url":"https://avatars.githubusercontent.com/u/52437?v=3","gravatar_id":"","url":"https://api.github.com/users/tp","html_url":"https://github.com/tp","followers_url":"https://api.github.com/users/tp/followers","following_url":"https://api.github.com/users/tp/following{/other_user}","gists_url":"https://api.github.com/users/tp/gists{/gist_id}","starred_url":"https://api.github.com/users/tp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tp/subscriptions","organizations_url":"https://api.github.com/users/tp/orgs","repos_url":"https://api.github.com/users/tp/repos","events_url":"https://api.github.com/users/tp/events{/privacy}","received_events_url":"https://api.github.com/users/tp/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-06-06T09:43:13Z","updated_at":"2015-06-07T12:13:04Z","closed_at":"2015-06-07T12:13:04Z","body":"I get the the following panic when running this statement:\r\n\r\npanic: \r\n`panic: pq: got 2 parameters but the statement requires 0`\r\n\r\nstatement:\r\n```\r\ntx.MustExec(`DO\r\n$do$\r\nBEGIN\r\nIF EXISTS (SELECT 1 FROM dbversion WHERE key = $1 AND intvalue = $2) THEN\r\n  RAISE EXCEPTION 'unexpected version';\r\nEND IF;\r\nEND\r\n$do$`, dbVersionKey, 10)\r\n```\r\n\r\nI can't seem anything wrong with this but did not find any example of using functions with pq, so I am not sure if I am missing something."},"comment":{"url":"https://api.github.com/repos/lib/pq/issues/comments/109745709","html_url":"https://github.com/lib/pq/issues/372#issuecomment-109745709","issue_url":"https://api.github.com/repos/lib/pq/issues/372","id":109745709,"user":{"login":"tp","id":52437,"avatar_url":"https://avatars.githubusercontent.com/u/52437?v=3","gravatar_id":"","url":"https://api.github.com/users/tp","html_url":"https://github.com/tp","followers_url":"https://api.github.com/users/tp/followers","following_url":"https://api.github.com/users/tp/following{/other_user}","gists_url":"https://api.github.com/users/tp/gists{/gist_id}","starred_url":"https://api.github.com/users/tp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tp/subscriptions","organizations_url":"https://api.github.com/users/tp/orgs","repos_url":"https://api.github.com/users/tp/repos","events_url":"https://api.github.com/users/tp/events{/privacy}","received_events_url":"https://api.github.com/users/tp/received_events","type":"User","site_admin":false},"created_at":"2015-06-07T12:13:04Z","updated_at":"2015-06-07T12:13:04Z","body":"Thanks for the explanation @cbandy. :clap: \r\n\r\nI was able to gain a better understanding of functions in postgres and have since rewritten the code like this:\r\n\r\n```go\r\n\t\ttx.MustExec(`\r\n\t\t\tCREATE OR REPLACE FUNCTION ensureSchemaVersion(key text, version int) RETURNS INT\r\n\t\t\tAS $$\r\n\t\t\t\tBEGIN\r\n\t\t\t\tIF NOT EXISTS (SELECT 1 FROM dbversion dbv WHERE dbv.key = $1 AND dbv.intvalue = $2) THEN\r\n\t\t\t\t  RAISE EXCEPTION 'unexpected version';\r\n\t\t\t\tEND IF;\r\n\t\t\t\t\tRETURN $2;\r\n\t\t\t\tEND;\r\n\t\t\t$$ LANGUAGE plpgsql;\r\n\t\t`)\r\n\r\n\t\ttx.MustExec(\"select ensureSchemaVersion($1, $2)\", dbVersionKey, 0)\r\n```\r\n\r\nSorry for suspecting pq, when it was my fault."}}