Browse Source

Rename with epgsql prefix everywhere. #20

* Change version to exact number to avoid problems
Michael Truog 11 years ago
parent
commit
d33bd6b766

+ 2 - 2
CHANGES

@@ -1,13 +1,13 @@
 latest
 
-Asynchronous API extracted from pgsql_sock into apgsql (returns whole result sets) and ipgsql (returns row by row results).
+Asynchronous API extracted from epgsql_sock into epgsqla (returns whole result sets) and epgsqli (returns row by row results).
 Original tests are used to test all APIs through emulation modules.
 Execute several prepared statements as a batch (execute_batch).
 Bind timestamps in erlang:now() format.
 
 6f9d545 2011-11-01
 
-Asynchronous API is implemented by pgsql_sock.erl, see pgsql.erl for examples.
+Asynchronous API is implemented by epgsql_sock.erl, see epgsql.erl for examples.
 gen_fsm replaced by internal queue of client requests.
 Results can be delivered as regular erlang messages.
 Single process to hold driver state and receive socket data.

+ 2 - 2
Makefile

@@ -15,8 +15,8 @@ test:
 	@$(REBAR) eunit
 
 performance_test: compile
-	erlc ./test/pgsql_perf_tests.erl
-	erl -noshell -pa ./ebin -eval "eunit:test(pgsql_perf_tests, [verbose])" -run init stop
+	erlc ./test/epgsql_perf_tests.erl
+	erl -noshell -pa ./ebin -eval "eunit:test(epgsql_perf_tests, [verbose])" -run init stop
 
 dialyzer: build.plt compile
 	dialyzer --plt $< ebin

+ 58 - 58
README.md

@@ -16,10 +16,10 @@ provide a common fork for community development.
 
 * Difference highlights
 
-  + 3 API sets: pgsql, apgsql and ipgsql:
-    pgsql maintains backwards compatibility with the original driver API,
-    apgsql delivers complete results as regular erlang messages,
-    ipgsql delivers results as messages incrementally (row by row)
+  + 3 API sets: epgsql, epgsqla and epgsqli:
+    epgsql maintains backwards compatibility with the original driver API,
+    epgsqla delivers complete results as regular erlang messages,
+    epgsqli delivers results as messages incrementally (row by row)
   + internal queue of client requests, so you don't need to wait for the
     response to send the next request
   + single process to hold driver state and receive socket data
@@ -46,7 +46,7 @@ provide a common fork for community development.
 
 * Connect
 
-         {ok, C} = pgsql:connect(Host, [Username], [Password], Opts).
+         {ok, C} = epgsql:connect(Host, [Username], [Password], Opts).
 
   Host      - host to connect to.
   Username  - username to connect as, defaults to $USER.
@@ -63,16 +63,16 @@ provide a common fork for community development.
   
   Example:
   
-      {ok, C} = pgsql:connect("localhost", "username", [{database, "test_db"}]).
-      ok = pgsql:close(C).
+      {ok, C} = epgsql:connect("localhost", "username", [{database, "test_db"}]).
+      ok = epgsql:close(C).
 
   The timeout parameter will trigger an `{error, timeout}` result when the
   socket fails to connect within Timeout milliseconds.
 
-  Asynchronous connect example (applies to ipgsql too):
+  Asynchronous connect example (applies to epgsqli too):
 
-        {ok, C} = apgsql:start_link(),
-        Ref = apgsql:connect(C, "localhost", "username", [{database, "test_db"}]),
+        {ok, C} = epgsqla:start_link(),
+        Ref = epgsqla:connect(C, "localhost", "username", [{database, "test_db"}]),
         receive
           {C, Ref, connected} ->
               {ok, C};
@@ -85,13 +85,13 @@ provide a common fork for community development.
 
 * Simple Query
 
-        {ok, Columns, Rows}        = pgsql:squery(C, "select ...").
-        {ok, Count}                = pgsql:squery(C, "update ...").
-        {ok, Count, Columns, Rows} = pgsql:squery(C, "insert ... returning ...").
+        {ok, Columns, Rows}        = epgsql:squery(C, "select ...").
+        {ok, Count}                = epgsql:squery(C, "update ...").
+        {ok, Count, Columns, Rows} = epgsql:squery(C, "insert ... returning ...").
 
-        {error, Error}             = pgsql:squery(C, "invalid SQL").
+        {error, Error}             = epgsql:squery(C, "invalid SQL").
 
-  + `Columns`       - list of column records, see pgsql.hrl for definition.
+  + `Columns`       - list of column records, see epgsql.hrl for definition.
   + `Rows`          - list of tuples, one for each row.
   + `Count`         - integer count of rows inserted/updated/etc
 
@@ -101,21 +101,21 @@ provide a common fork for community development.
   Several queries separated by semicolon can be executed by squery.
 
         [{ok, _, [{<<"1">>}]}, {ok, _, [{<<"2">>}]}] =
-          pgsql:squery(C, "select 1; select 2").
+          epgsql:squery(C, "select 1; select 2").
 
-  `apgsql:squery` returns result as a single message:
+  `epgsqla:squery` returns result as a single message:
 
-        Ref = apgsql:squery(C, Sql),
+        Ref = epgsqla:squery(C, Sql),
         receive
           {C, Ref, Result} -> Result
         end.
 
-  `Result` has same format as return value of pgsql:squery.
+  `Result` has same format as return value of epgsql:squery.
 
-  `ipgsql:squery` returns results incrementally for each query inside Sql and
+  `epgsqli:squery` returns results incrementally for each query inside Sql and
   for each row:
 
-        Ref = ipgsql:squery(C, Sql),
+        Ref = epgsqli:squery(C, Sql),
         receive
           {C, Ref, {columns, Columns}} ->
               %% columns description
@@ -139,11 +139,11 @@ provide a common fork for community development.
 
 * Extended Query
 
-        {ok, Columns, Rows}        = pgsql:equery(C, "select ...", [Parameters]).
-        {ok, Count}                = pgsql:equery(C, "update ...", [Parameters]).
-        {ok, Count, Columns, Rows} = pgsql:equery(C, "insert ... returning ...", [Parameters]).
+        {ok, Columns, Rows}        = epgsql:equery(C, "select ...", [Parameters]).
+        {ok, Count}                = epgsql:equery(C, "update ...", [Parameters]).
+        {ok, Count, Columns, Rows} = epgsql:equery(C, "insert ... returning ...", [Parameters]).
 
-        {error, Error}             = pgsql:equery(C, "invalid SQL", [Parameters]).
+        {error, Error}             = epgsql:equery(C, "invalid SQL", [Parameters]).
 
   + `Parameters`    - optional list of values to be bound to $1, $2, $3, etc.
 
@@ -155,59 +155,59 @@ provide a common fork for community development.
 
   PostgreSQL's binary format is used to return integers as Erlang
   integers, floats as floats, bytea/text/varchar columns as binaries,
-  bools as true/false, etc. For details see `pgsql_binary.erl` and the
+  bools as true/false, etc. For details see `epgsql_binary.erl` and the
   Data Representation section below.
 
   Asynchronous api equery requires you to parse statement beforehand
 
-        Ref = apgsql:equery(C, Statement, [Parameters]),
+        Ref = epgsqla:equery(C, Statement, [Parameters]),
         receive
           {C, Ref, Res} -> Res
         end.
 
   + `Statement` - parsed statement (see parse below)
-  + `Res` has same format as return value of `pgsql:equery`.
+  + `Res` has same format as return value of `epgsql:equery`.
 
-  `ipgsql:equery(C, Statement, [Parameters])` sends same set of messages as
+  `epgsqli:equery(C, Statement, [Parameters])` sends same set of messages as
   squery including the final `{C, Ref, done}`.
 
 
 * Parse/Bind/Execute
 
-         {ok, Statement} = pgsql:parse(C, [StatementName], Sql, [ParameterTypes]).
+         {ok, Statement} = epgsql:parse(C, [StatementName], Sql, [ParameterTypes]).
 
   + `StatementName`   - optional, reusable, name for the prepared statement.
   + `ParameterTypes`  - optional list of PostgreSQL types for each parameter.
 
-  For valid type names see `pgsql_types.erl`.
+  For valid type names see `epgsql_types.erl`.
 
-  `apgsql:parse` sends `{C, Ref, {ok, Statement} | {error, Reason}}`.
-  `ipgsql:parse` sends:
+  `epgsqla:parse` sends `{C, Ref, {ok, Statement} | {error, Reason}}`.
+  `epgsqli:parse` sends:
 
         {C, Ref, {types, Types}}
         {C, Ref, {columns, Columns}}
         {C, Ref, no_data} if statement will not return rows
         {C, Ref, {error, Reason}}
 
-        ok = pgsql:bind(C, Statement, [PortalName], ParameterValues).
+        ok = epgsql:bind(C, Statement, [PortalName], ParameterValues).
 
   + `PortalName`      - optional name for the result portal.
 
-  both `apgsql:bind` and `ipgsql:bind` send `{C, Ref, ok | {error, Reason}}`
+  both `epgsqla:bind` and `epgsqli:bind` send `{C, Ref, ok | {error, Reason}}`
 
-        {ok | partial, Rows} = pgsql:execute(C, Statement, [PortalName], [MaxRows]).
-        {ok, Count}          = pgsql:execute(C, Statement, [PortalName]).
-        {ok, Count, Rows}    = pgsql:execute(C, Statement, [PortalName]).
+        {ok | partial, Rows} = epgsql:execute(C, Statement, [PortalName], [MaxRows]).
+        {ok, Count}          = epgsql:execute(C, Statement, [PortalName]).
+        {ok, Count, Rows}    = epgsql:execute(C, Statement, [PortalName]).
 
   + `PortalName`      - optional portal name used in `bind/4`.
   + `MaxRows`         - maximum number of rows to return (0 for all rows).
 
   execute returns `{partial, Rows}` when more rows are available.
 
-  `apgsql:execute` sends `{C, Ref, Result}` where `Result` has the same
-  format as the return value of `pgsql:execute`.
+  `epgsqla:execute` sends `{C, Ref, Result}` where `Result` has the same
+  format as the return value of `epgsql:execute`.
 
-  `ipgsql:execute` sends
+  `epgsqli:execute` sends
 
         {C, Ref, {data, Row}}
         {C, Ref, {error, Reason}}
@@ -215,13 +215,13 @@ provide a common fork for community development.
         {C, Ref, {complete, {_Type, Count}}}
         {C, Ref, {complete, _Type}}
 
-        ok = pgsql:close(C, Statement).
-        ok = pgsql:close(C, statement | portal, Name).
-        ok = pgsql:sync(C).
+        ok = epgsql:close(C, Statement).
+        ok = epgsql:close(C, statement | portal, Name).
+        ok = epgsql:sync(C).
 
-  All pgsql functions return `{error, Error}` when an error occurs.
+  All epgsql functions return `{error, Error}` when an error occurs.
 
-  apgsql and ipgsql close and sync functions send `{C, Ref, ok}`.
+  epgsqla and epgsqli close and sync functions send `{C, Ref, ok}`.
 
 
 * Batch execution
@@ -229,20 +229,20 @@ provide a common fork for community development.
   Batch execution is bind + execute for several prepared statements.
   It uses unnamed portals and MaxRows = 0.
 
-        Results = pgsql:execute_batch(C, Batch).
+        Results = epgsql:execute_batch(C, Batch).
 
   + `Batch`   - list of `{Statement, ParameterValues}`
   + `Results` - list of `{ok, Count}` or `{ok, Count, Rows}`
 
   Example
 
-        {ok, S1} = pgsql:parse(C, "one", "select $1", [int4]),
-        {ok, S2} = pgsql:parse(C, "two", "select $1 + $2", [int4, int4]),
+        {ok, S1} = epgsql:parse(C, "one", "select $1", [int4]),
+        {ok, S2} = epgsql:parse(C, "two", "select $1 + $2", [int4, int4]),
         [{ok, [{1}]}, {ok, [{3}]}] =
-          pgsql:execute_batch(C, [{S1, [1]}, {S2, [1, 2]}]).
+          epgsql:execute_batch(C, [{S1, [1]}, {S2, [1, 2]}]).
 
-  `apgsql:execute_batch` sends `{C, Ref, Results}`
-  `ipgsql:execute_batch` sends
+  `epgsqla:execute_batch` sends `{C, Ref, Results}`
+  `epgsqli:execute_batch` sends
 
         {C, Ref, {data, Row}}
         {C, Ref, {error, Reason}}
@@ -276,13 +276,13 @@ provide a common fork for community development.
 * Errors
 
   Errors originating from the PostgreSQL backend are returned as `{error, #error{}}`,
-  see `pgsql.hrl` for the record definition. epgsql functions may also return
+  see `epgsql.hrl` for the record definition. epgsql functions may also return
   `{error, What}` where What is one of the following:
 
   + `{unsupported_auth_method, Method}`     - required auth method is unsupported
   + `timeout`                               - request timed out
   + `closed`                                - connection was closed
-  + `sync_required`                         - error occured and pgsql:sync must be called
+  + `sync_required`                         - error occured and epgsql:sync must be called
 
 * Server Notifications
 
@@ -290,22 +290,22 @@ provide a common fork for community development.
   to notice and warning messages generated by the server, and "notifications" which
   are generated by the LISTEN/NOTIFY mechanism.
 
-  Passing the `{async, Pid}` option to `pgsql:connect` will result in these async
+  Passing the `{async, Pid}` option to `epgsql:connect` will result in these async
   messages being sent to the specified process, otherwise they will be dropped.
 
   Message formats:
 
-  `{pgsql, Connection, {notification, Channel, Pid, Payload}}`
+  `{epgsql, Connection, {notification, Channel, Pid, Payload}}`
 
   + `Connection`  - connection the notification occurred on
   + `Channel`     - channel the notification occurred on
   + `Pid`         - database session pid that sent notification
   +` Payload`     - optional payload, only available from PostgreSQL >= 9.0
 
-          {pgsql, Connection, {notice, Error}}
+          {epgsql, Connection, {notice, Error}}
 
   + `Connection`  - connection the notice occurred on
-  + `Error`       - an `#error{}` record, see `pgsql.hrl`
+  + `Error`       - an `#error{}` record, see `epgsql.hrl`
 
 
 * Mailing list / forum

+ 0 - 0
include/pgsql.hrl → include/epgsql.hrl


+ 0 - 0
include/pgsql_binary.hrl → include/epgsql_binary.hrl


+ 1 - 1
src/epgsql.app.src

@@ -1,6 +1,6 @@
 {application, epgsql,
  [{description, "PostgreSQL Client"},
-  {vsn, git},
+  {vsn, "2.0.0"},
   {modules, []},
   {registered, []},
   {applications, [kernel,

+ 6 - 6
src/pgsql.erl → src/epgsql.erl

@@ -1,7 +1,7 @@
 %%% Copyright (C) 2008 - Will Glozer.  All rights reserved.
 %%% Copyright (C) 2011 - Anton Lebedevich.  All rights reserved.
 
--module(pgsql).
+-module(epgsql).
 
 -export([connect/2, connect/3, connect/4, connect/5,
          close/1,
@@ -25,7 +25,7 @@
               bind_param/0,
               squery_row/0, equery_row/0, ok_reply/1]).
 
--include("pgsql.hrl").
+-include("epgsql.hrl").
 
 -type connection() :: pid().
 -type connect_option() :: {database, string()}
@@ -65,7 +65,7 @@ connect(Host, Username, Opts) ->
     connect(Host, Username, "", Opts).
 
 connect(Host, Username, Password, Opts) ->
-    {ok, C} = pgsql_sock:start_link(),
+    {ok, C} = epgsql_sock:start_link(),
     connect(C, Host, Username, Password, Opts).
 
 -spec connect(connection(), inet:ip_address() | inet:hostname(),
@@ -94,11 +94,11 @@ update_type_cache(C) ->
 
 -spec close(connection()) -> ok.
 close(C) ->
-    pgsql_sock:close(C).
+    epgsql_sock:close(C).
 
 -spec get_parameter(connection(), binary()) -> binary() | undefined.
 get_parameter(C, Name) ->
-    pgsql_sock:get_parameter(C, Name).
+    epgsql_sock:get_parameter(C, Name).
 
 -spec squery(connection(), string() | iodata()) ->
                     ok_reply(squery_row()) | {error, query_error()} |
@@ -200,7 +200,7 @@ sync(C) ->
 
 -spec cancel(connection()) -> ok.
 cancel(C) ->
-    pgsql_sock:cancel(C).
+    epgsql_sock:cancel(C).
 
 %% misc helper functions
 -spec with_transaction(connection(), fun((connection()) -> Reply)) ->

+ 4 - 4
src/pgsql_binary.erl → src/epgsql_binary.erl

@@ -1,6 +1,6 @@
 %%% Copyright (C) 2008 - Will Glozer.  All rights reserved.
 
--module(pgsql_binary).
+-module(epgsql_binary).
 
 -export([new_codec/1,
          update_type_cache/2,
@@ -12,7 +12,7 @@
     oid2type = []
 }).
 
--include("pgsql_binary.hrl").
+-include("epgsql_binary.hrl").
 
 -define(datetime, (get(datetime_mod))).
 
@@ -29,14 +29,14 @@ update_type_cache(TypeInfos, Codec) ->
     Codec#codec{type2oid = Type2Oid, oid2type = Oid2Type}.
 
 oid2type(Oid, #codec{oid2type = Oid2Type}) ->
-    case pgsql_types:oid2type(Oid) of
+    case epgsql_types:oid2type(Oid) of
         {unknown_oid, _} ->
             proplists:get_value(Oid, Oid2Type, {unknown_oid, Oid});
         Type -> Type
     end.
 
 type2oid(Type, #codec{type2oid = Type2Oid}) ->
-    case pgsql_types:type2oid(Type) of
+    case epgsql_types:type2oid(Type) of
         {unknown_type, _} ->
             proplists:get_value(Type, Type2Oid, {unknown_type, Type});
         Oid -> Oid

+ 2 - 2
src/pgsql_fdatetime.erl → src/epgsql_fdatetime.erl

@@ -1,10 +1,10 @@
 %%% Copyright (C) 2008 - Will Glozer.  All rights reserved.
 
--module(pgsql_fdatetime).
+-module(epgsql_fdatetime).
 
 -export([decode/2, encode/2]).
 
--include("pgsql_binary.hrl").
+-include("epgsql_binary.hrl").
 
 -define(postgres_epoc_jdate, 2451545).
 -define(postgres_epoc_secs, 946684800).

+ 2 - 2
src/pgsql_idatetime.erl → src/epgsql_idatetime.erl

@@ -1,10 +1,10 @@
 %%% Copyright (C) 2008 - Will Glozer.  All rights reserved.
 
--module(pgsql_idatetime).
+-module(epgsql_idatetime).
 
 -export([decode/2, encode/2]).
 
--include("pgsql_binary.hrl").
+-include("epgsql_binary.hrl").
 
 -define(postgres_epoc_jdate, 2451545).
 -define(postgres_epoc_usecs, 946684800000000).

+ 29 - 29
src/pgsql_sock.erl → src/epgsql_sock.erl

@@ -1,7 +1,7 @@
 %%% Copyright (C) 2009 - Will Glozer.  All rights reserved.
 %%% Copyright (C) 2011 - Anton Lebedevich.  All rights reserved.
 
--module(pgsql_sock).
+-module(epgsql_sock).
 
 -behavior(gen_server).
 
@@ -16,8 +16,8 @@
 %% state callbacks
 -export([auth/2, initializing/2, on_message/2]).
 
--include("pgsql.hrl").
--include("pgsql_binary.hrl").
+-include("epgsql.hrl").
+-include("epgsql_binary.hrl").
 
 %% Commands defined as per this page:
 %% http://www.postgresql.org/docs/9.2/static/protocol-message-formats.html
@@ -95,7 +95,7 @@ init([]) ->
     {ok, #state{}}.
 
 handle_call({update_type_cache, TypeInfos}, _From, #state{codec = Codec} = State) ->
-    Codec2 = pgsql_binary:update_type_cache(TypeInfos, Codec),
+    Codec2 = epgsql_binary:update_type_cache(TypeInfos, Codec),
     {reply, ok, State#state{codec = Codec2}};
 
 handle_call({get_parameter, Name}, _From, State) ->
@@ -211,8 +211,8 @@ command({squery, Sql}, State) ->
 %% sends Describe after Bind to get RowDescription
 command({equery, Statement, Parameters}, #state{codec = Codec} = State) ->
     #statement{name = StatementName, columns = Columns} = Statement,
-    Bin1 = pgsql_wire:encode_parameters(Parameters, Codec),
-    Bin2 = pgsql_wire:encode_formats(Columns),
+    Bin1 = epgsql_wire:encode_parameters(Parameters, Codec),
+    Bin2 = epgsql_wire:encode_formats(Columns),
     send(State, ?BIND, ["", 0, StatementName, 0, Bin1, Bin2]),
     send(State, ?EXECUTE, ["", 0, <<0:?int32>>]),
     send(State, ?CLOSE, [?PREPARED_STATEMENT, StatementName, 0]),
@@ -220,7 +220,7 @@ command({equery, Statement, Parameters}, #state{codec = Codec} = State) ->
     {noreply, State};
 
 command({parse, Name, Sql, Types}, State) ->
-    Bin = pgsql_wire:encode_types(Types, State#state.codec),
+    Bin = epgsql_wire:encode_types(Types, State#state.codec),
     send(State, ?PARSE, [Name, 0, Sql, 0, Bin]),
     send(State, ?DESCRIBE, [?PREPARED_STATEMENT, Name, 0]),
     send(State, ?FLUSH, []),
@@ -229,8 +229,8 @@ command({parse, Name, Sql, Types}, State) ->
 command({bind, Statement, PortalName, Parameters}, #state{codec = Codec} = State) ->
     #statement{name = StatementName, columns = Columns, types = Types} = Statement,
     Typed_Parameters = lists:zip(Types, Parameters),
-    Bin1 = pgsql_wire:encode_parameters(Typed_Parameters, Codec),
-    Bin2 = pgsql_wire:encode_formats(Columns),
+    Bin1 = epgsql_wire:encode_parameters(Typed_Parameters, Codec),
+    Bin2 = epgsql_wire:encode_formats(Columns),
     send(State, ?BIND, [PortalName, 0, StatementName, 0, Bin1, Bin2]),
     send(State, ?FLUSH, []),
     {noreply, State};
@@ -249,14 +249,14 @@ command({execute_batch, Batch}, State) ->
                              columns = Columns,
                              types = Types} = Statement,
                   Typed_Parameters = lists:zip(Types, Parameters),
-                  Bin1 = pgsql_wire:encode_parameters(Typed_Parameters, Codec),
-                  Bin2 = pgsql_wire:encode_formats(Columns),
-                  [pgsql_wire:encode(?BIND, [0, StatementName, 0,
+                  Bin1 = epgsql_wire:encode_parameters(Typed_Parameters, Codec),
+                  Bin2 = epgsql_wire:encode_formats(Columns),
+                  [epgsql_wire:encode(?BIND, [0, StatementName, 0,
                                              Bin1, Bin2]),
-                   pgsql_wire:encode(?EXECUTE, [0, <<0:?int32>>])]
+                   epgsql_wire:encode(?EXECUTE, [0, <<0:?int32>>])]
           end,
           Batch),
-    Sync = pgsql_wire:encode(?SYNC, []),
+    Sync = epgsql_wire:encode(?SYNC, []),
     do_send(Mod, Sock, [BindExecute, Sync]),
     {noreply, State};
 
@@ -307,10 +307,10 @@ setopts(#state{mod = Mod, sock = Sock}, Opts) ->
     end.
 
 send(#state{mod = Mod, sock = Sock}, Data) ->
-    do_send(Mod, Sock, pgsql_wire:encode(Data)).
+    do_send(Mod, Sock, epgsql_wire:encode(Data)).
 
 send(#state{mod = Mod, sock = Sock}, Type, Data) ->
-    do_send(Mod, Sock, pgsql_wire:encode(Type, Data)).
+    do_send(Mod, Sock, epgsql_wire:encode(Type, Data)).
 
 do_send(gen_tcp, Sock, Bin) ->
     try erlang:port_command(Sock, Bin) of
@@ -325,7 +325,7 @@ do_send(Mod, Sock, Bin) ->
     Mod:send(Sock, Bin).
 
 loop(#state{data = Data, handler = Handler} = State) ->
-    case pgsql_wire:decode_message(Data) of
+    case epgsql_wire:decode_message(Data) of
         {Message, Tail} ->
             case ?MODULE:Handler(Message, State#state{data = Tail}) of
                 {noreply, State2} ->
@@ -396,7 +396,7 @@ notify(State = #state{queue = Q}, Notice) ->
 
 notify_async(State = #state{async = Pid}, Msg) ->
     case is_pid(Pid) of
-        true  -> Pid ! {pgsql, self(), Msg};
+        true  -> Pid ! {epgsql, self(), Msg};
         false -> false
     end,
     State.
@@ -513,12 +513,12 @@ initializing({?READY_FOR_QUERY, <<Status:8>>}, State) ->
     erase(password),
     %% TODO decode dates to now() format
     case lists:keysearch(<<"integer_datetimes">>, 1, Parameters) of
-        {value, {_, <<"on">>}}  -> put(datetime_mod, pgsql_idatetime);
-        {value, {_, <<"off">>}} -> put(datetime_mod, pgsql_fdatetime)
+        {value, {_, <<"on">>}}  -> put(datetime_mod, epgsql_idatetime);
+        {value, {_, <<"off">>}} -> put(datetime_mod, epgsql_fdatetime)
     end,
     State2 = finish(State#state{handler = on_message,
                                txstatus = Status,
-                               codec = pgsql_binary:new_codec([])},
+                               codec = epgsql_binary:new_codec([])},
                    connected),
     {noreply, State2};
 
@@ -534,19 +534,19 @@ on_message({?PARSE_COMPLETE, <<>>}, State) ->
 
 %% ParameterDescription
 on_message({?PARAMETER_DESCRIPTION, <<_Count:?int16, Bin/binary>>}, State) ->
-    Types = [pgsql_binary:oid2type(Oid, State#state.codec) || <<Oid:?int32>> <= Bin],
+    Types = [epgsql_binary:oid2type(Oid, State#state.codec) || <<Oid:?int32>> <= Bin],
     State2 = notify(State#state{types = Types}, {types, Types}),
     {noreply, State2};
 
 %% RowDescription
 on_message({?ROW_DESCRIPTION, <<Count:?int16, Bin/binary>>}, State) ->
-    Columns = pgsql_wire:decode_columns(Count, Bin, State#state.codec),
+    Columns = epgsql_wire:decode_columns(Count, Bin, State#state.codec),
     Columns2 =
         case command_tag(State) of
             C when C == describe_portal; C == squery ->
                 Columns;
             C when C == parse; C == describe_statement ->
-                [Col#column{format = pgsql_wire:format(Col#column.type)}
+                [Col#column{format = epgsql_wire:format(Col#column.type)}
                  || Col <- Columns]
         end,
     State2 = State#state{columns = Columns2},
@@ -603,7 +603,7 @@ on_message({?CLOSE_COMPLETE, <<>>}, State) ->
 
 %% DataRow
 on_message({?DATA_ROW, <<_Count:?int16, Bin/binary>>}, State) ->
-    Data = pgsql_wire:decode_data(get_columns(State), Bin, State#state.codec),
+    Data = epgsql_wire:decode_data(get_columns(State), Bin, State#state.codec),
     {noreply, add_row(State, Data)};
 
 %% PortalSuspended
@@ -615,7 +615,7 @@ on_message({?PORTAL_SUSPENDED, <<>>}, State) ->
 
 %% CommandComplete
 on_message({?COMMAND_COMPLETE, Bin}, State) ->
-    Complete = pgsql_wire:decode_complete(Bin),
+    Complete = epgsql_wire:decode_complete(Bin),
     Command = command_tag(State),
     Notice = {complete, Complete},
     Rows = lists:reverse(State#state.rows),
@@ -687,19 +687,19 @@ on_message(Error = {error, _}, State) ->
 
 %% NoticeResponse
 on_message({?NOTICE, Data}, State) ->
-    State2 = notify_async(State, {notice, pgsql_wire:decode_error(Data)}),
+    State2 = notify_async(State, {notice, epgsql_wire:decode_error(Data)}),
     {noreply, State2};
 
 %% ParameterStatus
 on_message({?PARAMETER_STATUS, Data}, State) ->
-    [Name, Value] = pgsql_wire:decode_strings(Data),
+    [Name, Value] = epgsql_wire:decode_strings(Data),
     Parameters2 = lists:keystore(Name, 1, State#state.parameters,
                                  {Name, Value}),
     {noreply, State#state{parameters = Parameters2}};
 
 %% NotificationResponse
 on_message({?NOTIFICATION, <<Pid:?int32, Strings/binary>>}, State) ->
-    case pgsql_wire:decode_strings(Strings) of
+    case epgsql_wire:decode_strings(Strings) of
         [Channel, Payload] -> ok;
         [Channel]          -> Payload = <<>>
     end,

+ 1 - 1
src/pgsql_types.erl → src/epgsql_types.erl

@@ -1,4 +1,4 @@
--module(pgsql_types).
+-module(epgsql_types).
 
 -export([oid2type/1, type2oid/1]).
 

+ 8 - 8
src/pgsql_wire.erl → src/epgsql_wire.erl

@@ -1,7 +1,7 @@
 %%% Copyright (C) 2009 - Will Glozer.  All rights reserved.
 %%% Copyright (C) 2011 - Anton Lebedevich.  All rights reserved.
 
--module(pgsql_wire).
+-module(epgsql_wire).
 
 -export([decode_message/1,
          decode_error/1,
@@ -16,8 +16,8 @@
          format/1,
          encode_parameters/2]).
 
--include("pgsql.hrl").
--include("pgsql_binary.hrl").
+-include("epgsql.hrl").
+-include("epgsql_binary.hrl").
 
 decode_message(<<Type:8, Len:?int32, Rest/binary>> = Bin) ->
     Len2 = Len - 4,
@@ -101,7 +101,7 @@ decode_data([_C | T], <<-1:?int32, Rest/binary>>, Acc, Codec) ->
     decode_data(T, Rest, [null | Acc], Codec);
 decode_data([C | T], <<Len:?int32, Value:Len/binary, Rest/binary>>, Acc, Codec) ->
     case C of
-        #column{type = Type, format = 1}   -> Value2 = pgsql_binary:decode(Type, Value, Codec);
+        #column{type = Type, format = 1}   -> Value2 = epgsql_binary:decode(Type, Value, Codec);
         #column{}                          -> Value2 = Value
     end,
     decode_data(T, Rest, [Value2 | Acc], Codec).
@@ -118,7 +118,7 @@ decode_columns(N, Bin, Acc, Codec) ->
      Size:?int16, Modifier:?int32, Format:?int16, Rest2/binary>> = Rest,
     Desc = #column{
       name     = Name,
-      type     = pgsql_binary:oid2type(Type_Oid, Codec),
+      type     = epgsql_binary:oid2type(Type_Oid, Codec),
       size     = Size,
       modifier = Modifier,
       format   = Format},
@@ -150,7 +150,7 @@ encode_types([], Count, Acc, _Codec) ->
 encode_types([Type | T], Count, Acc, Codec) ->
     case Type of
         undefined -> Oid = 0;
-        _Any      -> Oid = pgsql_binary:type2oid(Type, Codec)
+        _Any      -> Oid = epgsql_binary:type2oid(Type, Codec)
     end,
     encode_types(T, Count + 1, <<Acc/binary, Oid:?int32>>, Codec).
 
@@ -165,7 +165,7 @@ encode_formats([#column{format = Format} | T], Count, Acc) ->
     encode_formats(T, Count + 1, <<Acc/binary, Format:?int16>>).
 
 format(Type) ->
-    case pgsql_binary:supports(Type) of
+    case epgsql_binary:supports(Type) of
         true  -> 1;
         false -> 0
     end.
@@ -186,7 +186,7 @@ encode_parameters([P | T], Count, Formats, Values, Codec) ->
 %% encode parameter
 
 encode_parameter({Type, Value}, Codec) ->
-    case pgsql_binary:encode(Type, Value, Codec) of
+    case epgsql_binary:encode(Type, Value, Codec) of
         Bin when is_binary(Bin) -> {1, Bin};
         {error, unsupported}    -> encode_parameter(Value)
     end;

+ 18 - 18
src/apgsql.erl → src/epgsqla.erl

@@ -1,6 +1,6 @@
 %%% Copyright (C) 2011 - Anton Lebedevich.  All rights reserved.
 
--module(apgsql).
+-module(epgsqla).
 
 -export([start_link/0,
          connect/2, connect/3, connect/4, connect/5,
@@ -17,12 +17,12 @@
          sync/1,
          cancel/1]).
 
--include("pgsql.hrl").
+-include("epgsql.hrl").
 
 %% -- client interface --
 -spec start_link() -> {ok, pid()}.
 start_link() ->
-    pgsql_sock:start_link().
+    epgsql_sock:start_link().
 
 connect(Host, Opts) ->
     connect(Host, os:getenv("USER"), "", Opts).
@@ -31,30 +31,30 @@ connect(Host, Username, Opts) ->
     connect(Host, Username, "", Opts).
 
 connect(Host, Username, Password, Opts) ->
-    {ok, C} = pgsql_sock:start_link(),
+    {ok, C} = epgsql_sock:start_link(),
     connect(C, Host, Username, Password, Opts).
 
--spec connect(pgsql:connection(), inet:ip_address() | inet:hostname(),
-              string(), string(), [pgsql:connect_option()]) -> reference().
+-spec connect(epgsql:connection(), inet:ip_address() | inet:hostname(),
+              string(), string(), [epgsql:connect_option()]) -> reference().
 connect(C, Host, Username, Password, Opts) ->
     cast(C, {connect, Host, Username, Password, Opts}).
 
--spec close(pgsql:connection()) -> ok.
+-spec close(epgsql:connection()) -> ok.
 close(C) ->
-    pgsql_sock:close(C).
+    epgsql_sock:close(C).
 
--spec get_parameter(pgsql:connection(), binary()) -> binary() | undefined.
+-spec get_parameter(epgsql:connection(), binary()) -> binary() | undefined.
 get_parameter(C, Name) ->
-    pgsql_sock:get_parameter(C, Name).
+    epgsql_sock:get_parameter(C, Name).
 
--spec squery(pgsql:connection(), string()) -> reference().
+-spec squery(epgsql:connection(), string()) -> reference().
 squery(C, Sql) ->
     cast(C, {squery, Sql}).
 
 equery(C, Sql) ->
     equery(C, Sql, []).
 
--spec equery(pgsql:connection(), #statement{}, [pgsql:bind_param()]) -> reference().
+-spec equery(epgsql:connection(), #statement{}, [epgsql:bind_param()]) -> reference().
 equery(C, Statement, Parameters) ->
     cast(C, {equery, Statement, Parameters}).
 
@@ -64,14 +64,14 @@ parse(C, Sql) ->
 parse(C, Sql, Types) ->
     parse(C, "", Sql, Types).
 
--spec parse(pgsql:connection(), iolist(), string(), [epgsql_type()]) -> reference().
+-spec parse(epgsql:connection(), iolist(), string(), [epgsql_type()]) -> reference().
 parse(C, Name, Sql, Types) ->
     cast(C, {parse, Name, Sql, Types}).
 
 bind(C, Statement, Parameters) ->
     bind(C, Statement, "", Parameters).
 
--spec bind(pgsql:connection(), #statement{}, string(), [pgsql:bind_param()]) -> reference().
+-spec bind(epgsql:connection(), #statement{}, string(), [epgsql:bind_param()]) -> reference().
 bind(C, Statement, PortalName, Parameters) ->
     cast(C, {bind, Statement, PortalName, Parameters}).
 
@@ -81,11 +81,11 @@ execute(C, S) ->
 execute(C, S, N) ->
     execute(C, S, "", N).
 
--spec execute(pgsql:connection(), #statement{}, string(), non_neg_integer()) -> reference().
+-spec execute(epgsql:connection(), #statement{}, string(), non_neg_integer()) -> reference().
 execute(C, Statement, PortalName, MaxRows) ->
     cast(C, {execute, Statement, PortalName, MaxRows}).
 
--spec execute_batch(pgsql:connection(), [{#statement{}, [pgsql:bind_param()]}]) -> reference().
+-spec execute_batch(epgsql:connection(), [{#statement{}, [epgsql:bind_param()]}]) -> reference().
 execute_batch(C, Batch) ->
     cast(C, {execute_batch, Batch}).
 
@@ -107,9 +107,9 @@ close(C, Type, Name) ->
 sync(C) ->
     cast(C, sync).
 
--spec cancel(pgsql:connection()) -> ok.
+-spec cancel(epgsql:connection()) -> ok.
 cancel(C) ->
-    pgsql_sock:cancel(C).
+    epgsql_sock:cancel(C).
 
 %% -- internal functions --
 

+ 18 - 18
src/ipgsql.erl → src/epgsqli.erl

@@ -1,6 +1,6 @@
 %%% Copyright (C) 2011 - Anton Lebedevich.  All rights reserved.
 
--module(ipgsql).
+-module(epgsqli).
 
 -export([start_link/0,
          connect/2, connect/3, connect/4, connect/5,
@@ -17,12 +17,12 @@
          sync/1,
          cancel/1]).
 
--include("pgsql.hrl").
+-include("epgsql.hrl").
 
 %% -- client interface --
 
 start_link() ->
-    pgsql_sock:start_link().
+    epgsql_sock:start_link().
 
 connect(Host, Opts) ->
     connect(Host, os:getenv("USER"), "", Opts).
@@ -31,30 +31,30 @@ connect(Host, Username, Opts) ->
     connect(Host, Username, "", Opts).
 
 connect(Host, Username, Password, Opts) ->
-    {ok, C} = pgsql_sock:start_link(),
+    {ok, C} = epgsql_sock:start_link(),
     connect(C, Host, Username, Password, Opts).
 
--spec connect(pgsql:connection(), inet:ip_address() | inet:hostname(),
-              string(), string(), [pgsql:connect_option()]) -> reference().
+-spec connect(epgsql:connection(), inet:ip_address() | inet:hostname(),
+              string(), string(), [epgsql:connect_option()]) -> reference().
 connect(C, Host, Username, Password, Opts) ->
     incremental(C, {connect, Host, Username, Password, Opts}).
 
--spec close(pgsql:connection()) -> ok.
+-spec close(epgsql:connection()) -> ok.
 close(C) ->
-    pgsql_sock:close(C).
+    epgsql_sock:close(C).
 
--spec get_parameter(pgsql:connection(), binary()) -> binary() | undefined.
+-spec get_parameter(epgsql:connection(), binary()) -> binary() | undefined.
 get_parameter(C, Name) ->
-    pgsql_sock:get_parameter(C, Name).
+    epgsql_sock:get_parameter(C, Name).
 
--spec squery(pgsql:connection(), string()) -> reference().
+-spec squery(epgsql:connection(), string()) -> reference().
 squery(C, Sql) ->
     incremental(C, {squery, Sql}).
 
 equery(C, Sql) ->
     equery(C, Sql, []).
 
--spec equery(pgsql:connection(), #statement{}, [pgsql:bind_param()]) -> reference().
+-spec equery(epgsql:connection(), #statement{}, [epgsql:bind_param()]) -> reference().
 equery(C, Statement, Parameters) ->
     incremental(C, {equery, Statement, Parameters}).
 
@@ -64,14 +64,14 @@ parse(C, Sql) ->
 parse(C, Sql, Types) ->
     parse(C, "", Sql, Types).
 
--spec parse(pgsql:connection(), iolist(), string(), [epgsql_type()]) -> reference().
+-spec parse(epgsql:connection(), iolist(), string(), [epgsql_type()]) -> reference().
 parse(C, Name, Sql, Types) ->
     incremental(C, {parse, Name, Sql, Types}).
 
 bind(C, Statement, Parameters) ->
     bind(C, Statement, "", Parameters).
 
--spec bind(pgsql:connection(), #statement{}, string(), [pgsql:bind_param()]) -> reference().
+-spec bind(epgsql:connection(), #statement{}, string(), [epgsql:bind_param()]) -> reference().
 bind(C, Statement, PortalName, Parameters) ->
     incremental(C, {bind, Statement, PortalName, Parameters}).
 
@@ -81,11 +81,11 @@ execute(C, S) ->
 execute(C, S, N) ->
     execute(C, S, "", N).
 
--spec execute(pgsql:connection(), #statement{}, string(), non_neg_integer()) -> reference().
+-spec execute(epgsql:connection(), #statement{}, string(), non_neg_integer()) -> reference().
 execute(C, Statement, PortalName, MaxRows) ->
     incremental(C, {execute, Statement, PortalName, MaxRows}).
 
--spec execute_batch(pgsql:connection(), [{#statement{}, [pgsql:bind_param()]}]) -> reference().
+-spec execute_batch(epgsql:connection(), [{#statement{}, [epgsql:bind_param()]}]) -> reference().
 execute_batch(C, Batch) ->
     incremental(C, {execute_batch, Batch}).
 
@@ -107,9 +107,9 @@ close(C, Type, Name) ->
 sync(C) ->
     incremental(C, sync).
 
--spec cancel(pgsql:connection()) -> ok.
+-spec cancel(epgsql:connection()) -> ok.
 cancel(C) ->
-    pgsql_sock:cancel(C).
+    epgsql_sock:cancel(C).
 
 
 %% -- internal functions --

+ 17 - 17
test/pgsql_cast.erl → test/epgsql_cast.erl

@@ -1,9 +1,9 @@
 %%% Copyright (C) 2008 - Will Glozer.  All rights reserved.
 %%% Copyright (C) 2011 - Anton Lebedevich.  All rights reserved.
 %%%
-%%% Emulates original epgsql API over apgsql for original tests
+%%% Emulates original epgsql API over epgsqla for original tests
 
--module(pgsql_cast).
+-module(epgsql_cast).
 
 -export([connect/2, connect/3, connect/4, close/1]).
 -export([get_parameter/2, squery/2, equery/2, equery/3]).
@@ -13,7 +13,7 @@
 -export([with_transaction/2]).
 -export([receive_result/2, sync_on_error/2]).
 
--include("pgsql.hrl").
+-include("epgsql.hrl").
 
 %% -- client interface --
 
@@ -24,8 +24,8 @@ connect(Host, Username, Opts) ->
     connect(Host, Username, "", Opts).
 
 connect(Host, Username, Password, Opts) ->
-    {ok, C} = pgsql_sock:start_link(),
-    Ref = apgsql:connect(C, Host, Username, Password, Opts),
+    {ok, C} = epgsql_sock:start_link(),
+    Ref = epgsqla:connect(C, Host, Username, Password, Opts),
     %% TODO connect timeout
     receive
         {C, Ref, connected} ->
@@ -37,13 +37,13 @@ connect(Host, Username, Password, Opts) ->
     end.
 
 close(C) ->
-    apgsql:close(C).
+    epgsqla:close(C).
 
 get_parameter(C, Name) ->
-    apgsql:get_parameter(C, Name).
+    epgsqla:get_parameter(C, Name).
 
 squery(C, Sql) ->
-    Ref = apgsql:squery(C, Sql),
+    Ref = epgsqla:squery(C, Sql),
     receive_result(C, Ref).
 
 equery(C, Sql) ->
@@ -54,7 +54,7 @@ equery(C, Sql, Parameters) ->
     case parse(C, Sql) of
         {ok, #statement{types = Types} = S} ->
             Typed_Parameters = lists:zip(Types, Parameters),
-            Ref = apgsql:equery(C, S, Typed_Parameters),
+            Ref = epgsqla:equery(C, S, Typed_Parameters),
             receive_result(C, Ref);
         Error ->
             Error
@@ -69,7 +69,7 @@ parse(C, Sql, Types) ->
     parse(C, "", Sql, Types).
 
 parse(C, Name, Sql, Types) ->
-    Ref = apgsql:parse(C, Name, Sql, Types),
+    Ref = epgsqla:parse(C, Name, Sql, Types),
     sync_on_error(C, receive_result(C, Ref)).
 
 %% bind
@@ -78,7 +78,7 @@ bind(C, Statement, Parameters) ->
     bind(C, Statement, "", Parameters).
 
 bind(C, Statement, PortalName, Parameters) ->
-    Ref = apgsql:bind(C, Statement, PortalName, Parameters),
+    Ref = epgsqla:bind(C, Statement, PortalName, Parameters),
     sync_on_error(C, receive_result(C, Ref)).
 
 %% execute
@@ -90,11 +90,11 @@ execute(C, S, N) ->
     execute(C, S, "", N).
 
 execute(C, S, PortalName, N) ->
-    Ref = apgsql:execute(C, S, PortalName, N),
+    Ref = epgsqla:execute(C, S, PortalName, N),
     receive_result(C, Ref).
 
 execute_batch(C, Batch) ->
-    Ref = apgsql:execute_batch(C, Batch),
+    Ref = epgsqla:execute_batch(C, Batch),
     receive_result(C, Ref).
 
 %% statement/portal functions
@@ -103,7 +103,7 @@ describe(C, #statement{name = Name}) ->
     describe(C, statement, Name).
 
 describe(C, Type, Name) ->
-    Ref = apgsql:describe(C, Type, Name),
+    Ref = epgsqla:describe(C, Type, Name),
     %% TODO unknown result format of Describe portal
     sync_on_error(C, receive_result(C, Ref)).
 
@@ -111,11 +111,11 @@ close(C, #statement{name = Name}) ->
     close(C, statement, Name).
 
 close(C, Type, Name) ->
-    Ref = apgsql:close(C, Type, Name),
+    Ref = epgsqla:close(C, Type, Name),
     receive_result(C, Ref).
 
 sync(C) ->
-    Ref = apgsql:sync(C),
+    Ref = epgsqla:sync(C),
     receive_result(C, Ref).
 
 %% misc helper functions
@@ -142,7 +142,7 @@ receive_result(C, Ref) ->
     end.
 
 sync_on_error(C, Error = {error, _}) ->
-    Ref = apgsql:sync(C),
+    Ref = epgsqla:sync(C),
     receive_result(C, Ref),
     Error;
 

+ 19 - 19
test/pgsql_incremental.erl → test/epgsql_incremental.erl

@@ -1,9 +1,9 @@
 %%% Copyright (C) 2008 - Will Glozer.  All rights reserved.
 %%% Copyright (C) 2011 - Anton Lebedevich.  All rights reserved.
 %%%
-%%% Emulates original epgsql API over ipgsql for original tests
+%%% Emulates original epgsql API over epgsqli for original tests
 
--module(pgsql_incremental).
+-module(epgsql_incremental).
 
 -export([connect/2, connect/3, connect/4, close/1]).
 -export([get_parameter/2, squery/2, equery/2, equery/3]).
@@ -12,7 +12,7 @@
 -export([close/2, close/3, sync/1]).
 -export([with_transaction/2]).
 
--include("pgsql.hrl").
+-include("epgsql.hrl").
 
 %% -- client interface --
 
@@ -23,8 +23,8 @@ connect(Host, Username, Opts) ->
     connect(Host, Username, "", Opts).
 
 connect(Host, Username, Password, Opts) ->
-    {ok, C} = pgsql_sock:start_link(),
-    Ref = ipgsql:connect(C, Host, Username, Password, Opts),
+    {ok, C} = epgsql_sock:start_link(),
+    Ref = epgsqli:connect(C, Host, Username, Password, Opts),
     receive
         {C, Ref, connected} ->
             {ok, C};
@@ -35,13 +35,13 @@ connect(Host, Username, Password, Opts) ->
     end.
 
 close(C) ->
-    ipgsql:close(C).
+    epgsqli:close(C).
 
 get_parameter(C, Name) ->
-    ipgsql:get_parameter(C, Name).
+    epgsqli:get_parameter(C, Name).
 
 squery(C, Sql) ->
-    Ref = ipgsql:squery(C, Sql),
+    Ref = epgsqli:squery(C, Sql),
     case receive_results(C, Ref, []) of
         [Result] -> Result;
         Results  -> Results
@@ -54,7 +54,7 @@ equery(C, Sql, Parameters) ->
     case parse(C, Sql) of
         {ok, #statement{types = Types} = S} ->
             Typed_Parameters = lists:zip(Types, Parameters),
-            Ref = ipgsql:equery(C, S, Typed_Parameters),
+            Ref = epgsqli:equery(C, S, Typed_Parameters),
             receive_result(C, Ref, undefined);
         Error ->
             Error
@@ -69,7 +69,7 @@ parse(C, Sql, Types) ->
     parse(C, "", Sql, Types).
 
 parse(C, Name, Sql, Types) ->
-    Ref = ipgsql:parse(C, Name, Sql, Types),
+    Ref = epgsqli:parse(C, Name, Sql, Types),
     sync_on_error(C, receive_describe(C, Ref, #statement{name = Name})).
 
 %% bind
@@ -78,7 +78,7 @@ bind(C, Statement, Parameters) ->
     bind(C, Statement, "", Parameters).
 
 bind(C, Statement, PortalName, Parameters) ->
-    Ref = ipgsql:bind(C, Statement, PortalName, Parameters),
+    Ref = epgsqli:bind(C, Statement, PortalName, Parameters),
     sync_on_error(C, receive_atom(C, Ref, ok, ok)).
 
 %% execute
@@ -90,11 +90,11 @@ execute(C, S, N) ->
     execute(C, S, "", N).
 
 execute(C, S, PortalName, N) ->
-    Ref = ipgsql:execute(C, S, PortalName, N),
+    Ref = epgsqli:execute(C, S, PortalName, N),
     receive_extended_result(C, Ref, []).
 
 execute_batch(C, Batch) ->
-    Ref = ipgsql:execute_batch(C, Batch),
+    Ref = epgsqli:execute_batch(C, Batch),
     receive_extended_results(C, Ref, []).
 
 %% statement/portal functions
@@ -103,22 +103,22 @@ describe(C, #statement{name = Name}) ->
     describe(C, statement, Name).
 
 describe(C, statement, Name) ->
-    Ref = ipgsql:describe(C, statement, Name),
+    Ref = epgsqli:describe(C, statement, Name),
     sync_on_error(C, receive_describe(C, Ref, #statement{name = Name}));
 
 describe(C, Type, Name) ->
     %% TODO unknown result format of Describe portal
-    ipgsql:describe(C, Type, Name).
+    epgsqli:describe(C, Type, Name).
 
 close(C, #statement{name = Name}) ->
     close(C, statement, Name).
 
 close(C, Type, Name) ->
-    Ref = ipgsql:close(C, Type, Name),
+    Ref = epgsqli:close(C, Type, Name),
     receive_atom(C, Ref, ok, ok).
 
 sync(C) ->
-    Ref = ipgsql:sync(C),
+    Ref = epgsqli:sync(C),
     receive_atom(C, Ref, ok, ok).
 
 %% misc helper functions
@@ -207,7 +207,7 @@ receive_describe(C, Ref, Statement = #statement{}) ->
         {C, Ref, {types, Types}} ->
             receive_describe(C, Ref, Statement#statement{types = Types});
         {C, Ref, {columns, Columns}} ->
-            Columns2 = [Col#column{format = pgsql_wire:format(Col#column.type)} || Col <- Columns],
+            Columns2 = [Col#column{format = epgsql_wire:format(Col#column.type)} || Col <- Columns],
             {ok, Statement#statement{columns = Columns2}};
         {C, Ref, no_data} ->
             {ok, Statement#statement{columns = []}};
@@ -228,7 +228,7 @@ receive_atom(C, Ref, Receive, Return) ->
     end.
 
 sync_on_error(C, Error = {error, _}) ->
-    Ref = ipgsql:sync(C),
+    Ref = epgsqli:sync(C),
     receive_atom(C, Ref, ok, ok),
     Error;
 

+ 7 - 7
test/pgsql_perf_tests.erl → test/epgsql_perf_tests.erl

@@ -1,6 +1,6 @@
 %%%
 
--module(pgsql_perf_tests).
+-module(epgsql_perf_tests).
 
 -include_lib("eunit/include/eunit.hrl").
 
@@ -22,19 +22,19 @@ drop_data_test_() ->
 prepare_data() ->
     {"insert blob", with_connection(fun (C) ->
         Noise = noise(?noise_size),
-        {ok, [], []} = pgsql:squery(C, "create table test_big_blobs (id int4 primary key, noise bytea)"),
-        {ok, 1} = pgsql:equery(C, "insert into test_big_blobs (id, noise) values (1, $1)", [Noise])
+        {ok, [], []} = epgsql:squery(C, "create table test_big_blobs (id int4 primary key, noise bytea)"),
+        {ok, 1} = epgsql:equery(C, "insert into test_big_blobs (id, noise) values (1, $1)", [Noise])
     end)}.
 
 get_data() ->
     {"get blob back", with_connection(fun (C) ->
-        {ok, _, [{Noise}]} = pgsql:equery(C, "select noise from test_big_blobs"),
+        {ok, _, [{Noise}]} = epgsql:equery(C, "select noise from test_big_blobs"),
         ?assertEqual(?noise_size, byte_size(Noise))
     end)}.
 
 drop_data() ->
     {"cleanup", with_connection(fun (C) ->
-        {ok, [], []} = pgsql:squery(C, "drop table test_big_blobs")
+        {ok, [], []} = epgsql:squery(C, "drop table test_big_blobs")
     end)}.
 
 noise(N) ->
@@ -51,10 +51,10 @@ with_connection(F) ->
 with_connection(F, Username, Args) ->
     Args2 = [{port, ?port}, {database, "epgsql_test_db1"} | Args],
     fun () ->
-        {ok, C} = pgsql:connect(?host, Username, Args2),
+        {ok, C} = epgsql:connect(?host, Username, Args2),
         try
             F(C)
         after
-            pgsql:close(C)
+            epgsql:close(C)
         end
     end.

+ 11 - 11
test/pgsql_tests.erl → test/epgsql_tests.erl

@@ -1,11 +1,11 @@
--module(pgsql_tests).
+-module(epgsql_tests).
 
 -export([run_tests/0]).
 -compile([export_all]).
 
 -include_lib("eunit/include/eunit.hrl").
 -include_lib("public_key/include/public_key.hrl").
--include("pgsql.hrl").
+-include("epgsql.hrl").
 
 -define(host, "localhost").
 -define(port, 5432).
@@ -81,7 +81,7 @@ connect_with_ssl_test(Module) ->
 
 connect_with_client_cert_test(Module) ->
     lists:foreach(fun application:start/1, ?ssl_apps),
-    Dir = filename:join(filename:dirname(code:which(pgsql_tests)), "../test_data"),
+    Dir = filename:join(filename:dirname(code:which(epgsql_tests)), "../test_data"),
     File = fun(Name) -> filename:join(Dir, Name) end,
     {ok, Pem} = file:read_file(File("epgsql.crt")),
     [{'Certificate', Der, not_encrypted}] = public_key:pem_decode(Pem),
@@ -679,11 +679,11 @@ warning_notice_test(Module) ->
                begin
                  raise warning 'oops';
                end;
-               $$ language plpgsql;
+               $$ language plepgsql;
                select pg_temp.raise()",
           [{ok, _, _}, _] = Module:squery(C, Q),
           receive
-              {pgsql, C, {notice, #error{message = <<"oops">>}}} -> ok
+              {epgsql, C, {notice, #error{message = <<"oops">>}}} -> ok
           after
               100 -> erlang:error(didnt_receive_notice)
           end
@@ -698,7 +698,7 @@ listen_notify_test(Module) ->
           {ok, _, [{Pid}]} = Module:equery(C, "select pg_backend_pid()"),
           {ok, [], []}     = Module:squery(C, "notify epgsql_test"),
           receive
-              {pgsql, C, {notification, <<"epgsql_test">>, Pid, <<>>}} -> ok
+              {epgsql, C, {notification, <<"epgsql_test">>, Pid, <<>>}} -> ok
           after
               100 -> erlang:error(didnt_receive_notification)
           end
@@ -714,7 +714,7 @@ listen_notify_payload_test(Module) ->
           {ok, _, [{Pid}]} = Module:equery(C, "select pg_backend_pid()"),
           {ok, [], []}     = Module:squery(C, "notify epgsql_test, 'test!'"),
           receive
-              {pgsql, C, {notification, <<"epgsql_test">>, Pid, <<"test!">>}} -> ok
+              {epgsql, C, {notification, <<"epgsql_test">>, Pid, <<"test!">>}} -> ok
           after
               100 -> erlang:error(didnt_receive_notification)
           end
@@ -729,7 +729,7 @@ application_test(_Module) ->
 %% -- run all tests --
 
 run_tests() ->
-    Files = filelib:wildcard(filename:dirname(code:which(pgsql_tests))
+    Files = filelib:wildcard(filename:dirname(code:which(epgsql_tests))
                              ++ "/*tests.beam"),
     Mods = [list_to_atom(filename:basename(F, ".beam")) || F <- Files],
     eunit:test(Mods, []).
@@ -758,9 +758,9 @@ all_test_() ->
                   end,
                   Tests)
         end,
-    [WithModule(pgsql),
-     WithModule(pgsql_cast),
-     WithModule(pgsql_incremental)].
+    [WithModule(epgsql),
+     WithModule(epgsql_cast),
+     WithModule(epgsql_incremental)].
 
 %% -- internal functions --