From 880f4d8a36c84cbc4ef45dde4934582643588464 Mon Sep 17 00:00:00 2001 From: Shayan Shojaei Date: Sun, 2 Jul 2023 14:42:44 +0330 Subject: [PATCH 1/9] create beginPrepared function --- cjs/src/index.js | 13 +++++++++++-- deno/src/index.js | 13 +++++++++++-- deno/types/index.d.ts | 3 +++ src/index.js | 13 +++++++++++-- types/index.d.ts | 3 +++ 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/cjs/src/index.js b/cjs/src/index.js index 3117627a..6fa67002 100644 --- a/cjs/src/index.js +++ b/cjs/src/index.js @@ -77,6 +77,7 @@ function Postgres(a, b) { reserve, listen, begin, + beginPrepared, close, end }) @@ -230,7 +231,7 @@ function Postgres(a, b) { } } - async function begin(options, fn) { + async function begin(options, fn, transactionId) { !fn && (fn = options, options = '') const queries = Queue() let savepoints = 0 @@ -266,7 +267,11 @@ function Postgres(a, b) { throw e instanceof PostgresError && e.code === '25P02' && uncaughtError || e } - !name && await sql`commit` + if (transactionId) { + !name && await sql.unsafe(`prepare transaction '${transactionId}'`) + }else{ + !name && await sql`commit` + } return result function savepoint(name, fn) { @@ -294,6 +299,10 @@ function Postgres(a, b) { } } + async function beginPrepared(transactionId, options, fn) { + return begin(options, fn, transactionId) + } + function move(c, queue) { c.queue.remove(c) queue.push(c) diff --git a/deno/src/index.js b/deno/src/index.js index 762bb589..31fa10c9 100644 --- a/deno/src/index.js +++ b/deno/src/index.js @@ -78,6 +78,7 @@ function Postgres(a, b) { reserve, listen, begin, + beginPrepared, close, end }) @@ -231,7 +232,7 @@ function Postgres(a, b) { } } - async function begin(options, fn) { + async function begin(options, fn, transactionId) { !fn && (fn = options, options = '') const queries = Queue() let savepoints = 0 @@ -267,7 +268,11 @@ function Postgres(a, b) { throw e instanceof PostgresError && e.code === '25P02' && uncaughtError || e } - !name && await sql`commit` + if (transactionId) { + !name && await sql.unsafe(`prepare transaction '${transactionId}'`) + }else{ + !name && await sql`commit` + } return result function savepoint(name, fn) { @@ -295,6 +300,10 @@ function Postgres(a, b) { } } + async function beginPrepared(transactionId, options, fn) { + return begin(options, fn, transactionId) + } + function move(c, queue) { c.queue.remove(c) queue.push(c) diff --git a/deno/types/index.d.ts b/deno/types/index.d.ts index ca5a7446..98b5c9b5 100644 --- a/deno/types/index.d.ts +++ b/deno/types/index.d.ts @@ -681,6 +681,9 @@ declare namespace postgres { begin(cb: (sql: TransactionSql) => T | Promise): Promise>; begin(options: string, cb: (sql: TransactionSql) => T | Promise): Promise>; + beginPrepared(transactionId: string, cb: (sql: TransactionSql) => T | Promise): Promise>; + beginPrepared(transactionId: string, options: string, cb: (sql: TransactionSql) => T | Promise): Promise>; + array[] = SerializableParameter[]>(value: T, type?: number | undefined): ArrayParameter; file(path: string | Buffer | URL | number, options?: { cache?: boolean | undefined } | undefined): PendingQuery; file(path: string | Buffer | URL | number, args: (ParameterOrJSON)[], options?: { cache?: boolean | undefined } | undefined): PendingQuery; diff --git a/src/index.js b/src/index.js index 15c391e0..39f00e88 100644 --- a/src/index.js +++ b/src/index.js @@ -77,6 +77,7 @@ function Postgres(a, b) { reserve, listen, begin, + beginPrepared, close, end }) @@ -230,7 +231,7 @@ function Postgres(a, b) { } } - async function begin(options, fn) { + async function begin(options, fn, transactionId) { !fn && (fn = options, options = '') const queries = Queue() let savepoints = 0 @@ -266,7 +267,11 @@ function Postgres(a, b) { throw e instanceof PostgresError && e.code === '25P02' && uncaughtError || e } - !name && await sql`commit` + if (transactionId) { + !name && await sql.unsafe(`prepare transaction '${transactionId}'`) + }else{ + !name && await sql`commit` + } return result function savepoint(name, fn) { @@ -294,6 +299,10 @@ function Postgres(a, b) { } } + async function beginPrepared(transactionId, options, fn) { + return begin(options, fn, transactionId) + } + function move(c, queue) { c.queue.remove(c) queue.push(c) diff --git a/types/index.d.ts b/types/index.d.ts index 1c85198c..6c998bd0 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -679,6 +679,9 @@ declare namespace postgres { begin(cb: (sql: TransactionSql) => T | Promise): Promise>; begin(options: string, cb: (sql: TransactionSql) => T | Promise): Promise>; + beginPrepared(transactionId: string, cb: (sql: TransactionSql) => T | Promise): Promise>; + beginPrepared(transactionId: string, options: string, cb: (sql: TransactionSql) => T | Promise): Promise>; + array[] = SerializableParameter[]>(value: T, type?: number | undefined): ArrayParameter; file(path: string | Buffer | URL | number, options?: { cache?: boolean | undefined } | undefined): PendingQuery; file(path: string | Buffer | URL | number, args: (ParameterOrJSON)[], options?: { cache?: boolean | undefined } | undefined): PendingQuery; From cfb11fe31a57db41f33549c58ee90231cc13afb6 Mon Sep 17 00:00:00 2001 From: Shayan Shojaei Date: Sun, 2 Jul 2023 15:01:21 +0330 Subject: [PATCH 2/9] change implementation to new method --- cjs/src/index.js | 11 ++++++----- deno/src/index.js | 11 ++++++----- deno/types/index.d.ts | 3 --- src/index.js | 11 ++++++----- types/index.d.ts | 3 --- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/cjs/src/index.js b/cjs/src/index.js index 6fa67002..de4ae9f4 100644 --- a/cjs/src/index.js +++ b/cjs/src/index.js @@ -77,7 +77,6 @@ function Postgres(a, b) { reserve, listen, begin, - beginPrepared, close, end }) @@ -231,11 +230,12 @@ function Postgres(a, b) { } } - async function begin(options, fn, transactionId) { + async function begin(options, fn) { !fn && (fn = options, options = '') const queries = Queue() let savepoints = 0 , connection + let transactionId = null try { await sql.unsafe('begin ' + options.replace(/[^a-z ]/ig, ''), [], { onexecute }).execute() @@ -247,6 +247,7 @@ function Postgres(a, b) { async function scope(c, fn, name) { const sql = Sql(handler) sql.savepoint = savepoint + sql.prepare = prepare let uncaughtError , result @@ -290,6 +291,9 @@ function Postgres(a, b) { } } + async function prepare(name) { + transactionId = name + } function onexecute(c) { connection = c move(c, reserved) @@ -299,9 +303,6 @@ function Postgres(a, b) { } } - async function beginPrepared(transactionId, options, fn) { - return begin(options, fn, transactionId) - } function move(c, queue) { c.queue.remove(c) diff --git a/deno/src/index.js b/deno/src/index.js index 31fa10c9..fb1cda9b 100644 --- a/deno/src/index.js +++ b/deno/src/index.js @@ -78,7 +78,6 @@ function Postgres(a, b) { reserve, listen, begin, - beginPrepared, close, end }) @@ -232,11 +231,12 @@ function Postgres(a, b) { } } - async function begin(options, fn, transactionId) { + async function begin(options, fn) { !fn && (fn = options, options = '') const queries = Queue() let savepoints = 0 , connection + let transactionId = null try { await sql.unsafe('begin ' + options.replace(/[^a-z ]/ig, ''), [], { onexecute }).execute() @@ -248,6 +248,7 @@ function Postgres(a, b) { async function scope(c, fn, name) { const sql = Sql(handler) sql.savepoint = savepoint + sql.prepare = prepare let uncaughtError , result @@ -291,6 +292,9 @@ function Postgres(a, b) { } } + async function prepare(name) { + transactionId = name + } function onexecute(c) { connection = c move(c, reserved) @@ -300,9 +304,6 @@ function Postgres(a, b) { } } - async function beginPrepared(transactionId, options, fn) { - return begin(options, fn, transactionId) - } function move(c, queue) { c.queue.remove(c) diff --git a/deno/types/index.d.ts b/deno/types/index.d.ts index 98b5c9b5..ca5a7446 100644 --- a/deno/types/index.d.ts +++ b/deno/types/index.d.ts @@ -681,9 +681,6 @@ declare namespace postgres { begin(cb: (sql: TransactionSql) => T | Promise): Promise>; begin(options: string, cb: (sql: TransactionSql) => T | Promise): Promise>; - beginPrepared(transactionId: string, cb: (sql: TransactionSql) => T | Promise): Promise>; - beginPrepared(transactionId: string, options: string, cb: (sql: TransactionSql) => T | Promise): Promise>; - array[] = SerializableParameter[]>(value: T, type?: number | undefined): ArrayParameter; file(path: string | Buffer | URL | number, options?: { cache?: boolean | undefined } | undefined): PendingQuery; file(path: string | Buffer | URL | number, args: (ParameterOrJSON)[], options?: { cache?: boolean | undefined } | undefined): PendingQuery; diff --git a/src/index.js b/src/index.js index 39f00e88..a254b617 100644 --- a/src/index.js +++ b/src/index.js @@ -77,7 +77,6 @@ function Postgres(a, b) { reserve, listen, begin, - beginPrepared, close, end }) @@ -231,11 +230,12 @@ function Postgres(a, b) { } } - async function begin(options, fn, transactionId) { + async function begin(options, fn) { !fn && (fn = options, options = '') const queries = Queue() let savepoints = 0 , connection + let transactionId = null try { await sql.unsafe('begin ' + options.replace(/[^a-z ]/ig, ''), [], { onexecute }).execute() @@ -247,6 +247,7 @@ function Postgres(a, b) { async function scope(c, fn, name) { const sql = Sql(handler) sql.savepoint = savepoint + sql.prepare = prepare let uncaughtError , result @@ -290,6 +291,9 @@ function Postgres(a, b) { } } + async function prepare(name) { + transactionId = name + } function onexecute(c) { connection = c move(c, reserved) @@ -299,9 +303,6 @@ function Postgres(a, b) { } } - async function beginPrepared(transactionId, options, fn) { - return begin(options, fn, transactionId) - } function move(c, queue) { c.queue.remove(c) diff --git a/types/index.d.ts b/types/index.d.ts index 6c998bd0..1c85198c 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -679,9 +679,6 @@ declare namespace postgres { begin(cb: (sql: TransactionSql) => T | Promise): Promise>; begin(options: string, cb: (sql: TransactionSql) => T | Promise): Promise>; - beginPrepared(transactionId: string, cb: (sql: TransactionSql) => T | Promise): Promise>; - beginPrepared(transactionId: string, options: string, cb: (sql: TransactionSql) => T | Promise): Promise>; - array[] = SerializableParameter[]>(value: T, type?: number | undefined): ArrayParameter; file(path: string | Buffer | URL | number, options?: { cache?: boolean | undefined } | undefined): PendingQuery; file(path: string | Buffer | URL | number, args: (ParameterOrJSON)[], options?: { cache?: boolean | undefined } | undefined): PendingQuery; From 7a2fbc7522b0f7841197c714a0caf12957d9c297 Mon Sep 17 00:00:00 2001 From: Shayan Shojaei Date: Sun, 2 Jul 2023 15:03:12 +0330 Subject: [PATCH 3/9] add prepare method type to TransactionSql --- deno/types/index.d.ts | 2 ++ types/index.d.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/deno/types/index.d.ts b/deno/types/index.d.ts index ca5a7446..64a00a4c 100644 --- a/deno/types/index.d.ts +++ b/deno/types/index.d.ts @@ -698,6 +698,8 @@ declare namespace postgres { interface TransactionSql = {}> extends Sql { savepoint(cb: (sql: TransactionSql) => T | Promise): Promise>; savepoint(name: string, cb: (sql: TransactionSql) => T | Promise): Promise>; + + prepare(name: string): Promise>; } } diff --git a/types/index.d.ts b/types/index.d.ts index 1c85198c..ab797ee4 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -696,6 +696,8 @@ declare namespace postgres { interface TransactionSql = {}> extends Sql { savepoint(cb: (sql: TransactionSql) => T | Promise): Promise>; savepoint(name: string, cb: (sql: TransactionSql) => T | Promise): Promise>; + + prepare(name: string): Promise>; } } From daa3ef1c9a6c9260c6f4e055026f7c0cbd9d9788 Mon Sep 17 00:00:00 2001 From: Shayan Shojaei Date: Sun, 2 Jul 2023 15:15:50 +0330 Subject: [PATCH 4/9] add documentations and test --- README.md | 20 ++++++++++++++++++++ cjs/tests/index.js | 10 ++++++++++ deno/README.md | 20 ++++++++++++++++++++ deno/tests/index.js | 10 ++++++++++ tests/index.js | 10 ++++++++++ 5 files changed, 70 insertions(+) diff --git a/README.md b/README.md index 5e49a51f..b0e64a75 100644 --- a/README.md +++ b/README.md @@ -637,6 +637,26 @@ sql.begin('read write', async sql => { }) ``` + +#### PREPARE `await sql.prepare([name]) -> fn()` + +Indicates that the transactions should be prepared using the `PREPARED TRANASCTION [NAME]` statement +instead of being committed. + +```js +sql.begin('read write', async sql => { + const [user] = await sql` + insert into users ( + name + ) values ( + 'Murray' + ) + ` + + await sql.prepare('tx1') +}) +``` + Do note that you can often achieve the same result using [`WITH` queries (Common Table Expressions)](https://www.postgresql.org/docs/current/queries-with.html) instead of using transactions. ## Data Transformation diff --git a/cjs/tests/index.js b/cjs/tests/index.js index 3d8b6162..42508d81 100644 --- a/cjs/tests/index.js +++ b/cjs/tests/index.js @@ -238,6 +238,16 @@ t('Savepoint returns Result', async() => { return [1, result[0].x] }) +t('Prepared transaction', async() => { + let result + await sql.begin(async sql => { + result = await sql`select 1 as x` + await sql.prepare('tx1') + }) + + return [1, result[0].x] +}) + t('Transaction requests are executed implicitly', async() => { const sql = postgres({ debug: true, idle_timeout: 1, fetch_types: false }) return [ diff --git a/deno/README.md b/deno/README.md index 054e53ab..f599a18f 100644 --- a/deno/README.md +++ b/deno/README.md @@ -633,6 +633,26 @@ sql.begin('read write', async sql => { }) ``` + +#### PREPARE `await sql.prepare([name]) -> fn()` + +Indicates that the transactions should be prepared using the `PREPARED TRANASCTION [NAME]` statement +instead of being committed. + +```js +sql.begin('read write', async sql => { + const [user] = await sql` + insert into users ( + name + ) values ( + 'Murray' + ) + ` + + await sql.prepare('tx1') +}) +``` + Do note that you can often achieve the same result using [`WITH` queries (Common Table Expressions)](https://www.postgresql.org/docs/current/queries-with.html) instead of using transactions. ## Data Transformation diff --git a/deno/tests/index.js b/deno/tests/index.js index 4b4459bd..11315831 100644 --- a/deno/tests/index.js +++ b/deno/tests/index.js @@ -240,6 +240,16 @@ t('Savepoint returns Result', async() => { return [1, result[0].x] }) +t('Prepared transaction', async() => { + let result + await sql.begin(async sql => { + result = await sql`select 1 as x` + await sql.prepare('tx1') + }) + + return [1, result[0].x] +}) + t('Transaction requests are executed implicitly', async() => { const sql = postgres({ debug: true, idle_timeout: 1, fetch_types: false }) return [ diff --git a/tests/index.js b/tests/index.js index 4bf03f58..6db5b443 100644 --- a/tests/index.js +++ b/tests/index.js @@ -238,6 +238,16 @@ t('Savepoint returns Result', async() => { return [1, result[0].x] }) +t('Prepared transaction', async() => { + let result + await sql.begin(async sql => { + result = await sql`select 1 as x` + await sql.prepare('tx1') + }) + + return [1, result[0].x] +}) + t('Transaction requests are executed implicitly', async() => { const sql = postgres({ debug: true, idle_timeout: 1, fetch_types: false }) return [ From e509e84ed63fde73697b09207286fb3490ff8038 Mon Sep 17 00:00:00 2001 From: Shayan Shojaei Date: Sun, 2 Jul 2023 15:21:59 +0330 Subject: [PATCH 5/9] fix test --- cjs/tests/index.js | 9 ++++++--- deno/tests/index.js | 9 ++++++--- tests/index.js | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/cjs/tests/index.js b/cjs/tests/index.js index 42508d81..2c703e2a 100644 --- a/cjs/tests/index.js +++ b/cjs/tests/index.js @@ -239,13 +239,16 @@ t('Savepoint returns Result', async() => { }) t('Prepared transaction', async() => { - let result + await sql`create table test (a int)` + await sql.begin(async sql => { - result = await sql`select 1 as x` + await sql`insert into test values(1)` await sql.prepare('tx1') }) - return [1, result[0].x] + await sql.unsafe("commit prepared 'tx1'") + + return ['1', (await sql`select count(1) from test`)[0].count, await sql`drop table test`] }) t('Transaction requests are executed implicitly', async() => { diff --git a/deno/tests/index.js b/deno/tests/index.js index 11315831..60f0f041 100644 --- a/deno/tests/index.js +++ b/deno/tests/index.js @@ -241,13 +241,16 @@ t('Savepoint returns Result', async() => { }) t('Prepared transaction', async() => { - let result + await sql`create table test (a int)` + await sql.begin(async sql => { - result = await sql`select 1 as x` + await sql`insert into test values(1)` await sql.prepare('tx1') }) - return [1, result[0].x] + await sql.unsafe("commit prepared 'tx1'") + + return ['1', (await sql`select count(1) from test`)[0].count, await sql`drop table test`] }) t('Transaction requests are executed implicitly', async() => { diff --git a/tests/index.js b/tests/index.js index 6db5b443..dd0af57c 100644 --- a/tests/index.js +++ b/tests/index.js @@ -239,13 +239,16 @@ t('Savepoint returns Result', async() => { }) t('Prepared transaction', async() => { - let result + await sql`create table test (a int)` + await sql.begin(async sql => { - result = await sql`select 1 as x` + await sql`insert into test values(1)` await sql.prepare('tx1') }) - return [1, result[0].x] + await sql.unsafe("commit prepared 'tx1'") + + return ['1', (await sql`select count(1) from test`)[0].count, await sql`drop table test`] }) t('Transaction requests are executed implicitly', async() => { From e2c134b6072e7e6d04bbcbc00f13adc69f6fb1ca Mon Sep 17 00:00:00 2001 From: Shayan Shojaei Date: Sun, 2 Jul 2023 15:31:48 +0330 Subject: [PATCH 6/9] enable prepared transactions in the bootstrap script --- tests/bootstrap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bootstrap.js b/tests/bootstrap.js index b30ca14b..7d30dce3 100644 --- a/tests/bootstrap.js +++ b/tests/bootstrap.js @@ -13,7 +13,7 @@ exec('dropdb', ['postgres_js_test']) exec('createdb', ['postgres_js_test']) exec('psql', ['-c', 'grant all on database postgres_js_test to postgres_js_test']) exec('psql', ['-c', 'alter database postgres_js_test owner to postgres_js_test']) - +exec('psql', ['-c', 'alter system set max_prepared_transactions to 100']) export function exec(cmd, args) { const { stderr } = spawnSync(cmd, args, { stdio: 'pipe', encoding: 'utf8' }) From 62e1aad9b50678b379a804ebded405f84697cd89 Mon Sep 17 00:00:00 2001 From: Shayan Shojaei Date: Sun, 2 Jul 2023 15:57:33 +0330 Subject: [PATCH 7/9] enable prepared transactions in the github actions setup file --- .github/workflows/test.yml | 1 + tests/bootstrap.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3af94064..68040b9a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,6 +35,7 @@ jobs: sudo apt-get -y install "postgresql-${{ matrix.postgres }}" sudo cp ./tests/pg_hba.conf /etc/postgresql/${{ matrix.postgres }}/main/pg_hba.conf sudo sed -i 's/.*wal_level.*/wal_level = logical/' /etc/postgresql/${{ matrix.postgres }}/main/postgresql.conf + sudo echo 'max_prepared_transactions = 100' >> /etc/postgresql/${{ matrix.postgres }}/main/postgresql.conf sudo sed -i 's/.*ssl = .*/ssl = on/' /etc/postgresql/${{ matrix.postgres }}/main/postgresql.conf openssl req -new -x509 -nodes -days 365 -text -subj "/CN=localhost" -extensions v3_req -config <(cat /etc/ssl/openssl.cnf <(printf "\n[v3_req]\nbasicConstraints=critical,CA:TRUE\nkeyUsage=nonRepudiation,digitalSignature,keyEncipherment\nsubjectAltName=DNS:localhost")) -keyout server.key -out server.crt sudo cp server.key /etc/postgresql/${{ matrix.postgres }}/main/server.key diff --git a/tests/bootstrap.js b/tests/bootstrap.js index 7d30dce3..0070c7b7 100644 --- a/tests/bootstrap.js +++ b/tests/bootstrap.js @@ -13,7 +13,6 @@ exec('dropdb', ['postgres_js_test']) exec('createdb', ['postgres_js_test']) exec('psql', ['-c', 'grant all on database postgres_js_test to postgres_js_test']) exec('psql', ['-c', 'alter database postgres_js_test owner to postgres_js_test']) -exec('psql', ['-c', 'alter system set max_prepared_transactions to 100']) export function exec(cmd, args) { const { stderr } = spawnSync(cmd, args, { stdio: 'pipe', encoding: 'utf8' }) From 551230750736b69be06a793265786b37867ca24d Mon Sep 17 00:00:00 2001 From: Shayan Shojaei Date: Sun, 2 Jul 2023 16:32:30 +0330 Subject: [PATCH 8/9] fix github actions --- .github/workflows/test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 68040b9a..998bb2d0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,8 +34,7 @@ jobs: sudo apt-get update sudo apt-get -y install "postgresql-${{ matrix.postgres }}" sudo cp ./tests/pg_hba.conf /etc/postgresql/${{ matrix.postgres }}/main/pg_hba.conf - sudo sed -i 's/.*wal_level.*/wal_level = logical/' /etc/postgresql/${{ matrix.postgres }}/main/postgresql.conf - sudo echo 'max_prepared_transactions = 100' >> /etc/postgresql/${{ matrix.postgres }}/main/postgresql.conf + sudo sed -i 's/.*wal_level.*/wal_level = logical/' /etc/postgresql/${{ matrix.postgres }}/main/postgresql.confsudo sed -i 's/.*max_prepared_transactions.*/max_prepared_transactions = 100/' /etc/postgresql/${{ matrix.postgres }}/main/postgresql.conf sudo sed -i 's/.*ssl = .*/ssl = on/' /etc/postgresql/${{ matrix.postgres }}/main/postgresql.conf openssl req -new -x509 -nodes -days 365 -text -subj "/CN=localhost" -extensions v3_req -config <(cat /etc/ssl/openssl.cnf <(printf "\n[v3_req]\nbasicConstraints=critical,CA:TRUE\nkeyUsage=nonRepudiation,digitalSignature,keyEncipherment\nsubjectAltName=DNS:localhost")) -keyout server.key -out server.crt sudo cp server.key /etc/postgresql/${{ matrix.postgres }}/main/server.key From 51da3ae0e634beedff26dbae435af84c5c54e647 Mon Sep 17 00:00:00 2001 From: Shayan Shojaei Date: Sun, 2 Jul 2023 16:33:29 +0330 Subject: [PATCH 9/9] fix github actions yml file --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 998bb2d0..92ec7033 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,7 +34,8 @@ jobs: sudo apt-get update sudo apt-get -y install "postgresql-${{ matrix.postgres }}" sudo cp ./tests/pg_hba.conf /etc/postgresql/${{ matrix.postgres }}/main/pg_hba.conf - sudo sed -i 's/.*wal_level.*/wal_level = logical/' /etc/postgresql/${{ matrix.postgres }}/main/postgresql.confsudo sed -i 's/.*max_prepared_transactions.*/max_prepared_transactions = 100/' /etc/postgresql/${{ matrix.postgres }}/main/postgresql.conf + sudo sed -i 's/.*wal_level.*/wal_level = logical/' /etc/postgresql/${{ matrix.postgres }}/main/postgresql.conf + sudo sed -i 's/.*max_prepared_transactions.*/max_prepared_transactions = 100/' /etc/postgresql/${{ matrix.postgres }}/main/postgresql.conf sudo sed -i 's/.*ssl = .*/ssl = on/' /etc/postgresql/${{ matrix.postgres }}/main/postgresql.conf openssl req -new -x509 -nodes -days 365 -text -subj "/CN=localhost" -extensions v3_req -config <(cat /etc/ssl/openssl.cnf <(printf "\n[v3_req]\nbasicConstraints=critical,CA:TRUE\nkeyUsage=nonRepudiation,digitalSignature,keyEncipherment\nsubjectAltName=DNS:localhost")) -keyout server.key -out server.crt sudo cp server.key /etc/postgresql/${{ matrix.postgres }}/main/server.key