Skip to content

Commit e1dfa71

Browse files
committed
Keep former calls to work::prepared().
Looks like ancient versions of libpqxx (like the ones shipped on Ubuntu 18.04) don't have exec_prepared(). So test for libpqxx 7 and conditionally use work::prepared() if we find an older version.
1 parent 420af08 commit e1dfa71

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

log.cc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,12 @@ pqxx_logger::pqxx_logger(std::string target, std::string conninfo, struct schema
145145

146146
ostringstream seed;
147147
seed << smith::rng;
148-
148+
149+
#ifdef HAVE_LIBPQXX7
149150
result r = w.exec_prepared("instance", GITREV, target, hostname, s.version, seed.str());
151+
#else
152+
result r = w.prepared("instance")(GITREV)(target)(hostname)(s.version)(seed.str()).exec();
153+
#endif
150154

151155
id = r[0][0].as<long>(id);
152156

@@ -169,7 +173,11 @@ void pqxx_logger::error(prod &query, const dut::failure &e)
169173
work w(*c);
170174
ostringstream s;
171175
s << query;
176+
#ifdef HAVE_LIBPQXX7
172177
w.exec_prepared("error", e.what(), s.str(), e.sqlstate);
178+
#else
179+
w.prepared("error")(e.what())(s.str())(e.sqlstate).exec();
180+
#endif
173181
w.commit();
174182
}
175183

@@ -180,7 +188,11 @@ void pqxx_logger::generated(prod &query)
180188
work w(*c);
181189
ostringstream s;
182190
impedance::report(s);
191+
#ifdef HAVE_LIBPQXX7
183192
w.exec_prepared("stat", queries, sum_height/queries, sum_nodes/queries, sum_retries/queries, s.str());
193+
#else
194+
w.prepared("stat")(queries)(sum_height/queries)(sum_nodes/queries)(sum_retries/queries)(s.str()).exec();
195+
#endif
184196
w.commit();
185197
}
186198
}

0 commit comments

Comments
 (0)