Repository navigation
Run CREATE TABLE AS and SELECT INTO - #443
Merged
Merged
Conversation
tamnd
added a commit
that referenced
this pull request
Oct 20, 2026
) * Add the changelog entry for #443 * Free the rows of each run of a LATERAL relation that no tuple uses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CREATE TABLE ASandSELECT ... INTOnow run. The statement makes a table with a column for each column of the query, and then it writes the rows of the query into the table. The regression suite uses these statements intest_setupand in many other tests.Changes
rupg-analyzeaddscreate_table_asandselect_into, which followExecCreateTableAsandcreate_ctas_internal. Each column keeps the type, the typmod and the collation of the query. A list of column names can rename the columns, and a list with too many names gives 42601.CheckAttributeTypedoes.IF NOT EXISTSgives the notice 42P07 for a table that exists.WITH NO DATAmakes an empty table. The tag is thenCREATE TABLE AS.WITH (...)sets the options of the table and of its TOAST table.rupg-sessionfills the table with anINSERT ... SELECTof the query, and the tag isSELECT n. If the query fails, the table is gone.SELECTwithINTOis now a definition, not a query, in the simple and the extended protocol.Known differences
CREATE TEMP TABLE AS,CREATE UNLOGGED TABLE AS,CREATE MATERIALIZED VIEWandCREATE TABLE AS EXECUTEgive "not supported yet".COLLATEof an expression. A column such as'x' COLLATE "C"gets the collation of its type, and two explicit collations that do not agree give no error.Tests
connection/create_table_as.testis the output of PostgreSQL 19 for the same script in a new database. fmt, clippy, the workspace tests and the checks of xtask pass on server1.