Skip to content

Commit

Permalink
Test functions with ':=' and causes a crash case
Browse files Browse the repository at this point in the history
Tests if soci can create psql functions with assignments (:=).
Tests the situation where preparing an invalid query caused a crash with certain combinations of client/server versions.
  • Loading branch information
ricardofandrade authored and mloskot committed Mar 24, 2013
1 parent 684be04 commit 7941919
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/backends/postgresql/test/test-postgresql.cpp
Expand Up @@ -43,6 +43,7 @@ struct oid_table_creator : public table_creator_base
// whatever that means.
void test1()
{
try
{
session sql(backEnd, connectString);

Expand Down Expand Up @@ -76,8 +77,14 @@ void test1()

assert(id == 7);
assert(name == "John");

// Must not cause the application to crash.
statement st(sql);
st.prepare(""); // Throws an exception in some versions.
}
catch(...)
{
}

std::cout << "test 1 passed" << std::endl;
}

Expand All @@ -99,6 +106,7 @@ class function_creator : function_creator_base
sql <<
"create or replace function soci_test(msg varchar) "
"returns varchar as $$ "
"declare x int := 1;"
"begin "
" return msg; "
"end $$ language plpgsql";
Expand All @@ -107,6 +115,7 @@ class function_creator : function_creator_base
sql <<
"create or replace function soci_test(varchar) "
"returns varchar as \' "
"declare x int := 1;"
"begin "
" return $1; "
"end \' language plpgsql";
Expand Down

0 comments on commit 7941919

Please sign in to comment.