| <!doctype html> | |
| <html lang="en" dir="ltr" class="docs-wrapper plugin-docs plugin-id-default docs-version-2.x docs-doc-page docs-doc-id-sql-stmts/create-function" data-has-hydrated="false"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="generator" content="Docusaurus v3.10.2"> | |
| <title data-rh="true">CREATE FUNCTION | Apache Cloudberry (Incubating)</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:url" content="https://cloudberry.apache.org/docs/sql-stmts/create-function"><meta data-rh="true" property="og:locale" content="en"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docusaurus_version" content="2.x"><meta data-rh="true" name="docusaurus_tag" content="docs-default-2.x"><meta data-rh="true" name="docsearch:version" content="2.x"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-2.x"><meta data-rh="true" property="og:title" content="CREATE FUNCTION | Apache Cloudberry (Incubating)"><meta data-rh="true" name="description" content="Defines a new function."><meta data-rh="true" property="og:description" content="Defines a new function."><link data-rh="true" rel="icon" href="/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://cloudberry.apache.org/docs/sql-stmts/create-function"><link data-rh="true" rel="alternate" href="https://cloudberry.apache.org/docs/sql-stmts/create-function" hreflang="en"><link data-rh="true" rel="alternate" href="https://cloudberry.apache.org/docs/sql-stmts/create-function" hreflang="x-default"><link data-rh="true" rel="alternate" type="text/markdown" title="Markdown source" href="https://cloudberry.apache.org/docs/sql-stmts/create-function.md"><link rel="alternate" type="application/rss+xml" href="/blog/rss.xml" title="Apache Cloudberry (Incubating) is one advanced and mature open-source MPP (Massively Parallel Processing) databases available. RSS Feed"> | |
| <link rel="alternate" type="application/atom+xml" href="/blog/atom.xml" title="Apache Cloudberry (Incubating) is one advanced and mature open-source MPP (Massively Parallel Processing) databases available. Atom Feed"> | |
| <link rel="alternate" type="application/json" href="/blog/feed.json" title="Apache Cloudberry (Incubating) is one advanced and mature open-source MPP (Massively Parallel Processing) databases available. JSON Feed"> | |
| <link rel="preconnect" href="https://analytics.apache.org/"> | |
| <script>var _paq=window._paq=window._paq||[];_paq.push(["setRequestMethod","POST"]),_paq.push(["trackPageView"]),_paq.push(["enableLinkTracking"]),_paq.push(["enableHeartBeatTimer"]),function(){var e="https://analytics.apache.org/";_paq.push(["setRequestMethod","POST"]),_paq.push(["setTrackerUrl",e+"matomo.php"]),_paq.push(["setSiteId","66"]);var a=document,t=a.createElement("script"),p=a.getElementsByTagName("script")[0];t.type="text/javascript",t.async=!0,t.src=e+"matomo.js",p.parentNode.insertBefore(t,p)}()</script> | |
| <script src="https://widget.kapa.ai/kapa-widget.bundle.js" data-website-id="9d55c09f-0362-44eb-a3bf-37ba3c12d572" data-project-name="Apache Cloudberry" data-project-color="#ff5900" data-project-logo="https://cloudberry.apache.org/img/favicon.ico" data-modal-title="Apache Cloudberry AI Assistant" data-modal-disclaimer="Answers are generated by AI from the [Apache Cloudberry documentation](https://cloudberry.apache.org/docs/) and may be inaccurate. Please verify important details against the docs." data-modal-example-questions="How do I install Apache Cloudberry?,How is Cloudberry different from Greenplum?,How do I load data with gpfdist?" data-user-analytics-cookie-enabled="false" data-bot-protection-mechanism="hcaptcha" data-consent-required="true" data-consent-screen-disclaimer="By clicking &quot;I agree, let's chat&quot;, you consent to the use of the AI assistant in accordance with kapa.ai's [Privacy Policy](https://www.kapa.ai/content/privacy-policy). This service uses hCaptcha, which is subject to hCaptcha's [Privacy Policy](https://www.hcaptcha.com/privacy) and [Terms of Service](https://www.hcaptcha.com/terms)." async></script><link rel="stylesheet" href="/assets/css/styles.bbfb43b6.css"> | |
| <script src="/assets/js/runtime~main.7a592a8d.js" defer="defer"></script> | |
| <script src="/assets/js/main.85f72eb7.js" defer="defer"></script> | |
| </head> | |
| <body> | |
| <svg style="display: none;"><defs> | |
| <symbol id="theme-svg-external-link" viewBox="0 0 24 24"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"/></symbol> | |
| </defs></svg> | |
| <script>!function(){var t=function(){try{return new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}}()||function(){try{return window.localStorage.getItem("theme")}catch(t){}}();document.documentElement.setAttribute("data-theme",t||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")),document.documentElement.setAttribute("data-theme-choice",t||"system")}(),function(){try{const c=new URLSearchParams(window.location.search).entries();for(var[t,e]of c)if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}()</script><div id="__docusaurus"><div role="region" aria-label="Skip to main content"><a class="skipToContent_fXgn" href="#__docusaurus_skipToContent_fallback">Skip to main content</a></div><div class="tipsWrap_WWTe"><div class="tipsContent_sMsy"><div class="text_VINd"><a href="https://github.com/apache/cloudberry" target="_blank" rel="noopener noreferrer"><span>If you like Apache Cloudberry (Incubating), give it a star on GitHub! </span><img src="/img/home/hcard/star.svg" alt=""></a></div><div class="close_vVex"><img src="/img/home/hcard/close.svg" alt=""></div></div></div><nav aria-label="Main" class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><div class="nav-left-logo"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/apache_cloudberry_color_black.svg" alt="Apache Cloudberry (Incubating)" class="themedComponent_mlkZ themedComponent--light_NVdE"><img src="/img/apache_cloudberry_color_white.svg" alt="Apache Cloudberry (Incubating)" class="themedComponent_mlkZ themedComponent--dark_xIcU"></div></a></div></div><div class="navbar__items navbar__items--right"><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">Docs</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/docs/next">Next</a></li><li><a aria-current="page" class="dropdown__link dropdown__link--active" href="/docs/">2.x (Current)</a></li><li><a class="dropdown__link" href="/docs/1.x">1.x</a></li></ul></div><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">Community</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/community">Overview</a></li><li><a class="dropdown__link" href="/community/slack">Slack Guide</a></li><li><a class="dropdown__link" href="/community/discord">Discord Guide</a></li><li><a class="dropdown__link" href="/community/wechat">WeChat Guide</a></li><li><a class="dropdown__link" href="/community/events">Community Events</a></li><li><a class="dropdown__link" href="/community/bi-weekly-meetings">Bi-weekly Meetings</a></li><li><a class="dropdown__link" href="/community/mailing-lists">Mailing Lists</a></li><li><a class="dropdown__link" href="/community/brand">Brand Guidelines</a></li><li><a class="dropdown__link" href="/community/accounts">Official Accounts</a></li><li><a class="dropdown__link" href="/community/security">Security Policy</a></li></ul></div><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">Contribute</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/contribute">Overview</a></li><li><a class="dropdown__link" href="/contribute/how-to-contribute">How to Contribute</a></li><li><a class="dropdown__link" href="/contribute/git">Working with Git & GitHub</a></li><li><a class="dropdown__link" href="/contribute/code">Code Contribution Guide</a></li><li><a class="dropdown__link" href="/contribute/proposal">Proposal Guide</a></li><li><a class="dropdown__link" href="/contribute/doc">Doc Contribution Guide</a></li></ul></div><a class="navbar__item navbar__link" href="/blog">Blog</a><a class="navbar__item navbar__link" href="/releases">Download</a><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">Team</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/team">Who we are</a></li><li><a class="dropdown__link" href="/team/new-committers">Inviting New Committers</a></li><li><a class="dropdown__link" href="/team/new-ppmc-member">Inviting New PPMC Members</a></li><li><a class="dropdown__link" href="/team/sign-icla">Sign ICLA</a></li><li><a class="dropdown__link" href="/team/setup-apache-email-account">Setup the Apache account</a></li></ul></div><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">Resources</a><ul class="dropdown__menu"><li><a href="https://github.com/apache/cloudberry/wiki" target="_blank" rel="noopener noreferrer" class="dropdown__link">Wiki</a></li><li><a href="https://github.com/apache/cloudberry/discussions/868" target="_blank" rel="noopener noreferrer" class="dropdown__link">Roadmap</a></li><li><a href="https://github.com/apache/cloudberry/discussions" target="_blank" rel="noopener noreferrer" class="dropdown__link">Forum</a></li><li><a class="dropdown__link" href="/support">Support</a></li><li><a class="dropdown__link" href="/powered-by">Powered By</a></li><li><a class="dropdown__link" href="/sizing/">Sizing Calculator</a></li></ul></div><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">ASF</a><ul class="dropdown__menu"><li><a href="https://www.apache.org/" target="_blank" rel="noopener noreferrer" class="dropdown__link">Foundation</a></li><li><a href="https://www.apache.org/licenses/" target="_blank" rel="noopener noreferrer" class="dropdown__link">License</a></li><li><a href="https://www.apache.org/events/current-event.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Events</a></li><li><a href="https://privacy.apache.org/policies/privacy-policy-public.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Privacy</a></li><li><a href="https://www.apache.org/security/" target="_blank" rel="noopener noreferrer" class="dropdown__link">Security</a></li><li><a href="https://www.apache.org/foundation/sponsorship.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Sponsorship</a></li><li><a href="https://www.apache.org/foundation/thanks.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Thanks</a></li><li><a href="https://www.apache.org/foundation/policies/conduct" target="_blank" rel="noopener noreferrer" class="dropdown__link">Code of Conduct</a></li></ul></div><div class="toggle_vylO colorModeToggle_x44X check-theme-switch"><button class="clean-btn toggleButton_gllP toggleButtonDisabled_aARS" type="button" disabled="" title="dark mode" aria-label="Switch between dark and light mode (currently dark mode)"><svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" class="toggleIcon_g3eP lightToggleIcon_pyhR"><path fill="currentColor" d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"></path></svg><svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" class="toggleIcon_g3eP darkToggleIcon_wfgR"><path fill="currentColor" d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"></path></svg><svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" class="toggleIcon_g3eP systemToggleIcon_QzmC"><path fill="currentColor" d="m12 21c4.971 0 9-4.029 9-9s-4.029-9-9-9-9 4.029-9 9 4.029 9 9 9zm4.95-13.95c1.313 1.313 2.05 3.093 2.05 4.95s-0.738 3.637-2.05 4.95c-1.313 1.313-3.093 2.05-4.95 2.05v-14c1.857 0 3.637 0.737 4.95 2.05z"></path></svg></button></div><div class="navbarSearchContainer_dCNk"><div class="navbar__search searchBarContainer_NW3z"><input placeholder="Search" aria-label="Search" class="navbar__search-input" value=""><div class="loadingRing_RJI3 searchBarLoadingRing_YnHq"><div></div><div></div><div></div><div></div></div></div></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="__docusaurus_skipToContent_fallback" class="theme-layout-main main-wrapper mainWrapper_z2l0"><div class="docsWrapper_BF9v"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docRoot_Rg9N"><aside class="theme-doc-sidebar-container docSidebarContainer_RSuS"><div class="sidebarViewport_pYEE"><div class="sidebar_njMd"><nav aria-label="Docs sidebar" class="menu thin-scrollbar menu_SIkG"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/docs/"><span class="categoryLinkLabel_W154">Introduction</span></a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/docs/build/"><span class="categoryLinkLabel_W154">Build Apache Cloudberry</span></a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist" href="/docs/deployment/"><span class="categoryLinkLabel_W154">Deploy in Production</span></a><button aria-label="Expand sidebar category 'Deploy in Production'" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/docs/database-basic/create-and-manage-database"><span class="categoryLinkLabel_W154">Basic Database Operations</span></a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist" href="/docs/data-loading/"><span class="categoryLinkLabel_W154">Load Data</span></a><button aria-label="Expand sidebar category 'Load Data'" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/docs/operate-with-data/operate-with-db-objects/create-and-manage-tablespaces"><span class="categoryLinkLabel_W154">Operate with Data</span></a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/docs/performance/define-database-performance"><span class="categoryLinkLabel_W154">Optimize Performance</span></a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist" href="/docs/security/"><span class="categoryLinkLabel_W154">Security and Permission</span></a><button aria-label="Expand sidebar category 'Security and Permission'" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/docs/sys-admin/configure-database-system"><span class="categoryLinkLabel_W154">Manage System</span></a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/docs/developer/develop-background-process-worker"><span class="categoryLinkLabel_W154">Developer</span></a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/docs/ecosystem/sql-clients/dbeaver"><span class="categoryLinkLabel_W154">Ecosystem</span></a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" role="button" aria-expanded="true" href="/docs/sql-stmts/"><span class="categoryLinkLabel_W154">References</span></a></div><ul class="menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--active" tabindex="0" href="/docs/sql-stmts/"><span class="categoryLinkLabel_W154">SQL Statements</span></a><button aria-label="Collapse sidebar category 'SQL Statements'" aria-expanded="true" type="button" class="clean-btn menu__caret"></button></div><ul class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/abort"><span class="linkLabel_WmDU">ABORT</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-aggregate"><span class="linkLabel_WmDU">ALTER AGGREGATE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-collation"><span class="linkLabel_WmDU">ALTER COLLATION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-conversion"><span class="linkLabel_WmDU">ALTER CONVERSION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-database"><span class="linkLabel_WmDU">ALTER DATABASE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-default-privileges"><span class="linkLabel_WmDU">ALTER DEFAULT PRIVILEGES</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-domain"><span class="linkLabel_WmDU">ALTER DOMAIN</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-extension"><span class="linkLabel_WmDU">ALTER EXTENSION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-external-table"><span class="linkLabel_WmDU">ALTER EXTERNAL TABLE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-foreign-data-wrapper"><span class="linkLabel_WmDU">ALTER FOREIGN DATA WRAPPER</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-foreign-table"><span class="linkLabel_WmDU">ALTER FOREIGN TABLE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-function"><span class="linkLabel_WmDU">ALTER FUNCTION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-group"><span class="linkLabel_WmDU">ALTER GROUP</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-index"><span class="linkLabel_WmDU">ALTER INDEX</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-language"><span class="linkLabel_WmDU">ALTER LANGUAGE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-materialized-view"><span class="linkLabel_WmDU">ALTER MATERIALIZED VIEW</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-operator-class"><span class="linkLabel_WmDU">ALTER OPERATOR CLASS</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-operator-family"><span class="linkLabel_WmDU">ALTER OPERATOR FAMILY</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-operator"><span class="linkLabel_WmDU">ALTER OPERATOR</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-policy"><span class="linkLabel_WmDU">ALTER POLICY</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-procedure"><span class="linkLabel_WmDU">ALTER PROCEDURE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-protocol"><span class="linkLabel_WmDU">ALTER PROTOCOL</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-resource-group"><span class="linkLabel_WmDU">ALTER RESOURCE GROUP</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-resource-queue"><span class="linkLabel_WmDU">ALTER RESOURCE QUEUE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-role"><span class="linkLabel_WmDU">ALTER ROLE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-routine"><span class="linkLabel_WmDU">ALTER ROUTINE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-rule"><span class="linkLabel_WmDU">ALTER RULE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-schema"><span class="linkLabel_WmDU">ALTER SCHEMA</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-sequence"><span class="linkLabel_WmDU">ALTER SEQUENCE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-server"><span class="linkLabel_WmDU">ALTER SERVER</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-statistics"><span class="linkLabel_WmDU">ALTER STATISTICS</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-table"><span class="linkLabel_WmDU">ALTER TABLE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-tablespace"><span class="linkLabel_WmDU">ALTER TABLESPACE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-text-search-configuration"><span class="linkLabel_WmDU">ALTER TEXT SEARCH CONFIGURATION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-text-search-dictionary"><span class="linkLabel_WmDU">ALTER TEXT SEARCH DICTIONARY</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-text-search-parser"><span class="linkLabel_WmDU">ALTER TEXT SEARCH PARSER</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-text-search-template"><span class="linkLabel_WmDU">ALTER TEXT SEARCH TEMPLATE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-trigger"><span class="linkLabel_WmDU">ALTER TRIGGER</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-type"><span class="linkLabel_WmDU">ALTER TYPE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-user-mapping"><span class="linkLabel_WmDU">ALTER USER MAPPING</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-user"><span class="linkLabel_WmDU">ALTER USER</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/alter-view"><span class="linkLabel_WmDU">ALTER VIEW</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/analyze"><span class="linkLabel_WmDU">ANALYZE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/begin"><span class="linkLabel_WmDU">BEGIN</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/call"><span class="linkLabel_WmDU">CALL</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/checkpoint"><span class="linkLabel_WmDU">CHECKPOINT</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/close"><span class="linkLabel_WmDU">CLOSE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/cluster"><span class="linkLabel_WmDU">CLUSTER</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/comment"><span class="linkLabel_WmDU">COMMENT</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/commit"><span class="linkLabel_WmDU">COMMIT</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/copy"><span class="linkLabel_WmDU">COPY</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-access-method"><span class="linkLabel_WmDU">CREATE ACCESS METHOD</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-aggregate"><span class="linkLabel_WmDU">CREATE AGGREGATE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-cast"><span class="linkLabel_WmDU">CREATE CAST</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-collation"><span class="linkLabel_WmDU">CREATE COLLATION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-conversion"><span class="linkLabel_WmDU">CREATE CONVERSION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-database"><span class="linkLabel_WmDU">CREATE DATABASE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-domain"><span class="linkLabel_WmDU">CREATE DOMAIN</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-extension"><span class="linkLabel_WmDU">CREATE EXTENSION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-external-table"><span class="linkLabel_WmDU">CREATE EXTERNAL TABLE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-foreign-data-wrapper"><span class="linkLabel_WmDU">CREATE FOREIGN DATA WRAPPER</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-foreign-table"><span class="linkLabel_WmDU">CREATE FOREIGN TABLE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/docs/sql-stmts/create-function"><span class="linkLabel_WmDU">CREATE FUNCTION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-group"><span class="linkLabel_WmDU">CREATE GROUP</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-index"><span class="linkLabel_WmDU">CREATE INDEX</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-language"><span class="linkLabel_WmDU">CREATE LANGUAGE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-materialized-view"><span class="linkLabel_WmDU">CREATE MATERIALIZED VIEW</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-operator-class"><span class="linkLabel_WmDU">CREATE OPERATOR CLASS</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-operator-family"><span class="linkLabel_WmDU">CREATE OPERATOR FAMILY</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-operator"><span class="linkLabel_WmDU">CREATE OPERATOR</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-policy"><span class="linkLabel_WmDU">CREATE POLICY</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-procedure"><span class="linkLabel_WmDU">CREATE PROCEDURE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-protocol"><span class="linkLabel_WmDU">CREATE PROTOCOL</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-resource-group"><span class="linkLabel_WmDU">CREATE RESOURCE GROUP</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-resource-queue"><span class="linkLabel_WmDU">CREATE RESOURCE QUEUE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-role"><span class="linkLabel_WmDU">CREATE ROLE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-rule"><span class="linkLabel_WmDU">CREATE RULE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-schema"><span class="linkLabel_WmDU">CREATE SCHEMA</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-sequence"><span class="linkLabel_WmDU">CREATE SEQUENCE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-server"><span class="linkLabel_WmDU">CREATE SERVER</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-statistics"><span class="linkLabel_WmDU">CREATE STATISTICS</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-table-as"><span class="linkLabel_WmDU">CREATE TABLE AS</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-table"><span class="linkLabel_WmDU">CREATE TABLE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-tablespace"><span class="linkLabel_WmDU">CREATE TABLESPACE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-text-search-configuration"><span class="linkLabel_WmDU">CREATE TEXT SEARCH CONFIGURATION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-text-search-dictionary"><span class="linkLabel_WmDU">CREATE TEXT SEARCH DICTIONARY</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-text-search-parser"><span class="linkLabel_WmDU">CREATE TEXT SEARCH PARSER</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-text-search-template"><span class="linkLabel_WmDU">CREATE TEXT SEARCH TEMPLATE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-transform"><span class="linkLabel_WmDU">CREATE TRANSFORM</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-trigger"><span class="linkLabel_WmDU">CREATE TRIGGER</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-type"><span class="linkLabel_WmDU">CREATE TYPE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-user-mapping"><span class="linkLabel_WmDU">CREATE USER MAPPING</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-user"><span class="linkLabel_WmDU">CREATE USER</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/create-view"><span class="linkLabel_WmDU">CREATE VIEW</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/deallocate"><span class="linkLabel_WmDU">DEALLOCATE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/declare"><span class="linkLabel_WmDU">DECLARE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/delete"><span class="linkLabel_WmDU">DELETE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/discard"><span class="linkLabel_WmDU">DISCARD</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/do"><span class="linkLabel_WmDU">DO</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-access-method"><span class="linkLabel_WmDU">DROP ACCESS METHOD</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-aggregate"><span class="linkLabel_WmDU">DROP AGGREGATE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-cast"><span class="linkLabel_WmDU">DROP CAST</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-collation"><span class="linkLabel_WmDU">DROP COLLATION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-conversion"><span class="linkLabel_WmDU">DROP CONVERSION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-database"><span class="linkLabel_WmDU">DROP DATABASE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-domain"><span class="linkLabel_WmDU">DROP DOMAIN</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-extension"><span class="linkLabel_WmDU">DROP EXTENSION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-external-table"><span class="linkLabel_WmDU">DROP EXTERNAL TABLE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-foreign-data-wrapper"><span class="linkLabel_WmDU">DROP FOREIGN DATA WRAPPER</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-foreign-table"><span class="linkLabel_WmDU">DROP FOREIGN TABLE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-function"><span class="linkLabel_WmDU">DROP FUNCTION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-group"><span class="linkLabel_WmDU">DROP GROUP</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-index"><span class="linkLabel_WmDU">DROP INDEX</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-language"><span class="linkLabel_WmDU">DROP LANGUAGE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-materialized-view"><span class="linkLabel_WmDU">DROP MATERIALIZED VIEW</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-operator-class"><span class="linkLabel_WmDU">DROP OPERATOR CLASS</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-operator-family"><span class="linkLabel_WmDU">DROP OPERATOR FAMILY</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-operator"><span class="linkLabel_WmDU">DROP OPERATOR</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-owned"><span class="linkLabel_WmDU">DROP OWNED</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-policy"><span class="linkLabel_WmDU">DROP POLICY</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-procedure"><span class="linkLabel_WmDU">DROP PROCEDURE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-protocol"><span class="linkLabel_WmDU">DROP PROTOCOL</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-resource-group"><span class="linkLabel_WmDU">DROP RESOURCE GROUP</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-resource-queue"><span class="linkLabel_WmDU">DROP RESOURCE QUEUE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-role"><span class="linkLabel_WmDU">DROP ROLE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-routine"><span class="linkLabel_WmDU">DROP ROUTINE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-rule"><span class="linkLabel_WmDU">DROP RULE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-schema"><span class="linkLabel_WmDU">DROP SCHEMA</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-sequence"><span class="linkLabel_WmDU">DROP SEQUENCE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-server"><span class="linkLabel_WmDU">DROP SERVER</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-statistics"><span class="linkLabel_WmDU">DROP STATISTICS</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-table"><span class="linkLabel_WmDU">DROP TABLE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-tablespace"><span class="linkLabel_WmDU">DROP TABLESPACE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-text-search-configuration"><span class="linkLabel_WmDU">DROP TEXT SEARCH CONFIGURATION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-text-search-dictionary"><span class="linkLabel_WmDU">DROP TEXT SEARCH DICTIONARY</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-text-search-parser"><span class="linkLabel_WmDU">DROP TEXT SEARCH PARSER</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-text-search-template"><span class="linkLabel_WmDU">DROP TEXT SEARCH TEMPLATE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-transform"><span class="linkLabel_WmDU">DROP TRANSFORM</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-trigger"><span class="linkLabel_WmDU">DROP TRIGGER</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-type"><span class="linkLabel_WmDU">DROP TYPE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-user-mapping"><span class="linkLabel_WmDU">DROP USER MAPPING</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-user"><span class="linkLabel_WmDU">DROP USER</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/drop-view"><span class="linkLabel_WmDU">DROP VIEW</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/end"><span class="linkLabel_WmDU">END</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/execute"><span class="linkLabel_WmDU">EXECUTE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/explain"><span class="linkLabel_WmDU">EXPLAIN</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/fetch"><span class="linkLabel_WmDU">FETCH</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/grant"><span class="linkLabel_WmDU">GRANT</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/import-foreign-schema"><span class="linkLabel_WmDU">IMPORT FOREIGN SCHEMA</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/insert"><span class="linkLabel_WmDU">INSERT</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/listen"><span class="linkLabel_WmDU">LISTEN</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/load"><span class="linkLabel_WmDU">LOAD</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/lock"><span class="linkLabel_WmDU">LOCK</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/move"><span class="linkLabel_WmDU">MOVE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/notify"><span class="linkLabel_WmDU">NOTIFY</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/prepare"><span class="linkLabel_WmDU">PREPARE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/reassign-owned"><span class="linkLabel_WmDU">REASSIGN OWNED</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/refresh-materialized-view"><span class="linkLabel_WmDU">REFRESH MATERIALIZED VIEW</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/reindex"><span class="linkLabel_WmDU">REINDEX</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/release-savepoint"><span class="linkLabel_WmDU">RELEASE SAVEPOINT</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/reset"><span class="linkLabel_WmDU">RESET</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/retrieve"><span class="linkLabel_WmDU">RETRIEVE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/revoke"><span class="linkLabel_WmDU">REVOKE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/rollback-to-savepoint"><span class="linkLabel_WmDU">ROLLBACK TO SAVEPOINT</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/rollback"><span class="linkLabel_WmDU">ROLLBACK</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/savepoint"><span class="linkLabel_WmDU">SAVEPOINT</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/select-into"><span class="linkLabel_WmDU">SELECT INTO</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/select"><span class="linkLabel_WmDU">SELECT</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/set-constraints"><span class="linkLabel_WmDU">SET CONSTRAINTS</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/set-role"><span class="linkLabel_WmDU">SET ROLE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/set-session-authorization"><span class="linkLabel_WmDU">SET SESSION AUTHORIZATION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/set-transaction"><span class="linkLabel_WmDU">SET TRANSACTION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/set"><span class="linkLabel_WmDU">SET</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/show"><span class="linkLabel_WmDU">SHOW</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/start-transaction"><span class="linkLabel_WmDU">START TRANSACTION</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/truncate"><span class="linkLabel_WmDU">TRUNCATE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/unlisten"><span class="linkLabel_WmDU">UNLISTEN</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/update"><span class="linkLabel_WmDU">UPDATE</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/vacuum"><span class="linkLabel_WmDU">VACUUM</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-3 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/sql-stmts/values"><span class="linkLabel_WmDU">VALUES</span></a></li></ul></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/data-types"><span class="linkLabel_WmDU">Data Types</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/config-params-guc-list"><span class="linkLabel_WmDU">Configuration Parameters</span></a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist" tabindex="0" href="/docs/modules/"><span class="categoryLinkLabel_W154">Extension Modules</span></a><button aria-label="Expand sidebar category 'Extension Modules'" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist" tabindex="0" href="/docs/functions/"><span class="categoryLinkLabel_W154">Built-in Functions</span></a><button aria-label="Expand sidebar category 'Built-in Functions'" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist" tabindex="0" href="/docs/sys-utilities/"><span class="categoryLinkLabel_W154">System Utilities</span></a><button aria-label="Expand sidebar category 'System Utilities'" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" tabindex="0" href="/docs/sys-catalogs/sys-tables/gp-configuration-history"><span class="categoryLinkLabel_W154">System Catalogs</span></a></div></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="categoryLink_byQd menu__link menu__link--sublist menu__link--sublist-caret" role="button" aria-expanded="false" href="/docs/tutorials/crash-course"><span class="categoryLinkLabel_W154">Tutorials</span></a></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/pxf/"><span class="linkLabel_WmDU">Platform Extension Framework (PXF)</span></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/core-internals/"><span class="linkLabel_WmDU">Apache Cloudberry Core Internals</span></a></li></ul></nav></div></div></aside><main class="docMainContainer_hjYf"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_z5aJ"><div class="docItemContainer_c0TR"><article><div class="docItemTopBar_cHfk"><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Alpn" aria-label="Breadcrumbs"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="Home page" class="breadcrumbs__link" href="/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_xK9p"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li class="breadcrumbs__item"><span class="breadcrumbs__link" id="支付">References</span><meta itemprop="position" content="1"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item"><span class="breadcrumbs__link" style="cursor:pointer">SQL Statements</span><meta itemprop="position" content="2"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">CREATE FUNCTION</span><meta itemprop="position" content="3"></li></ul></nav><div class="root_HUhY"><button type="button" class="trigger_dLHX" aria-haspopup="menu" aria-expanded="false"><span class="triggerLabel_Yaiy">Copy page</span><svg class="chevron_UCSA" width="10" height="10" viewBox="0 0 10 10" aria-hidden="true"><path d="M2 3.5L5 6.5L8 3.5" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg></button></div></div><span class="theme-doc-version-badge badge badge--secondary">Version: 2.x</span><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_bxCs"><button type="button" class="clean-btn tocCollapsibleButton_TO0P">On this page</button></div><div class="theme-doc-markdown markdown"><header><h1>CREATE FUNCTION</h1></header> | |
| <p>Defines a new function.</p> | |
| <h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="synopsis">Synopsis<a href="#synopsis" class="hash-link" aria-label="Direct link to Synopsis" title="Direct link to Synopsis" translate="no"></a></h2> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token operator" style="color:rgb(127, 219, 202)">OR</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">REPLACE</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)"><</span><span class="token plain">name</span><span class="token operator" style="color:rgb(127, 219, 202)">></span><span class="token plain"> </span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token operator" style="color:rgb(127, 219, 202)"><</span><span class="token plain">argmode</span><span class="token operator" style="color:rgb(127, 219, 202)">></span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token operator" style="color:rgb(127, 219, 202)"><</span><span class="token plain">argname</span><span class="token operator" style="color:rgb(127, 219, 202)">></span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)"><</span><span class="token plain">argtype</span><span class="token operator" style="color:rgb(127, 219, 202)">></span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token plain"> { </span><span class="token keyword" style="color:rgb(127, 219, 202)">DEFAULT</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> } </span><span class="token operator" style="color:rgb(127, 219, 202)"><</span><span class="token plain">default_expr</span><span class="token operator" style="color:rgb(127, 219, 202)">></span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURNS</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)"><</span><span class="token plain">rettype</span><span class="token operator" style="color:rgb(127, 219, 202)">></span><span class="token plain"> </span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURNS</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">TABLE</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)"><</span><span class="token plain">column_name</span><span class="token operator" style="color:rgb(127, 219, 202)">></span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)"><</span><span class="token plain">column_type</span><span class="token operator" style="color:rgb(127, 219, 202)">></span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> { </span><span class="token keyword" style="color:rgb(127, 219, 202)">LANGUAGE</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)"><</span><span class="token plain">lang_name</span><span class="token operator" style="color:rgb(127, 219, 202)">></span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> TRANSFORM { </span><span class="token keyword" style="color:rgb(127, 219, 202)">FOR</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">TYPE</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)"><</span><span class="token plain">type_name</span><span class="token operator" style="color:rgb(127, 219, 202)">></span><span class="token plain"> } </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> WINDOW</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> { IMMUTABLE </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> STABLE </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> VOLATILE }</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">NOT</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"> LEAKPROOF</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> { CALLED </span><span class="token keyword" style="color:rgb(127, 219, 202)">ON</span><span class="token plain"> </span><span class="token boolean" style="color:rgb(255, 88, 116)">NULL</span><span class="token plain"> INPUT </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURNS</span><span class="token plain"> </span><span class="token boolean" style="color:rgb(255, 88, 116)">NULL</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">ON</span><span class="token plain"> </span><span class="token boolean" style="color:rgb(255, 88, 116)">NULL</span><span class="token plain"> INPUT </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> STRICT }</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> { </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token plain"> EXTERNAL </span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"> SECURITY </span><span class="token keyword" style="color:rgb(127, 219, 202)">INVOKER</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token plain"> EXTERNAL </span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"> SECURITY </span><span class="token keyword" style="color:rgb(127, 219, 202)">DEFINER</span><span class="token plain"> }</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">EXECUTE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">ON</span><span class="token plain"> { </span><span class="token keyword" style="color:rgb(127, 219, 202)">ANY</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> COORDINATOR </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">ALL</span><span class="token plain"> SEGMENTS </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> INITPLAN }</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> PARALLEL { UNSAFE </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> RESTRICTED </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> SAFE }</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> COST </span><span class="token operator" style="color:rgb(127, 219, 202)"><</span><span class="token plain">execution_cost</span><span class="token operator" style="color:rgb(127, 219, 202)">></span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">ROWS</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)"><</span><span class="token plain">result_rows</span><span class="token operator" style="color:rgb(127, 219, 202)">></span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> SUPPORT </span><span class="token operator" style="color:rgb(127, 219, 202)"><</span><span class="token plain">support_function</span><span class="token operator" style="color:rgb(127, 219, 202)">></span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">SET</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)"><</span><span class="token plain">configuration_parameter</span><span class="token operator" style="color:rgb(127, 219, 202)">></span><span class="token plain"> { </span><span class="token keyword" style="color:rgb(127, 219, 202)">TO</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)"><</span><span class="token keyword" style="color:rgb(127, 219, 202)">value</span><span class="token operator" style="color:rgb(127, 219, 202)">></span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)"><</span><span class="token keyword" style="color:rgb(127, 219, 202)">value</span><span class="token operator" style="color:rgb(127, 219, 202)">></span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FROM</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">CURRENT</span><span class="token plain"> }</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">'<definition>'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">'<obj_file>'</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">'<link_symbol>'</span><span class="token plain"> </span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">WITH</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">{ </span><span class="token keyword" style="color:rgb(127, 219, 202)">DESCRIBE</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)"><</span><span class="token plain">describe_function</span><span class="token operator" style="color:rgb(127, 219, 202)">></span><span class="token plain"> } </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> } </span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><br></div></code></pre></div></div> | |
| <h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="description">Description<a href="#description" class="hash-link" aria-label="Direct link to Description" title="Direct link to Description" translate="no"></a></h2> | |
| <p><code>CREATE FUNCTION</code> defines a new function. <code>CREATE OR REPLACE FUNCTION</code> either creates a new function, or replaces an existing definition. To define a function, the user must have the <code>USAGE</code> privilege on the language.</p> | |
| <p>If a schema name is included, then the function is created in the specified schema. Otherwise it is created in the current schema. The name of the new function must not match any existing function with the same input argument types in the same schema. However, functions of different argument types may share a name (overloading).</p> | |
| <p>To update the current definition of an existing function, use <code>CREATE OR REPLACE FUNCTION</code>. It is not possible to change the name or argument types of a function this way (this would actually create a new, distinct function). Also, <code>CREATE OR REPLACE FUNCTION</code> will not let you change the return type of an existing function. To do that, you must drop and recreate the function. (When using <code>OUT</code> parameters, that means you cannot change the types of any <code>OUT</code> parameters except by dropping the function.)</p> | |
| <p>When <code>CREATE OR REPLACE FUNCTION</code> is used to replace an existing function, the ownership and permissions of the function do not change. All other function properties are assigned the values specified or implied in the command. You must own the function to replace it (this includes being a member of the owning role).</p> | |
| <p>If you drop and then recreate a function, the new function is not the same entity as the old; you will have to drop existing objects (rules, views, triggers, and so on) that refer to the old function. Use <code>CREATE OR REPLACE FUNCTION</code> to change a function definition without breaking objects that refer to the function. Also, <a class="" href="/docs/next/sql-stmts/alter-function">ALTER FUNCTION</a> can be used to change most of the auxiliary properties of an existing function.</p> | |
| <p>The user that creates the function becomes the owner of the function.</p> | |
| <p>To be able to create a function, you must have <code>USAGE</code> privilege on the argument types and the return type.</p> | |
| <p>For more information about creating functions, refer to the <a href="https://www.postgresql.org/docs/12/xfunc.html" target="_blank" rel="noopener noreferrer" class="">User Defined Functions</a> section of the PostgreSQL documentation.</p> | |
| <p><strong>Limited Use of VOLATILE and STABLE Functions</strong></p> | |
| <p>To prevent data from becoming out-of-sync across the segments in Apache Cloudberry, any function classified as <code>STABLE</code> or <code>VOLATILE</code> cannot be run at the segment level if it contains SQL or modifies the database in any way. For example, functions such as <code>random()</code> or <code>timeofday()</code> are not allowed to run on distributed data in Apache Cloudberry because they could potentially cause inconsistent data between the segment instances.</p> | |
| <p>To ensure data consistency, <code>VOLATILE</code> and <code>STABLE</code> functions can safely be used in statements that are evaluated on and run from the coordinator. For example, the following statements are always run on the coordinator (statements without a <code>FROM</code> clause):</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> setval</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">'myseq'</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">201</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> foo</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <p>In cases where a statement has a <code>FROM</code> clause containing a distributed table and the function used in the <code>FROM</code> clause simply returns a set of rows, execution may be allowed on the segments:</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FROM</span><span class="token plain"> foo</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <p>One exception to this rule are functions that return a table reference (<code>rangeFuncs</code>) or functions that use the <code>refCursor</code> data type. Note that you cannot return a <code>refcursor</code> from any kind of function in Apache Cloudberry.</p> | |
| <p><strong>Function Volatility and EXECUTE ON Attributes</strong></p> | |
| <p>Volatility attributes (<code>IMMUTABLE</code>, <code>STABLE</code>, <code>VOLATILE</code>) and <code>EXECUTE ON</code> attributes specify two different aspects of function execution. In general, volatility indicates when the function is run, and <code>EXECUTE ON</code> indicates where it is run.</p> | |
| <p>For example, a function defined with the <code>IMMUTABLE</code> attribute can be run at query planning time, while a function with the <code>VOLATILE</code> attribute must be run for every row in the query. A function with the <code>EXECUTE ON COORDINATOR</code> attribute is run only on the coordinator segment and a function with the <code>EXECUTE ON ALL SEGMENTS</code> attribute is run on all primary segment instances (not the coordinator).</p> | |
| <p><strong>Functions And Replicated Tables</strong></p> | |
| <p>A user-defined function that runs only <code>SELECT</code> commands on replicated tables can run on segments. Replicated tables, created with the <code>DISTRIBUTED REPLICATED</code> clause, store all of their rows on every segment. It is safe for a function to read them on the segments, but updates to replicated tables must run on the coordinator instance.</p> | |
| <h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="parameters">Parameters<a href="#parameters" class="hash-link" aria-label="Direct link to Parameters" title="Direct link to Parameters" translate="no"></a></h2> | |
| <p><strong><code>name</code></strong></p> | |
| <p>The name (optionally schema-qualified) of the function to create.</p> | |
| <p><strong><code>argmode</code></strong></p> | |
| <p>The mode of an argument: either <code>IN</code>, <code>OUT</code>, <code>INOUT</code>, or <code>VARIADIC</code>. If omitted, the default is <code>IN</code>. Only <code>OUT</code> arguments can follow an argument declared as <code>VARIADIC</code>. Also, <code>OUT</code> and <code>INOUT</code> arguments cannot be used together with the <code>RETURNS TABLE</code> notation.</p> | |
| <p><strong><code>argname</code></strong></p> | |
| <p>The name of an argument. Some languages (currently only SQL and PL/pgSQL) let you use the name in the function body. For other languages the name of an input argument is just extra documentation, so far as the function itself is concerned; but you can use input argument names when calling a function to improve readability. In any case, the name of an output argument is significant, since it defines the column name in the result row type. (If you omit the name for an output argument, the system will choose a default column name.)</p> | |
| <p><strong><code>argtype</code></strong></p> | |
| <p>The data type(s) of the function's arguments (optionally schema-qualified), if any. The argument types may be base, composite, or domain types, or may reference the type of a table column.</p> | |
| <p>Depending on the implementation language it may also be allowed to specify pseudotypes such as <code>cstring</code>. Pseudotypes indicate that the actual argument type is either incompletely specified, or outside the set of ordinary SQL data types.</p> | |
| <p>The type of a column is referenced by writing <code>table_name.column_name%TYPE</code>. Using this feature can sometimes help make a function independent of changes to the definition of a table.</p> | |
| <p><strong><code>default_expr</code></strong></p> | |
| <p>An expression to be used as the default value if the parameter is not specified. The expression must be coercible to the argument type of the parameter. Only input (including <code>INOUT</code>) parameters can have a default value. Each input parameter in the argument list that follows a parameter with a default value must have a default value as well.</p> | |
| <p><strong><code>rettype</code></strong></p> | |
| <p>The return data type (optionally schema-qualified). The return type can be a base, composite, or domain type, or may reference the type of a table column. Depending on the implementation language it may also be allowed to specify pseudotypes such as <code>cstring</code>. If the function is not supposed to return a value, specify <code>void</code> as the return type.</p> | |
| <p>When there are <code>OUT</code> or <code>INOUT</code> parameters, the <code>RETURNS</code> clause may be omitted. If present, it must agree with the result type implied by the output parameters: <code>RECORD</code> if there are multiple output parameters, or the same type as the single output parameter.</p> | |
| <p>The <code>SETOF</code> modifier indicates that the function will return a set of items, rather than a single item.</p> | |
| <p>The type of a column is referenced by writing <code>table_name.column_name%TYPE</code>.</p> | |
| <p><strong><code>column_name</code></strong></p> | |
| <p>The name of an output column in the <code>RETURNS TABLE</code> syntax. This is effectively another way of declaring a named <code>OUT</code> parameter, except that <code>RETURNS TABLE</code> also implies <code>RETURNS SETOF</code>.</p> | |
| <p><strong><code>column_type</code></strong></p> | |
| <p>The data type of an output column in the <code>RETURNS TABLE</code> syntax.</p> | |
| <p><strong><code>lang_name</code></strong></p> | |
| <p>The name of the language that the function is implemented in. May be <code>SQL</code>, <code>C</code>, <code>internal</code>, or the name of a user-defined procedural language, e.g. <code>plpgsql</code>. Enclosing the name in single quotes is deprecated and requires matching case.</p> | |
| <p><strong><code>TRANSFORM { FOR TYPE type_name } [, ... ] }</code></strong></p> | |
| <p>Lists which transforms a call to the function should apply. Transforms convert between SQL types and language-specific data types. Procedural language implementations usually have hardcoded knowledge of the built-in types, so those don't need to be listed here. If a procedural language implementation does not know how to handle a type and no transform is supplied, it will fall back to a default behavior for converting data types, but this depends on the implementation.</p> | |
| <p><strong><code>WINDOW</code></strong></p> | |
| <p><code>WINDOW</code> indicates that the function is a window function rather than a plain function. This is currently only useful for functions written in C. The <code>WINDOW</code> attribute cannot be changed when replacing an existing function definition.</p> | |
| <p><strong><code>IMMUTABLE</code></strong><br> | |
| <strong><code>STABLE</code></strong><br> | |
| <strong><code>VOLATILE</code></strong></p> | |
| <p>These attributes inform the query optimizer about the behavior of the function. At most one choice may be specified. If none of these appear, <code>VOLATILE</code> is the default assumption. Since Apache Cloudberry currently has limited use of <code>VOLATILE</code> functions, if a function is truly <code>IMMUTABLE</code>, you must declare it as so to be able to use it without restrictions.</p> | |
| <p><code>IMMUTABLE</code> indicates that the function cannot modify the database and always returns the same result when given the same argument values. It does not do database lookups or otherwise use information not directly present in its argument list. If this option is given, any call of the function with all-constant arguments can be immediately replaced with the function value.</p> | |
| <p><code>STABLE</code> indicates that the function cannot modify the database, and that within a single table scan it will consistently return the same result for the same argument values, but that its result could change across SQL statements. This is the appropriate selection for functions whose results depend on database lookups, parameter variables (such as the current time zone), and so on. Also note that the <code>current_timestamp()</code> family of functions qualify as stable, since their values do not change within a transaction.</p> | |
| <p><code>VOLATILE</code> indicates that the function value can change even within a single table scan, so no optimizations can be made. Relatively few database functions are volatile in this sense; some examples are <code>random()</code>, <code>timeofday()</code>. But note that any function that has side-effects must be classified volatile, even if its result is quite predictable, to prevent calls from being optimized away; an example is <code>setval()</code>.</p> | |
| <p><strong><code>LEAKPROOF</code></strong></p> | |
| <p><code>LEAKPROOF</code> indicates that the function has no side effects. It reveals no information about its arguments other than by its return value. For example, a function that throws an error message for some argument values but not others, or that includes the argument values in any error message, is not leakproof. This affects how the system executes queries against views created with the <code>security_barrier</code> option or tables with row level security enabled. The system will enforce conditions from security policies and security barrier views before any user-supplied conditions from the query itself that contain non-leakproof functions, in order to prevent the inadvertent exposure of data. Functions and operators marked as leakproof are assumed to be trustworthy, and may be executed before conditions from security policies and security barrier views. In addition, functions which do not take arguments or which are not passed any arguments from the security barrier view or table do not have to be marked as leakproof to be executed before security conditions. See <a class="" href="/docs/next/sql-stmts/create-view">CREATE VIEW</a>. This option can only be set by the superuser.</p> | |
| <p><strong><code>CALLED ON NULL INPUT</code></strong><br> | |
| <strong><code>RETURNS NULL ON NULL INPUT</code></strong><br> | |
| <strong><code>STRICT</code></strong></p> | |
| <p><code>CALLED ON NULL INPUT</code> (the default) indicates that the function will be called normally when some of its arguments are null. It is then the function author's responsibility to check for null values if necessary and respond appropriately.</p> | |
| <p><code>RETURNS NULL ON NULL INPUT</code> or <code>STRICT</code> indicates that the function always returns null whenever any of its arguments are null. If this parameter is specified, the function is not run when there are null arguments; instead a null result is assumed automatically.</p> | |
| <p><strong><code>[EXTERNAL] SECURITY INVOKER</code></strong><br> | |
| <strong><code>[EXTERNAL] SECURITY DEFINER</code></strong></p> | |
| <p><code>SECURITY INVOKER</code> (the default) indicates that the function is to be run with the privileges of the user that calls it.</p> | |
| <p><code>SECURITY DEFINER</code> specifies that the function is to be run with the privileges of the user that created it.</p> | |
| <p>The key word <code>EXTERNAL</code> is allowed for SQL conformance, but it is optional since, unlike in SQL, this feature applies to all functions not just external ones.</p> | |
| <p><strong><code>EXECUTE ON ANY</code></strong><br> | |
| <strong><code>EXECUTE ON COORDINATOR</code></strong><br> | |
| <strong><code>EXECUTE ON ALL SEGMENTS</code></strong><br> | |
| <strong><code>EXECUTE ON INITPLAN</code></strong></p> | |
| <p>The <code>EXECUTE ON</code> attributes specify where (coordinator or segment instance) a function runs when it is invoked during the query execution process.</p> | |
| <p><code>EXECUTE ON ANY</code> (the default) indicates that the function can be run on the coordinator, or any segment instance, and it returns the same result regardless of where it is run. Apache Cloudberry determines where the function runs.</p> | |
| <p><code>EXECUTE ON COORDINATOR</code> indicates that the function must run only on the coordinator instance.</p> | |
| <p><code>EXECUTE ON ALL SEGMENTS</code> indicates that the function must run on all primary segment instances, but not the coordinator, for each invocation. The overall result of the function is the <code>UNION ALL</code> of the results from all segment instances.</p> | |
| <p><code>EXECUTE ON INITPLAN</code> indicates that the function contains an SQL command that dispatches queries to the segment instances and requires special processing on the coordinator instance by Apache Cloudberry when possible.</p> | |
| <blockquote> | |
| <p><strong>Note</strong> <code>EXECUTE ON INITPLAN</code> is only supported in functions that are used in the <code>FROM</code> clause of a <code>CREATE TABLE AS</code> or <code>INSERT</code> command such as the <code>get_data()</code> function in these commands.</p> | |
| </blockquote> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">TABLE</span><span class="token plain"> t </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FROM</span><span class="token plain"> get_data</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">INSERT</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">INTO</span><span class="token plain"> t1 </span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FROM</span><span class="token plain"> get_data</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <p>Apache Cloudberry does not support the <code>EXECUTE ON INITPLAN</code> attribute in a function that is used in the <code>WITH</code> clause of a query, a CTE (common table expression). For example, specifying <code>EXECUTE ON INITPLAN</code> in function <code>get_data()</code> in this CTE is not supported.</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">WITH</span><span class="token plain"> tbl_a </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FROM</span><span class="token plain"> get_data</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">from</span><span class="token plain"> tbl_a</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">UNION</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FROM</span><span class="token plain"> tbl_b</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <p>For information about using <code>EXECUTE ON</code> attributes, see <a href="#notes" class="">Notes</a>.</p> | |
| <p><strong><code>PARALLEL</code></strong></p> | |
| <p><code>PARALLEL UNSAFE</code> indicates that the function can't be executed in parallel mode and the presence of such a function in an SQL statement forces a serial execution plan. This is the default. <code>PARALLEL RESTRICTED</code> indicates that the function can be executed in parallel mode, but the execution is restricted to parallel group leader. <code>PARALLEL SAFE</code> indicates that the function is safe to run in parallel mode without restriction.</p> | |
| <p>Functions should be labeled parallel unsafe if they modify any database state, or if they make changes to the transaction such as using sub-transactions, or if they access sequences or attempt to make persistent changes to settings (e.g., <code>setval()</code>). They should be labeled as parallel restricted if they access temporary tables, client connection state, cursors, prepared statements, or miscellaneous backend-local state which the system cannot synchronize in parallel mode (e.g., <code>setseed()</code> cannot be executed other than by the group leader because a change made by another process would not be reflected in the leader). In general, if a function is labeled as being safe when it is restricted or unsafe, or if it is labeled as being restricted when it is in fact unsafe, it may throw errors or produce wrong answers when used in a parallel query. C-language functions could in theory exhibit totally undefined behavior if mislabeled, since there is no way for the system to protect itself against arbitrary C code, but in most likely cases the result will be no worse than for any other function. If in doubt, functions should be labeled as <code>UNSAFE</code>, which is the default.</p> | |
| <p><strong><code>COST execution_cost</code></strong></p> | |
| <p>A positive number identifying the estimated execution cost for the function, in units of <a href="https://www.postgresql.org/docs/12/runtime-config-query.html" target="_blank" rel="noopener noreferrer" class="">cpu_operator_cost</a>. If the function returns a set, execution_cost identifies the cost per returned row. If the cost is not specified, C-language and internal functions default to 1 unit, while functions in other languages default to 100 units. Larger values cause the planner to try to avoid evaluating the function more often than necessary.</p> | |
| <p><strong><code>ROWS result_rows</code></strong></p> | |
| <p>A positive number giving the estimated number of rows that the planner should expect the function to return. This is only allowed when the function is declared to return a set. The default assumption is 1000 rows.</p> | |
| <p><strong><code>SUPPORT support_function</code></strong></p> | |
| <p>The name (optionally schema-qualified) of a planner support function to use for this function. You must be superuser to use this option.</p> | |
| <p><strong><code>configuration_parameter</code></strong><br> | |
| <strong><code>value</code></strong></p> | |
| <p>The <code>SET</code> clause applies a value to a session configuration parameter when the function is entered. The configuration parameter is restored to its prior value when the function exits. <code>SET FROM CURRENT</code> saves the value of the parameter that is current when <code>CREATE FUNCTION</code> is run as the value to be applied when the function is entered.</p> | |
| <p>If a <code>SET</code> clause is attached to a function, then the effects of a <code>SET LOCAL</code> command executed inside the function for the same variable are restricted to the function: the configuration parameter's prior value is still restored at function exit. However, an ordinary <code>SET</code> command (without <code>LOCAL</code>) overrides the <code>SET</code> clause, much as it would do for a previous <code>SET LOCAL</code> command: the effects of such a command will persist after function exit, unless the current transaction is rolled back.</p> | |
| <p>See <a class="" href="/docs/next/sql-stmts/set">SET</a> for more information about allowed parameter names and values.</p> | |
| <p><strong><code>definition</code></strong></p> | |
| <p>A string constant defining the function; the meaning depends on the language. It may be an internal function name, the path to an object file, an SQL command, or text in a procedural language.</p> | |
| <p>It is often helpful to use dollar quoting (refer to <a href="https://www.postgresql.org/docs/12/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING" target="_blank" rel="noopener noreferrer" class="">Dollar-Quoted String Constants | |
| </a> in the PostgreSQL documentation) to write the function definition string, rather than the normal single quote syntax. Without dollar quoting, any single quotes or backslashes in the function definition must be escaped by doubling them.</p> | |
| <p><strong><code>obj_file, link_symbol</code></strong></p> | |
| <p>This form of the <code>AS</code> clause is used for dynamically loadable C language functions when the function name in the C language source code is not the same as the name of the SQL function. The string obj_file is the name of the file containing the dynamically loadable object, and is interpreted as for the <a class="" href="/docs/next/sql-stmts/load">LOAD</a> command. The string link_symbol is the name of the function in the C language source code. If the link symbol is omitted, it is assumed to be the same as the name of the SQL function being defined. The C names of all functions must be different, so you must give overloaded SQL functions different C names (for example, use the argument types as part of the C names).</p> | |
| <p>When repeated <code>CREATE FUNCTION</code> calls refer to the same object file, the file is only loaded once per session. To unload and reload the file (perhaps during development), start a new session.</p> | |
| <p>Locating shared libraries either relative to <code>$libdir</code> (which is located at <code>$GPHOME/lib</code>) or through the dynamic library path (set by the <code>dynamic_library_path</code> server configuration parameter) will simplify version upgrades if the new installation is at a different location.</p> | |
| <p><strong><code>describe_function</code></strong></p> | |
| <p>The name of a callback function to run when a query that calls this function is parsed. The callback function returns a tuple descriptor that indicates the result type.</p> | |
| <h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="overloading">Overloading<a href="#overloading" class="hash-link" aria-label="Direct link to Overloading" title="Direct link to Overloading" translate="no"></a></h2> | |
| <p>Apache Cloudberry allows function overloading; that is, the same name can be used for several different functions so long as they have distinct input argument types. Whether or not you use it, this capability entails security precautions when calling functions in databases where some users mistrust other users; refer to <a href="https://www.postgresql.org/docs/12/typeconv-func.html" target="_blank" rel="noopener noreferrer" class="">Functions</a> in the PostgreSQL documentation for more information.</p> | |
| <p>Two functions are considered the same if they have the same names and input argument types, ignoring any <code>OUT</code> parameters. Thus for example these declarations conflict:</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> foo</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="color:rgb(127, 219, 202)">int</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> foo</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="color:rgb(127, 219, 202)">int</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">out</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><br></div></code></pre></div></div> | |
| <p>Functions that have different argument type lists will not be considered to conflict at creation time, but if defaults are provided they might conflict in use. For example, consider:</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> foo</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="color:rgb(127, 219, 202)">int</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> foo</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="color:rgb(127, 219, 202)">int</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">int</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">default</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">42</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><br></div></code></pre></div></div> | |
| <p>A call <code>foo(10)</code> will fail due to the ambiguity about which function should be called.</p> | |
| <h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="notes">Notes<a href="#notes" class="hash-link" aria-label="Direct link to Notes" title="Direct link to Notes" translate="no"></a></h2> | |
| <p>Any compiled code (shared library files) for custom functions must be placed in the same location on every host in your Apache Cloudberry cluster (coordinator and all segments). This location must also be in the <code>LD_LIBRARY_PATH</code> so that the server can locate the files. It is recommended that you locate shared libraries either relative to <code>$libdir</code> (which is located at <code>$GPHOME/lib</code>) or through the dynamic library path (set by the <code>dynamic_library_path</code> server configuration parameter) on all coordinator segment instances in the Apache Cloudberry cluster.</p> | |
| <p>The full SQL type syntax is allowed for input arguments and return value. However, parenthesized type modifiers (e.g., the precision field for type <code>numeric</code>) are discarded by <code>CREATE FUNCTION</code>. Thus for example <code>CREATE FUNCTION foo (varchar(10)) ...</code> is exactly the same as <code>CREATE FUNCTION foo (varchar) ...</code>.</p> | |
| <p>When replacing an existing function with <code>CREATE OR REPLACE FUNCTION</code>, there are restrictions on changing parameter names. You cannot change the name already assigned to any input parameter (although you can add names to parameters that had none before). If there is more than one output parameter, you cannot change the names of the output parameters, because that would change the column names of the anonymous composite type that describes the function's result. These restrictions are made to ensure that existing calls of the function do not stop working when it is replaced.</p> | |
| <p>If a function is declared <code>STRICT</code> with a <code>VARIADIC</code> argument, the strictness check tests that the variadic array as a whole is non-null. The function will still be called if the array has null elements.</p> | |
| <p><strong>Using Functions with Queries on Distributed Data</strong></p> | |
| <p>In some cases, Apache Cloudberry does not support using functions in a query where the data in a table specified in the <code>FROM</code> clause is distributed over Apache Cloudberry segments. As an example, this SQL query contains the function <code>func()</code>:</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> func</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">a</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FROM</span><span class="token plain"> table1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <p>The function is not supported for use in the query if all of the following conditions are met:</p> | |
| <ul> | |
| <li class="">The data of table <code>table1</code> is distributed over Apache Cloudberry segments.</li> | |
| <li class="">The function <code>func()</code> reads or modifies data from distributed tables.</li> | |
| <li class="">The function <code>func()</code> returns more than one row or takes an argument (<code>a</code>) that comes from <code>table1</code>.</li> | |
| </ul> | |
| <p>If any of the conditions are not met, the function is supported. Specifically, the function is supported if any of the following conditions apply:</p> | |
| <ul> | |
| <li class="">The function <code>func()</code> does not access data from distributed tables, or accesses data that is only on the Apache Cloudberry coordinator.</li> | |
| <li class="">The table <code>table1</code> is a coordinator only table.</li> | |
| <li class="">The function <code>func()</code> returns only one row and only takes input arguments that are constant values. The function is supported if it can be changed to require no input arguments.</li> | |
| </ul> | |
| <p><strong>Using EXECUTE ON attributes</strong></p> | |
| <p>Most functions that run queries to access tables can only run on the coordinator. However, functions that run only <code>SELECT</code> queries on replicated tables can run on segments. If the function accesses a hash-distributed table or a randomly distributed table, the function should be defined with the <code>EXECUTE ON COORDINATOR</code> attribute. Otherwise, the function might return incorrect results when the function is used in a complicated query. Without the attribute, planner optimization might determine it would be beneficial to push the function invocation to segment instances.</p> | |
| <p>These are limitations for functions defined with the <code>EXECUTE ON COORDINATOR</code> or <code>EXECUTE ON ALL SEGMENTS</code> attribute:</p> | |
| <ul> | |
| <li class="">The function must be a set-returning function.</li> | |
| <li class="">The function cannot be in the <code>FROM</code> clause of a query.</li> | |
| <li class="">The function cannot be in the <code>SELECT</code> list of a query with a <code>FROM</code> clause.</li> | |
| <li class="">A query that includes the function falls back from GPORCA to the Postgres Planner.</li> | |
| </ul> | |
| <p>The attribute <code>EXECUTE ON INITPLAN</code> indicates that the function contains an SQL command that dispatches queries to the segment instances and requires special processing on the coordinator instance by Apache Cloudberry. When possible, Apache Cloudberry handles the function on the coordinator instance in the following manner.</p> | |
| <ol> | |
| <li class="">First, Apache Cloudberry runs the function as part of an InitPlan node on the coordinator instance and holds the function output temporarily.</li> | |
| <li class="">Then, in the MainPlan of the query plan, the function is called in an EntryDB (a special query executor (QE) that runs on the coordinator instance) and Apache Cloudberry returns the data that was captured when the function was run as part of the InitPlan node. The function is not run in the MainPlan.</li> | |
| </ol> | |
| <p>This simple example uses the function <code>get_data()</code> in a CTAS command to create a table using data from the table <code>country</code>. The function contains a <code>SELECT</code> command that retrieves data from the table <code>country</code> and uses the <code>EXECUTE ON INITPLAN</code> attribute.</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">TABLE</span><span class="token plain"> country</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain"> </span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> c_id </span><span class="token keyword" style="color:rgb(127, 219, 202)">integer</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> c_name </span><span class="token keyword" style="color:rgb(127, 219, 202)">text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> region </span><span class="token keyword" style="color:rgb(127, 219, 202)">int</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">DISTRIBUTED</span><span class="token plain"> RANDOMLY</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">INSERT</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">INTO</span><span class="token plain"> country </span><span class="token keyword" style="color:rgb(127, 219, 202)">VALUES</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">11</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token string" style="color:rgb(173, 219, 103)">'INDIA'</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">22</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token string" style="color:rgb(173, 219, 103)">'CANADA'</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">2</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">33</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token string" style="color:rgb(173, 219, 103)">'USA'</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">3</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">OR</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">REPLACE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> get_data</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURNS</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">TABLE</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> c_id </span><span class="token keyword" style="color:rgb(127, 219, 202)">integer</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> c_name </span><span class="token keyword" style="color:rgb(127, 219, 202)">text</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> $$</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> c</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">c_id</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> c</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">c_name</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FROM</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> country c</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain">$$</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">LANGUAGE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">SQL</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">EXECUTE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">ON</span><span class="token plain"> INITPLAN</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">TABLE</span><span class="token plain"> t </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FROM</span><span class="token plain"> get_data</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">DISTRIBUTED</span><span class="token plain"> RANDOMLY</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <p>If you view the query plan of the CTAS command with <code>EXPLAIN ANALYZE VERBOSE</code>, the plan shows that the function is run as part of an InitPlan node, and one of the listed slices is labeled as <code>entry db</code>. The query plan of a simple CTAS command without the function does not have an InitPlan node or an <code>entry db</code> slice.</p> | |
| <p>If the function did not contain the <code>EXECUTE ON INITPLAN</code> attribute, the CTAS command returns the error <code>function cannot execute on a QE slice</code>.</p> | |
| <p>When a function uses the <code>EXECUTE ON INITPLAN</code> attribute, a command that uses the function such as <code>CREATE TABLE t AS SELECT * FROM get_data()</code> gathers the results of the function onto the coordinator segment and then redistributes the results to segment instances when inserting the data. If the function returns a large amount of data, the coordinator might become a bottleneck when gathering and redistributing data. Performance might improve if you rewrite the function to run the CTAS command in the user defined function and use the table name as an input parameter. In this example, the function runs a CTAS command and does not require the <code>EXECUTE ON INITPLAN</code> attribute. Running the <code>SELECT</code> command creates the table <code>t1</code> using the function that runs the CTAS command.</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">OR</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">REPLACE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> my_ctas</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">_tbl </span><span class="token keyword" style="color:rgb(127, 219, 202)">text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURNS</span><span class="token plain"> VOID </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain">$$</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">BEGIN</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">EXECUTE</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">format</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">'CREATE TABLE %s AS SELECT c.c_id, c.c_name FROM country c DISTRIBUTED RANDOMLY'</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> _tbl</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">END</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain">$$</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">LANGUAGE</span><span class="token plain"> plpgsql</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> my_ctas</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">'t1'</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="examples">Examples<a href="#examples" class="hash-link" aria-label="Direct link to Examples" title="Direct link to Examples" translate="no"></a></h2> | |
| <p>Add two integers using a SQL function:</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">add</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="color:rgb(127, 219, 202)">integer</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">integer</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURNS</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">integer</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">'select $1 + $2;'</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">LANGUAGE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">SQL</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> IMMUTABLE</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURNS</span><span class="token plain"> </span><span class="token boolean" style="color:rgb(255, 88, 116)">NULL</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">ON</span><span class="token plain"> </span><span class="token boolean" style="color:rgb(255, 88, 116)">NULL</span><span class="token plain"> INPUT</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <p>Increment an integer, making use of an argument name, in PL/pgSQL:</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">OR</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">REPLACE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> increment</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">i </span><span class="token keyword" style="color:rgb(127, 219, 202)">integer</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURNS</span><span class="token plain"> </span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">integer</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> $$</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">BEGIN</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURN</span><span class="token plain"> i </span><span class="token operator" style="color:rgb(127, 219, 202)">+</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">END</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain">$$ </span><span class="token keyword" style="color:rgb(127, 219, 202)">LANGUAGE</span><span class="token plain"> plpgsql</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <p>Return a record containing multiple output parameters:</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> dup</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token operator" style="color:rgb(127, 219, 202)">in</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">int</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">out</span><span class="token plain"> f1 </span><span class="token keyword" style="color:rgb(127, 219, 202)">int</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">out</span><span class="token plain"> f2 </span><span class="token keyword" style="color:rgb(127, 219, 202)">text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> $$ </span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> $</span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> CAST</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">$</span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">||</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">' is text'</span><span class="token plain"> $$</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">LANGUAGE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">SQL</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FROM</span><span class="token plain"> dup</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">42</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <p>You can do the same thing more verbosely with an explicitly named composite type:</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">TYPE</span><span class="token plain"> dup_result </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">f1 </span><span class="token keyword" style="color:rgb(127, 219, 202)">int</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> f2 </span><span class="token keyword" style="color:rgb(127, 219, 202)">text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> dup</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="color:rgb(127, 219, 202)">int</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURNS</span><span class="token plain"> dup_result</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> $$ </span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> $</span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> CAST</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">$</span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">||</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">' is text'</span><span class="token plain"> $$</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">LANGUAGE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">SQL</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FROM</span><span class="token plain"> dup</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">42</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <p>Another way to return multiple columns is to use a <code>TABLE</code> function:</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> dup</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="color:rgb(127, 219, 202)">int</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURNS</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">TABLE</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">f1 </span><span class="token keyword" style="color:rgb(127, 219, 202)">int</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> f2 </span><span class="token keyword" style="color:rgb(127, 219, 202)">text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> $$ </span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> $</span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> CAST</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">$</span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">||</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">' is text'</span><span class="token plain"> $$</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">LANGUAGE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">SQL</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FROM</span><span class="token plain"> dup</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">42</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <p>However, a <code>TABLE</code> function is different from the preceding examples, because it actually returns a set of records, not just one record.</p> | |
| <p>Increase the default segment host memory per query for a PL/pgSQL function:</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">OR</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">REPLACE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> function_with_query</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURNS</span><span class="token plain"> </span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain">SETOF </span><span class="token keyword" style="color:rgb(127, 219, 202)">text</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> $$</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">BEGIN</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURN</span><span class="token plain"> QUERY</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">EXPLAIN</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">ANALYZE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FROM</span><span class="token plain"> large_table</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">END</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain">$$ </span><span class="token keyword" style="color:rgb(127, 219, 202)">LANGUAGE</span><span class="token plain"> plpgsql</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">SET</span><span class="token plain"> statement_mem</span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token string" style="color:rgb(173, 219, 103)">'256MB'</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <p>Use polymorphic types to return an <code>ENUM</code> array:</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">TYPE</span><span class="token plain"> rainbow </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">ENUM</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">'red'</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token string" style="color:rgb(173, 219, 103)">'orange'</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token string" style="color:rgb(173, 219, 103)">'yellow'</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token string" style="color:rgb(173, 219, 103)">'green'</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token string" style="color:rgb(173, 219, 103)">'blue'</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token string" style="color:rgb(173, 219, 103)">'indigo'</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token string" style="color:rgb(173, 219, 103)">'violet'</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> return_enum_as_array</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain"> anyenum</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> anyelement</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> anyelement </span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURNS</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">TABLE</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">ae anyenum</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> aa anyarray</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> $$</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> $</span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> array</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token plain">$</span><span class="token number" style="color:rgb(247, 140, 108)">2</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> $</span><span class="token number" style="color:rgb(247, 140, 108)">3</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"> </span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain">$$ </span><span class="token keyword" style="color:rgb(127, 219, 202)">LANGUAGE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">SQL</span><span class="token plain"> STABLE</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FROM</span><span class="token plain"> return_enum_as_array</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">'red'</span><span class="token plain">::rainbow</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">'green'</span><span class="token plain">::rainbow</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">'blue'</span><span class="token plain">::rainbow</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <p>This function is defined with the <code>EXECUTE ON ALL SEGMENTS</code> to run on all primary segment instances. The <code>SELECT</code> command runs the function that returns the time it was run on each segment instance.</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> run_on_segs </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="color:rgb(127, 219, 202)">text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">returns</span><span class="token plain"> setof </span><span class="token keyword" style="color:rgb(127, 219, 202)">text</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">as</span><span class="token plain"> $$</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">begin</span><span class="token plain"> </span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">return</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">next</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">$</span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">||</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">' - '</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">||</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">now</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain">::</span><span class="token keyword" style="color:rgb(127, 219, 202)">text</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> $$ </span><span class="token keyword" style="color:rgb(127, 219, 202)">language</span><span class="token plain"> plpgsql VOLATILE </span><span class="token keyword" style="color:rgb(127, 219, 202)">EXECUTE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">ON</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">ALL</span><span class="token plain"> SEGMENTS</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> run_on_segs</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">'my test'</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <p>This function looks up a part name in the parts table. The parts table is replicated, so the function can run on the coordinator or on the primary segments.</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">OR</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">REPLACE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> get_part_name</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">partno </span><span class="token keyword" style="color:rgb(127, 219, 202)">int</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURNS</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">text</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain">$$</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">DECLARE</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> result </span><span class="token keyword" style="color:rgb(127, 219, 202)">text</span><span class="token plain"> :</span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">' '</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">BEGIN</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> part_name </span><span class="token keyword" style="color:rgb(127, 219, 202)">INTO</span><span class="token plain"> result </span><span class="token keyword" style="color:rgb(127, 219, 202)">FROM</span><span class="token plain"> parts </span><span class="token keyword" style="color:rgb(127, 219, 202)">WHERE</span><span class="token plain"> part_id </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> partno</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURN</span><span class="token plain"> result</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">END</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain">$$ </span><span class="token keyword" style="color:rgb(127, 219, 202)">LANGUAGE</span><span class="token plain"> plpgsql</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <p>If you run <code>SELECT get_part_name(100);</code> at the coordinator the function runs on the coordinator. (The coordinator instance directs the query to a single primary segment.) If orders is a distributed table and you run the following query, the <code>get_part_name()</code> function runs on the primary segments.</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token identifier punctuation" style="color:rgb(199, 146, 234)">`</span><span class="token identifier">SELECT order_id, get_part_name(orders.part_no) FROM orders;</span><span class="token identifier punctuation" style="color:rgb(199, 146, 234)">`</span><br></div></code></pre></div></div> | |
| <h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="writing-security-definer-functions-safely">Writing security definer functions safely<a href="#writing-security-definer-functions-safely" class="hash-link" aria-label="Direct link to Writing security definer functions safely" title="Direct link to Writing security definer functions safely" translate="no"></a></h2> | |
| <p>Because a <code>SECURITY DEFINER</code> function is executed with the privileges of the user that created it, care is needed to ensure that the function cannot be misused. For security, <code>search_path</code> should be set to exclude any schemas writable by untrusted users. This prevents malicious users from creating objects that mask objects used by the function. Particularly important in this regard is the temporary-table schema, which is searched first by default, and is normally writable by anyone. A secure arrangement can be had by forcing the temporary schema to be searched last. To do this, write <code>pg_temp</code> as the last entry in <code>search_path</code>. This function illustrates safe usage:</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> check_password</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">uname </span><span class="token keyword" style="color:rgb(127, 219, 202)">TEXT</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> pass </span><span class="token keyword" style="color:rgb(127, 219, 202)">TEXT</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURNS</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">BOOLEAN</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">AS</span><span class="token plain"> $$</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">DECLARE</span><span class="token plain"> passed </span><span class="token keyword" style="color:rgb(127, 219, 202)">BOOLEAN</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">BEGIN</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">SELECT</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">pwd </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> $</span><span class="token number" style="color:rgb(247, 140, 108)">2</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">INTO</span><span class="token plain"> passed</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FROM</span><span class="token plain"> pwds</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">WHERE</span><span class="token plain"> username </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> $</span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">RETURN</span><span class="token plain"> passed</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">END</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain">$$ </span><span class="token keyword" style="color:rgb(127, 219, 202)">LANGUAGE</span><span class="token plain"> plpgsql</span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> SECURITY </span><span class="token keyword" style="color:rgb(127, 219, 202)">DEFINER</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">-- Set a secure search_path: trusted schema(s), then 'pg_temp'.</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">SET</span><span class="token plain"> search_path </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> admin</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> pg_temp</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <p>The <code>SET</code> option was not available in earlier versions of Apache Cloudberry, and so older functions may contain rather complicated logic to save, set, and restore <code>search_path</code>. The <code>SET</code> option is far easier to use for this purpose.</p> | |
| <p>Another point to keep in mind is that by default, execute privilege is granted to <code>PUBLIC</code> for newly created functions (see <a class="" href="/docs/next/sql-stmts/grant">GRANT</a> for more information). Frequently you will wish to restrict use of a security definer function to only some users. To do that, you must revoke the default <code>PUBLIC</code> privileges and then grant <code>EXECUTE</code> privilege selectively. To avoid having a window where the new function is accessible to all, create it and set the privileges within a single transaction. For example:</p> | |
| <div class="language-sql codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-sql codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">BEGIN</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">CREATE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> check_password</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">uname </span><span class="token keyword" style="color:rgb(127, 219, 202)">TEXT</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> pass </span><span class="token keyword" style="color:rgb(127, 219, 202)">TEXT</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain"> SECURITY </span><span class="token keyword" style="color:rgb(127, 219, 202)">DEFINER</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">REVOKE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">ALL</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">ON</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> check_password</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">uname </span><span class="token keyword" style="color:rgb(127, 219, 202)">TEXT</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> pass </span><span class="token keyword" style="color:rgb(127, 219, 202)">TEXT</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FROM</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">PUBLIC</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">GRANT</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">EXECUTE</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">ON</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">FUNCTION</span><span class="token plain"> check_password</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">uname </span><span class="token keyword" style="color:rgb(127, 219, 202)">TEXT</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> pass </span><span class="token keyword" style="color:rgb(127, 219, 202)">TEXT</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">TO</span><span class="token plain"> admins</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></div><div class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">COMMIT</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></div></code></pre></div></div> | |
| <h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="compatibility">Compatibility<a href="#compatibility" class="hash-link" aria-label="Direct link to Compatibility" title="Direct link to Compatibility" translate="no"></a></h2> | |
| <p><code>CREATE FUNCTION</code> is defined in SQL:1999 and later. The Apache Cloudberry version is similar but not fully compatible. The attributes are not portable, neither are the different available languages.</p> | |
| <p>For compatibility with some other database systems, argmode can be written either before or after argname. But only the first way is standard-compliant.</p> | |
| <p>For parameter defaults, the SQL standard specifies only the syntax with the <code>DEFAULT</code> key word. The syntax with <code>=</code> is used in T-SQL and Firebird.</p> | |
| <h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="see-also">See also<a href="#see-also" class="hash-link" aria-label="Direct link to See also" title="Direct link to See also" translate="no"></a></h2> | |
| <p><a class="" href="/docs/next/sql-stmts/alter-function">ALTER FUNCTION</a>, <a class="" href="/docs/next/sql-stmts/drop-function">DROP FUNCTION</a>, <a class="" href="/docs/next/sql-stmts/grant">GRANT</a>, <a class="" href="/docs/next/sql-stmts/load">LOAD</a>, <a class="" href="/docs/next/sql-stmts/revoke">REVOKE</a>, createlang</p></div><footer class="theme-doc-footer docusaurus-mt-lg"><div class="theme-doc-footer-edit-meta-row row"><div class="col"><a href="https://github.com/apache/cloudberry-site/edit/main/versioned_docs/version-2.x/sql-stmts/create-function.md" target="_blank" rel="noopener noreferrer" class="theme-edit-this-page"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_Z9Sw" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col lastUpdated_VsjB"><span class="theme-last-updated">Last updated<!-- --> on <b><time datetime="2026-11-20T02:20:02.000Z" itemprop="dateModified">Nov 20, 2026</time></b> by <b>Dianjin Wang</b></span></div></div></footer></article><nav class="pagination-nav" aria-label="Docs pages"><a class="pagination-nav__link pagination-nav__link--prev" href="/docs/sql-stmts/create-foreign-table"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label single-line-overflow hide-before-after">CREATE FOREIGN TABLE</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/docs/sql-stmts/create-group"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label single-line-overflow hide-before-after">CREATE GROUP</div></a></nav></div></div><div class="col col--3 docTocCol_G3jg"><div class="tableOfContents_jeP5 thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#synopsis" class="table-of-contents__link toc-highlight">Synopsis</a></li><li><a href="#description" class="table-of-contents__link toc-highlight">Description</a></li><li><a href="#parameters" class="table-of-contents__link toc-highlight">Parameters</a></li><li><a href="#overloading" class="table-of-contents__link toc-highlight">Overloading</a></li><li><a href="#notes" class="table-of-contents__link toc-highlight">Notes</a></li><li><a href="#examples" class="table-of-contents__link toc-highlight">Examples</a></li><li><a href="#writing-security-definer-functions-safely" class="table-of-contents__link toc-highlight">Writing security definer functions safely</a></li><li><a href="#compatibility" class="table-of-contents__link toc-highlight">Compatibility</a></li><li><a href="#see-also" class="table-of-contents__link toc-highlight">See also</a></li></ul></div></div></div></div></main></div></div></div><div class="wrap_QlFE"><div class="mainWrap_IbWk"><div class="linksWrap_Zcc4"><div class="footerLink_s3zo"><div class="footerLinkTitle_PxTg">Support</div><div class="footerLinkItem_Kf4k"><a href="https://github.com/apache/cloudberry/issues" target="_blank" rel="noopener noreferrer">GitHub Issues</a></div><div class="footerLinkItem_Kf4k"><a href="https://github.com/apache/cloudberry/discussions" target="_blank" rel="noopener noreferrer">GitHub Discussions</a></div><div class="footerLinkItem_Kf4k"><a href="https://join.slack.com/t/asf-cloudberry/shared_invite/zt-3um34r7hf-Sh~6jG6hVxlQJo1tbhK2sw" target="_blank" rel="noopener noreferrer">Slack</a></div><div class="footerLinkItem_Kf4k"><a href="https://discord.gg/GJrz3Fxf6y" target="_blank" rel="noopener noreferrer">Discord</a></div><div class="footerLinkItem_Kf4k"><a href="https://x.com/ASFCloudberry" target="_blank" rel="noopener noreferrer">Twitter</a></div><div class="footerLinkItem_Kf4k"><a href="https://youtube.com/@ApacheCloudberry" target="_blank" rel="noopener noreferrer">Youtube</a></div><div class="footerLinkItem_Kf4k"><a target="_self" href="/community/security">Security</a></div></div><div class="footerLink_s3zo"><div class="footerLinkTitle_PxTg">Resources</div><div class="footerLinkItem_Kf4k"><a href="/releases" target="_blank">Download</a></div><div class="footerLinkItem_Kf4k"><a target="_self" href="/docs/">Documentation</a></div><div class="footerLinkItem_Kf4k"><a target="_self" href="/community/events">Events</a></div><div class="footerLinkItem_Kf4k"><a href="/community/brand" target="_blank">Brand Guidelines</a></div><div class="footerLinkItem_Kf4k"><a href="/powered-by" target="_blank">Powered By</a></div></div><div class="footerLink_s3zo"><div class="footerLinkTitle_PxTg">Contribution</div><div class="footerLinkItem_Kf4k"><a target="_self" href="/contribute/git">Working with Git & GitHub</a></div><div class="footerLinkItem_Kf4k"><a target="_self" href="/contribute/how-to-contribute">Contribution Overview</a></div><div class="footerLinkItem_Kf4k"><a target="_self" href="/contribute/code">Code Contribution</a></div><div class="footerLinkItem_Kf4k"><a target="_self" href="/contribute/doc">Doc Contribution</a></div></div></div><div class="logoLinkWrap_MDp5"><div class="logoWrap_qcVI"><img class="logo_cphB" src="/img/apache-incubator.svg" alt=""></div><div class="links_yA93"><svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" fill="none" viewBox="0 0 30 30" class="item_KKoc" cursor="pointer"><path d="M15.002 0c-8.288 0-15 6.713-15 15 0 6.637 4.293 12.244 10.256 14.231.75.131 1.031-.319 1.031-.712 0-.356-.019-1.538-.019-2.794-3.769.694-4.744-.919-5.044-1.763-.168-.43-.9-1.762-1.537-2.118-.525-.282-1.275-.975-.019-.994 1.181-.019 2.025 1.087 2.306 1.537 1.35 2.27 3.507 1.632 4.37 1.238.13-.975.524-1.631.956-2.006-3.338-.375-6.826-1.669-6.826-7.406 0-1.632.582-2.982 1.538-4.032-.15-.375-.675-1.912.15-3.975 0 0 1.256-.394 4.125 1.538 1.2-.338 2.475-.506 3.75-.506s2.55.168 3.75.506c2.869-1.95 4.125-1.538 4.125-1.538.825 2.063.3 3.6.15 3.975.956 1.05 1.538 2.382 1.538 4.032 0 5.756-3.507 7.03-6.844 7.406.544.468 1.012 1.369 1.012 2.775 0 2.006-.018 3.619-.018 4.125 0 .394.28.862 1.03.712A15.02 15.02 0 0 0 30.003 15c0-8.287-6.713-15-15-15"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="32" height="26" fill="none" viewBox="0 0 32 26" class="item_KKoc" cursor="pointer"><path d="M31.319 3.484c-1.145.507-2.36.84-3.603.987a6.3 6.3 0 0 0 2.758-3.47 12.5 12.5 0 0 1-3.983 1.52A6.274 6.274 0 0 0 15.64 6.815q.002.74.161 1.43a17.81 17.81 0 0 1-12.93-6.555 6.25 6.25 0 0 0-.85 3.154 6.27 6.27 0 0 0 2.791 5.222 6.25 6.25 0 0 1-2.841-.785l-.001.077a6.28 6.28 0 0 0 5.033 6.153 6.3 6.3 0 0 1-2.834.108 6.28 6.28 0 0 0 5.86 4.356 12.6 12.6 0 0 1-7.79 2.686q-.75 0-1.497-.088a17.75 17.75 0 0 0 9.616 2.818c11.54 0 17.849-9.559 17.849-17.848q0-.409-.019-.812a12.8 12.8 0 0 0 3.13-3.246"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="30" height="24" fill="none" viewBox="0 0 30 24" class="item_KKoc" cursor="pointer"><path d="M15.366 0c.801.004 2.805.024 4.935.11l.755.032c2.145.102 4.287.275 5.35.571 1.417.398 2.53 1.56 2.907 3.033.6 2.339.675 6.903.684 8.008l.002.229v.032l-.002.229c-.009 1.104-.084 5.669-.684 8.008-.381 1.478-1.495 2.64-2.907 3.032-1.063.297-3.205.47-5.35.571l-.755.033c-2.13.086-4.134.105-4.935.11h-.734c-1.696-.01-8.785-.087-11.04-.714-1.418-.398-2.532-1.56-2.908-3.032-.6-2.34-.675-6.904-.684-8.008v-.49c.01-1.105.084-5.67.684-8.008.382-1.478 1.496-2.64 2.908-3.033C5.847.086 12.936.01 14.632 0zm-3.367 6.749v10.5l9-5.25z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" fill="none" viewBox="0 0 30 30" class="item_KKoc" cursor="pointer"><path d="M6.791 18.77a2.96 2.96 0 0 1-2.952 2.952 2.96 2.96 0 0 1-2.951-2.951 2.96 2.96 0 0 1 2.951-2.952h2.952zm1.487 0a2.96 2.96 0 0 1 2.952-2.951 2.96 2.96 0 0 1 2.952 2.952v7.39a2.96 2.96 0 0 1-2.952 2.952 2.96 2.96 0 0 1-2.952-2.952zM11.23 6.792A2.96 2.96 0 0 1 8.278 3.84 2.96 2.96 0 0 1 11.23.888a2.96 2.96 0 0 1 2.952 2.951v2.952zm0 1.487a2.96 2.96 0 0 1 2.952 2.952 2.96 2.96 0 0 1-2.952 2.952H3.84A2.96 2.96 0 0 1 .887 11.23a2.96 2.96 0 0 1 2.951-2.952zm11.98 2.952a2.96 2.96 0 0 1 2.951-2.952 2.96 2.96 0 0 1 2.952 2.952 2.96 2.96 0 0 1-2.952 2.952H23.21zm-1.488 0a2.96 2.96 0 0 1-2.951 2.952 2.96 2.96 0 0 1-2.952-2.952V3.84A2.96 2.96 0 0 1 18.771.887a2.96 2.96 0 0 1 2.951 2.951zm-2.951 11.98a2.96 2.96 0 0 1 2.951 2.951 2.96 2.96 0 0 1-2.951 2.952 2.96 2.96 0 0 1-2.952-2.952V23.21zm0-1.488a2.96 2.96 0 0 1-2.952-2.951 2.96 2.96 0 0 1 2.952-2.952h7.39a2.96 2.96 0 0 1 2.952 2.952 2.96 2.96 0 0 1-2.952 2.951z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" fill="none" viewBox="0 0 30 30" class="item_KKoc" cursor="pointer"><path d="M25.396 5.463a24.2 24.2 0 0 0-6.062-1.876.06.06 0 0 0-.063.03c-.25.45-.525 1.026-.712 1.483a22.3 22.3 0 0 0-6.7 0 14 14 0 0 0-.725-1.482.07.07 0 0 0-.063-.03A24 24 0 0 0 5.01 5.463a.06.06 0 0 0-.03.027C1.416 11.307.434 17.008.999 22.642a.1.1 0 0 0 .04.073 23.2 23.2 0 0 0 7.187 3.663.07.07 0 0 0 .07-.023 18.4 18.4 0 0 0 1.47-2.453.076.076 0 0 0-.04-.105 16 16 0 0 1-2.262-1.11c-.048-.027-.05-.095-.005-.122q.234-.177.457-.365a.07.07 0 0 1 .073-.01c4.995 2.302 10.37 2.302 15.307 0a.07.07 0 0 1 .075.008c.148.125.303.25.46.367a.07.07 0 0 1-.002.122c-.72.433-1.47.8-2.265 1.108-.043.017-.058.067-.04.107.437.858.93 1.675 1.47 2.45a.07.07 0 0 0 .072.026 23.2 23.2 0 0 0 7.2-3.663.1.1 0 0 0 .038-.07c.655-6.512-1.07-12.162-4.883-17.152a.05.05 0 0 0-.025-.03m-14.87 13.7c-1.367 0-2.497-1.27-2.497-2.815s1.105-2.815 2.497-2.815c1.405 0 2.523 1.282 2.498 2.815 0 1.544-1.105 2.815-2.498 2.815m9.293 0c-1.368 0-2.498-1.27-2.498-2.815s1.105-2.815 2.498-2.815c1.405 0 2.522 1.282 2.497 2.815 0 1.544-1.092 2.815-2.497 2.815"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="28" height="30" fill="none" viewBox="0 0 28 30" class="item_KKoc" cursor="pointer"><path d="M22.48 4.286H5.195c-.845 0-1.52.724-1.52 1.568v18.579c0 .844.675 1.568 1.52 1.568h17.283c.845 0 1.52-.724 1.52-1.568V5.854c0-.844-.675-1.568-1.52-1.568"></path><path fill="#000" d="M6.233 12.156h3.081v10.756H6.233zm1.57-5.315c.988 0 1.802.875 1.802 1.938s-.814 1.939-1.803 1.939C6.814 10.718 6 9.842 6 8.779s.814-1.938 1.802-1.938m3.488 5.315h2.965v1.439h.058c.407-.876 1.453-1.751 2.965-1.751 3.14 0 3.721 2.25 3.721 5.127v5.879h-3.081v-5.253c0-1.25 0-2.877-1.628-2.877s-1.86 1.376-1.86 2.752v5.315h-3.082v-10.63z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" width="34" height="28" fill="none" viewBox="0 0 34 28" class="item_KKoc" cursor="pointer"><path d="M26.863 16.567c.748 0 1.347-.636 1.347-1.347 0-.748-.599-1.347-1.347-1.347s-1.347.599-1.347 1.347c0 .749.599 1.347 1.347 1.347m-6.639 0c.749 0 1.347-.636 1.347-1.347 0-.748-.598-1.347-1.347-1.347-.748 0-1.346.599-1.346 1.347 0 .749.598 1.347 1.346 1.347m9.852 7.56a.52.52 0 0 0-.258.553c0 .074 0 .148.036.221.148.627.442 1.622.442 1.66 0 .11.037.184.037.257a.33.33 0 0 1-.331.332c-.074 0-.11-.037-.184-.074l-2.174-1.253c-.147-.074-.331-.147-.516-.147-.11 0-.22 0-.294.037-1.032.294-2.1.442-3.242.442-5.49 0-9.91-3.687-9.91-8.258s4.42-8.257 9.91-8.257c5.489 0 9.91 3.686 9.91 8.257 0 2.47-1.327 4.719-3.427 6.23M24.01 8.147a14 14 0 0 0-.42-.007c-6.261 0-11.409 4.29-11.409 9.757 0 .83.119 1.634.342 2.4h-.133c-1.33 0-2.659-.221-3.877-.553-.111-.037-.222-.037-.333-.037-.221 0-.443.074-.627.185L4.932 21.4a.5.5 0 0 1-.221.074.41.41 0 0 1-.406-.405c0-.11.036-.184.073-.294.037-.037.37-1.251.554-1.987 0-.074.037-.184.037-.258a.83.83 0 0 0-.332-.662C2.089 16.065.5 13.378.5 10.398.501 4.916 5.855.5 12.428.5 18.073.5 22.82 3.753 24.01 8.146m-7.731.627c.859 0 1.54-.716 1.54-1.54 0-.858-.681-1.539-1.54-1.539-.86 0-1.54.68-1.54 1.54 0 .859.68 1.54 1.54 1.54m-7.89 0c.86 0 1.54-.716 1.54-1.54 0-.858-.68-1.539-1.54-1.539-.859 0-1.539.68-1.539 1.54 0 .859.68 1.54 1.54 1.54"></path></svg></div></div></div><div class="copyrightWrap_yPz7"><div class="copyright_AoBa"> | |
| <p> | |
| Apache Cloudberry is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF. | |
| </p> | |
| <p> | |
| Copyright © 2026 The Apache Software Foundation, Licensed under the Apache License, Version 2.0.</p> | |
| <p> | |
| Apache Cloudberry, Cloudberry, Apache, the Apache logo, and the Apache Cloudberry project logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries. All other marks mentioned may be trademarks or registered trademarks of their respective owners. | |
| </p> | |
| </div></div></div></div> | |
| </body> | |
| </html> |