Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

ALTER PROCEDURE

Updated on 2024-06-03 GMT+08:00

Description

Modifies the attributes of a user-defined stored procedure or recompiles a stored procedure.

Precautions

  • Only the owner of a stored procedure or a user granted with the ALTER permission can run the ALTER PROCEDURE command. The system administrator has this permission by default. The following are permission constraints depending on the attributes to be modified:
    • If a stored procedure involves operations on temporary tables, ALTER PROCEDURE cannot be used.
    • To modify the owner or schema of a stored procedure, you must be the owner of the stored procedure or system administrator and a member of the new owner role.
    • Only the system administrator and initial user can change the schema of a stored procedure to a public schema.
  • The plpgsql_dependency parameter must be set for stored procedure compilation.
  • Only the initial user or the user who creates the stored procedure can modify the stored procedure to a stored procedure that has the definer permission.
  • When separation of duties is enabled, no role is allowed to modify the owner of a stored procedure with the definer permission.
  • When separation of duties is disabled, only the initial user and system administrator can change the owner of a stored procedure with the definer permission. However, the stored procedure owner cannot be changed to an O&M administrator.
  • Only the initial user can change the owner of a stored procedure to the initial user.

Syntax

  • Modify the additional parameters of a user-defined stored procedure.
    ALTER PROCEDURE procedure_name ( [ { [ argname ] [ argmode ] argtype} [, ...] ] )
        action [ ... ] [ RESTRICT ];

    The syntax of the ACTION clause is as follows:

    {CALLED ON NULL INPUT  | STRICT}
     | {IMMUTABLE | STABLE | VOLATILE}
     | {SHIPPABLE | NOT SHIPPABLE}
     | {NOT FENCED | FENCED}
     | [ NOT ] LEAKPROOF
     | { [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER }
     | AUTHID { DEFINER | CURRENT_USER }
     | COST execution_cost
     | ROWS result_rows
     | SET configuration_parameter { { TO | = } { value | DEFAULT }| FROM CURRENT}
     | RESET {configuration_parameter | ALL}
  • Modify the name of a user-defined stored procedure.
    ALTER PROCEDURE proname ( [ { [ argname ] [ argmode ] argtype} [, ...] ] )
        RENAME TO new_name;
  • Modify the owner of a user-defined stored procedure.
    ALTER PROCEDURE proname ( [ { [ argname ] [ argmode ] argtype} [, ...] ] )
        OWNER TO new_owner;
  • Modify the schema of a user-defined stored procedure.
    ALTER PROCEDURE proname ( [ { [ argname ] [ argmode ] argtype} [, ...] ] )
        SET SCHEMA new_schema;
  • Recompile a stored procedure.
    ALTER PROCEDURE procedure_name COMPILE;

Parameters

  • procedure_name

    Specifies the name of the stored procedure to be modified.

    Value range: an existing stored procedure name

  • argmode

    Specifies whether a parameter is an input or output parameter.

    Value range: IN, OUT, INOUT, and VARIADIC

  • argname

    Specifies the parameter name.

    Value range: a string. It must comply with the naming convention.

  • argtype

    Specifies the type of the stored procedure parameter.

  • CALLED ON NULL INPUT

    Declares that some parameters of the stored procedure can be called in normal mode if the parameter values are null. Omitting this parameter is the same as specifying it.

  • IMMUTABLE

    Specifies that the stored procedure always returns the same result if the parameter values are the same.

  • STABLE

    Specifies that the stored procedure cannot modify the database, and that within a single table scan it will consistently return the same result for the same parameter value, but its result varies by SQL statements.

  • VOLATILE

    Specifies that the stored procedure value can change in a single table scan and no optimization is performed.

  • LEAKPROOF

    Specifies that the stored procedure has no side effect and the parameter contains only the return value. LEAKPROOF can be set only by the system administrator.

  • EXTERNAL

    (Optional) The purpose is to be compatible with SQL. This feature applies to all functions, not only external functions.

  • SECURITY INVOKER

    AUTHID CURRENT_USER

    Specifies that the stored procedure will be executed with the permissions of the user who calls it. Omitting this parameter is the same as specifying it.

    SECURITY INVOKER and AUTHID CURRENT_USER have the same functions.

  • SECURITY DEFINER

    AUTHID DEFINER

    Specifies that the stored procedure will be executed with the permissions of the user who created it.

    AUTHID DEFINER and SECURITY DEFINER have the same functions.

  • COST execution_cost

    Estimates the execution cost of the stored procedure.

    The unit of execution_cost is cpu_operator_cost.

    Value range: a positive integer

  • ROWS result_rows

    Estimates the number of rows returned by the stored procedure. This is only allowed when the stored procedure is declared to return a set.

    Value range: a positive number. The default value is 1000.

  • configuration_parameter
    • value

      Sets a specified database session parameter to a specified value. If the value is DEFAULT or RESET, the default setting is used in the new session. OFF disables the setting.

      Value range: a string.

      • DEFAULT
      • OFF
      • RESET
      • User-specified value: The value must meet the restriction of the modified parameter.
    • FROM CURRENT

      Uses the value of configuration_parameter of the current session.

  • new_name

    Specifies the new name of the stored procedure. To change the schema of a stored procedure, you must have the CREATE permission on the new schema.

    Value range: a string. It must comply with the naming convention.

  • new_owner

    Specifies the new owner of the stored procedure. To change the owner of a stored procedure, the new owner must have the CREATE permission on the schema to which the stored procedure belongs.

    Value range: an existing user role

  • new_schema

    Specifies the new schema of the stored procedure.

    Value range: an existing schema

Examples

See Examples in section "CREATE PROCEDURE."

Recompilation examples:
-- Enable the dependency function.
gaussdb=# SET behavior_compat_options ='plpgsql_dependency';

-- Create a stored procedure.
gaussdb=# CREATE OR REPLACE PROCEDURE test_proc(a int)
IS
    proc_var int;
BEGIN
    proc_var := a;
END;
/

-- Recompile a stored procedure with the stored procedure name.
gaussdb=# ALTER PROCEDURE test_proc COMPILE;

-- Recompile a stored procedure with a signed int type stored procedure.
gaussdb=# ALTER PROCEDURE test_proc(int) COMPILE;

-- Drop the stored procedure.
gaussdb=# DROP PROCEDURE test_proc;

Helpful Links

CREATE PROCEDURE and DROP PROCEDURE

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback