postgresql/src/backend/parser
Tom Lane 4576208454 Force standard_conforming_strings to always be ON.
Continuing to support this backwards-compatibility feature has
nontrivial costs; in particular it is potentially a security hazard
if an application somehow gets confused about which setting the
server is using.  We changed the default to ON fifteen years ago,
which seems like enough time for applications to have adapted.
Let's remove support for the legacy string syntax.

We should not remove the GUC altogether, since client-side code will
still test it, pg_dump scripts will attempt to set it to ON, etc.
Instead, just prevent it from being set to OFF.  There is precedent
for this approach (see commit de66987ad).

This patch does remove the related GUC escape_string_warning, however.
That setting does nothing when standard_conforming_strings is on,
so it's now useless.  We could leave it in place as a do-nothing
setting to avoid breaking clients that still set it, if there are any.
But it seems likely that any such client is also trying to turn off
standard_conforming_strings, so it'll need work anyway.

The client-side changes in this patch are pretty minimal, because even
though we are dropping the server's support, most of our clients still
need to be able to talk to older server versions.  We could remove
dead client code only once we disclaim compatibility with pre-v19
servers, which is surely years away.  One change of note is that
pg_dump/pg_dumpall now set standard_conforming_strings = on in their
source session, rather than accepting the source server's default.
This ensures that literals in view definitions and such will be
printed in a way that's acceptable to v19+.  In particular,
pg_upgrade will work transparently even if the source installation has
standard_conforming_strings = off.  (However, pg_restore will behave
the same as before if given an archive file containing
standard_conforming_strings = off.  Such an archive will not be safely
restorable into v19+, but we shouldn't break the ability to extract
valid data from it for use with an older server.)

Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/3279216.1767072538@sss.pgh.pa.us
2026-01-21 15:08:38 -05:00
..
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
analyze.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
check_keywords.pl Update copyright for 2026 2026-01-01 13:24:10 -05:00
gram.y Add parse location to IndexElem. 2026-01-04 14:16:20 -05:00
gramparse.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
Makefile Drop warning-free support for Flex 2.5.35 2025-01-15 15:35:08 +01:00
meson.build Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_agg.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_clause.c Add parse location to IndexElem. 2026-01-04 14:16:20 -05:00
parse_coerce.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_collate.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_cte.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_enr.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_expr.c pg_stat_statements: Fix crash in list squashing with Vars 2026-01-20 08:11:12 +09:00
parse_func.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_jsontable.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_merge.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_node.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_oper.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_param.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_relation.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_target.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_type.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
parse_utilcmd.c Fix possible incorrect column reference in ERROR message 2026-01-09 11:01:36 +13:00
parser.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
README Update parser README to include parse_jsontable.c 2025-09-08 10:07:14 +09:00
scan.l Force standard_conforming_strings to always be ON. 2026-01-21 15:08:38 -05:00
scansup.c Update copyright for 2026 2026-01-01 13:24:10 -05:00

src/backend/parser/README

Parser
======

This directory does more than tokenize and parse SQL queries.  It also
creates Query structures for the various complex queries that are passed
to the optimizer and then executor.

parser.c	things start here
scan.l		break query into tokens
scansup.c	handle escapes in input strings
gram.y		parse the tokens and produce a "raw" parse tree
analyze.c	top level of parse analysis for optimizable queries
parse_agg.c	handle aggregates, like SUM(col1),  AVG(col2), ...
parse_clause.c	handle clauses like WHERE, ORDER BY, GROUP BY, ...
parse_coerce.c	handle coercing expressions to different data types
parse_collate.c	assign collation information in completed expressions
parse_cte.c	handle Common Table Expressions (WITH clauses)
parse_expr.c	handle expressions like col, col + 3, x = 3 or x = 4
parse_enr.c	handle ephemeral named rels (trigger transition tables, ...)
parse_func.c	handle functions, table.column and column identifiers
parse_jsontable.c handle JSON_TABLE
parse_merge.c	handle MERGE
parse_node.c	create nodes for various structures
parse_oper.c	handle operators in expressions
parse_param.c	handle Params (for the cases used in the core backend)
parse_relation.c support routines for tables and column handling
parse_target.c	handle the result list of the query
parse_type.c	support routines for data type handling
parse_utilcmd.c	parse analysis for utility commands (done at execution time)

See also src/common/keywords.c, which contains the table of standard
keywords and the keyword lookup function.  We separated that out because
various frontend code wants to use it too.