Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb034ef9

Browse files
committed
Remove gratuitous uses of deprecated SELECT INTO
CREATE TABLE AS has been preferred over SELECT INTO (outside of ecpgand PL/pgSQL) for a long time. There were still a few uses of SELECTINTO in tests and documentation, some old, some more recent. Thischanges them to CREATE TABLE AS. Some occurrences in the tests remainwhere they are specifically testing SELECT INTO parsing or similar.Discussion:https://www.postgresql.org/message-id/flat/96dc0df3-e13a-a85d-d045-d6e2c85218da%40enterprisedb.com
1 parent6c55760 commitb034ef9

File tree

15 files changed

+30
-20
lines changed

15 files changed

+30
-20
lines changed

‎contrib/sepgsql/expected/label.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
--
77
CREATE TABLE t1 (a int, b text);
88
INSERT INTO t1 VALUES (1, 'aaa'), (2, 'bbb'), (3, 'ccc');
9-
SELECT * INTO t2 FROM t1 WHERE a % 2 = 0;
9+
CREATE TABLE t2 AS SELECT * FROM t1 WHERE a % 2 = 0;
1010
CREATE FUNCTION f1 () RETURNS text
1111
AS 'SELECT sepgsql_getcon()'
1212
LANGUAGE sql;

‎contrib/sepgsql/sql/label.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
--
88
CREATETABLEt1 (aint, btext);
99
INSERT INTO t1VALUES (1,'aaa'), (2,'bbb'), (3,'ccc');
10-
SELECT* INTO t2FROM t1WHERE a %2=0;
10+
CREATETABLEt2ASSELECT*FROM t1WHERE a %2=0;
1111

1212
CREATEFUNCTIONf1 () RETURNStext
1313
AS'SELECT sepgsql_getcon()'

‎doc/src/sgml/hstore.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ SELECT * FROM each('aaa=>bq, b=>NULL, ""=>1');
883883
<para>
884884
Using a table:
885885
<programlisting>
886-
SELECT (each(h)).key, (each(h)).value INTO stat FROM testhstore;
886+
CREATE TABLE stat ASSELECT (each(h)).key, (each(h)).value FROM testhstore;
887887
</programlisting>
888888
</para>
889889

‎src/bin/pg_basebackup/t/010_pg_basebackup.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,10 @@
502502

503503
# create tables to corrupt and get their relfilenodes
504504
my$file_corrupt1 =$node->safe_psql('postgres',
505-
q{SELECT a INTOcorrupt1 FROM generate_series(1,10000) AS a; ALTER TABLE corrupt1 SET (autovacuum_enabled=false); SELECT pg_relation_filepath('corrupt1')}
505+
q{CREATE TABLEcorrupt1 AS SELECT a FROM generate_series(1,10000) AS a; ALTER TABLE corrupt1 SET (autovacuum_enabled=false); SELECT pg_relation_filepath('corrupt1')}
506506
);
507507
my$file_corrupt2 =$node->safe_psql('postgres',
508-
q{SELECT b INTOcorrupt2 FROM generate_series(1,2) AS b; ALTER TABLE corrupt2 SET (autovacuum_enabled=false); SELECT pg_relation_filepath('corrupt2')}
508+
q{CREATE TABLEcorrupt2 AS SELECT b FROM generate_series(1,2) AS b; ALTER TABLE corrupt2 SET (autovacuum_enabled=false); SELECT pg_relation_filepath('corrupt2')}
509509
);
510510

511511
# set page header and block sizes

‎src/bin/pg_checksums/t/002_actions.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ sub check_relation_corruption
2121

2222
$node->safe_psql(
2323
'postgres',
24-
"SELECT a INTO$table FROM generate_series(1,10000) AS a;
24+
"CREATE TABLE$table AS SELECT a FROM generate_series(1,10000) AS a;
2525
ALTER TABLE$table SET (autovacuum_enabled=false);");
2626

2727
$node->safe_psql('postgres',

‎src/test/regress/expected/create_index.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@ DROP TABLE syscol_table;
15821582
--
15831583
-- Tests for IS NULL/IS NOT NULL with b-tree indexes
15841584
--
1585-
SELECT unique1, unique2 INTO onek_with_null FROM onek;
1585+
CREATE TABLE onek_with_null ASSELECT unique1, unique2 FROM onek;
15861586
INSERT INTO onek_with_null (unique1,unique2) VALUES (NULL, -1), (NULL, NULL);
15871587
CREATE UNIQUE INDEX onek_nulltest ON onek_with_null (unique2,unique1);
15881588
SET enable_seqscan = OFF;

‎src/test/regress/expected/create_misc.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
--(any resemblance to real life is purely coincidental)
66
--
77
INSERT INTO tenk2 SELECT * FROM tenk1;
8-
SELECT * INTOTABLE onek2 FROM onek;
8+
CREATETABLE onek2 AS SELECT * FROM onek;
99
INSERT INTO fast_emp4000 SELECT * FROM slow_emp4000;
1010
SELECT *
1111
INTO TABLE Bprime

‎src/test/regress/expected/random.out

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ INTERSECT
2323
(0 rows)
2424

2525
-- count roughly 1/10 of the tuples
26-
SELECT count(*) AS random INTO RANDOM_TBL
26+
CREATE TABLE RANDOM_TBL AS
27+
SELECT count(*) AS random
2728
FROM onek WHERE random() < 1.0/10;
2829
-- select again, the count should be different
2930
INSERT INTO RANDOM_TBL (random)

‎src/test/regress/expected/select_implicit.out

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ SELECT count(*) FROM test_missing_target x, test_missing_target y
202202

203203
-- group w/o existing GROUP BY target under ambiguous condition
204204
-- into a table
205-
SELECT count(*) INTO TABLE test_missing_target2
205+
CREATE TABLE test_missing_target2 AS
206+
SELECT count(*)
206207
FROM test_missing_target x, test_missing_target y
207208
WHERE x.a = y.a
208209
GROUP BY x.b ORDER BY x.b;
@@ -318,7 +319,8 @@ LINE 1: SELECT count(b) FROM test_missing_target x, test_missing_tar...
318319
^
319320
-- group w/o existing GROUP BY target under ambiguous condition
320321
-- into a table
321-
SELECT count(x.b) INTO TABLE test_missing_target3
322+
CREATE TABLE test_missing_target3 AS
323+
SELECT count(x.b)
322324
FROM test_missing_target x, test_missing_target y
323325
WHERE x.a = y.a
324326
GROUP BY x.b/2 ORDER BY x.b/2;

‎src/test/regress/expected/select_implicit_1.out

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ SELECT count(*) FROM test_missing_target x, test_missing_target y
202202

203203
-- group w/o existing GROUP BY target under ambiguous condition
204204
-- into a table
205-
SELECT count(*) INTO TABLE test_missing_target2
205+
CREATE TABLE test_missing_target2 AS
206+
SELECT count(*)
206207
FROM test_missing_target x, test_missing_target y
207208
WHERE x.a = y.a
208209
GROUP BY x.b ORDER BY x.b;
@@ -318,7 +319,8 @@ LINE 1: SELECT count(b) FROM test_missing_target x, test_missing_tar...
318319
^
319320
-- group w/o existing GROUP BY target under ambiguous condition
320321
-- into a table
321-
SELECT count(x.b) INTO TABLE test_missing_target3
322+
CREATE TABLE test_missing_target3 AS
323+
SELECT count(x.b)
322324
FROM test_missing_target x, test_missing_target y
323325
WHERE x.a = y.a
324326
GROUP BY x.b/2 ORDER BY x.b/2;

‎src/test/regress/expected/select_implicit_2.out

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ SELECT count(*) FROM test_missing_target x, test_missing_target y
202202

203203
-- group w/o existing GROUP BY target under ambiguous condition
204204
-- into a table
205-
SELECT count(*) INTO TABLE test_missing_target2
205+
CREATE TABLE test_missing_target2 AS
206+
SELECT count(*)
206207
FROM test_missing_target x, test_missing_target y
207208
WHERE x.a = y.a
208209
GROUP BY x.b ORDER BY x.b;
@@ -318,7 +319,8 @@ LINE 1: SELECT count(b) FROM test_missing_target x, test_missing_tar...
318319
^
319320
-- group w/o existing GROUP BY target under ambiguous condition
320321
-- into a table
321-
SELECT count(x.b) INTO TABLE test_missing_target3
322+
CREATE TABLE test_missing_target3 AS
323+
SELECT count(x.b)
322324
FROM test_missing_target x, test_missing_target y
323325
WHERE x.a = y.a
324326
GROUP BY x.b/2 ORDER BY x.b/2;

‎src/test/regress/sql/create_index.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ DROP TABLE syscol_table;
609609
-- Tests for IS NULL/IS NOT NULL with b-tree indexes
610610
--
611611

612-
SELECT unique1, unique2 INTO onek_with_nullFROM onek;
612+
CREATETABLEonek_with_nullASSELECT unique1, unique2FROM onek;
613613
INSERT INTO onek_with_null (unique1,unique2)VALUES (NULL,-1), (NULL,NULL);
614614
CREATEUNIQUE INDEXonek_nulltestON onek_with_null (unique2,unique1);
615615

‎src/test/regress/sql/create_misc.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
INSERT INTO tenk2SELECT*FROM tenk1;
1010

11-
SELECT* INTOTABLE onek2FROM onek;
11+
CREATETABLEonek2ASSELECT*FROM onek;
1212

1313
INSERT INTO fast_emp4000SELECT*FROM slow_emp4000;
1414

‎src/test/regress/sql/random.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ INTERSECT
1717
FROM onekORDER BY random()LIMIT1);
1818

1919
-- count roughly 1/10 of the tuples
20-
SELECTcount(*)AS random INTO RANDOM_TBL
20+
CREATETABLERANDOM_TBLAS
21+
SELECTcount(*)AS random
2122
FROM onekWHERE random()<1.0/10;
2223

2324
-- select again, the count should be different

‎src/test/regress/sql/select_implicit.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ SELECT count(*) FROM test_missing_target x, test_missing_target y
8686

8787
-- group w/o existing GROUP BY target under ambiguous condition
8888
-- into a table
89-
SELECTcount(*) INTO TABLE test_missing_target2
89+
CREATETABLEtest_missing_target2AS
90+
SELECTcount(*)
9091
FROM test_missing_target x, test_missing_target y
9192
WHEREx.a=y.a
9293
GROUP BYx.bORDER BYx.b;
@@ -142,7 +143,8 @@ SELECT count(b) FROM test_missing_target x, test_missing_target y
142143

143144
-- group w/o existing GROUP BY target under ambiguous condition
144145
-- into a table
145-
SELECTcount(x.b) INTO TABLE test_missing_target3
146+
CREATETABLEtest_missing_target3AS
147+
SELECTcount(x.b)
146148
FROM test_missing_target x, test_missing_target y
147149
WHEREx.a=y.a
148150
GROUP BYx.b/2ORDER BYx.b/2;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp