Menu

#430 generate_series() does not work with INSERT

Development Queue
open
nobody
7
2013-12-04
2013-07-05
No

Pavan reported the following bug:

I tried to use generate_series() function to load a bunch of test data in a table. It fails with the following error:

psql (PGXC 1.1devel, based on PG 9.2beta2)
Type "help" for help.

postgres=# CREATE TABLE testtbl(a int, b char(10));
CREATE TABLE
postgres=# \d+ testtbl
Table "public.testtbl"
Column | Type | Modifiers | Storage | Stats target | Description
--------+---------------+-----------+----------+--------------+-------------
a | integer | | plain | |
b | character(10) | | extended | |
Has OIDs: no
Distribute By: HASH(a)
Location Nodes: ALL DATANODES

postgres=# INSERT INTO testtbl VALUES (generate_series(1,10000), 'foo');
ERROR: set-valued function called in context that cannot accept a set

I thought we had fixed this issue long back, no ? I also tried to search the list and it seems it used to work at some point. Am I doing something wrong ? I'm using the master branch from the repository.

----

Afterwords, he found that this could be an issue with FQS:

It seems we are trying to FQS this query, which is clearly wrong. The INSERTs must go through the coordinator so that each row can be inserted in the relevant datanode. If I turn FQS off, then the INSERT works fine.

postgres=# set enable_fast_query_shipping TO on;
SET
postgres=# EXPLAIN INSERT INTO testtbl VALUES (generate_series(1,10000), 'foo');
QUERY PLAN
----------------------------------------------------------------------------
Data Node Scan on "__REMOTE_FQS_QUERY__" (cost=0.00..0.00 rows=0 width=0)
Node expr: generate_series(1, 10000)
(2 rows)

postgres=# set enable_fast_query_shipping TO off;
SET
postgres=# EXPLAIN INSERT INTO testtbl VALUES (generate_series(1,10000), 'foo');
QUERY PLAN
-----------------------------------------------------
Insert on testtbl (cost=0.00..0.01 rows=1 width=0)
Node/s: d1, d2
Node expr: a
-> Result (cost=0.00..0.01 rows=1 width=0)
(4 rows)

Discussion

  • Koichi Suzuki

    Koichi Suzuki - 2013-07-05
    • priority: 5 --> 7
     
  • Koichi Suzuki

    Koichi Suzuki - 2013-12-02
    • Group: 1.2 Dev Q --> 1.3 Dev Q
     
  • Koichi Suzuki

    Koichi Suzuki - 2013-12-04
    • Group: 1.3 Dev Q --> Development Queue
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.