Postgrex without Array types?

131 views
Skip to first unread message

Nick Pavlica

unread,
Jul 5, 2016, 2:53:11 PM7/5/16
to elixir-lang-talk
All,
  I'm trying to use Elixir with CockroachDB (https://github.com/cockroachdb/cockroach).  They are implementing the Postgresql protocol for their SQL interface, but haven't implemented the Array type.  There is a ticket open for adding arrays, but they haven't had a chance to implement it yet.  I've been trying to connect with Postgrex, but get the following error:

11:28:55.749 [error] Postgrex.Protocol (#PID<0.157.0>) failed to connect: ** (Postgrex.Error) ERROR (internal_error): syntax error at or near "("
SELECT t.oid, t.typname, t.typsend, t.typreceive, t.typoutput, t.typinput,
       t.typelem, coalesce(r.rngsubtype, 0), ARRAY (
                                                   ^
Is it possible to connect without calling for an ARRAY type?  They have several Postgresql drivers working, so I know that it can be done :)  I've been looking at the Postgrex source, but haven't found a solution yet.  Your guidance is appreciated!


Thanks!
--Nick  

José Valim

unread,
Jul 5, 2016, 3:03:48 PM7/5/16
to elixir-l...@googlegroups.com
Hi Nick!

Postgrex does a query to get all of the database types once it connects. Maybe you can try rewriting the query yourself in a way it doesn't use ARRAY? You may need to slightly change the code after too but you should definitely give it a try. :)



José Valim
Skype: jv.ptec
Founder and Director of R&D

--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/e722f476-2b4a-46e1-b902-6b5315ce3c33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nick Pavlica

unread,
Jul 6, 2016, 10:11:10 AM7/6/16
to elixir-lang-talk, jose....@plataformatec.com.br
Jose,
   

Postgrex does a query to get all of the database types once it connects. Maybe you can try rewriting the query yourself in a way it doesn't use ARRAY? You may need to slightly change the code after too but you should definitely give it a try. :)



This gave me a great place to start investigating.  While trying to rewrite the query in lib/postgrex/types.ex, I discovered that there are features other than ARRAY that haven't yet been implemented in CockroachDB.  I posted my questions to the CockroachDB group, and got this response: (https://groups.google.com/forum/#!topic/cockroach-db/WVm4P8PX1cM).  Essentially stating that they don't have any meta data tables, but do plan to support information_schema in the near term.  At the moment, they are using a static map (https://github.com/cockroachdb/cockroach/blob/master/sql/pgwire/types.go#L362) of all the available types.  If I understand  the Postgrex code properly, it builds the type map dynamically in types.ex.  I'm guessing that I would need to modify types.ex so that it would use the static type map that CockroachDB uses.  That being said, is there a way to add this functionality/behavior to Postgrex, without having to create a whole new thing, like PostgrexCDB?  


Thanks!
-- Nick

José Valim

unread,
Jul 6, 2016, 10:42:47 AM7/6/16
to Nick Pavlica, elixir-lang-talk
You should open up an issue in Postgrex. Maybe we can allow a types configuration that you would set in the format that Postgrex expects and, when this configuration is available, Postgrex would no longer perform the query.



José Valim
Skype: jv.ptec
Founder and Director of R&D

Reply all
Reply to author
Forward
0 new messages