Cleaner code

28 views
Skip to first unread message

Nicklas Widlund Bjurman

unread,
Jul 17, 2014, 8:57:00 AM7/17/14
to epg...@googlegroups.com
The semiocast/pgsqldrivers are very clean. I especially like:
  • That the drivers are built upon OTP principles
  • That one opens and closes connections through pgsql_connection:open respectively pgsql_connection:close
  • That there isn't a lot of proplist searching all the time

Would it be acceptable to rewrite the epgsql code to such an extent?

Best regards
Nicklas W Bjurman

David Welton

unread,
Jul 17, 2014, 9:00:00 AM7/17/14
to Nicklas Widlund Bjurman, epg...@googlegroups.com
Hi,

I'm personally ok with pretty much whatever, as long as the API
remains fairly consistent.

--
David N. Welton

http://www.welton.it/davidw/

http://www.dedasys.com/

Nicklas Widlund Bjurman

unread,
Jul 17, 2014, 9:22:21 AM7/17/14
to epg...@googlegroups.com, lordm...@gmail.com
On Thursday, July 17, 2014 3:00:00 PM UTC+2, David Welton wrote:
Hi,

I'm personally ok with pretty much whatever, as long as the API
remains fairly consistent.


It would break the API considerably, what I am thinking about is to move all API calls to the epgsql_connection module.

That includes the functions open, close, query, execute etc. as well as moving the epgsqla and epgsqli function to the unified epgsql_connection module.

As we are already breaking the API for the upcoming 3.0 release, I believe this is probably the best opportunity for a complete rehaul of the API.

Michael Truog

unread,
Jul 17, 2014, 3:20:15 PM7/17/14
to Nicklas Widlund Bjurman, epg...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "Erlang epgsql Postgres driver use and development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to epgsql+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Please keep in mind a few things:

- The semiocast driver has timeouts, we need timeouts in a postgres driver (this is an old issue with the epgsql driver)
- The epgsql driver returns all binary results while the semiocast driver converts the binary values to Erlang types.  If epgsql is able to convert the binary values to Erlang types, we probably want that as a configuration option for backwards compatibility and for those that think the approach is better (it may be in some circumstances).

David Welton

unread,
Jul 17, 2014, 4:08:10 PM7/17/14
to Michael Truog, Nicklas Widlund Bjurman, epg...@googlegroups.com
> - The epgsql driver returns all binary results while the semiocast driver
> converts the binary values to Erlang types. If epgsql is able to convert
> the binary values to Erlang types, we probably want that as a configuration
> option for backwards compatibility and for those that think the approach is
> better (it may be in some circumstances).

epgsql:equery seems to return Erlang types to me. squery doesn't.

Michael Truog

unread,
Jul 17, 2014, 4:48:57 PM7/17/14
to David Welton, Nicklas Widlund Bjurman, epg...@googlegroups.com
On 07/17/2014 01:08 PM, David Welton wrote:
>> - The epgsql driver returns all binary results while the semiocast driver
>> converts the binary values to Erlang types. If epgsql is able to convert
>> the binary values to Erlang types, we probably want that as a configuration
>> option for backwards compatibility and for those that think the approach is
>> better (it may be in some circumstances).
> epgsql:equery seems to return Erlang types to me. squery doesn't.
>
My testing of the devel branch indicates that equery should also be returning binaries, at least when using the epgsql module (there may be cases where this is not true, my test is not exhaustive at all, just a simple comparison):
https://github.com/CloudI/CloudI/blob/develop/src/lib/cloudi_service_db_pgsql/test_ct/cloudi_service_db_pgsql_SUITE.erl#L261

I have cloudi_service_db_pgsql using the semiocast driver along with a fork of the epgsql wg code and the newer epgsql devel branch.

Lord Metroid

unread,
Jul 17, 2014, 5:31:20 PM7/17/14
to epg...@googlegroups.com
So we decided to occupy the epgsql module namespace. However... epgsql, epgsqla and epgsqli are in my mind three namespaces because it comes before the underscore of the module name.

Perhaps one could incorporate this functionality by spacifying the wished for results in a normal query through a flag or using an FSM.


Best regards
Nicklas W Bjurman

David Welton

unread,
Jul 17, 2014, 6:18:47 PM7/17/14
to Michael Truog, Nicklas Widlund Bjurman, epg...@googlegroups.com
equery definitely returns Erlang types. That's what epgsql_binary.erl is for.

epgsql:equery(C, "select * from orders").
{ok,[{column,<<"id">>,int4,4,-1,1},
{column,<<"price">>,int4,4,-1,1},
{column,<<"product_id">>,int4,4,-1,1},
{column,<<"user_id">>,int4,4,-1,1},
{column,<<"document_id">>,int4,4,-1,1},
{column,<<"created_at">>,timestamp,8,-1,1},
{column,<<"updated_at">>,timestamp,8,-1,1}],
[{2,5000,1,11,null,
{{2011,9,1},{14,1,47.759813}},
{{2011,9,1},{14,1,47.759813}}},
{3,5000,1,14,null,
{{2011,9,2},{10,38,1.585845}},
{{2011,9,2},{10,38,1.585845}}},
{4,5000,1,4,null,
{{2011,9,13},{8,49,41.148063}},
{{2011,9,13},{8,49,41.148063}}},
{6,5000,1,16,null,
{{2011,9,13},{12,46,28.383378}},
{{2011,9,13},{12,46,28.383378}}},
{7,45342,60,10,null,
{{2011,9,19},{16,1,53.162951}},
{{2011,9,19},{16,1,53.162951}}},
> --
> You received this message because you are subscribed to the Google Groups
> "Erlang epgsql Postgres driver use and development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to epgsql+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



Reply all
Reply to author
Forward
0 new messages