stefanoa0
Hello everyone, I hope you are well.
I’m migrating from PostgreSQL to CockroachDB and everything was going well until I came across the following error using the Geo.Postgis lib:
** (Postgrex.Error) ERROR 42883 (undefined_function) st_contains(): unknown signature: st_buffer(geometry, geometry) (desired <geometry>)
Here is the specific where snippet:
|> where(
[u],
st_contains(st_buffer(st_set_srid(st_make_point(^lng, ^lat), 4326), ^distance), u.geo_point)
)
I tried changing to a fragment function with the string:
fragment("ST_Contains(ST_Buffer(ST_SetSRID(ST_MakePoint($2, $3), 4326), $4), u0.geo_point)", lng, lat, distance)
But the same error happened
Has anyone had a similar error?
Thanks for your time!
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
** (ArgumentError) expected :max_attempts to be a positive integer, got: {:@, [line: 10, column: 19], [{:max_attempts, [line: 10, column:...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex











Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
pdgonzalez872
hi @stefanoa0 , welcome to ElixirForum!
So,
ST_Containsis not native to Postgres, it comes from the postgis extension. You can use the function when you install an extension. Here is the documentation for the function: https://postgis.net/docs/manual-3.4/ST_Contains.html.The lib you are using is a wrapper around the
postgisextension, that’s why your fragment didn’t work. Postgres just doesn’t know a function with that name.Here is a link that will help you migrate that specific functionality over: How we built scalable spatial data and spatial indexing in CockroachDB
I love Postgres, including the postgis library. Sad to see you migrate away from Postgres, but good luck nonetheless!
stefanoa0
Hi pdgonzalez872
Thanks for your response.
I saw that CoackroachDB has the functions I’m using, including running the query directly in the console and it works normally, my problem is just using the fragment in Ecto, as I need to pass the parameters to generate the geopolygon.
Isn’t there any other way to generate this fragment? I could manually sanitize the query values and not allow injections
stefanoa0
Hello
I made some progress with the error and discovered that:
When I do:
It’s works!!! BUT the distance variable is not in use, I just changed this interpolation to a integer 1, then when I use the ^distance this appears:
In specific that point:
The interpolation is “casting” the distance var as a geometry type, not an float type.
It’s something, but I need to resolve this now…
pdgonzalez872
Alright, seems like your approach of moving to cockroach db was to change the
DATABASE_URL(or equivalent) to the new db and go from there? I’m surprised things mostly worked. Neat!The error you posted first tells us the functions are different. While there may be one that has the same name, it seems to want different arguments/be called differently than the one from postgis. From the link I mentioned above it seems like they go in depth as to why they chose a certain approach.
I think this problem is better framed as: “I need to translate this a postgis function cockroachdb’s version”. This is how I see this at least. There is likely some minor refactoring you will need to do to get this working as you’d expect, I hope you have a good test case for it. I’m sure cockroachdb folks would potentially be able to help with this, maybe try there?
stefanoa0
Hello
Thanks for this informations, but the CockroachDB is compatible with PostgresSQL, as described:
[> CockroachDB supports the PostgreSQL wire protocol and the majority of PostgreSQL syntax. This means that existing applications built on PostgreSQL can often be migrated to CockroachDB without changing application code.]
So, the migrations was easy and all the queries are running very well, but that query who uses the Postgis functions needed to changed, I had to cast the distance to float and It’s works!
So, thanks for your help and time!
pdgonzalez872
Great!
Well, we saw that in this case it wasn’t a 1 to 1 since you had to refactor that function call. BUT, on CockRoachDB’s defense, postgis is
notpart of core, it’s an extension to Postgres even though it is the de-facto way of dealing with spacial data in Postgres. So, their claim could still very well be valid.You are welcome!