SELECT INTO without columns or star

From: Zhang Mingli <zmlpostgres(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: SELECT INTO without columns or star
Date: 2023-03-31 15:09:45
Message-ID: 06046abe-0179-44e0-8770-b1243765c079@Spark
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, hackers

When I exec a sql SELECT INTO without columns or * by mistake, it succeeds:

select * from t1;
 a | b
---+---
 1 | 2
 2 | 3
 3 | 4
(3 rows)

select into t2 from t1;
SELECT 3

 \pset null '(null)'
Null display is "(null)".

select * from t2;
--
(3 rows)

It seems that t2 has empty rows but not null. Is it an expected behavior?
And what’s the semantic of SELECT INTO without any columns?
I also see lots of that SELECT INTO in out test cases like:
-- SELECT INTO doesn't support USING
SELECT INTO tableam_tblselectinto_heap2 USING heap2 FROM tableam_tbl_heap2;

Regards,
Zhang Mingli

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2023-03-31 15:13:28 Re: SELECT INTO without columns or star
Previous Message Nikita Malakhov 2023-03-31 14:57:13 Re: SQL JSON path enhanced numeric literals