Skip to content

Commit

Permalink
Backport change from trunk.
Browse files Browse the repository at this point in the history
It fixes bug CORE-3998 : Parametrized execute statement fails
  • Loading branch information
hvlad committed Nov 27, 2012
1 parent 12e97c4 commit 8433046
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/jrd/PreparedStatement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@
#include "../dsql/sqlda_pub.h"
#include "../dsql/dsql_proto.h"

namespace
{
class ParamCmp
{
public:
static int greaterThan(const Jrd::dsql_par* p1, const Jrd::dsql_par* p2)
{
return p1->par_index > p2->par_index;
}
};
}


namespace Jrd {


Expand Down Expand Up @@ -100,21 +113,19 @@ void PreparedStatement::parseDsqlMessage(dsql_msg* dsqlMsg, Firebird::Array<dsc>
// To generate correct BLR we must walk params in ascending par_index order.
// So store all params in array in an ascending par_index order despite of
// order in linked list.
// ASF: Input parameters don't come necessarily in ascending or descending order,
// so I changed the code to use a SortedArray.

Firebird::SortedArray<const dsql_par*,
Firebird::InlineStorage<const dsql_par*, 16>,
const dsql_par*,
Firebird::DefaultKeyValue<const dsql_par*>,
ParamCmp> params;

Firebird::HalfStaticArray<const dsql_par*, 16> params;
USHORT first_index = 0;
for (const dsql_par* par = dsqlMsg->msg_parameters; par; par = par->par_next)
{
if (par->par_index)
{
if (!first_index)
first_index = par->par_index;

if (first_index > par->par_index)
params.insert(0, par);
else
params.add(par);
}
params.add(par);
}

size_t msgLength = 0;
Expand Down

0 comments on commit 8433046

Please sign in to comment.