Skip to content

Commit

Permalink
fix: also detect properly data type with a comment
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed Dec 2, 2022
1 parent 7f6c3a7 commit 35f2c28
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 31 deletions.
35 changes: 35 additions & 0 deletions src/rust/data/mariadb_test_case_14.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<h4 class="anchored_heading" id="gtid_pos_auto_engines"><code>gtid_pos_auto_engines</code></h4>
<p>This variable is used to enable multiple versions of the <a
href="/kb/en/mysqlgtid_slave_pos-table/">mysql.gtid_slave_pos</a> table, one for each transactional storage
engine in use. This can improve replication performance if a server is using multiple different storage engines in
different transactions.</p>
<p>The value is a list of engine names, separated by commas (','). Replication
of transactions using these engines will automatically create new versions
of the mysql.gtid_slave_pos table in the same engine and use that for future
transactions (table creation takes place in a background thread). This avoids introducing a cross-engine transaction
to update the GTID position. Only transactional storage engines are supported for
gtid_pos_auto_engines (this currently means <a href="/kb/en/innodb/">InnoDB</a>, <a
href="/kb/en/tokudb/">TokuDB</a>, or <a href="/kb/en/myrocks/">MyRocks</a>).</p>
<p>The variable can be changed dynamically, but replica SQL threads should be stopped when changing it, and it will take
effect when the replicas are running again.</p>
<p>When setting the variable on the command line or in a configuration file, it is
possible to specify engines that are not enabled in the server. The server will then still start if, for example,
that engine is no longer used. Attempting to set a non-enabled engine dynamically in a running server (with SET
GLOBAL gtid_pos_auto_engines) will still result in an error.</p>
<p>Removing a storage engine from the variable will have no effect once the new tables have been created - as long as
these tables are detected, they will be used.</p>
<ul start="1">
<li><strong>Commandline:</strong> <code class="fixed"
style="white-space:pre-wrap">--gtid-pos-auto-engines=value</code>
</li>
<li><strong>Scope:</strong> Global
</li>
<li><strong>Dynamic:</strong> Yes
</li>
<li><strong>Data Type:</strong> <code>string</code> (comma-separated list of engine names)
</li>
<li><strong>Default:</strong> empty
</li>
<li><strong>Introduced:</strong> <a href="/kb/en/mariadb-1031-release-notes/">MariaDB 10.3.1</a>
</li>
</ul>
69 changes: 38 additions & 31 deletions src/rust/mariadb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,20 @@ fn process_li(mut entry: KbParsedEntry, li_node: Node) -> KbParsedEntry {
entry.dynamic = Some(row_value.to_lowercase() == "yes");
}
"data type" | "type" => {
entry.r#type = Some(row_value.to_lowercase().trim().to_string());
if li_node.find(Name("code")).count() == 1 {
entry.r#type = Some(
li_node
.find(Name("code"))
.next()
.unwrap()
.text()
.to_lowercase()
.trim()
.to_string(),
);
} else {
entry.r#type = Some(row_value.to_lowercase().trim().to_string());
}

if entry.r#type != Some("".to_string()) {
entry.r#type = cleaner::clean_type(entry.r#type.unwrap());
Expand Down Expand Up @@ -333,36 +346,6 @@ fn process_li(mut entry: KbParsedEntry, li_node: Node) -> KbParsedEntry {
entry.r#type = cleaner::clean_type(row_value.to_lowercase());
}
}
/*
case 'description:':
doc.type = cleaner.cleanType(value.toLowerCase());
break;
break;
case 'data type:':
/*
* Default method, <li> has a <code> child
* Example: <li><strong>Data Type:</strong> <code>numeric</code></li>
*/
let dataType = valueKey.find('code');
if (dataType.length > 0) {
doc.type = cleaner.cleanType(dataType.first().text().toLowerCase().trim());
} else {
/*
* Fallback method, <li> has text
* Example: <li><strong>Data Type:</strong> boolean</li>
*/
let dataType = value.replace(/undefined/gi, '');
dataType = dataType.toLowerCase().trim();
if (dataType !== '') {
doc.type = cleaner.cleanType(dataType);
} else if (dataType === '') {
console.log('Empty datatype found for : ' + doc.id);
} else {
console.log('No datatype found for : ' + doc.id);
}
}
break; */
_key => {
//println!("{} '{}' -> '{}'", li_node.html(), key_name, row_value);
//println!("tr: {} -> {}", row_name, row_value);
Expand Down Expand Up @@ -892,4 +875,28 @@ mod tests {
entries
);
}

#[test]
fn test_case_14() {
let entries = extract_mariadb_from_text(QueryResponse {
body: get_test_data("mariadb_test_case_14.html"),
url: "https://example.com",
});

assert_eq!(
vec![KbParsedEntry {
has_description: false,
cli: Some("--gtid-pos-auto-engines=value".to_string()),
default: Some("empty".to_string()),
dynamic: Some(true),
id: "gtid_pos_auto_engines".to_string(),
name: Some("gtid_pos_auto_engines".to_string()),
scope: Some(vec!["global".to_string()]),
r#type: Some("string".to_string()),
valid_values: None,
range: None,
},],
entries
);
}
}

0 comments on commit 35f2c28

Please sign in to comment.