From d7d0e1067b690f08006bb57149e204f4b9ddb99c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 27 Jul 2012 10:29:50 +0200 Subject: Document new index definition support --- NEWS | 8 +- doc/manual.xhtml | 638 ++++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 542 insertions(+), 104 deletions(-) diff --git a/NEWS b/NEWS index 0fdda4f..5793013 100644 --- a/NEWS +++ b/NEWS @@ -1,11 +1,17 @@ Version 2.1.0 + * Support for defining database indexes. Both simple and composite indexes + can be defined with support for database-specific index types, methods, and + options. For more information, refer to Section 12.6, "Index Definition + Pragmas" as well as Sections [13-17].16, " Index Definition" + in the ODB manual. + * Support for mapping additional database types, such as geospatial types, user-defined types, and collections. This mechanism allows you to map any database type to one of the types for which ODB provides built-in support (normally string or binary). The text or binary representation of the data can then be extracted into a C++ data type of your choice. - For more information, refer to Section 12.6, "Database Type Mapping + For more information, refer to Section 12.7, "Database Type Mapping Pragmas" in the ODB manual. * The session constructor now accepts an options bool argument (true by diff --git a/doc/manual.xhtml b/doc/manual.xhtml index 88e8f07..700294c 100644 --- a/doc/manual.xhtml +++ b/doc/manual.xhtml @@ -513,20 +513,22 @@ for consistency. 12.4.11readonly 12.4.12inverse 12.4.13version - 12.4.14unordered - 12.4.15table - 12.4.16index_type - 12.4.17key_type - 12.4.18value_type - 12.4.19value_null/value_not_null - 12.4.20id_options - 12.4.21index_options - 12.4.22key_options - 12.4.23value_options - 12.4.24id_column - 12.4.25index_column - 12.4.26key_column - 12.4.27value_column + 12.4.14index + 12.4.15unique + 12.4.16unordered + 12.4.17table + 12.4.18index_type + 12.4.19key_type + 12.4.20value_type + 12.4.21value_null/value_not_null + 12.4.22id_options + 12.4.23index_options + 12.4.24key_options + 12.4.25value_options + 12.4.26id_column + 12.4.27index_column + 12.4.28key_column + 12.4.29value_column @@ -541,17 +543,20 @@ for consistency. - 12.6Database Type Mapping Pragmas + 12.6Index Definition Pragmas - 12.7C++ Compiler Warnings + 12.7Database Type Mapping Pragmas + + + 12.8C++ Compiler Warnings - - - - - - + + + + + +
12.7.1GNU C++
12.7.2Visual C++
12.7.3Sun C++
12.7.4IBM XL C++
12.7.5HP aC++
12.7.6Clang
12.8.1GNU C++
12.8.2Visual C++
12.8.3Sun C++
12.8.4IBM XL C++
12.8.5HP aC++
12.8.6Clang
@@ -577,6 +582,7 @@ for consistency. + 13.6MySQL Index Definition @@ -599,6 +605,7 @@ for consistency. + 14.6SQLite Index Definition @@ -622,6 +629,7 @@ for consistency. + 15.6PostgreSQL Index Definition @@ -646,6 +654,7 @@ for consistency. + 16.6Oracle Index Definition @@ -669,6 +678,7 @@ for consistency. + 17.6SQL Server Index Definition @@ -4575,7 +4585,12 @@ private: The second column contains the element index within a container. And the last column contains the element value. If the object id or element value are composite, then, instead of a single - column, they can occupy multiple columns.

+ column, they can occupy multiple columns. For an ordered + container table the ODB compiler also defines two indexes: + one for the object id column(s) and the other for the index + column. Refer to Section 12.6, "Index Definition + Pragmas" for more information on how to customize these + indexes.

Consider the following persistent object as an example:

@@ -4629,7 +4644,7 @@ private: of person's nicknames is probably not important. To instruct the ODB compiler to ignore the order in ordered containers we can use the db unordered pragma (Section 12.3.7, - "unordered", Section 12.4.14, + "unordered", Section 12.4.16, "unordered"). For example:

@@ -4666,7 +4681,11 @@ private:
      persistent class instance of which the container is a member.
      And the second column contains the element value. If the object
      id or element value are composite, then, instead of a single
-     column, they can occupy multiple columns.

+ column, they can occupy multiple columns. ODB compiler also + defines an index on a set container table for the object id + column(s). Refer to Section 12.6, "Index Definition + Pragmas" for more information on how to customize this + index.

Consider the following persistent object as an example:

@@ -4729,7 +4748,11 @@ private: The second column contains the element key. And the last column contains the element value. If the object id, element key, or element value are composite, then instead of a single column - they can occupy multiple columns.

+ they can occupy multiple columns. ODB compiler also + defines an index on a map container table for the object id + column(s). Refer to Section 12.6, "Index Definition + Pragmas" for more information on how to customize this + index.

Consider the following persistent object as an example:

@@ -4887,8 +4910,8 @@ class employee use the not_null pragma (Section 12.4.5, "null/not_null") for single object pointers and the value_not_null pragma - (Section - 12.4.19, "value_null/value_not_null") + (Section + 12.4.21, "value_null/value_not_null") for containers of object pointers. For example:

@@ -5345,7 +5368,7 @@ CREATE TABLE employee (
      pointer. Also note that an ordered container (Section
      5.1, "Ordered Containers") of pointers that is an inverse side
      of a bidirectional relationship is always treated as unordered
-     (Section 12.4.14, "unordered")
+     (Section 12.4.16, "unordered")
      because the contents of such a container are implicitly built from
      the direct side of the relationship which does not contain the
      element order (index).

@@ -6238,9 +6261,9 @@ CREATE TABLE person (

The same principle applies when a composite value type is used as an element of a container, except that instead of db column, either the db value_column - (Section 12.4.27, "value_column") or + (Section 12.4.29, "value_column") or db key_column - (Section 12.4.26, "key_column") + (Section 12.4.28, "key_column") pragmas are used to specify the column prefix.

When a composite value type contains a container, an extra table @@ -6284,8 +6307,8 @@ CREATE TABLE person (

To customize the container table name we can use the - db table pragma (Section - 12.4.15, "table"), for example:

+ db table pragma (Section + 12.4.17, "table"), for example:

 #pragma db value
@@ -8873,18 +8896,19 @@ for (bool done (false); !done; )
   

The qualifier tells the ODB compiler what kind of C++ construct this pragma describes. Valid qualifiers are object, view, value, member, - namespace, and map. A pragma with the - object qualifier describes a persistent object type. It - tells the ODB compiler that the C++ class it describes is a persistent - class. Similarly, pragmas with the view qualifier describe - view types, the value qualifier describes value types - and the member qualifier is used to describe data - members of persistent object, view, and value types. The - namespace qualifier is used to describe common + namespace, index, and map. + A pragma with the object qualifier describes a persistent + object type. It tells the ODB compiler that the C++ class it describes + is a persistent class. Similarly, pragmas with the view + qualifier describe view types, the value qualifier + describes value types and the member qualifier is used + to describe data members of persistent object, view, and value types. + The namespace qualifier is used to describe common properties of objects, views, and value types that belong to - a C++ namespace. The map qualifier describes a - mapping between additional database types and types for - which ODB provides built-in support.

+ a C++ namespace. The index qualifier defines a + database index. And, finally, the map qualifier + describes a mapping between additional database types and types + for which ODB provides built-in support.

The specifier informs the ODB compiler about a particular database-related property of the C++ declaration. For example, the @@ -9024,7 +9048,7 @@ class person the C++ compiler to build the application. Some C++ compilers issue warnings about pragmas that they do not recognize. There are several ways to deal with this problem which are covered - at the end of this chapter in Section 12.7, + at the end of this chapter in Section 12.8, "C++ Compiler Warnings".

12.1 Object Type Pragmas

@@ -10269,7 +10293,7 @@ typedef std::vector<std::string> nicknames;

The semantics of the id_options specifier for a container type are similar to those of the id_options specifier for - a container data member (Section 12.4.20, + a container data member (Section 12.4.22, "id_options").

@@ -10286,7 +10310,7 @@ typedef std::vector<std::string> nicknames;

The semantics of the index_options specifier for a container type are similar to those of the index_options specifier for - a container data member (Section 12.4.21, + a container data member (Section 12.4.23, "index_options").

@@ -10303,7 +10327,7 @@ typedef std::map<std::string, std::string> properties;

The semantics of the key_options specifier for a container type are similar to those of the key_options specifier for - a container data member (Section 12.4.22, + a container data member (Section 12.4.24, "key_options").

@@ -10320,7 +10344,7 @@ typedef std::set<std::string> nicknames;

The semantics of the value_options specifier for a container type are similar to those of the value_options specifier for - a container data member (Section 12.4.23, + a container data member (Section 12.4.25, "value_options").

@@ -10477,87 +10501,99 @@ typedef std::map<unsigned short, float> age_weight_map; + index + define database index for a member + 12.4.14 + + + + unique + define unique database index for a member + 12.4.15 + + + unordered ordered container should be stored unordered - 12.4.14 + 12.4.16 table table name for a container - 12.4.15 + 12.4.17 index_type database type for a container's index type - 12.4.16 + 12.4.18 key_type database type for a container's key type - 12.4.17 + 12.4.19 value_type database type for a container's value type - 12.4.18 + 12.4.20 value_null/value_not_null container's value can/cannot be NULL - 12.4.19 + 12.4.21 id_options database options for a container's id column - 12.4.20 + 12.4.22 index_options database options for a container's index column - 12.4.21 + 12.4.23 key_options database options for a container's key column - 12.4.22 + 12.4.24 value_options database options for a container's value column - 12.4.23 + 12.4.25 id_column column name for a container's object id - 12.4.24 + 12.4.26 index_column column name for a container's index - 12.4.25 + 12.4.27 key_column column name for a container's key - 12.4.26 + 12.4.28 value_column column name for a container's value - 12.4.27 + 12.4.29 @@ -10856,8 +10892,8 @@ class person { ... - #pragma db options("UNIQUE") - std::string email_; // Mapped to TEXT NOT NULL UNIQUE. + #pragma db options("CHECK(email != '')") + std::string email_; // Mapped to TEXT NOT NULL CHECK(email != ''). };
@@ -10879,14 +10915,14 @@ class person std::string first_; // TEXT NOT NULL COLLATE binary - #pragma db options("UNIQUE") - std::string last_; // TEXT NOT NULL COLLATE binary UNIQUE + #pragma db options("CHECK(email != '')") + std::string last_; // TEXT NOT NULL COLLATE binary CHECK(email != '') #pragma db options() std::string title_; // TEXT NOT NULL - #pragma db options() options("UNIQUE") - std::string email_; // TEXT NOT NULL UNIQUE + #pragma db options() options("CHECK(email != '')") + std::string email_; // TEXT NOT NULL CHECK(email != '') };
@@ -11089,7 +11125,7 @@ class person relationship information. Only ordered and set containers can be used for inverse members. If an inverse member is of an ordered container type, it is automatically marked as unordered - (Section 12.4.14, "unordered").

+ (Section 12.4.16, "unordered").

For a more detailed discussion of inverse members, refer to Section 6.2, "Bidirectional Relationships".

@@ -11124,7 +11160,45 @@ class person

For a more detailed discussion of optimistic concurrency, refer to Chapter 11, "Optimistic Concurrency".

-

12.4.14 unordered

+

12.4.14 index

+ +

The index specifier instructs the ODB compiler to define + a database index for the data member. For example:

+ +
+#pragma db object
+class person
+{
+  ...
+
+  #pragma db index
+  std::string name_;
+};
+  
+ +

For more information on defining database indexes, refer to + Section 12.6, "Index Definition Pragmas".

+ +

12.4.15 unique

+ +

The index specifier instructs the ODB compiler to define + a unique database index for the data member. For example:

+ +
+#pragma db object
+class person
+{
+  ...
+
+  #pragma db unique
+  std::string name_;
+};
+  
+ +

For more information on defining database indexes, refer to + Section 12.6, "Index Definition Pragmas".

+ +

12.4.16 unordered

The unordered specifier specifies that a member of an ordered container type should be stored unordered in the database. @@ -11147,7 +11221,7 @@ class person storage in the database, refer to Section 5.1, "Ordered Containers".

-

12.4.15 table

+

12.4.17 table

The table specifier specifies the table name that should be used to store the contents of a container member. For example:

@@ -11195,7 +11269,7 @@ class person qualified names, refer to Section 12.1.8, "schema".

-

12.4.16 index_type

+

12.4.18 index_type

The index_type specifier specifies the native database type that should be used for an ordered container's @@ -11215,7 +11289,7 @@ class person }; -

12.4.17 key_type

+

12.4.19 key_type

The key_type specifier specifies the native database type that should be used for a map container's @@ -11235,7 +11309,7 @@ class person }; -

12.4.18 value_type

+

12.4.20 value_type

The value_type specifier specifies the native database type that should be used for a container's @@ -11256,11 +11330,11 @@ class person

The value_null and value_not_null - (Section 12.4.19, + (Section 12.4.21, "value_null/value_not_null") specifiers can be used to control the NULL semantics of a value column.

-

12.4.19 value_null/value_not_null

+

12.4.21 value_null/value_not_null

The value_null and value_not_null specifiers specify that a container's element value for a data member can or @@ -11293,7 +11367,7 @@ class account Multiset Containers") the element value is automatically treated as not allowing a NULL value.

-

12.4.20 id_options

+

12.4.22 id_options

The id_options specifier specifies additional column definition options that should be used for a container's @@ -11317,7 +11391,7 @@ class person of the options specifier (Section 12.4.7, "options").

-

12.4.21 index_options

+

12.4.23 index_options

The index_options specifier specifies additional column definition options that should be used for a container's @@ -11338,7 +11412,7 @@ class person of the options specifier (Section 12.4.7, "options").

-

12.4.22 key_options

+

12.4.24 key_options

The key_options specifier specifies additional column definition options that should be used for a container's @@ -11359,7 +11433,7 @@ class person of the options specifier (Section 12.4.7, "options").

-

12.4.23 value_options

+

12.4.25 value_options

The value_options specifier specifies additional column definition options that should be used for a container's @@ -11380,7 +11454,7 @@ class person of the options specifier (Section 12.4.7, "options").

-

12.4.24 id_column

+

12.4.26 id_column

The id_column specifier specifies the column name that should be used to store the object id in a @@ -11404,7 +11478,7 @@ class person

If the column name is not specified, then object_id is used by default.

-

12.4.25 index_column

+

12.4.27 index_column

The index_column specifier specifies the column name that should be used to store the element index in an @@ -11428,7 +11502,7 @@ class person

If the column name is not specified, then index is used by default.

-

12.4.26 key_column

+

12.4.28 key_column

The key_column specifier specifies the column name that should be used to store the key in a map @@ -11452,7 +11526,7 @@ class person

If the column name is not specified, then key is used by default.

-

12.4.27 value_column

+

12.4.29 value_column

The value_column specifier specifies the column name that should be used to store the element value in a @@ -11692,7 +11766,207 @@ namespace hr "session"). For more information on sessions, refer to Chapter 10, "Session".

-

12.6 Database Type Mapping Pragmas

+

12.6 Index Definition Pragmas

+ +

While it is possible to manually add indexes to the generated + database schema, it is more convenient to do this as part of + the persistent class definitions. A pragma with the index + qualifier describes a database index. It has the following + general format:

+ +
+#pragma db index[("<name>")]                       \
+           [unique|type("<type>")]                 \
+           [method("<method>")]                    \
+           [options("<index-options>")]            \
+           member(<name>[, "<column-options>"])... \
+           members(<name>[,<name>...])...
+
+ +

The index qualifier can optionally specify the + index name. If the index name is not specified, then one is + automatically derived by appending the _i suffix + to the column name of the index member. If the name is not + specified and the index contains multiple members, then the + index definition is invalid.

+ +

The optional type, method, and + options clauses specify the index type, for + example UNIQUE, index method, for example + BTREE, and index options, respectively. The + unique clause is a shortcut for + type("UNIQUE"). Note that not all database + systems support specifying an index method or options. + For more information on the database system-specific index + types, methods, and options, refer to Part II, + "Database Systems".

+ +

To specify index members we can use the member + or members clauses, or a mix of the two. The + member clause allows us to specify a single + index member with optional column options, for example, + "ASC". If we need to create a composite + index that contains multiple members, then we can repeat + the member clause several times or, if the + members don't have any column options, we can use a single + members clause instead. Similar to the index + type, method, and options, the format of column options is + database system-specific. For more details, refer to + Part II, "Database Systems".

+ +

The following code fragment shows some typical examples + of index definitions:

+ +
+#pragma db object
+class object
+{
+  ...
+
+  int x;
+  int y;
+  int z1;
+  int z2;
+
+  // An index for member x with automatically-assigned name x_i.
+  //
+  #pragma db index member(x)
+
+  // A unique index named y_index for member y which is sorted in
+  // the descending order. The index is using the BTREE method.
+  //
+  #pragma db index("y_index") unique method("BTREE") member(y, "DESC")
+
+  // A composite BITMAP index named z_i for members z1 and z2.
+  //
+  #pragma db index("z_i") type("BITMAP") members(z1, z2)
+};
+
+ +

ODB also offers a shortcut for defining an index with the default + method and options for a single data member. Such an index can + be defined using the index (Section + 12.4.14, "index") or unique + (Section 12.4.15, "unique") + member specifier. For example:

+ +
+#pragma db object
+class object
+{
+  ...
+
+  #pragma db index
+  int x;
+
+  #pragma db type("INT") unique
+  int y;
+};
+
+ +

The above example is semantically equivalent to the following + more verbose version:

+ +
+#pragma db object
+class object
+{
+  ...
+
+  int x;
+
+  #pragma db type("INT")
+  int y;
+
+  #pragma db index member(x)
+  #pragma db index unique member(y)
+};
+
+ +

While it is convenient to define an index inside a persistent + class, it is also possible to do that out of the class body. In this + case, the index name, if specified, must be prefixed with the + potentially-qualified class name. For example:

+ +
+namespace n
+{
+  #pragma db object
+  class object
+  {
+    ...
+
+    int x;
+    int y;
+  };
+
+  // An index for member x in persistent class object with automatically-
+  // assigned name x_i.
+  //
+  #pragma db index(object) member(x)
+}
+
+// An index named y_index for member y in persistent class n::object.
+//
+#pragma db index(n::object::"y_index") member(y)
+
+ +

It is possible to define an index on a member that is of a + composite value type or on some of its nested members. For + example:

+ +
+#pragma db value
+struct point
+{
+  int x;
+  int y;
+  int z;
+};
+
+#pragma db object
+class object
+{
+  // An index that includes all of the p1's nested members.
+  //
+  #pragma db index
+  point p1;
+
+  point p2;
+
+  // An index that includes only p2.x and p2.y.
+  //
+  #pragma db index("p2_xy_i") members(p2.x, p2.y)
+};
+
+ +

When generating a schema for a container member (Chapter 5, + "Containers"), ODB automatically defines two indexes on the container + table. One is for the object id that references the object table and the + other is for the index column in case the container is ordered + (Section 5.1, "Ordered Containers"). By default these + indexes use the default index name, type, method, and options. The + index pragma allows us to customize these two indexes by + recognizing the special id and index nested + member names when specified after a container member. For example:

+ +
+#pragma db object
+class object
+{
+  std::vector<int> v;
+
+  // Change the container id index name.
+  //
+  #pragma db index("id_index") member(v.id)
+
+  // Change the container index index method.
+  //
+  #pragma db index method("BTREE") member(v.index)
+};
+
+ +

12.7 Database Type Mapping Pragmas

A pragma with the map qualifier describes a mapping between two database types. For each database system @@ -11755,6 +12029,8 @@ namespace hr #pragma db object class object { + ... + #pragma db type("INTEGER[]") std::string array_; }; @@ -11860,6 +12136,8 @@ namespace odb #pragma db object class object { + ... + #pragma db type("INTEGER[]") std::vector<int> array_; }; @@ -11876,6 +12154,8 @@ typedef std::vector<int> int_vector; #pragma db object class object { + ... + std::vector<int> array_; // Mapped to INTEGER[]. }; @@ -11887,7 +12167,7 @@ class object for each database, shows how to provide custom mapping for some of the additional types.

-

12.7 C++ Compiler Warnings

+

12.8 C++ Compiler Warnings

When a C++ header file defining persistent classes and containing ODB pragmas is used to build the application, the C++ compiler may @@ -11940,7 +12220,7 @@ class person

The disadvantage of this approach is that it can quickly become overly verbose when positioned pragmas are used.

-

12.7.1 GNU C++

+

12.8.1 GNU C++

GNU g++ does not issue warnings about unknown pragmas unless requested with the -Wall command line option. @@ -11952,7 +12232,7 @@ class person g++ -Wall -Wno-unknown-pragmas ... -

12.7.2 Visual C++

+

12.8.2 Visual C++

Microsoft Visual C++ issues an unknown pragma warning (C4068) at warning level 1 or higher. This means that unless we have disabled @@ -11986,7 +12266,7 @@ class person #pragma warning (pop) -

12.7.3 Sun C++

+

12.8.3 Sun C++

The Sun C++ compiler does not issue warnings about unknown pragmas unless the +w or +w2 option is specified. @@ -11998,7 +12278,7 @@ class person CC +w -erroff=unknownpragma ... -

12.7.4 IBM XL C++

+

12.8.4 IBM XL C++

IBM XL C++ issues an unknown pragma warning (1540-1401) by default. To disable this warning we can add the -qsuppress=1540-1401 @@ -12008,7 +12288,7 @@ CC +w -erroff=unknownpragma ... xlC -qsuppress=1540-1401 ... -

12.7.5 HP aC++

+

12.8.5 HP aC++

HP aC++ (aCC) issues an unknown pragma warning (2161) by default. To disable this warning we can add the +W2161 @@ -12018,7 +12298,7 @@ xlC -qsuppress=1540-1401 ... aCC +W2161 ... -

12.7.6 Clang

+

12.8.6 Clang

Clang does not issue warnings about unknown pragmas unless requested with the -Wall command line option. @@ -12277,7 +12557,7 @@ class object

It is also possible to add support for additional MySQL types, such as geospatial types. For more information, refer to - Section 12.6, "Database Type Mapping + Section 12.7, "Database Type Mapping Pragmas".

13.2 MySQL Database Class

@@ -12723,6 +13003,31 @@ namespace odb foreign key definitions commented out. They are retained only for documentation.

+

13.6 MySQL Index Definitions

+ +

When the index pragma (Section 12.6, + "Index Definition Pragmas") is used to define a MySQL index, + the type clause specifies the index type (for example, + UNIQUE, FULLTEXT, SPATIAL), + the method clause specifies the index method (for + example, BTREE, HASH), and the + options clause is not used. The column options + can be used to specify column length limits and the sort order. + For example:

+ +
+#pragma db object
+class object
+{
+  ...
+
+  std::string name_;
+
+  #pragma db index method("HASH") member(name_, "(100) DESC")
+};
+  
+ + @@ -12895,7 +13200,7 @@ class object

It is also possible to add support for additional SQLite types, such as NUMERIC. For more information, refer to - Section 12.6, "Database Type Mapping + Section 12.7, "Database Type Mapping Pragmas".

14.2 SQLite Database Class

@@ -13467,6 +13772,30 @@ CREATE TABLE Employee ( functionality. Future versions of the library will remove this limitation.

+

14.6 SQLite Index Definitions

+ +

When the index pragma (Section 12.6, + "Index Definition Pragmas") is used to define an SQLite index, + the type clause specifies the index type (for example, + UNIQUE) while the method and + options clauses are not used. The column options + can be used to specify collations and the sort order. For example:

+ +
+#pragma db object
+class object
+{
+  ...
+
+  std::string name_;
+
+  #pragma db index member(name_, "COLLATE binary DESC")
+};
+  
+ +

Index names in SQLite are database-global. To avoid name clashes, + ODB automatically prefixes each index name with the table name on + which it is defined.

@@ -13655,7 +13984,7 @@ class object such as NUMERIC, geometry types, XML, JSON, enumeration types, composite types, arrays, geospatial types, and the key-value store (HSTORE). - For more information, refer to Section 12.6, + For more information, refer to Section 12.7, "Database Type Mapping Pragmas".

15.2 PostgreSQL Database Class

@@ -14095,8 +14424,10 @@ SHOW integer_datetimes

15.5.5 Timezones

-

ODB does not currently support the PostgreSQL date-time types - with timezone information.

+

ODB does not currently natively support the PostgreSQL date-time types + with timezone information. However, these types can be accessed by + mapping them to one of the natively supported types, as discussed + in Section 12.7, "Database Type Mapping Pragmas".

15.5.6 NUMERIC Type Support

@@ -14104,8 +14435,46 @@ SHOW integer_datetimes to providing a binary buffer containing the binary representation of the value. For more information on the binary format used to store NUMERIC values refer to the PostgreSQL - documentation.

+ documentation. An alternative approach to accessing NUMERIC + values is to map this type to one of the natively supported + ones, as discussed in Section 12.7, "Database + Type Mapping Pragmas".

+ + +

15.6 PostgreSQL Index Definitions

+

When the index pragma (Section 12.6, + "Index Definition Pragmas") is used to define a PostgreSQL index, + the type clause specifies the index type (for example, + UNIQUE), the method clause specifies the + index method (for example, BTREE, HASH, + GIN, etc.), and the options clause + specifies additional index options, such as storage parameters, + table spaces, and the WHERE predicate. To support + the definition of concurrent indexes, the type + clause can end with the word CONCURRENTLY (upper and + lower cases are recognized). The column options can be used to + specify collations, operator classes, and the sort order. For example:

+ +
+#pragma db object
+class object
+{
+  ...
+
+  std::string name_;
+
+  #pragma db index                            \
+             type("UNIQUE CONCURRENTLY")      \
+             method("HASH")                   \
+             member(name_, "DESC")            \
+             options("WITH(FILLFACTOR = 80)")
+};
+  
+ +

Index names in PostgreSQL are schema-global. To avoid name clashes, + ODB automatically prefixes each index name with the table name on + which it is defined.

@@ -14291,7 +14660,7 @@ class object

It is also possible to add support for additional Oracle types, such as XML, geospatial types, user-defined types, and collections (arrays, table types). For more information, refer to - Section 12.6, "Database Type Mapping + Section 12.7, "Database Type Mapping Pragmas".

16.2 Oracle Database Class

@@ -14864,6 +15233,11 @@ CREATE TABLE Employee ( used to store the FLOAT and NUMBER values, refer to the Oracle Call Interface (OCI) documentation.

+

An alternative approach to accessing large FLOAT and + NUMBER values is to map these type to one of the + natively supported ones, as discussed in Section + 12.7, "Database Type Mapping Pragmas".

+

Note that a NUMBER type that is used to represent a floating point number (declared by specifying NUMBER without any range and scale) can be extracted into the C++ @@ -14872,12 +15246,45 @@ CREATE TABLE Employee (

16.5.6 Timezones

ODB does not currently support the Oracle date-time types with timezone - information.

+ information. However, these types can be accessed by mapping them to + one of the natively supported types, as discussed in + Section 12.7, "Database Type Mapping Pragmas".

16.5.7 LONG Types

ODB does not support the deprecated Oracle LONG and - LONG RAW data types.

+ LONG RAW data types. However, these types can be accessed + by mapping them to one of the natively supported types, as discussed + in Section 12.7, "Database Type Mapping Pragmas".

+ +

16.6 Oracle Index Definitions

+ +

When the index pragma (Section 12.6, + "Index Definition Pragmas") is used to define an Oracle index, + the type clause specifies the index type (for example, + UNIQUE, BITMAP), the method + clause is not used, and the options clause specifies + additional index properties, such as partitioning, table spaces, etc. + The column options can be used to specify the sort order. For example:

+ +
+#pragma db object
+class object
+{
+  ...
+
+  std::string name_;
+
+  #pragma db index                     \
+             type("BITMAP")            \
+             member(name_, "DESC")     \
+             options("TABLESPACE TBS1")
+};
+  
+ +

Index names in Oracle are schema-global. To avoid name clashes, + ODB automatically prefixes each index name with the table name on + which it is defined.

@@ -15151,7 +15558,7 @@ t.commit ();

It is also possible to add support for additional SQL Server types, such as geospatial types, XML, and user-defined types. - For more information, refer to Section 12.6, "Database + For more information, refer to Section 12.7, "Database Type Mapping Pragmas".

17.2 SQL Server Database Class

@@ -15813,6 +16220,31 @@ namespace odb by passing the --mssql-server-version 9.0 ODB compiler option.

+

17.6 SQL Server Index Definitions

+ +

When the index pragma (Section 12.6, + "Index Definition Pragmas") is used to define an SQL Server index, + the type clause specifies the index type (for example, + UNIQUE, CLUSTERED), the method + clause is not used, and the options clause specifies + additional index properties. The column options can be used to specify + the sort order. For example:

+ +
+#pragma db object
+class object
+{
+  ...
+
+  std::string name_;
+
+  #pragma db index                             \
+             type("UNIQUE CLUSTERED")          \
+             member(name_, "DESC")             \
+             options("WITH(FILLFACTOR = 80)")
+};
+  
+ -- cgit v1.1