Skip to content

Commit 004b401

Browse files
crepererumkodiakhq[bot]
andauthoredJul 19, 2023
chore: upgrade to sqlx 0.7.1 (influxdata#8266)
There are a bunch of dependencies in `Cargo.lock` that are related to mysql. These are NOT compiled at all, and are also not part of `cargo tree`. The reason for the inclusion is a bug in cargo: rust-lang/cargo#10801 Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent d3b3805 commit 004b401

File tree

12 files changed

+414
-271
lines changed

12 files changed

+414
-271
lines changed
 

‎Cargo.lock

+349-191
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎data_types/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ once_cell = "1"
1717
ordered-float = "3"
1818
schema = { path = "../schema" }
1919
sha2 = "0.10"
20-
sqlx = { version = "0.6", features = ["runtime-tokio-rustls", "postgres", "uuid"] }
20+
sqlx = { version = "0.7.1", features = ["runtime-tokio-rustls", "postgres", "uuid"] }
2121
thiserror = "1.0.43"
2222
uuid = { version = "1", features = ["v4"] }
2323
workspace-hack = { version = "0.1", path = "../workspace-hack" }

‎data_types/src/columns.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use super::TableId;
44
use generated_types::influxdata::iox::schema::v1 as proto;
55
use influxdb_line_protocol::FieldValue;
66
use schema::{builder::SchemaBuilder, InfluxColumnType, InfluxFieldType, Schema};
7-
use sqlx::postgres::PgHasArrayType;
87
use std::{
98
collections::{BTreeMap, BTreeSet, HashMap},
109
convert::TryFrom,
@@ -26,12 +25,6 @@ impl ColumnId {
2625
}
2726
}
2827

29-
impl PgHasArrayType for ColumnId {
30-
fn array_type_info() -> sqlx::postgres::PgTypeInfo {
31-
<i64 as PgHasArrayType>::array_type_info()
32-
}
33-
}
34-
3528
/// Column definitions for a table indexed by their name
3629
#[derive(Debug, Clone, Eq, PartialEq)]
3730
pub struct ColumnsByName(BTreeMap<String, ColumnSchema>);
@@ -328,7 +321,7 @@ impl TryFrom<proto::column_schema::ColumnType> for ColumnType {
328321

329322
/// Set of columns.
330323
#[derive(Debug, Clone, PartialEq, Eq, sqlx::Type)]
331-
#[sqlx(transparent)]
324+
#[sqlx(transparent, no_pg_array)]
332325
pub struct ColumnSet(Vec<ColumnId>);
333326

334327
impl ColumnSet {

‎data_types/src/partition_template.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ pub static PARTITION_BY_DAY_PROTO: Lazy<Arc<proto::PartitionTemplate>> = Lazy::n
244244

245245
/// A partition template specified by a namespace record.
246246
#[derive(Debug, PartialEq, Clone, Default, sqlx::Type)]
247-
#[sqlx(transparent)]
247+
#[sqlx(transparent, no_pg_array)]
248248
pub struct NamespacePartitionTemplateOverride(Option<serialization::Wrapper>);
249249

250250
impl TryFrom<proto::PartitionTemplate> for NamespacePartitionTemplateOverride {
@@ -259,7 +259,7 @@ impl TryFrom<proto::PartitionTemplate> for NamespacePartitionTemplateOverride {
259259

260260
/// A partition template specified by a table record.
261261
#[derive(Debug, PartialEq, Eq, Clone, Default, sqlx::Type)]
262-
#[sqlx(transparent)]
262+
#[sqlx(transparent, no_pg_array)]
263263
pub struct TablePartitionTemplateOverride(Option<serialization::Wrapper>);
264264

265265
impl TablePartitionTemplateOverride {

‎deny.toml

-8
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@ yanked = "deny"
77
unmaintained = "warn"
88
notice = "warn"
99
ignore = [
10-
# "It was sometimes possible for SQLite versions >= 1.0.12, < 3.39.2 to allow an array-bounds overflow when large
11-
# string were input into SQLite's printf function."
12-
#
13-
# We are not using `printf` with untrusted inputs.
14-
#
15-
# This is currently blocked by upstream:
16-
# https://github.com/launchbadge/sqlx/issues/2346
17-
"RUSTSEC-2022-0090",
1810
]
1911
git-fetch-with-cli = true
2012

‎garbage_collector/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ metric = { path = "../metric" }
3232
once_cell = { version = "1.18", features = ["parking_lot"] }
3333
parquet_file = { path = "../parquet_file" }
3434
tempfile = "3"
35-
sqlx = { version = "0.6", features = [ "runtime-tokio-rustls" ] }
35+
sqlx = { version = "0.7.1", features = [ "runtime-tokio-rustls" ] }
3636

‎iox_catalog/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ parking_lot = { version = "0.12" }
1818
serde = { version = "1.0", features = ["derive"] }
1919
siphasher = "0.3"
2020
snafu = "0.7"
21-
sqlx = { version = "0.6", features = [ "runtime-tokio-rustls" , "postgres", "uuid", "sqlite" ] }
21+
sqlx = { version = "0.7.1", features = [ "runtime-tokio-rustls" , "postgres", "uuid", "sqlite" ] }
2222
sqlx-hotswap-pool = { path = "../sqlx-hotswap-pool" }
2323
thiserror = "1.0.43"
2424
tokio = { version = "1.29", features = ["io-util", "macros", "parking_lot", "rt-multi-thread", "time"] }

‎iox_catalog/src/postgres.rs

+13-19
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,9 @@ async fn new_raw_pool(
329329
parsed_dsn: &str,
330330
) -> Result<sqlx::Pool<Postgres>, sqlx::Error> {
331331
// sqlx exposes some options as pool options, while other options are available as connection options.
332-
let mut connect_options = PgConnectOptions::from_str(parsed_dsn)?;
333-
// the default is INFO, which is frankly surprising.
334-
connect_options.log_statements(log::LevelFilter::Trace);
332+
let connect_options = PgConnectOptions::from_str(parsed_dsn)?
333+
// the default is INFO, which is frankly surprising.
334+
.log_statements(log::LevelFilter::Trace);
335335

336336
let app_name = options.app_name.clone();
337337
let app_name2 = options.app_name.clone(); // just to log below
@@ -816,7 +816,7 @@ RETURNING *;
816816
.bind(name) // $1
817817
.bind(partition_template) // $2
818818
.bind(namespace_id) // $3
819-
.fetch_one(&mut tx)
819+
.fetch_one(&mut *tx)
820820
.await
821821
.map_err(|e| match e {
822822
sqlx::Error::RowNotFound => Error::TableCreateLimitError {
@@ -843,7 +843,8 @@ RETURNING *;
843843
// columns with an unsupported type.
844844
for template_part in table.partition_template.parts() {
845845
if let TemplatePart::TagValue(tag_name) = template_part {
846-
insert_column_with_connection(&mut tx, tag_name, table.id, ColumnType::Tag).await?;
846+
insert_column_with_connection(&mut *tx, tag_name, table.id, ColumnType::Tag)
847+
.await?;
847848
}
848849
}
849850

@@ -1538,15 +1539,14 @@ WHERE object_store_id = $1;
15381539
) -> Result<Vec<Uuid>> {
15391540
sqlx::query(
15401541
// sqlx's readme suggests using PG's ANY operator instead of IN; see link below.
1542+
// https://github.com/launchbadge/sqlx/blob/main/FAQ.md#how-can-i-do-a-select--where-foo-in--query
15411543
r#"
15421544
SELECT object_store_id
15431545
FROM parquet_file
15441546
WHERE object_store_id = ANY($1);
15451547
"#,
15461548
)
1547-
// from https://github.com/launchbadge/sqlx/blob/main/FAQ.md#how-can-i-do-a-select--where-foo-in--query
1548-
// a bug of the parameter typechecking code requires all array parameters to be slices
1549-
.bind(&object_store_ids[..]) // $1
1549+
.bind(object_store_ids) // $1
15501550
.map(|pgr| pgr.get::<Uuid, _>("object_store_id"))
15511551
.fetch_all(&mut self.inner)
15521552
.await
@@ -1576,13 +1576,13 @@ WHERE object_store_id = ANY($1);
15761576
.map_err(|e| Error::StartTransaction { source: e })?;
15771577

15781578
let marked_at = Timestamp::from(self.time_provider.now());
1579-
flag_for_delete(&mut tx, delete, marked_at).await?;
1579+
flag_for_delete(&mut *tx, delete, marked_at).await?;
15801580

1581-
update_compaction_level(&mut tx, upgrade, target_level).await?;
1581+
update_compaction_level(&mut *tx, upgrade, target_level).await?;
15821582

15831583
let mut ids = Vec::with_capacity(create.len());
15841584
for file in create {
1585-
let id = create_parquet_file(&mut tx, file).await?;
1585+
let id = create_parquet_file(&mut *tx, file).await?;
15861586
ids.push(id);
15871587
}
15881588

@@ -1667,12 +1667,9 @@ async fn flag_for_delete<'q, E>(
16671667
where
16681668
E: Executor<'q, Database = Postgres>,
16691669
{
1670-
// If I try to do `.bind(parquet_file_ids)` directly, I get a compile error from sqlx.
1671-
// See https://github.com/launchbadge/sqlx/issues/1744
1672-
let ids: Vec<_> = ids.iter().map(|p| p.get()).collect();
16731670
let query = sqlx::query(r#"UPDATE parquet_file SET to_delete = $1 WHERE id = ANY($2);"#)
16741671
.bind(marked_at) // $1
1675-
.bind(&ids[..]); // $2
1672+
.bind(ids); // $2
16761673
query
16771674
.execute(executor)
16781675
.await
@@ -1689,9 +1686,6 @@ async fn update_compaction_level<'q, E>(
16891686
where
16901687
E: Executor<'q, Database = Postgres>,
16911688
{
1692-
// If I try to do `.bind(parquet_file_ids)` directly, I get a compile error from sqlx.
1693-
// See https://github.com/launchbadge/sqlx/issues/1744
1694-
let ids: Vec<_> = parquet_file_ids.iter().map(|p| p.get()).collect();
16951689
let query = sqlx::query(
16961690
r#"
16971691
UPDATE parquet_file
@@ -1700,7 +1694,7 @@ WHERE id = ANY($2);
17001694
"#,
17011695
)
17021696
.bind(compaction_level) // $1
1703-
.bind(&ids[..]); // $2
1697+
.bind(parquet_file_ids); // $2
17041698
query
17051699
.execute(executor)
17061700
.await

‎iox_catalog/src/sqlite.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ RETURNING *;
577577
.bind(name) // $1
578578
.bind(partition_template) // $2
579579
.bind(namespace_id) // $3
580-
.fetch_one(&mut tx)
580+
.fetch_one(&mut *tx)
581581
.await
582582
.map_err(|e| match e {
583583
sqlx::Error::RowNotFound => Error::TableCreateLimitError {
@@ -604,7 +604,8 @@ RETURNING *;
604604
// columns with an unsupported type.
605605
for template_part in table.partition_template.parts() {
606606
if let TemplatePart::TagValue(tag_name) = template_part {
607-
insert_column_with_connection(&mut tx, tag_name, table.id, ColumnType::Tag).await?;
607+
insert_column_with_connection(&mut *tx, tag_name, table.id, ColumnType::Tag)
608+
.await?;
608609
}
609610
}
610611

@@ -1451,14 +1452,14 @@ WHERE object_store_id IN ({v});",
14511452

14521453
for id in delete {
14531454
let marked_at = Timestamp::from(self.time_provider.now());
1454-
flag_for_delete(&mut tx, *id, marked_at).await?;
1455+
flag_for_delete(&mut *tx, *id, marked_at).await?;
14551456
}
14561457

1457-
update_compaction_level(&mut tx, upgrade, target_level).await?;
1458+
update_compaction_level(&mut *tx, upgrade, target_level).await?;
14581459

14591460
let mut ids = Vec::with_capacity(create.len());
14601461
for file in create {
1461-
let res = create_parquet_file(&mut tx, file.clone()).await?;
1462+
let res = create_parquet_file(&mut *tx, file.clone()).await?;
14621463
ids.push(res.id);
14631464
}
14641465
tx.commit()
@@ -1562,8 +1563,7 @@ async fn update_compaction_level<'q, E>(
15621563
where
15631564
E: Executor<'q, Database = Sqlite>,
15641565
{
1565-
// If I try to do `.bind(parquet_file_ids)` directly, I get a compile error from sqlx.
1566-
// See https://github.com/launchbadge/sqlx/issues/1744
1566+
// We use a JSON-based "IS IN" check.
15671567
let ids: Vec<_> = parquet_file_ids.iter().map(|p| p.get()).collect();
15681568
let query = sqlx::query(
15691569
r#"

‎sqlx-hotswap-pool/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license.workspace = true
1010
publish = false
1111

1212
[dependencies]
13-
sqlx = { version = "0.6.3", features = ["runtime-tokio-rustls", "postgres", "json", "tls"] }
13+
sqlx = { version = "0.7.1", features = ["runtime-tokio-rustls", "postgres", "json", "tls-rustls"] }
1414
either = "1.8.1"
1515
futures = "0.3"
1616
workspace-hack = { version = "0.1", path = "../workspace-hack" }

‎test_helpers_end_to_end/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ rand = "0.8.3"
3131
regex = "1.9"
3232
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
3333
snafu = "0.7"
34-
sqlx = { version = "0.6", features = [ "runtime-tokio-rustls" , "postgres", "uuid" ] }
34+
sqlx = { version = "0.7.1", features = [ "runtime-tokio-rustls" , "postgres", "uuid" ] }
3535
tempfile = "3.6.0"
3636
test_helpers = { path = "../test_helpers", features = ["future_timeout"] }
3737
tokio = { version = "1.29", features = ["macros", "net", "parking_lot", "rt-multi-thread", "signal", "sync", "time"] }

0 commit comments

Comments
 (0)
Please sign in to comment.