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

Commit143290e

Browse files
committed
Introduce minimal C99 usage to verify compiler support.
This just converts a few for loops in postgres.c to declare variablesin the loop initializer, and uses designated initializers in smgr.c'sdefinition of smgr callbacks.Author: Andres FreundDiscussion:https://postgr.es/m/97d4b165-192d-3605-749c-f614a0c4e783@2ndquadrant.com
1 parentd9dd406 commit143290e

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

‎src/backend/storage/smgr/smgr.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,24 @@ typedef struct f_smgr
6767

6868
staticconstf_smgrsmgrsw[]= {
6969
/* magnetic disk */
70-
{mdinit,NULL,mdclose,mdcreate,mdexists,mdunlink,mdextend,
71-
mdprefetch,mdread,mdwrite,mdwriteback,mdnblocks,mdtruncate,
72-
mdimmedsync,mdpreckpt,mdsync,mdpostckpt
70+
{
71+
.smgr_init=mdinit,
72+
.smgr_shutdown=NULL,
73+
.smgr_close=mdclose,
74+
.smgr_create=mdcreate,
75+
.smgr_exists=mdexists,
76+
.smgr_unlink=mdunlink,
77+
.smgr_extend=mdextend,
78+
.smgr_prefetch=mdprefetch,
79+
.smgr_read=mdread,
80+
.smgr_write=mdwrite,
81+
.smgr_writeback=mdwriteback,
82+
.smgr_nblocks=mdnblocks,
83+
.smgr_truncate=mdtruncate,
84+
.smgr_immedsync=mdimmedsync,
85+
.smgr_pre_ckpt=mdpreckpt,
86+
.smgr_sync=mdsync,
87+
.smgr_post_ckpt=mdpostckpt
7388
}
7489
};
7590

‎src/backend/tcop/postgres.c

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,6 @@ exec_parse_message(const char *query_string,/* string to execute */
13101310
{
13111311
Query*query;
13121312
boolsnapshot_set= false;
1313-
inti;
13141313

13151314
raw_parse_tree=linitial_node(RawStmt,parsetree_list);
13161315

@@ -1366,7 +1365,7 @@ exec_parse_message(const char *query_string,/* string to execute */
13661365
/*
13671366
* Check all parameter types got determined.
13681367
*/
1369-
for (i=0;i<numParams;i++)
1368+
for (inti=0;i<numParams;i++)
13701369
{
13711370
Oidptype=paramTypes[i];
13721371

@@ -1555,10 +1554,8 @@ exec_bind_message(StringInfo input_message)
15551554
numPFormats=pq_getmsgint(input_message,2);
15561555
if (numPFormats>0)
15571556
{
1558-
inti;
1559-
15601557
pformats= (int16*)palloc(numPFormats*sizeof(int16));
1561-
for (i=0;i<numPFormats;i++)
1558+
for (inti=0;i<numPFormats;i++)
15621559
pformats[i]=pq_getmsgint(input_message,2);
15631560
}
15641561

@@ -1641,8 +1638,6 @@ exec_bind_message(StringInfo input_message)
16411638
*/
16421639
if (numParams>0)
16431640
{
1644-
intparamno;
1645-
16461641
params= (ParamListInfo)palloc(offsetof(ParamListInfoData,params)+
16471642
numParams*sizeof(ParamExternData));
16481643
/* we have static list of params, so no hooks needed */
@@ -1654,7 +1649,7 @@ exec_bind_message(StringInfo input_message)
16541649
params->parserSetupArg=NULL;
16551650
params->numParams=numParams;
16561651

1657-
for (paramno=0;paramno<numParams;paramno++)
1652+
for (intparamno=0;paramno<numParams;paramno++)
16581653
{
16591654
Oidptype=psrc->param_types[paramno];
16601655
int32plength;
@@ -1782,10 +1777,8 @@ exec_bind_message(StringInfo input_message)
17821777
numRFormats=pq_getmsgint(input_message,2);
17831778
if (numRFormats>0)
17841779
{
1785-
inti;
1786-
17871780
rformats= (int16*)palloc(numRFormats*sizeof(int16));
1788-
for (i=0;i<numRFormats;i++)
1781+
for (inti=0;i<numRFormats;i++)
17891782
rformats[i]=pq_getmsgint(input_message,2);
17901783
}
17911784

@@ -2212,7 +2205,6 @@ errdetail_params(ParamListInfo params)
22122205
{
22132206
StringInfoDataparam_str;
22142207
MemoryContextoldcontext;
2215-
intparamno;
22162208

22172209
/* This code doesn't support dynamic param lists */
22182210
Assert(params->paramFetch==NULL);
@@ -2222,7 +2214,7 @@ errdetail_params(ParamListInfo params)
22222214

22232215
initStringInfo(&param_str);
22242216

2225-
for (paramno=0;paramno<params->numParams;paramno++)
2217+
for (intparamno=0;paramno<params->numParams;paramno++)
22262218
{
22272219
ParamExternData*prm=&params->params[paramno];
22282220
Oidtypoutput;
@@ -2325,7 +2317,6 @@ static void
23252317
exec_describe_statement_message(constchar*stmt_name)
23262318
{
23272319
CachedPlanSource*psrc;
2328-
inti;
23292320

23302321
/*
23312322
* Start up a transaction command. (Note that this will normally change
@@ -2384,7 +2375,7 @@ exec_describe_statement_message(const char *stmt_name)
23842375
* message type */
23852376
pq_sendint16(&row_description_buf,psrc->num_params);
23862377

2387-
for (i=0;i<psrc->num_params;i++)
2378+
for (inti=0;i<psrc->num_params;i++)
23882379
{
23892380
Oidptype=psrc->param_types[i];
23902381

@@ -4179,10 +4170,8 @@ PostgresMain(int argc, char *argv[],
41794170
numParams=pq_getmsgint(&input_message,2);
41804171
if (numParams>0)
41814172
{
4182-
inti;
4183-
41844173
paramTypes= (Oid*)palloc(numParams*sizeof(Oid));
4185-
for (i=0;i<numParams;i++)
4174+
for (inti=0;i<numParams;i++)
41864175
paramTypes[i]=pq_getmsgint(&input_message,4);
41874176
}
41884177
pq_getmsgend(&input_message);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp