{"action":"created","issue":{"url":"https://api.github.com/repos/go-spatial/tegola/issues/323","repository_url":"https://api.github.com/repos/go-spatial/tegola","labels_url":"https://api.github.com/repos/go-spatial/tegola/issues/323/labels{/name}","comments_url":"https://api.github.com/repos/go-spatial/tegola/issues/323/comments","events_url":"https://api.github.com/repos/go-spatial/tegola/issues/323/events","html_url":"https://github.com/go-spatial/tegola/issues/323","id":299580740,"number":323,"title":"Look into different ways to substitute a bbox and zoom token","user":{"login":"pnorman","id":1190866,"avatar_url":"https://avatars0.githubusercontent.com/u/1190866?v=4","gravatar_id":"","url":"https://api.github.com/users/pnorman","html_url":"https://github.com/pnorman","followers_url":"https://api.github.com/users/pnorman/followers","following_url":"https://api.github.com/users/pnorman/following{/other_user}","gists_url":"https://api.github.com/users/pnorman/gists{/gist_id}","starred_url":"https://api.github.com/users/pnorman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pnorman/subscriptions","organizations_url":"https://api.github.com/users/pnorman/orgs","repos_url":"https://api.github.com/users/pnorman/repos","events_url":"https://api.github.com/users/pnorman/events{/privacy}","received_events_url":"https://api.github.com/users/pnorman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/go-spatial/tegola/milestones/8","html_url":"https://github.com/go-spatial/tegola/milestone/8","labels_url":"https://api.github.com/repos/go-spatial/tegola/milestones/8/labels","id":3059743,"number":8,"title":"v0.7.0","description":"","creator":{"login":"ARolek","id":667850,"avatar_url":"https://avatars3.githubusercontent.com/u/667850?v=4","gravatar_id":"","url":"https://api.github.com/users/ARolek","html_url":"https://github.com/ARolek","followers_url":"https://api.github.com/users/ARolek/followers","following_url":"https://api.github.com/users/ARolek/following{/other_user}","gists_url":"https://api.github.com/users/ARolek/gists{/gist_id}","starred_url":"https://api.github.com/users/ARolek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARolek/subscriptions","organizations_url":"https://api.github.com/users/ARolek/orgs","repos_url":"https://api.github.com/users/ARolek/repos","events_url":"https://api.github.com/users/ARolek/events{/privacy}","received_events_url":"https://api.github.com/users/ARolek/received_events","type":"User","site_admin":false},"open_issues":22,"closed_issues":0,"state":"open","created_at":"2018-01-24T03:20:49Z","updated_at":"2018-03-01T19:12:26Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2018-02-23T02:41:31Z","updated_at":"2018-03-01T19:37:38Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Tokens are well-established, with Mapnik making use of them too. All the same, they're still a hack that relies on parsing SQL as text and writing SQL carefully. SQL injection isn't a security worry here, since it's intentional the style author can write arbitrary SQL, but the same flaws with manipulating SQL as text lead to bugs when writing queries.\r\n\r\nMy inclination is towards prepared statements\r\n\r\nThe server would execute something like\r\n\r\n```sql\r\nPREPARE water (geometry(polygon, 3857), int) AS\r\n  SELECT geom FROM foo WHERE geom && $1\r\n;\r\n```\r\nThis would be generated by taking the middle line from the style and surrounding it with the `PREPARE` and `;`. `water` would be something derived from the layer and provider names and be unique.\r\n\r\nA prepared statement could be made with pgx's [func (*Conn) PrepareEx](https://godoc.org/github.com/jackc/pgx#Conn.PrepareEx) but requires knowing the oid of the geometrytype and might not allow specifying typmods.\r\n\r\n[func (*Conn) Exec](https://godoc.org/github.com/jackc/pgx#Conn.Exec) can take a prepared statement name, e.g.\r\n\r\n```golang\r\np.pool.Exec(\"water\", bboxForTile, zoom)\r\n```\r\n\r\nIssues with prepared statements might be\r\n\r\n1. Cached query plans. These are normally good, but a query used over the range of zooms where it goes between sequential and index scans would have problems. It might be necessary to prepare a query for each zoom.\r\n\r\n2. Interactions with pgbouncer and pgpool. These can work with prepared statements, but something like PostGIS data type OIDs might change across them, leading to problems with PrepareEx."},"comment":{"url":"https://api.github.com/repos/go-spatial/tegola/issues/comments/369705782","html_url":"https://github.com/go-spatial/tegola/issues/323#issuecomment-369705782","issue_url":"https://api.github.com/repos/go-spatial/tegola/issues/323","id":369705782,"user":{"login":"ARolek","id":667850,"avatar_url":"https://avatars3.githubusercontent.com/u/667850?v=4","gravatar_id":"","url":"https://api.github.com/users/ARolek","html_url":"https://github.com/ARolek","followers_url":"https://api.github.com/users/ARolek/followers","following_url":"https://api.github.com/users/ARolek/following{/other_user}","gists_url":"https://api.github.com/users/ARolek/gists{/gist_id}","starred_url":"https://api.github.com/users/ARolek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARolek/subscriptions","organizations_url":"https://api.github.com/users/ARolek/orgs","repos_url":"https://api.github.com/users/ARolek/repos","events_url":"https://api.github.com/users/ARolek/events{/privacy}","received_events_url":"https://api.github.com/users/ARolek/received_events","type":"User","site_admin":false},"created_at":"2018-03-01T19:37:38Z","updated_at":"2018-03-01T19:37:38Z","author_association":"COLLABORATOR","body":"This is related to #275 "}}
{"actor":{"display_login":"ARolek"}}