File: CachedQuery.h

package info (click to toggle)
storm-lang 0.7.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,028 kB
  • sloc: ansic: 261,471; cpp: 140,432; sh: 14,891; perl: 9,846; python: 2,525; lisp: 2,504; asm: 860; makefile: 678; pascal: 70; java: 52; xml: 37; awk: 12
file content (32 lines) | stat: -rw-r--r-- 1,151 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once
#include "QueryStr.h"

namespace sql {

	class DBConnection;
	class Statement;

	/**
	 * A query that can be cached by a connection.
	 *
	 * Mainly intended for use with the language extension. The idea is that the language extension
	 * generates a CachedQuery instance and passes it to `DBConnection.prepare`. This causes
	 * connection to prepare the query and then cache it for the duration of the connection itself.
	 *
	 * This scheme is also designed to allow supplying different versions of the query based on the
	 * capabilities of the underlying database (e.g. work-arounds for databases that don't support
	 * the RETURNS clause of insert statements for example).
	 */
	class CachedQuery : public Object {
		STORM_ABSTRACT_CLASS;
	public:
		// Create.
		STORM_CTOR CachedQuery() {}

		// Prepare a query for a particular database to produce a statement. The expectation is that
		// the implementation calls `db.prepare(<query>)` and returns the result. However, this
		// scheme also allows returning some more complex statement, e.g. for compatibility.
		virtual Statement *STORM_FN query(DBConnection *db) ABSTRACT;
	};

}