using the nextval('sequence_name') in sql, the result maybe is notright

Поиск
Список
Период
Сортировка
От Wanglin
Тема using the nextval('sequence_name') in sql, the result maybe is notright
Дата
Msg-id 58540bf0.1474c.16615c4ec95.Coremail.jluwln@163.com
обсуждение исходный текст
Ответы Re: using the nextval('sequence_name') in sql, the result maybe isnot right  (Alban Hertroys <haramrae@gmail.com>)
Re: using the nextval('sequence_name') in sql, the result maybe isnot right  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
Hi, all:
    PostgreSQL version : 10.3.  I use "nextval" in the sql , but I think the result is not right, maybe it is a bug.
   The test case as bellow:
   create sequence seq1;
select nextval('seq1');
create table tx1(id1 int, id2 int);
insert into tx1 select generate_series(1,100), random()*102;
explain verbose select * from tx1 where id2 = nextval('seq1');;
select * from tx1 where id2 = nextval('seq1');
postgres=# explain verbose select * from tx1 where id2 = nextval('seq1');; QUERY PLAN ------------------------------------------------------------ Seq Scan on public.tx1 (cost=0.00..43.90 rows=11 width=8) Output: id1, id2 Filter: (tx1.id2 = nextval('seq1'::regclass)) (3 rows)

postgres=# select * from tx1 where id2 = nextval('seq1'); -- here, may be the result is not right id1 | id2 -----+----- 56 | 57 (1 row)

:: I think "nextval('seq1')" equal 2, so " select * from tx1 where id2 = nextval('seq1')" equals " select * from tx1 where id2 = 2", is it ?

Thanks,
    Wanglin



 

В списке pgsql-general по дате отправления:

Предыдущее
От: David Steele
Дата:
Сообщение: Re: Setting up continuous archiving
Следующее
От: Alban Hertroys
Дата:
Сообщение: Re: using the nextval('sequence_name') in sql, the result maybe isnot right