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

Commitbaa4043

Browse files
Daniil AnisimovAlena0704
Daniil Anisimov
authored andcommitted
Add the routine for safe update.
Reviewed by:@Alena0704
1 parent8f42e12 commitbaa4043

File tree

1 file changed

+30
-13
lines changed

1 file changed

+30
-13
lines changed

‎storage.c‎

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,12 @@ HTAB *data_htab = NULL;
7474
dsa_area*data_dsa=NULL;
7575
HTAB*deactivated_queries=NULL;
7676

77-
/* Used to check data file consistency */
78-
staticconstuint32PGAQO_FILE_HEADER=123467589;
77+
/*
78+
* Used to check data file consistency
79+
* When changing data structures, PGAQO_FILE_HEADER should also be changed.
80+
* In this case, all AQO file storages will be reset.
81+
*/
82+
staticconstuint32PGAQO_FILE_HEADER=0x20230330;
7983
staticconstuint32PGAQO_PG_MAJOR_VERSION=PG_VERSION_NUM /100;
8084

8185
/*
@@ -374,7 +378,7 @@ aqo_query_stat(PG_FUNCTION_ARGS)
374378
Datumvalues[TOTAL_NCOLS+1];
375379
boolnulls[TOTAL_NCOLS+1];
376380
HASH_SEQ_STATUShash_seq;
377-
StatEntry*entry;
381+
StatEntry*entry;
378382

379383
/* check to see if caller supports us returning a tuplestore */
380384
if (rsinfo==NULL|| !IsA(rsinfo,ReturnSetInfo))
@@ -393,7 +397,9 @@ aqo_query_stat(PG_FUNCTION_ARGS)
393397
/* Build a tuple descriptor for our result type */
394398
if (get_call_result_type(fcinfo,NULL,&tupDesc)!=TYPEFUNC_COMPOSITE)
395399
elog(ERROR,"return type must be a row type");
396-
Assert(tupDesc->natts==TOTAL_NCOLS);
400+
401+
if (tupDesc->natts!=TOTAL_NCOLS)
402+
elog(ERROR,"[AQO] Incorrect number of output arguments");
397403

398404
tupstore=tuplestore_begin_heap(true, false,work_mem);
399405
rsinfo->returnMode=SFRM_Materialize;
@@ -1160,7 +1166,9 @@ aqo_query_texts(PG_FUNCTION_ARGS)
11601166
/* Build a tuple descriptor for our result type */
11611167
if (get_call_result_type(fcinfo,NULL,&tupDesc)!=TYPEFUNC_COMPOSITE)
11621168
elog(ERROR,"return type must be a row type");
1163-
Assert(tupDesc->natts==QT_TOTAL_NCOLS);
1169+
1170+
if (tupDesc->natts!=QT_TOTAL_NCOLS)
1171+
elog(ERROR,"[AQO] Incorrect number of output arguments");
11641172

11651173
tupstore=tuplestore_begin_heap(true, false,work_mem);
11661174
rsinfo->returnMode=SFRM_Materialize;
@@ -1754,7 +1762,9 @@ aqo_data(PG_FUNCTION_ARGS)
17541762
/* Build a tuple descriptor for our result type */
17551763
if (get_call_result_type(fcinfo,NULL,&tupDesc)!=TYPEFUNC_COMPOSITE)
17561764
elog(ERROR,"return type must be a row type");
1757-
Assert(tupDesc->natts==AD_TOTAL_NCOLS);
1765+
1766+
if (tupDesc->natts!=AD_TOTAL_NCOLS)
1767+
elog(ERROR,"[AQO] Incorrect number of output arguments");
17581768

17591769
tupstore=tuplestore_begin_heap(true, false,work_mem);
17601770
rsinfo->returnMode=SFRM_Materialize;
@@ -1914,7 +1924,9 @@ aqo_queries(PG_FUNCTION_ARGS)
19141924
/* Build a tuple descriptor for our result type */
19151925
if (get_call_result_type(fcinfo,NULL,&tupDesc)!=TYPEFUNC_COMPOSITE)
19161926
elog(ERROR,"return type must be a row type");
1917-
Assert(tupDesc->natts==AQ_TOTAL_NCOLS);
1927+
1928+
if (tupDesc->natts!=AQ_TOTAL_NCOLS)
1929+
elog(ERROR,"[AQO] Incorrect number of output arguments");
19181930

19191931
tupstore=tuplestore_begin_heap(true, false,work_mem);
19201932
rsinfo->returnMode=SFRM_Materialize;
@@ -2377,7 +2389,8 @@ aqo_cleanup(PG_FUNCTION_ARGS)
23772389
if (get_call_result_type(fcinfo,NULL,&tupDesc)!=TYPEFUNC_COMPOSITE)
23782390
elog(ERROR,"return type must be a row type");
23792391

2380-
Assert(tupDesc->natts==2);
2392+
if (tupDesc->natts!=2)
2393+
elog(ERROR,"[AQO] Incorrect number of output arguments");
23812394

23822395
/*
23832396
* Make forced cleanup: if at least one fss isn't actual, remove parent FS
@@ -2488,7 +2501,9 @@ aqo_cardinality_error(PG_FUNCTION_ARGS)
24882501
/* Build a tuple descriptor for our result type */
24892502
if (get_call_result_type(fcinfo,NULL,&tupDesc)!=TYPEFUNC_COMPOSITE)
24902503
elog(ERROR,"return type must be a row type");
2491-
Assert(tupDesc->natts==AQE_TOTAL_NCOLS);
2504+
2505+
if (tupDesc->natts!=AQE_TOTAL_NCOLS)
2506+
elog(ERROR,"[AQO] Incorrect number of output arguments");
24922507

24932508
tupstore=tuplestore_begin_heap(true, false,work_mem);
24942509
rsinfo->returnMode=SFRM_Materialize;
@@ -2556,8 +2571,8 @@ aqo_execution_time(PG_FUNCTION_ARGS)
25562571
MemoryContextper_query_ctx;
25572572
MemoryContextoldcontext;
25582573
Tuplestorestate*tupstore;
2559-
Datumvalues[AQE_TOTAL_NCOLS];
2560-
boolnulls[AQE_TOTAL_NCOLS];
2574+
Datumvalues[ET_TOTAL_NCOLS];
2575+
boolnulls[ET_TOTAL_NCOLS];
25612576
HASH_SEQ_STATUShash_seq;
25622577
QueriesEntry*qentry;
25632578
StatEntry*sentry;
@@ -2580,7 +2595,9 @@ aqo_execution_time(PG_FUNCTION_ARGS)
25802595
/* Build a tuple descriptor for our result type */
25812596
if (get_call_result_type(fcinfo,NULL,&tupDesc)!=TYPEFUNC_COMPOSITE)
25822597
elog(ERROR,"return type must be a row type");
2583-
Assert(tupDesc->natts==ET_TOTAL_NCOLS);
2598+
2599+
if (tupDesc->natts!=ET_TOTAL_NCOLS)
2600+
elog(ERROR,"[AQO] Incorrect number of output arguments");
25842601

25852602
tupstore=tuplestore_begin_heap(true, false,work_mem);
25862603
rsinfo->returnMode=SFRM_Materialize;
@@ -2713,7 +2730,7 @@ aqo_query_stat_update(PG_FUNCTION_ARGS)
27132730
PG_ARGISNULL(EST_ERROR))
27142731
PG_RETURN_BOOL(false);
27152732

2716-
queryid=PG_GETARG_INT64(AQ_QUERYID);
2733+
queryid=PG_GETARG_INT64(QUERYID);
27172734
stat_arg.execs_with_aqo=PG_GETARG_INT64(NEXECS_AQO);
27182735
stat_arg.execs_without_aqo=PG_GETARG_INT64(NEXECS);
27192736
if (queryid==0||stat_arg.execs_with_aqo<0||

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp