Permalink
Browse files

Test functions with ':=' and causes a crash case

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 23, 2013
1 parent 684be04 commit 7941919fa632e525e127fde753cf9a0cb64545d3
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/backends/postgresql/test/test-postgresql.cpp
@@ -43,6 +43,7 @@ struct oid_table_creator : public table_creator_base
// whatever that means.
void test1()
{
try
{
session sql(backEnd, connectString);
@@ -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;
}
@@ -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";
@@ -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";

0 comments on commit 7941919

Please sign in to comment.