forked from reorg/pg_repack
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move INSERT query of repack.repack_trigger to C
Making INSERT query in C prevents SQL injections, which are possible if an INSERT query is passed as an argument. Additionally this commit adds funtions: - repack.create_index_type - repack.create_log_table - repack.create_table Another change is that tablespace_orig considers default tablespace of a database.
- Loading branch information
Showing
7 changed files
with
123 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"name": "pg_repack", | ||
"abstract": "PostgreSQL module for data reorganization", | ||
"description": "Reorganize tables in PostgreSQL databases with minimal locks", | ||
"version": "1.4.8", | ||
"version": "1.4.9", | ||
"maintainer": [ | ||
"Beena Emerson <[email protected]>", | ||
"Josh Kupershmidt <[email protected]>", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-- | ||
-- repack.repack_trigger tests | ||
-- | ||
CREATE TABLE trigger_t1 (a int, b int, primary key (a, b)); | ||
CREATE INDEX trigger_t1_idx ON trigger_t1 (a, b); | ||
SELECT create_trigger FROM repack.tables WHERE relname = 'public.trigger_t1'; | ||
create_trigger | ||
---------------------------------------------------------------------------------------------------------------------------------------------------- | ||
CREATE TRIGGER repack_trigger AFTER INSERT OR DELETE OR UPDATE ON public.trigger_t1 FOR EACH ROW EXECUTE PROCEDURE repack.repack_trigger('a', 'b') | ||
(1 row) | ||
|
||
SELECT oid AS t1_oid FROM pg_catalog.pg_class WHERE relname = 'trigger_t1' | ||
\gset | ||
CREATE TYPE repack.pk_:t1_oid AS (a integer, b integer); | ||
CREATE TABLE repack.log_:t1_oid (id bigserial PRIMARY KEY, pk repack.pk_:t1_oid, row public.trigger_t1); | ||
CREATE TRIGGER repack_trigger AFTER INSERT OR DELETE OR UPDATE ON trigger_t1 | ||
FOR EACH ROW EXECUTE PROCEDURE repack.repack_trigger('a', 'b'); | ||
INSERT INTO trigger_t1 VALUES (111, 222); | ||
UPDATE trigger_t1 SET a=333, b=444 WHERE a = 111; | ||
DELETE FROM trigger_t1 WHERE a = 333; | ||
SELECT * FROM repack.log_:t1_oid; | ||
id | pk | row | ||
----+-----------+----------- | ||
1 | | (111,222) | ||
2 | (111,222) | (333,444) | ||
3 | (333,444) | | ||
(3 rows) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- | ||
-- repack.repack_trigger tests | ||
-- | ||
|
||
CREATE TABLE trigger_t1 (a int, b int, primary key (a, b)); | ||
CREATE INDEX trigger_t1_idx ON trigger_t1 (a, b); | ||
|
||
SELECT create_trigger FROM repack.tables WHERE relname = 'public.trigger_t1'; | ||
|
||
SELECT oid AS t1_oid FROM pg_catalog.pg_class WHERE relname = 'trigger_t1' | ||
\gset | ||
|
||
CREATE TYPE repack.pk_:t1_oid AS (a integer, b integer); | ||
CREATE TABLE repack.log_:t1_oid (id bigserial PRIMARY KEY, pk repack.pk_:t1_oid, row public.trigger_t1); | ||
CREATE TRIGGER repack_trigger AFTER INSERT OR DELETE OR UPDATE ON trigger_t1 | ||
FOR EACH ROW EXECUTE PROCEDURE repack.repack_trigger('a', 'b'); | ||
|
||
INSERT INTO trigger_t1 VALUES (111, 222); | ||
UPDATE trigger_t1 SET a=333, b=444 WHERE a = 111; | ||
DELETE FROM trigger_t1 WHERE a = 333; | ||
SELECT * FROM repack.log_:t1_oid; |