In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how the PostgreSQL function returns OUT parameters". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how the PostgreSQL function returns OUT parameters.
1. The field meaning of the system table pg_proc
Prorettype: return value type
Proretset: whether the return value is a collection
Proargmodes: parameter mode (IN, OUT, INOUT)
2. Find ready-made examples
In general, we can find ways to use it in the existing code of PG:
SELECT proname,proargmodes,prorettype::regtype,array_position (proargmodes,'o') FROM pg_proc WHERE NOT proretset AND proargmodes IS NOT NULL AND (array_position (proargmodes,'o') IS NOT NULL OR array_position (proargmodes,'b') IS NOT NULL) LIMIT 10
Returns the function definition that contains the OUT and INOUT parameters, and'b'is the INOUT parameter. Note the use of:: regtype above to enhance the readability of the results:
Pg_stat_get_archiver | {record | 1pg_event_trigger_table_rewrite_oid | {o oid | 1
More results.
3. Return multiple OUT parameters
Open the function pg_stat_get_archiver
/ / define TupleDesc by yourself, the quantity does not include IN input parameter / / same as the construction method of returned result set mentioned earlier tupdesc = CreateTemplateTupleDesc (7); / / different places BlessTupleDesc (tupdesc); / * build values and nulls array * / / return result PG_RETURN_DATUM (HeapTupleGetDatum (tupdesc, values, nulls))
The result set function calls BlessTupleDesc in TupleDescGetAttInMetadata.
4. Return a single output parameter
Call the PG_RETURN_xxx series directly and return it. In the pg_event_trigger_table_rewrite_oid function:
PG_RETURN_OID (currentEventTriggerState- > table_rewrite_oid)
5. INOUT parameters
There are no examples of official code, guess can be like this: the input value is obtained by PG_GETARG_xx, the output is the same as OUT, you can write a code to try if you are interested.
At this point, I believe you have a deeper understanding of "how the PostgreSQL function returns OUT parameters". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.