SQLsmith  v1.2.1-5-gfacd7a8
A random SQL query generator
postgres.hh
Go to the documentation of this file.
1 
4 #ifndef POSTGRES_HH
5 #define POSTGRES_HH
6 
7 #include "dut.hh"
8 #include "relmodel.hh"
9 #include "schema.hh"
10 
11 #include <pqxx/pqxx>
12 
13 extern "C" {
14 #include <libpq-fe.h>
15 }
16 
17 #define OID long
18 
19 struct pg_type : sqltype {
20  OID oid_;
21  char typdelim_;
22  OID typrelid_;
23  OID typelem_;
24  OID typarray_;
25  char typtype_;
26  pg_type(string name,
27  OID oid,
28  char typdelim,
29  OID typrelid,
30  OID typelem,
31  OID typarray,
32  char typtype)
33  : sqltype(name), oid_(oid), typdelim_(typdelim), typrelid_(typrelid),
34  typelem_(typelem), typarray_(typarray), typtype_(typtype) { }
35 
36  virtual bool consistent(struct sqltype *rvalue);
37  bool consistent_(sqltype *rvalue);
38 };
39 
40 
41 struct schema_pqxx : public schema {
42  pqxx::connection c;
43  map<OID, pg_type*> oid2type;
44  map<string, pg_type*> name2type;
45 
46  virtual std::string quote_name(const std::string &id) {
47  return c.quote_name(id);
48  }
49  schema_pqxx(std::string &conninfo, bool no_catalog);
50 };
51 
52 struct dut_pqxx : dut_base {
53  pqxx::connection c;
54  virtual void test(const std::string &stmt);
55  dut_pqxx(std::string conninfo);
56 };
57 
58 struct dut_libpq : dut_base {
59  PGconn *conn = 0;
60  std::string conninfo_;
61  virtual void test(const std::string &stmt);
62  void command(const std::string &stmt);
63  void connect(std::string &conninfo);
64  dut_libpq(std::string conninfo);
65 };
66 
67 #endif
Base class for device under test.
supporting classes for the grammar
Base class providing schema information to grammar.
Definition: dut.hh:44
virtual bool consistent(struct sqltype *rvalue)
This function is used to model postgres-style pseudotypes.
Definition: postgres.cc:19
Definition: schema.hh:16