Skip to content

Commit

Permalink
refs #3640 fixed a bug where too little info was being passed to post…
Browse files Browse the repository at this point in the history
… data alignment code

refs #3641 fixed a bug where the mysql database get next sequence value code did not respect the simulated sequence table name option
  • Loading branch information
davidnich committed Nov 10, 2019
1 parent 0769fbc commit ad40e1a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 16 deletions.
6 changes: 6 additions & 0 deletions doxygen/lang/900_release_notes.dox.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@

@subsection qore_0932_bug_fixes Bug Fixes in Qore

- <a href="../../modules/MysqlSqlUtil/html/index.html">MysqlSqlUtil</a>: fixed a bug where the sequence table name
was not respected in \c MysqlDatabase::getNextSequenceValueImpl()
(<a href="https://github.com/qorelanguage/qore/issues/3641">issue 3641</a>)
- <a href="../../modules/Schema/html/index.html">Schema</a>: fixed a bug where too little information was passed
to post schema alignment code
(<a href="https://github.com/qorelanguage/qore/issues/3640">issue 3640</a>)
- fixed a bug where in-object calls to implicit \c copy() methods would result in a core dump
(<a href="https://github.com/qorelanguage/qore/issues/3637">issue 3637</a>)
- <a href="../../modules/Mapper/html/index.html">Mapper</a> module: fixed a bug where list values could not be
Expand Down
15 changes: 10 additions & 5 deletions qlib/MysqlSqlUtil.qm
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ module MysqlSqlUtil {
- added support for the DataProvider module
(<a href="https://github.com/qorelanguage/qore/issues/3545">issue 3545</a>)

@subsection mysqlsqlutilv131 MysqlSqlUtil v1.3.2
- fixed a bug where the sequence table name was not respected in
@ref MysqlSqlUtil::MysqlDatabase::getNextSequenceValueImpl() "MysqlDatabase::getNextSequenceValueImpl()"
(<a href="https://github.com/qorelanguage/qore/issues/3641">issue 3641</a>)

@subsection mysqlsqlutilv131 MysqlSqlUtil v1.3.1
- fixed quoting of reserved words in column names in table alignment
(<a href="https://github.com/qorelanguage/qore/issues/3400">issue 3400</a>)
Expand Down Expand Up @@ -673,7 +678,7 @@ auto v = c.name;
const MysqlOptions = (
"sequence_table": Type::String,
"sequence_function": Type::String,
);
);

#! MySQL-specific schema description keys
const MysqlSchemaDescriptionOptions = AbstractDatabase::SchemaDescriptionOptions + MysqlOptions;
Expand All @@ -695,7 +700,7 @@ auto v = c.name;
"notnull": True,
),
),
);
);

#! MySQL creation options
const MyusqlCreationOptions = AbstractDatabase::CreationOptions;
Expand All @@ -710,12 +715,12 @@ end";
#! Options for computeStatistics()
const MysqlComputeStatisticsOptions = ComputeStatisticsOptions + (
"no-binlog" : Type::Boolean,
);
);

#! Options for reclaimSpace()
const MysqlReclaimSpaceOptions = ReclaimSpaceOptions + (
"no-binlog" : Type::Boolean,
);
);

#! hash of reserved words
const MysqlReservedWords = (
Expand Down Expand Up @@ -1167,7 +1172,7 @@ end";
#! returns the next value in the given sequence
private softint getNextSequenceValueImpl(string name) {
on_exit seqds.commit();
return seqds.selectRow("select sqlutil_nextval(%v) nextval", name).nextval;
return seqds.selectRow("select %s(%v) nextval", sequence_function, name).nextval;
}

#! returns the last value issued for the given sequence in the current session
Expand Down
32 changes: 21 additions & 11 deletions qlib/Schema.qm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
%strict-args

module Schema {
version = "1.3";
version = "1.3.1";
desc = "user module for working with SQL schemas";
author = "David Nichols <david@qore.org>";
url = "http://qore.org";
Expand All @@ -71,6 +71,10 @@ module Schema {

@section schema_relnotes Schema Module Release History

@subsection schema_v1_3_1 Schema Module v1.3.1
- fixed a bug where too little information was passed to post schema alignment code
(<a href="https://github.com/qorelanguage/qore/issues/3640">issue 3640</a>)

@subsection schema_v1_3 Schema Module v1.3
- improved logging output when performing schema alignments
(<a href="https://github.com/qorelanguage/qore/issues/3114">issue 3114</a>)
Expand Down Expand Up @@ -607,7 +611,7 @@ public namespace Schema {

bool first_time_install = checkFirstTimeInstall();

*hash initial_schema_info;
*hash<auto> initial_schema_info;

if (first_time_install)
logpf("creating %s schema %s", name, version);
Expand All @@ -630,18 +634,17 @@ public namespace Schema {
if (al.size() != sch.sql_cache.size()) {
printf("callback had %d lines, getAlignSql() had %d lines\n", sch.sql_cache.size(), al.size());

hash<string, bool> schh;

# make a hash of the sqlcache
if (al.size() > sch.sql_cache.size()) {
hash schh;
map schh.$1 = True, sch.sql_cache;

foreach string sql in (al) {
if (!schh{sql})
printf("MISSING IN CALLBACK %d: %s\n", $#, sql);
}
}
else {
hash schh;
} else {
map schh.$1 = True, al;

foreach string sql in (sch.sql_cache) {
Expand Down Expand Up @@ -703,7 +706,7 @@ public namespace Schema {
map AbstractSchema::doTable(table_cache{$1.key}, $1.value, upsert_strategy, False, verbose, \sh), co_data.pairIterator();
}

postDataActions(first_time_install);
postDataActions(table_cache, first_time_install, initial_schema_info, verbose);

if (!verbose) {
logProgress("\n");
Expand Down Expand Up @@ -1031,27 +1034,34 @@ public namespace Schema {
}

#! this method returns @ref Qore::True "True" if the schema can be updated
private bool checkUpdateSchema(bool force, reference<hash> initial_schema_info) {
private bool checkUpdateSchema(bool force, reference<hash<auto>> initial_schema_info) {
logpf("verifying/aligning schema version %s", version);
return True;
}

#! this method is called after schema structural alignment has been executed but before schema reference data management
private doPostAlignment(Tables table_cache, bool first_time_install, *hash initial_schema_info, int verbose) {
private doPostAlignment(Tables table_cache, bool first_time_install, *hash<auto> initial_schema_info, int verbose) {
doPostAlignment(table_cache, first_time_install, initial_schema_info);
}

#! this method is called after schema structural alignment has been executed but before schema reference data management
private doPostAlignment(Tables table_cache, bool first_time_install, *hash initial_schema_info) {
private doPostAlignment(Tables table_cache, bool first_time_install, *hash<auto> initial_schema_info) {
# this method intentionally left empty
}

#! this method is called to return the upsert strategy before schema reference data management
private int getUpsertStrategy(bool first_time_install) {
return first_time_install ? AbstractTable::UpsertInsertFirst : AbstractTable::UpsertUpdateFirst;
}

#! this method is called after schema reference data has been managed
private postDataActions(Tables table_cache, bool first_time_install, *hash<auto> initial_schema_info, int verbose) {
postDataActions(first_time_install);
}

#! this method is called after schema reference data has been managed
private postDataActions(bool first_time_install) {
# this method intentionally left empty
}

#! this method is called to perform schema reference data managment on the given table with the given data
Expand Down Expand Up @@ -1206,7 +1216,7 @@ public namespace Schema {
}

#! this method returns @ref Qore::True "True" if the schema can be updated
private bool checkUpdateSchema(bool force, reference<hash> initial_schema_info) {
private bool checkUpdateSchema(bool force, reference<hash<auto>> initial_schema_info) {
*string current_version = getSchemaVersion();
if (!current_version) {
logpf("schema is corrupt; aligning to schema template");
Expand Down

0 comments on commit ad40e1a

Please sign in to comment.