aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-01-23 11:40:58 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-01-23 11:40:58 +0200
commit465a4467adec94bb8fe996732ea378664fcf5e86 (patch)
tree23cb2f439313c73d4baaded034e1196eaf7c4f9b
parent4701df22146e4e4fc0c7fe58903fbd0482defcb5 (diff)
Handle SQL name limits in MySQL and SQL Server
-rw-r--r--NEWS21
-rw-r--r--odb/relational/mssql/context.cxx12
-rw-r--r--odb/relational/mysql/context.cxx14
3 files changed, 38 insertions, 9 deletions
diff --git a/NEWS b/NEWS
index 49e4aa4..ccbedde 100644
--- a/NEWS
+++ b/NEWS
@@ -36,16 +36,21 @@ Version 2.4.0
* Support for calling MySQL stored procedures. For details and limitations
refer to Section 17.7, "MySQL Stored Procedures" in the ODB manual.
- * New option, --statement-regex, can be used to process prepared statement
- names that are used by PostgreSQL. This can be useful, for example, to
- shorten names that exceed the PostgreSQL name limit. To this effect, ODB
- now also warns when an SQL name exceeds the default PostgreSQL limit of
- 63 characters.
-
* New option, --oracle-warn-truncation, makes ODB warn about SQL names
that are longer than 30 characters and are therefore truncated. ODB
- now also detects when such truncations lead to name conflicts and
- issues diagnostics even without this option specified.
+ now also detects when such truncations lead to Oracle name conflicts
+ and issues diagnostics even without this option specified.
+
+ * For MySQL, PostgreSQL, and SQL Server, ODB now warns when an SQL name
+ exceeds the database limit (64, 63, and 128 characters, respectively).
+ SQLite has no limitation on name lengths. For Oracle, which has a limit
+ that is much more likely to be reached in normal circumstances (30
+ characters), a more comprehensive detection is implemented (see item
+ above).
+
+ * New option, --statement-regex, can be used to process prepared statement
+ names that are used by PostgreSQL. This can be useful, for example, to
+ shorten names that exceed the PostgreSQL name limit.
Version 2.3.0
diff --git a/odb/relational/mssql/context.cxx b/odb/relational/mssql/context.cxx
index e99cdaf..eac4a95 100644
--- a/odb/relational/mssql/context.cxx
+++ b/odb/relational/mssql/context.cxx
@@ -133,6 +133,18 @@ namespace relational
if (i->empty ())
continue;
+ // Warn if the name is greater than the 128 limit.
+ //
+ if (i->size () > 128)
+ {
+ cerr << "warning: SQL name '" << *i << "' is longer than the "
+ << "SQL Server name limit of 128 characters and will be "
+ << "truncated" << endl;
+
+ cerr << "info: consider shortening it using #pragma db "
+ << "table/column/index or --*-regex options" << endl;
+ }
+
if (f)
f = false;
else
diff --git a/odb/relational/mysql/context.cxx b/odb/relational/mysql/context.cxx
index 4ccb206..945a3a9 100644
--- a/odb/relational/mysql/context.cxx
+++ b/odb/relational/mysql/context.cxx
@@ -129,13 +129,25 @@ namespace relational
if (i->empty ())
continue;
+ // Warn if the name is greater than the 64 limit.
+ //
+ if (i->size () > 64)
+ {
+ cerr << "warning: SQL name '" << *i << "' is longer than "
+ << "the MySQL name limit of 64 characters and will "
+ << "be truncated" << endl;
+
+ cerr << "info: consider shortening it using #pragma db "
+ << "table/column/index or --*-regex options" << endl;
+ }
+
if (f)
f = false;
else
r += '.';
r += '`';
- r += *i;
+ r.append (*i, 0, 64); // Max identifier length is 64.
r += '`';
}