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

Usage of "_as_of ()" #15

Open
lucasaccarola opened this issue Oct 22, 2020 · 0 comments
Open

Usage of "_as_of ()" #15

lucasaccarola opened this issue Oct 22, 2020 · 0 comments

Comments

@lucasaccarola
Copy link

Hi there,

using postgresql-11-periods/focal-pgdg,now 1.2-1.pgdg20.04+2 amd64

I've defined a table with system versioning as follow:

create table test1 (
  id serial primary key,
  status varchar (30) default 'on'
);
select periods.add_system_time_period ('test1', 'row_start', 'row_end');
select periods.add_system_versioning ('test1');

I've then add some rows to my table via:

insert into test1 (status) values ('on');
insert into test1 (status) values ('off');
insert into test1 (status) values ('on');

Now I'm trying to get my value at given date via test1__as_of ():

ls=# SELECT * FROM test1__as_of (now ());
 id | status |           row_start           | row_end             
----+--------+-------------------------------+----------
  1 | on     | 2020-10-21 19:37:07.567824+02 | infinity
  2 | off    | 2020-10-21 19:52:33.665405+02 | infinity
  3 | on     | 2020-10-21 19:53:44.834846+02 | infinity
(3 rows)

ls=# SELECT * FROM test1__as_of ('2020-10-21 19:52:35.665405+02');
 id | status |           row_start           | row_end             
----+--------+-------------------------------+----------
  1 | on    | 2020-10-21 19:37:07.567824+02 | infinity
  2 | off   | 2020-10-21 19:52:33.665405+02 | infinity
(2 rows)

ls=# SELECT * FROM test1__as_of ('2020-10-21 19:40:07.567824+02');
 id | status |           row_start           | row_end             
----+--------+-------------------------------+----------
  1 | on     | 2020-10-21 19:37:07.567824+02 | infinity
(1 row)

The question is: why I'm gotting all the records instead of a single one containing my status value at given date ?
Am I missing something ?

Best.

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

No branches or pull requests

1 participant