[erlang-questions] ejabberd postgres driver problem

tsuraan tsuraan@REDACTED
Mon Dec 10 19:10:49 CET 2007


I'm hoping this is an appropriate place to post my problem attempting to use
the ejabberd postgres driver in my own code...

I have a postgresql table whose format is like this:

mydb=# \d attachments
Table "public.attachments"
Column | Type | Modifiers
--------+---------+--------------------------------------------------------------
atchid | bigint | not null default
nextval('attachments_atchid_seq'::regclass)
msgkey | bigint | not null
docid | bigint | not null
parent | bigint |
name | text |
body | boolean |
Indexes:
"attachments_pkey" PRIMARY KEY, btree (atchid)
"attachments_msgkey_key" UNIQUE, btree (msgkey, docid, parent, name)
Foreign-key constraints:
"attachments_docid_fkey" FOREIGN KEY (docid) REFERENCES documents(docid) ON
UPDATE CASCADE ON DELETE CASCADE
"attachments_msgkey_fkey" FOREIGN KEY (msgkey) REFERENCES messages(msgkey)
ON UPDATE CASCADE ON DELETE CASCADE
"attachments_parent_fkey" FOREIGN KEY (parent) REFERENCES
attachments(atchid) ON UPDATE CASCADE ON DELETE CASCADE


In erlang, I do the following and get the pasted-in error:


7> {ok, Db} = pgsql:connect("localhost", "mydb", "me", "").
Params: [{secret,{7183,274541943}},
{{parameter,"TimeZone"},"CST6CDT"},
{{parameter,"standard_conforming_strings"},"off"},
{{parameter,"session_authorization"},"me"},
{{parameter,"server_version"},"8.1.5"},
{{parameter,"server_encoding"},"UTF8"},
{{parameter,"is_superuser"},"on"},
{{parameter,"integer_datetimes"},"off"},
{{parameter,"DateStyle"},"ISO, MDY"},
{{parameter,"client_encoding"},"UTF8"}]
{ok,<0.44.0>}
8> pgsql:squery(Db, "SELECT * FROM Attachments").

=ERROR REPORT==== 10-Dec-2007::11:55:35 ===
Error in process <0.44.0> with exit value:
{badarg,[{erlang,binary_to_list,[null]},{pgsql_proto,'-process_squery_cols/1-fun-0-',1},{lists,map,2},{lists,map,2},{pgsql_proto,process_squery_cols,1},{pgsql_proto,process_squery,1},{pgsql_proto,idle,2}]}

** exited: {badarg,[{erlang,binary_to_list,[null]},
{pgsql_proto,'-process_squery_cols/1-fun-0-',1},
{lists,map,2},
{lists,map,2},
{pgsql_proto,process_squery_cols,1},
{pgsql_proto,process_squery,1},
{pgsql_proto,idle,2}]} **

I really don't understand erlang tracebacks yet, so this error message is
pure greek to me.  Does anyone have a clue what is causing this,
or where I can start to debug this?

Other database stuff works, like so:

2> pgsql:squery(Db, "CREATE TEMP TABLE TEST(key bigint primary key)").
{ok,["CREATE TABLE"]}
3> pgsql:squery(Db, "SELECT * FROM TEST").
{ok,[{"SELECT",[{desc,1,"key",20,text,8,-1,121252}],[]}]}
4> pgsql:squery(Db, "INSERT INTO TEST VALUES(1)").
{ok,["INSERT 0 1"]}
5> pgsql:squery(Db, "SELECT * FROM TEST").
{ok,[{"SELECT",[{desc,1,"key",20,text,8,-1,121252}],[["1"]]}]}

So it looks like there's something about my table that's making the pg
driver die.  Can anyone see what's happening?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20071210/51937086/attachment.htm>


More information about the erlang-questions mailing list