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

Commit94077df

Browse files
committed
Avoid casting away const in sepgsql's quote_object_name.
quote_identifier's API is designed on the assumption that it'snot worth worrying about a short-term memory leak when we haveto produce a quoted version of the given identifier. Whoever wrotequote_object_name took it on themselves to override that judgment,but the only way to do so is to cast away const someplace. We canavoid that and substantially shorten the function by going alongwith quote_identifier's opinion. AFAICS quote_object_name is notused in any way where this would be unsustainable.Per discussion of commit45987aa, which exposed that we hada casting-away-const situation here.Discussion:https://postgr.es/m/20220827112304.GL2342@telsasoft.com
1 parentd1ce745 commit94077df

File tree

1 file changed

+6
-27
lines changed

1 file changed

+6
-27
lines changed

‎contrib/sepgsql/label.c

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -646,45 +646,24 @@ sepgsql_mcstrans_out(PG_FUNCTION_ARGS)
646646
/*
647647
* quote_object_name
648648
*
649-
* It tries to quote the supplied identifiers
649+
* Concatenate as many of the given strings as aren't NULL, with dots between.
650+
* Quote any of the strings that wouldn't be valid identifiers otherwise.
650651
*/
651652
staticchar*
652653
quote_object_name(constchar*src1,constchar*src2,
653654
constchar*src3,constchar*src4)
654655
{
655656
StringInfoDataresult;
656-
constchar*temp;
657657

658658
initStringInfo(&result);
659-
660659
if (src1)
661-
{
662-
temp=quote_identifier(src1);
663-
appendStringInfoString(&result,temp);
664-
if (src1!=temp)
665-
pfree(temp);
666-
}
660+
appendStringInfoString(&result,quote_identifier(src1));
667661
if (src2)
668-
{
669-
temp=quote_identifier(src2);
670-
appendStringInfo(&result,".%s",temp);
671-
if (src2!=temp)
672-
pfree(temp);
673-
}
662+
appendStringInfo(&result,".%s",quote_identifier(src2));
674663
if (src3)
675-
{
676-
temp=quote_identifier(src3);
677-
appendStringInfo(&result,".%s",temp);
678-
if (src3!=temp)
679-
pfree(temp);
680-
}
664+
appendStringInfo(&result,".%s",quote_identifier(src3));
681665
if (src4)
682-
{
683-
temp=quote_identifier(src4);
684-
appendStringInfo(&result,".%s",temp);
685-
if (src4!=temp)
686-
pfree(temp);
687-
}
666+
appendStringInfo(&result,".%s",quote_identifier(src4));
688667
returnresult.data;
689668
}
690669

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp