@@ -61,9 +61,9 @@ typedef struct pgspSharedState /* Shared state of the extension. */
6161
6262typedef struct pgspCtx { /* Used as `funcctx->user_fctx` in pg_show_plans(). */
6363 HASH_SEQ_STATUS * hash_seq ;
64- pgspEntry * pgvp_tmp_entry ; /* PGVP entry currently processing. */
64+ pgspEntry * pgsp_tmp_entry ; /* PGSP entry currently processing. */
6565 int curr_nest ; /* Current nest level porcessing. */
66- bool is_done ; /* Done processing current PGVP entry? */
66+ bool is_done ; /* Done processing current PGSP entry? */
6767} pgspCtx ;
6868
6969/* Function Prototypes */
@@ -99,7 +99,7 @@ static bool is_allowed_role(void);
9999/* Hook functions. */
100100/* Ask for shared memory. */
101101#if PG_VERSION_NUM >= 150000
102- static void pgvp_shmem_request (void );
102+ static void pgsp_shmem_request (void );
103103#endif
104104static void pgsp_shmem_startup (void );
105105/* Saves query plans to the shared hash table. */
@@ -190,7 +190,7 @@ _PG_init(void)
190190 /* Save old hooks, and install new ones. */
191191#if PG_VERSION_NUM >= 150000
192192 prev_shmem_request_hook = shmem_request_hook ;
193- shmem_request_hook = pgvp_shmem_request ;
193+ shmem_request_hook = pgsp_shmem_request ;
194194#else
195195 RequestAddinShmemSpace (shmem_required ());
196196 RequestNamedLWLockTranche ("pg_show_plans" , 1 );
@@ -239,13 +239,13 @@ compare_hash_key(const void *key1, const void *key2, Size keysize)
239239static int
240240ensure_cached (void )
241241{
242- pgspHashKey pgvp_hash_hey ;
242+ pgspHashKey pgsp_hash_hey ;
243243
244244 if (pgsp_cache )
245245 return 1 ;
246246
247- pgvp_hash_hey .pid = MyProcPid ;
248- pgsp_cache = create_hash_entry (& pgvp_hash_hey );
247+ pgsp_hash_hey .pid = MyProcPid ;
248+ pgsp_cache = create_hash_entry (& pgsp_hash_hey );
249249 if (!pgsp_cache )
250250 return 0 ; /* Ran out of memory. */
251251
@@ -395,7 +395,7 @@ is_allowed_role(void)
395395
396396#if PG_VERSION_NUM >= 150000
397397static void
398- pgvp_shmem_request (void )
398+ pgsp_shmem_request (void )
399399{
400400 if (prev_shmem_request_hook )
401401 prev_shmem_request_hook ();
@@ -519,9 +519,9 @@ pg_show_plans(PG_FUNCTION_ARGS)
519519 int offset ;
520520 int i ;
521521
522- pgspCtx * pgvp_ctx ;
522+ pgspCtx * pgsp_ctx ;
523523 HASH_SEQ_STATUS * hash_seq ;
524- pgspEntry * pgvp_tmp_entry ;
524+ pgspEntry * pgsp_tmp_entry ;
525525 int curr_nest ;
526526 bool is_done ;
527527
@@ -534,12 +534,12 @@ pg_show_plans(PG_FUNCTION_ARGS)
534534 oldcontext = MemoryContextSwitchTo (funcctx -> multi_call_memory_ctx );
535535
536536 LWLockAcquire (pgsp -> lock , LW_SHARED );
537- pgvp_ctx = (pgspCtx * )palloc (sizeof (pgspCtx ));
538- pgvp_ctx -> is_done = true;
539- pgvp_ctx -> curr_nest = 0 ;
540- pgvp_ctx -> hash_seq = (HASH_SEQ_STATUS * )palloc (sizeof (HASH_SEQ_STATUS ));
541- hash_seq_init (pgvp_ctx -> hash_seq , pgsp_hash );
542- funcctx -> user_fctx = (void * )pgvp_ctx ;
537+ pgsp_ctx = (pgspCtx * )palloc (sizeof (pgspCtx ));
538+ pgsp_ctx -> is_done = true;
539+ pgsp_ctx -> curr_nest = 0 ;
540+ pgsp_ctx -> hash_seq = (HASH_SEQ_STATUS * )palloc (sizeof (HASH_SEQ_STATUS ));
541+ hash_seq_init (pgsp_ctx -> hash_seq , pgsp_hash );
542+ funcctx -> user_fctx = (void * )pgsp_ctx ;
543543 funcctx -> max_calls = hash_get_num_entries (pgsp_hash );
544544
545545 if (get_call_result_type (fcinfo , NULL , & tupdesc ) != TYPEFUNC_COMPOSITE )
@@ -554,11 +554,11 @@ pg_show_plans(PG_FUNCTION_ARGS)
554554
555555 funcctx = SRF_PERCALL_SETUP ();
556556 /* Restore context. */
557- pgvp_ctx = (pgspCtx * )funcctx -> user_fctx ;
558- hash_seq = pgvp_ctx -> hash_seq ;
559- is_done = pgvp_ctx -> is_done ;
560- pgvp_tmp_entry = pgvp_ctx -> pgvp_tmp_entry ;
561- curr_nest = pgvp_ctx -> curr_nest ;
557+ pgsp_ctx = (pgspCtx * )funcctx -> user_fctx ;
558+ hash_seq = pgsp_ctx -> hash_seq ;
559+ is_done = pgsp_ctx -> is_done ;
560+ pgsp_tmp_entry = pgsp_ctx -> pgsp_tmp_entry ;
561+ curr_nest = pgsp_ctx -> curr_nest ;
562562 /* Pull other stuff from `funcctx`. */
563563 call_cntr = funcctx -> call_cntr ;
564564 max_calls = funcctx -> max_calls ;
@@ -570,55 +570,55 @@ pg_show_plans(PG_FUNCTION_ARGS)
570570
571571 if (is_done ) /* Done processing a hash entry? */
572572 { /* Grab a new one. */
573- pgvp_tmp_entry = hash_seq_search (hash_seq );
573+ pgsp_tmp_entry = hash_seq_search (hash_seq );
574574 /* Skip empty entries and the ones the user is not
575575 * allowed to see. */
576576 for (;;) {
577- if (pgvp_tmp_entry -> n_plans >= 1 ) {
577+ if (pgsp_tmp_entry -> n_plans >= 1 ) {
578578 if (is_allowed_role ())
579579 break ;
580- else if (pgvp_tmp_entry -> user_id == GetUserId ())
580+ else if (pgsp_tmp_entry -> user_id == GetUserId ())
581581 break ;
582582 }
583583 if (call_cntr == max_calls - 1 ) { /* No more entries. */
584584 hash_seq_term (hash_seq );
585585 LWLockRelease (pgsp -> lock );
586586 SRF_RETURN_DONE (funcctx );
587587 }
588- pgvp_tmp_entry = hash_seq_search (hash_seq );
588+ pgsp_tmp_entry = hash_seq_search (hash_seq );
589589 call_cntr ++ ;
590590 }
591- SpinLockAcquire (& pgvp_tmp_entry -> mutex );
591+ SpinLockAcquire (& pgsp_tmp_entry -> mutex );
592592 }
593593
594594 /* A single hash entry may store multiple (nested) plans, so
595595 * count offset to get the desired plan. */
596596 offset = 0 ;
597597 for (i = 0 ; i < curr_nest ; i ++ )
598- offset += pgvp_tmp_entry -> plan_len [i ] + 1 ;
598+ offset += pgsp_tmp_entry -> plan_len [i ] + 1 ;
599599
600600 MemSet (nulls , 0 , sizeof (nulls ));
601- values [0 ] = Int32GetDatum (pgvp_tmp_entry -> hash_key .pid );
601+ values [0 ] = Int32GetDatum (pgsp_tmp_entry -> hash_key .pid );
602602 values [1 ] = Int32GetDatum (curr_nest );
603- values [2 ] = ObjectIdGetDatum (pgvp_tmp_entry -> user_id );
604- values [3 ] = ObjectIdGetDatum (pgvp_tmp_entry -> db_id );
605- values [4 ] = CStringGetTextDatum (pgvp_tmp_entry -> plan + offset );
603+ values [2 ] = ObjectIdGetDatum (pgsp_tmp_entry -> user_id );
604+ values [3 ] = ObjectIdGetDatum (pgsp_tmp_entry -> db_id );
605+ values [4 ] = CStringGetTextDatum (pgsp_tmp_entry -> plan + offset );
606606 htup = heap_form_tuple (funcctx -> tuple_desc , values , nulls );
607607
608- if (curr_nest < pgvp_tmp_entry -> n_plans - 1 )
608+ if (curr_nest < pgsp_tmp_entry -> n_plans - 1 )
609609 { /* Still have nested plans. */
610610 curr_nest ++ ;
611611 call_cntr -- ; /* May not be legal, but it works. */
612612 is_done = false;
613613 } else { /* No more nested plans, get a new entry. */
614614 curr_nest = 0 ;
615615 is_done = true;
616- SpinLockRelease (& pgvp_tmp_entry -> mutex );
616+ SpinLockRelease (& pgsp_tmp_entry -> mutex );
617617 }
618618 /* Save values back to the context. */
619- pgvp_ctx -> is_done = is_done ;
620- pgvp_ctx -> curr_nest = curr_nest ;
621- pgvp_ctx -> pgvp_tmp_entry = pgvp_tmp_entry ;
619+ pgsp_ctx -> is_done = is_done ;
620+ pgsp_ctx -> curr_nest = curr_nest ;
621+ pgsp_ctx -> pgsp_tmp_entry = pgsp_tmp_entry ;
622622 funcctx -> call_cntr = call_cntr ;
623623
624624 SRF_RETURN_NEXT (funcctx , HeapTupleGetDatum (htup ));
0 commit comments