๐”– Bobbio Scriptorium
โœฆ   LIBER   โœฆ

Simple and safe SQL queries with C++ templates

โœ Scribed by Joseph (Yossi) Gil; Keren Lenz


Publisher
Elsevier Science
Year
2010
Tongue
English
Weight
673 KB
Volume
75
Category
Article
ISSN
0167-6423

No coin nor oath required. For personal study only.

โœฆ Synopsis


Most large software applications rely on an external relational database for storing and managing persistent data. Typically, such applications interact with the database by first constructing strings that represent SQL statements, and then submitting these for execution by the database engine. The fact that these statements are only checked for correctness at runtime is a source for many potential defects, including type and syntax errors and vulnerability to injection attacks.

The AraRat system presented here offers a method for dealing with these difficulties by coercing the host C++ compiler to do the necessary checks of the generated strings. A library of templates and preprocessor directives is used to embed in C++ a little language representing an augmented relational algebra formalism. Type checking of this embedded language, carried out by our template library, assures, at compile-time, the correctness and safety of the generated SQL strings. All SQL statements constructed by AraRat are guaranteed to be syntactically correct, and type safe with respect to the database schema. Moreover, AraRat statically ensures that the generated statements are immune to all injection attacks.

The standard techniques of ''expression templates'' and ''compile-time symbolic derivation'' for compile-time representation of symbolic structures, are enhanced in our system. We demonstrate the support of a type system and a symbol table lookup of the symbolic structure. A key observation of this work is that type equivalence of instantiated nominally typed generics in C++ (as well as other languages, e.g., Java) is structural rather than nominal. This makes it possible to embed the structural type system, characteristic to persistent data management, in the nominal type system of C++.

For some of its advanced features, AraRat relies on two small extensions to the standard C++ language: the typeof pseudo operator and the __COUNTER__ preprocessor macro.


๐Ÿ“œ SIMILAR VOLUMES


Novel and simple synthesis of hollow por
โœ Qun Xu; Jianbo Li; Qi Peng; Linlin Wu; Suping Li ๐Ÿ“‚ Article ๐Ÿ“… 2006 ๐Ÿ› Elsevier Science ๐ŸŒ English โš– 445 KB

A novel and simple approach to synthesize the hollow porous silica fibers with hierarchical structure had been proposed, in which natural silk fiber was used as template with the aid of supercritical CO 2 . Supercritical CO 2 can be used to proceed with coating, during which silica precursor (TEOS)