Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support extended query mode #65

Merged
merged 4 commits into from
Aug 5, 2022
Merged

support extended query mode #65

merged 4 commits into from
Aug 5, 2022

Conversation

ZENOTME
Copy link
Contributor

@ZENOTME ZENOTME commented Jul 29, 2022

Support extended query mode.
It's compatible with past versions, extended query mode only takes effect when using the flag "--extend"

for now, this pr has the following limit:

  • we only support most common type in binary format (but not all the type.
  • rust-postgres only support one-dimensional array type.

Hence we can run all original e2e test now.

src/main.rs Outdated
Comment on lines 65 to 67
/// extended query mode in postgresql(only valid in postgresql)
#[clap(long, action)]
extend: bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can add a different engine postgresql-extended instead of adding the option

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean create a different bin using different engine, and we can use different bin to run test in different mode. such as:

sqllogictest 'e2e_test/*.slt' (simeple query)
postgresql-extended 'e2e_test/*.slt' (extended query)

Copy link
Member

@xxchan xxchan Jul 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean using the engine CLI argument.

sqllogictest a.slt --engine postgresql
sqllogictest a.slt --engine mysql
sqllogictest a.slt --engine postgresql-extended

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool!

Signed-off-by: Zejiong Dong <[email protected]>
Copy link
Member

@xxchan xxchan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currenty implementation is OK but IMO this might be slightly better:

fn main() 
let engine: Box<dyn AsyncDB> = match opt.engine {
	"postgres" => Postgres { ... },
	"postgres-extended" => PostgresExtended { ... },
};

impl sqllogictest::AsyncDB for Postgres {}

impl sqllogictest::AsyncDB for PostgresExtended {}

In this way, the engine dispath is more clear, and we don't need the huge if in Postgres.

But since current sqllogictest CLI is a little big coupled with Postgres, maybe we can also refactor it later.

@ZENOTME
Copy link
Contributor Author

ZENOTME commented Aug 1, 2022

Currenty implementation is OK but IMO this might be slightly better:

fn main() 
let engine: Box<dyn AsyncDB> = match opt.engine {
	"postgres" => Postgres { ... },
	"postgres-extended" => PostgresExtended { ... },
};

impl sqllogictest::AsyncDB for Postgres {}

impl sqllogictest::AsyncDB for PostgresExtended {}

In this way, the engine dispath is more clear, and we don't need the huge if in Postgres.

But since current sqllogictest CLI is a little big coupled with Postgres, maybe we can also refactor it later.

Yes..I try this before but CLI has coupled with 'Postgres' such as

if let Err(err) = pg.client.simple_query(&query).await {
                eprintln!("  ignore error: {}", err);
}

So I'm agree with refactoring it later.

@ZENOTME ZENOTME marked this pull request as draft August 3, 2022 13:14
@ZENOTME
Copy link
Contributor Author

ZENOTME commented Aug 3, 2022

Sorry, I find someplace need to modify... I test in as many original e2e tests as possible first.

* add single_process to support NULL values.
* support '(empty)' in VARCHAR.
* support infinity in f32 and f64.
* modify output of bool type.

Signed-off-by: Zejiong Dong <[email protected]>
@ZENOTME
Copy link
Contributor Author

ZENOTME commented Aug 4, 2022

Now the postgresql-extended can support most of e2e_test!
The current limitation:

  • can't support array type.
    (because the tokio-postgres only support one-dimensional array)
  • can't support struct type.
  • can't support infinity of numeric.
    (we use rust-decimal to represent numeric and the rust-decimal don't support infinity)
  • can't support 'interval' type.

@ZENOTME ZENOTME marked this pull request as ready for review August 4, 2022 08:14
Copy link
Member

@skyzh skyzh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to refine this PR. Doesn't look neat and might make maintenance harder :) But we can merge this first and fix things later, as main.rs is already complex enough. cc @xxchan merge?

Cargo.toml Outdated
@@ -16,7 +16,7 @@ bin = ["anyhow", "chrono", "console", "tokio-postgres", "env_logger", "clap", "t
[dependencies]
anyhow = { version = "1", optional = true }
async-trait = "0.1"
chrono = { version = "0.4", optional = true }
chrono = { version = "0.4",optional = true }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing space?

Cargo.toml Outdated
@@ -27,7 +27,9 @@ glob = "0.3"
humantime = "2"
itertools = "0.10"
log = "0.4"
postgres-types = { version = "0.2.3", features = ["derive","with-chrono-0_4"] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please make this consistent with other lines :) Also I think it would be better to only enable Postgres-types in bin target?

Cargo.toml Outdated
quick-junit = { version = "0.2", optional = true }
rust_decimal = { version = "1.7.0", features = [ "tokio-pg" ] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto, only enable in bin target

tokio_postgres::SimpleQueryMessage::Row(row) => {
for i in 0..row.len() {
if i != 0 {
if !self.extend {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer making it a new engine instead of using self.extend to change query mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer making it a new engine instead of using self.extend to change query mode.

Yes. We can make it when refactor it.

@xxchan
Copy link
Member

xxchan commented Aug 5, 2022

Better to refine this PR. Doesn't look neat and might make maintenance harder :) But we can merge this first and fix things later, as main.rs is already complex enough. cc @xxchan merge?

I can refactor it later 🤤

@skyzh
Copy link
Member

skyzh commented Aug 5, 2022

My plan is like to have a separate crate for bin target of sqllogictest (e.g. sqllogictest-bin). Then I believe things could be a lot more neat.

@skyzh
Copy link
Member

skyzh commented Aug 5, 2022

Anyway, I'd merge this first and not bump version for now.

@skyzh
Copy link
Member

skyzh commented Aug 5, 2022

... after @ZENOTME has resolved some small issues in Cargo.toml.

Signed-off-by: Zejiong Dong <[email protected]>
@ZENOTME
Copy link
Contributor Author

ZENOTME commented Aug 5, 2022

... after @ZENOTME has resolved some small issues in Cargo.toml.

Already resolved it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants