{"action":"created","issue":{"url":"https://api.github.com/repos/pramsey/pgsql-ogr-fdw/issues/19","labels_url":"https://api.github.com/repos/pramsey/pgsql-ogr-fdw/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/pramsey/pgsql-ogr-fdw/issues/19/comments","events_url":"https://api.github.com/repos/pramsey/pgsql-ogr-fdw/issues/19/events","html_url":"https://github.com/pramsey/pgsql-ogr-fdw/issues/19","id":53988032,"number":19,"title":"Make the \"ogr_fdw_info\" program a pgsql function in the OGR_FDW extension","user":{"login":"bvthomsen","id":1866520,"avatar_url":"https://avatars.githubusercontent.com/u/1866520?v=3","gravatar_id":"","url":"https://api.github.com/users/bvthomsen","html_url":"https://github.com/bvthomsen","followers_url":"https://api.github.com/users/bvthomsen/followers","following_url":"https://api.github.com/users/bvthomsen/following{/other_user}","gists_url":"https://api.github.com/users/bvthomsen/gists{/gist_id}","starred_url":"https://api.github.com/users/bvthomsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bvthomsen/subscriptions","organizations_url":"https://api.github.com/users/bvthomsen/orgs","repos_url":"https://api.github.com/users/bvthomsen/repos","events_url":"https://api.github.com/users/bvthomsen/events{/privacy}","received_events_url":"https://api.github.com/users/bvthomsen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pramsey/pgsql-ogr-fdw/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-01-11T10:32:50Z","updated_at":"2015-01-17T15:58:22Z","closed_at":null,"body":"It it possible to convert the utility program ogd_fdw_info into a PL/pgSQL function residing in the OGR_FDW extension ? And let this function create the fdw table directly ?\r\n\r\nSomething  like:\r\nSQL> CREATE EXTENSION OGR_FDW;\r\n\r\nSQL> SELECT OGR_FDW_CREATE_TABLE(' ... OGR-def....', 'layername', 'my_new_table');\r\nor \r\nSQL> SELECT OGR_FDW_CREATE_TABLE('...OGR-def....','layername','my_new_table',MultiPolygon,4326);\r\n\r\nThe last call would create the table with a predefined typemod on the geometry column.\r\n\r\n "},"comment":{"url":"https://api.github.com/repos/pramsey/pgsql-ogr-fdw/issues/comments/70372021","html_url":"https://github.com/pramsey/pgsql-ogr-fdw/issues/19#issuecomment-70372021","issue_url":"https://api.github.com/repos/pramsey/pgsql-ogr-fdw/issues/19","id":70372021,"user":{"login":"robe2","id":4734450,"avatar_url":"https://avatars.githubusercontent.com/u/4734450?v=3","gravatar_id":"","url":"https://api.github.com/users/robe2","html_url":"https://github.com/robe2","followers_url":"https://api.github.com/users/robe2/followers","following_url":"https://api.github.com/users/robe2/following{/other_user}","gists_url":"https://api.github.com/users/robe2/gists{/gist_id}","starred_url":"https://api.github.com/users/robe2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robe2/subscriptions","organizations_url":"https://api.github.com/users/robe2/orgs","repos_url":"https://api.github.com/users/robe2/repos","events_url":"https://api.github.com/users/robe2/events{/privacy}","received_events_url":"https://api.github.com/users/robe2/received_events","type":"User","site_admin":false},"created_at":"2015-01-17T15:58:22Z","updated_at":"2015-01-17T15:58:22Z","body":"External program runs on the server.  \r\n\r\nCOPY PROGRAM can only be used by super users because it runs under the context of the postgres account.   That's why when I create the function, I mark it as security definer if I want regular users to be able to use it.\r\n\r\nThere is a psql equivalent called  \\copy from program which runs client side to achieve the same, except would launch an executable on client's computer and pipe into table in the database.  \r\n\r\nAs a side note about the type modifier.  It's not sufficient to just mark it as say geometry(MULTIPOLYGON, 4326) or at least I wasn't successful doing that.  Underlying the FDW still returns ST_SRID = 0 so intersects and other junk would fail.  That's why when I need it that way, I wrap the table in a view and cast the geometry to something like  ST_SetSRID(geom,4326)::geometry(MULTIPOLYGON, 4326)\r\n\r\n"}}