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

Commit2a4bba3

Browse files
author
Arthur Zakirov
committed
PGPRO-2601: Remove LastHSeqStatus and add test a cursor with the hash table
1 parent68989c2 commit2a4bba3

File tree

3 files changed

+40
-25
lines changed

3 files changed

+40
-25
lines changed

‎expected/pg_variables.out‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,8 @@ SELECT pgv_select('vars3', 'r1', 1);
730730

731731
(1 row)
732732

733-
SELECT pgv_select('vars3', 'r1') LIMIT 2;
733+
SELECT pgv_select('vars3', 'r1') LIMIT 2; -- warning
734+
WARNING: leaked hash_seq_search scan for hash table 0x561738129110
734735
pgv_select
735736
------------
736737
(,strNULL)
@@ -743,8 +744,34 @@ SELECT pgv_select('vars3', 'r1') LIMIT 2 OFFSET 2;
743744
(0,str00)
744745
(1 row)
745746

747+
-- PGPRO-2601 - Test a cursor with the hash table
748+
BEGIN;
749+
DECLARE r1_cur CURSOR FOR SELECT pgv_select('vars3', 'r1');
750+
FETCH 1 in r1_cur;
751+
pgv_select
752+
------------
753+
(,strNULL)
754+
(1 row)
755+
756+
SELECT pgv_select('vars3', 'r1');
757+
pgv_select
758+
------------
759+
(,strNULL)
760+
(2,)
761+
(0,str00)
762+
(3 rows)
763+
764+
FETCH 1 in r1_cur;
765+
pgv_select
766+
------------
767+
(2,)
768+
(1 row)
769+
770+
CLOSE r1_cur;
771+
COMMIT; -- warning
772+
WARNING: leaked hash_seq_search scan for hash table 0x561738129110
746773
-- Clean memory after unsuccessful creation of a variable
747-
SELECT pgv_insert('vars4', 'r1', row('str1', 'str1'));
774+
SELECT pgv_insert('vars4', 'r1', row('str1', 'str1')); -- fail
748775
ERROR: could not identify a hash function for type unknown
749776
SELECT package FROM pgv_stats() WHERE package = 'vars4';
750777
package

‎pg_variables.c‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,6 @@ static Variable *LastVariable = NULL;
108108
/* Recent row type id */
109109
staticOidLastTypeId=InvalidOid;
110110

111-
/*
112-
* Cache sequentially search through hash table status. It is necessary for
113-
* clean up if hash_seq_term() wasn't called or if we didn't scan the whole
114-
* table. In this case we need to manually call hash_seq_term() within
115-
* variable_ExecutorEnd().
116-
*/
117-
staticHASH_SEQ_STATUS*LastHSeqStatus=NULL;
118-
119111
/* Saved hook values for recall */
120112
staticExecutorEnd_hook_typeprev_ExecutorEnd=NULL;
121113

@@ -615,8 +607,6 @@ variable_select(PG_FUNCTION_ARGS)
615607
MemoryContextSwitchTo(oldcontext);
616608
PG_FREE_IF_COPY(package_name,0);
617609
PG_FREE_IF_COPY(var_name,1);
618-
619-
LastHSeqStatus=rstat;
620610
}
621611

622612
funcctx=SRF_PERCALL_SETUP();
@@ -633,7 +623,6 @@ variable_select(PG_FUNCTION_ARGS)
633623
}
634624
else
635625
{
636-
LastHSeqStatus=NULL;
637626
pfree(rstat);
638627
SRF_RETURN_DONE(funcctx);
639628
}
@@ -1212,8 +1201,6 @@ get_packages_stats(PG_FUNCTION_ARGS)
12121201
hash_seq_init(pstat,packagesHash);
12131202

12141203
funcctx->user_fctx=pstat;
1215-
1216-
LastHSeqStatus=pstat;
12171204
}
12181205
else
12191206
funcctx->user_fctx=NULL;
@@ -1260,7 +1247,6 @@ get_packages_stats(PG_FUNCTION_ARGS)
12601247
}
12611248
else
12621249
{
1263-
LastHSeqStatus=NULL;
12641250
pfree(pstat);
12651251
SRF_RETURN_DONE(funcctx);
12661252
}
@@ -2126,7 +2112,6 @@ pgvSubTransCallback(SubXactEvent event, SubTransactionId mySubid,
21262112
break;
21272113
}
21282114
}
2129-
LastHSeqStatus=NULL;
21302115
}
21312116

21322117
/*
@@ -2155,7 +2140,6 @@ pgvTransCallback(XactEvent event, void *arg)
21552140
break;
21562141
}
21572142
}
2158-
LastHSeqStatus=NULL;
21592143
}
21602144

21612145
/*
@@ -2164,11 +2148,6 @@ pgvTransCallback(XactEvent event, void *arg)
21642148
staticvoid
21652149
variable_ExecutorEnd(QueryDesc*queryDesc)
21662150
{
2167-
if (LastHSeqStatus)
2168-
{
2169-
hash_seq_term(LastHSeqStatus);
2170-
LastHSeqStatus=NULL;
2171-
}
21722151
if (prev_ExecutorEnd)
21732152
prev_ExecutorEnd(queryDesc);
21742153
else

‎sql/pg_variables.sql‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,20 @@ $$BEGIN
207207
END$$;
208208
-- Check that the hash table was cleaned up after rollback
209209
SELECT pgv_select('vars3','r1',1);
210-
SELECT pgv_select('vars3','r1')LIMIT2;
210+
SELECT pgv_select('vars3','r1')LIMIT2;-- warning
211211
SELECT pgv_select('vars3','r1')LIMIT2 OFFSET2;
212212

213+
-- PGPRO-2601 - Test a cursor with the hash table
214+
BEGIN;
215+
DECLARE r1_cur CURSOR FORSELECT pgv_select('vars3','r1');
216+
FETCH1in r1_cur;
217+
SELECT pgv_select('vars3','r1');
218+
FETCH1in r1_cur;
219+
CLOSE r1_cur;
220+
COMMIT;-- warning
221+
213222
-- Clean memory after unsuccessful creation of a variable
214-
SELECT pgv_insert('vars4','r1', row('str1','str1'));
223+
SELECT pgv_insert('vars4','r1', row('str1','str1'));-- fail
215224
SELECT packageFROM pgv_stats()WHERE package='vars4';
216225

217226
-- Remove package if it is empty

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp