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

Commit0803514

Browse files
committed
Fix underqualified cast-target type names in pg_dump and psql queries.
Queries running with some non-pg_catalog schema frontmost in their searchpath need to be careful to schema-qualify type names that should be soughtin pg_catalog. Vitaly Burovoy reported an oversight of this sort inpg_dump's dumpSequence, and grepping detected another one in psql'sdescribeOneTableDetails, both introduced by sequence-related changes inv10. In pg_dump, we can fix things by removing the cast altogether, sinceit doesn't really matter what data types are reported for these queryresult columns. Likewise in psql, the query seemed to be working undulyhard to get a result that's guaranteed to be exactly 'bigint'.I also changed a couple of occurrences of "::char" similarly. These arenot bugs, since "char" is a typename keyword and not subject to search_pathrules, but it seems better to use uniform style.Vitaly Burovoy and Tom LaneDiscussion:https://postgr.es/m/CAKOSWN=ds66zLw2SqkLTM8wbXFgDbc_OdkmT3dJfPT2mE5kipA@mail.gmail.com
1 parentee4673a commit0803514

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13160,7 +13160,7 @@ dumpCollation(Archive *fout, CollInfo *collinfo)
1316013160
collinfo->dobj.catId.oid);
1316113161
else
1316213162
appendPQExpBuffer(query, "SELECT "
13163-
"'c'::char AS collprovider, "
13163+
"'c' AS collprovider, "
1316413164
"collcollate, "
1316513165
"collctype, "
1316613166
"NULL AS collversion "
@@ -16549,13 +16549,16 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
1654916549
/*
1655016550
* Before PostgreSQL 10, sequence metadata is in the sequence itself,
1655116551
* so switch to the sequence's schema instead of pg_catalog.
16552+
*
16553+
* Note: it might seem that 'bigint' potentially needs to be
16554+
* schema-qualified, but actually that's a keyword.
1655216555
*/
1655316556

1655416557
/* Make sure we are in proper schema */
1655516558
selectSourceSchema(fout, tbinfo->dobj.namespace->dobj.name);
1655616559

1655716560
appendPQExpBuffer(query,
16558-
"SELECT 'bigint'::name AS sequence_type, "
16561+
"SELECT 'bigint' AS sequence_type, "
1655916562
"start_value, increment_by, max_value, min_value, "
1656016563
"cache_value, is_cycled FROM %s",
1656116564
fmtId(tbinfo->dobj.name));
@@ -16566,7 +16569,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
1656616569
selectSourceSchema(fout, tbinfo->dobj.namespace->dobj.name);
1656716570

1656816571
appendPQExpBuffer(query,
16569-
"SELECT 'bigint'::name AS sequence_type, "
16572+
"SELECT 'bigint' AS sequence_type, "
1657016573
"0 AS start_value, increment_by, max_value, min_value, "
1657116574
"cache_value, is_cycled FROM %s",
1657216575
fmtId(tbinfo->dobj.name));

‎src/bin/psql/describe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ describeOneTableDetails(const char *schemaname,
15961596
else
15971597
{
15981598
printfPQExpBuffer(&buf,
1599-
"SELECTpg_catalog.format_type('bigint'::regtype, NULL) AS \"%s\",\n"
1599+
"SELECT 'bigint' AS \"%s\",\n"
16001600
" start_value AS \"%s\",\n"
16011601
" min_value AS \"%s\",\n"
16021602
" max_value AS \"%s\",\n"
@@ -2489,7 +2489,7 @@ describeOneTableDetails(const char *schemaname,
24892489
{
24902490
printfPQExpBuffer(&buf,
24912491
"SELECT r.rulename, trim(trailing ';' from pg_catalog.pg_get_ruledef(r.oid, true)), "
2492-
"'O'::char AS ev_enabled\n"
2492+
"'O' AS ev_enabled\n"
24932493
"FROM pg_catalog.pg_rewrite r\n"
24942494
"WHERE r.ev_class = '%s' ORDER BY 1;",
24952495
oid);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp