mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Remove useless whitespace at end of lines
This commit is contained in:
@ -8,9 +8,9 @@ CREATE TABLE ids (
|
||||
idesc text
|
||||
);
|
||||
|
||||
CREATE TRIGGER ids_nextid
|
||||
CREATE TRIGGER ids_nextid
|
||||
BEFORE INSERT OR UPDATE ON ids
|
||||
FOR EACH ROW
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE autoinc (id, next_id);
|
||||
|
||||
INSERT INTO ids VALUES (0, 'first (-2 ?)');
|
||||
@ -19,11 +19,11 @@ INSERT INTO ids(idesc) VALUES ('third (1 ?!)');
|
||||
|
||||
SELECT * FROM ids;
|
||||
|
||||
UPDATE ids SET id = null, idesc = 'first: -2 --> 2'
|
||||
UPDATE ids SET id = null, idesc = 'first: -2 --> 2'
|
||||
WHERE idesc = 'first (-2 ?)';
|
||||
UPDATE ids SET id = 0, idesc = 'second: -1 --> 3'
|
||||
UPDATE ids SET id = 0, idesc = 'second: -1 --> 3'
|
||||
WHERE id = -1;
|
||||
UPDATE ids SET id = 4, idesc = 'third: 1 --> 4'
|
||||
UPDATE ids SET id = 4, idesc = 'third: 1 --> 4'
|
||||
WHERE id = 1;
|
||||
|
||||
SELECT * FROM ids;
|
||||
|
@ -3,7 +3,7 @@
|
||||
-- Adjust this setting to control where the objects get created.
|
||||
SET search_path = public;
|
||||
|
||||
CREATE OR REPLACE FUNCTION autoinc()
|
||||
RETURNS trigger
|
||||
CREATE OR REPLACE FUNCTION autoinc()
|
||||
RETURNS trigger
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C;
|
||||
|
@ -7,7 +7,7 @@ CREATE TABLE username_test (
|
||||
|
||||
CREATE TRIGGER insert_usernames
|
||||
BEFORE INSERT OR UPDATE ON username_test
|
||||
FOR EACH ROW
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE insert_username (username);
|
||||
|
||||
INSERT INTO username_test VALUES ('nothing');
|
||||
|
@ -3,7 +3,7 @@
|
||||
-- Adjust this setting to control where the objects get created.
|
||||
SET search_path = public;
|
||||
|
||||
CREATE OR REPLACE FUNCTION insert_username()
|
||||
RETURNS trigger
|
||||
CREATE OR REPLACE FUNCTION insert_username()
|
||||
RETURNS trigger
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C;
|
||||
|
@ -8,7 +8,7 @@ CREATE TABLE mdt (
|
||||
|
||||
CREATE TRIGGER mdt_moddatetime
|
||||
BEFORE UPDATE ON mdt
|
||||
FOR EACH ROW
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE moddatetime (moddate);
|
||||
|
||||
INSERT INTO mdt VALUES (1, 'first');
|
||||
|
@ -20,11 +20,11 @@ CREATE INDEX CI ON C (REFC);
|
||||
--Trigger for table A:
|
||||
|
||||
CREATE TRIGGER AT BEFORE DELETE OR UPDATE ON A FOR EACH ROW
|
||||
EXECUTE PROCEDURE
|
||||
EXECUTE PROCEDURE
|
||||
check_foreign_key (2, 'cascade', 'ID', 'B', 'REFB', 'C', 'REFC');
|
||||
/*
|
||||
2 - means that check must be performed for foreign keys of 2 tables.
|
||||
cascade - defines that corresponding keys must be deleted.
|
||||
cascade - defines that corresponding keys must be deleted.
|
||||
ID - name of primary key column in triggered table (A). You may
|
||||
use as many columns as you need.
|
||||
B - name of (first) table with foreign keys.
|
||||
@ -38,11 +38,11 @@ REFC - name of foreign key column in this table.
|
||||
--Trigger for table B:
|
||||
|
||||
CREATE TRIGGER BT BEFORE INSERT OR UPDATE ON B FOR EACH ROW
|
||||
EXECUTE PROCEDURE
|
||||
EXECUTE PROCEDURE
|
||||
check_primary_key ('REFB', 'A', 'ID');
|
||||
|
||||
/*
|
||||
REFB - name of foreign key column in triggered (B) table. You may use as
|
||||
REFB - name of foreign key column in triggered (B) table. You may use as
|
||||
many columns as you need, but number of key columns in referenced
|
||||
table must be the same.
|
||||
A - referenced table name.
|
||||
@ -52,7 +52,7 @@ ID - name of primary key column in referenced table.
|
||||
--Trigger for table C:
|
||||
|
||||
CREATE TRIGGER CT BEFORE INSERT OR UPDATE ON C FOR EACH ROW
|
||||
EXECUTE PROCEDURE
|
||||
EXECUTE PROCEDURE
|
||||
check_primary_key ('REFC', 'A', 'ID');
|
||||
|
||||
-- Now try
|
||||
|
@ -1,8 +1,8 @@
|
||||
drop table tttest;
|
||||
|
||||
create table tttest (
|
||||
price_id int4,
|
||||
price_val int4,
|
||||
price_id int4,
|
||||
price_val int4,
|
||||
price_on abstime,
|
||||
price_off abstime
|
||||
);
|
||||
@ -12,17 +12,17 @@ alter table tttest add column q1 text;
|
||||
alter table tttest add column q2 int;
|
||||
alter table tttest drop column q1;
|
||||
|
||||
create trigger timetravel
|
||||
create trigger timetravel
|
||||
before insert or delete or update on tttest
|
||||
for each row
|
||||
execute procedure
|
||||
for each row
|
||||
execute procedure
|
||||
timetravel (price_on, price_off);
|
||||
|
||||
insert into tttest values (1, 1, null, null);
|
||||
insert into tttest(price_id, price_val) values (2, 2);
|
||||
insert into tttest(price_id, price_val,price_off) values (3, 3, 'infinity');
|
||||
|
||||
insert into tttest(price_id, price_val,price_off) values (4, 4,
|
||||
insert into tttest(price_id, price_val,price_off) values (4, 4,
|
||||
abstime('now'::timestamp - '100 days'::interval));
|
||||
insert into tttest(price_id, price_val,price_on) values (3, 3, 'infinity'); -- duplicate key
|
||||
|
||||
@ -62,7 +62,7 @@ select set_timetravel('tttest', 1); -- turn TT ON!
|
||||
select get_timetravel('tttest'); -- check status
|
||||
|
||||
-- we want to correct some date
|
||||
update tttest set price_on = 'Jan-01-1990 00:00:01' where price_id = 5 and
|
||||
update tttest set price_on = 'Jan-01-1990 00:00:01' where price_id = 5 and
|
||||
price_off <> 'infinity';
|
||||
-- but this doesn't work
|
||||
|
||||
@ -71,11 +71,11 @@ select set_timetravel('tttest', 0); -- turn TT OFF!
|
||||
|
||||
select get_timetravel('tttest'); -- check status
|
||||
|
||||
update tttest set price_on = '01-Jan-1990 00:00:01' where price_id = 5 and
|
||||
update tttest set price_on = '01-Jan-1990 00:00:01' where price_id = 5 and
|
||||
price_off <> 'infinity';
|
||||
select * from tttest;
|
||||
-- isn't it what we need ?
|
||||
|
||||
-- get price for price_id == 5 as it was '10-Jan-1990'
|
||||
select * from tttest where price_id = 5 and
|
||||
select * from tttest where price_id = 5 and
|
||||
price_on <= '10-Jan-1990' and price_off > '10-Jan-1990';
|
||||
|
@ -3,17 +3,17 @@
|
||||
-- Adjust this setting to control where the objects get created.
|
||||
SET search_path = public;
|
||||
|
||||
CREATE OR REPLACE FUNCTION timetravel()
|
||||
RETURNS trigger
|
||||
CREATE OR REPLACE FUNCTION timetravel()
|
||||
RETURNS trigger
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C;
|
||||
|
||||
CREATE OR REPLACE FUNCTION set_timetravel(name, int4)
|
||||
RETURNS int4
|
||||
CREATE OR REPLACE FUNCTION set_timetravel(name, int4)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C RETURNS NULL ON NULL INPUT;
|
||||
|
||||
CREATE OR REPLACE FUNCTION get_timetravel(name)
|
||||
RETURNS int4
|
||||
CREATE OR REPLACE FUNCTION get_timetravel(name)
|
||||
RETURNS int4
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE C RETURNS NULL ON NULL INPUT;
|
||||
|
Reference in New Issue
Block a user