Skip to content

Commit

Permalink
feat: support multiple statements in one query (`implicit transaction…
Browse files Browse the repository at this point in the history
… block` not implemented) (#261) (#294)
  • Loading branch information
NoyException authored Dec 17, 2024
1 parent c7ed17a commit 1e155bc
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 176 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/clients-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Install system packages
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: bats cpanminus libmysqlclient-dev dotnet-sdk-8.0 dotnet-runtime-8.0 php-mysql r-base-core
packages: bats cpanminus libmysqlclient-dev dotnet-sdk-8.0 dotnet-runtime-8.0 php-mysql r-base-core libblas-dev
version: 1.0

- name: Install dependencies
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
- name: Install system packages
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: bats cpanminus libpq-dev postgresql-client dotnet-sdk-8.0 dotnet-runtime-8.0 r-base-core
packages: bats cpanminus libpq-dev postgresql-client dotnet-sdk-8.0 dotnet-runtime-8.0 r-base-core libblas-dev
version: 1.0

- name: Install dependencies
Expand Down
17 changes: 7 additions & 10 deletions compatibility/pg-pytools/psycopg_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from psycopg import sql
import psycopg

rows = [
Expand All @@ -13,16 +12,14 @@
with psycopg.connect("dbname=postgres user=postgres host=127.0.0.1 port=5432", autocommit=True) as conn:
# Open a cursor to perform database operations
with conn.cursor() as cur:
cur.execute("DROP SCHEMA IF EXISTS test CASCADE")
cur.execute("CREATE SCHEMA test")

cur.execute("""
CREATE TABLE test.tb1 (
id integer PRIMARY KEY,
num integer,
data text)
""")

DROP SCHEMA IF EXISTS test CASCADE;
CREATE SCHEMA test;
CREATE TABLE test.tb1 (
id integer PRIMARY KEY,
num integer,
data text)
""")

# Pass data to fill a query placeholders and let Psycopg perform the correct conversion
cur.execute(
Expand Down
2 changes: 2 additions & 0 deletions compatibility/pg/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ start_process() {
start_process $BATS_TEST_DIRNAME/c/pg_test 127.0.0.1 5432 postgres "" $BATS_TEST_DIRNAME/test.data
}

# Failed because of the following error:
# > Catalog Error: Table with name pg_range does not exist!
# @test "pg-csharp" {
# set_custom_teardown "sudo pkill -f dotnet"
# start_process dotnet build $BATS_TEST_DIRNAME/csharp/PGTest.csproj -o $BATS_TEST_DIRNAME/csharp/bin
Expand Down
14 changes: 7 additions & 7 deletions pgserver/connection_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ const (
ReadyForQueryTransactionIndicator_FailedTransactionBlock ReadyForQueryTransactionIndicator = 'E'
)

// ConvertedQuery represents a query that has been converted from the Postgres representation to the Vitess
// representation. String may contain the string version of the converted query. AST will contain the tree
// version of the converted query, and is the recommended form to use. If AST is nil, then use the String version,
// ConvertedStatement represents a statement that has been converted from the Postgres representation to the Vitess
// representation. String may contain the string version of the converted statement. AST will contain the tree
// version of the converted statement, and is the recommended form to use. If AST is nil, then use the String version,
// otherwise always prefer to AST.
type ConvertedQuery struct {
type ConvertedStatement struct {
String string
AST tree.Statement
StatementTag string
Tag string
PgParsable bool
SubscriptionConfig *SubscriptionConfig
BackupConfig *BackupConfig
Expand Down Expand Up @@ -86,7 +86,7 @@ type copyFromStdinState struct {
}

type PortalData struct {
Query ConvertedQuery
Statement ConvertedStatement
IsEmptyQuery bool
Fields []pgproto3.FieldDescription
ResultFormatCodes []int16
Expand All @@ -96,7 +96,7 @@ type PortalData struct {
}

type PreparedStatementData struct {
Query ConvertedQuery
Statement ConvertedStatement
ReturnFields []pgproto3.FieldDescription
BindVarTypes []uint32
Stmt *duckdb.Stmt
Expand Down
Loading

0 comments on commit 1e155bc

Please sign in to comment.