MCPcopy Create free account
hub / github.com/apache/cloudberry / exec_command_ef_ev

Function exec_command_ef_ev

src/bin/psql/command.c:1093–1210  ·  view source on GitHub ↗

* \ef/\ev -- edit the named function/view, or * present a blank CREATE FUNCTION/VIEW template if no argument is given */

Source from the content-addressed store, hash-verified

1091 * present a blank CREATE FUNCTION/VIEW template if no argument is given
1092 */
1093static backslashResult
1094exec_command_ef_ev(PsqlScanState scan_state, bool active_branch,
1095 PQExpBuffer query_buf, bool is_func)
1096{
1097 backslashResult status = PSQL_CMD_SKIP_LINE;
1098
1099 if (active_branch)
1100 {
1101 char *obj_desc = psql_scan_slash_option(scan_state,
1102 OT_WHOLE_LINE,
1103 NULL, true);
1104 int lineno = -1;
1105
1106 if (pset.sversion < (is_func ? 80400 : 70400))
1107 {
1108 char sverbuf[32];
1109
1110 formatPGVersionNumber(pset.sversion, false,
1111 sverbuf, sizeof(sverbuf));
1112 if (is_func)
1113 pg_log_error("The server (version %s) does not support editing function source.",
1114 sverbuf);
1115 else
1116 pg_log_error("The server (version %s) does not support editing view definitions.",
1117 sverbuf);
1118 status = PSQL_CMD_ERROR;
1119 }
1120 else if (!query_buf)
1121 {
1122 pg_log_error("no query buffer");
1123 status = PSQL_CMD_ERROR;
1124 }
1125 else
1126 {
1127 Oid obj_oid = InvalidOid;
1128 EditableObjectType eot = is_func ? EditableFunction : EditableView;
1129
1130 lineno = strip_lineno_from_objdesc(obj_desc);
1131 if (lineno == 0)
1132 {
1133 /* error already reported */
1134 status = PSQL_CMD_ERROR;
1135 }
1136 else if (!obj_desc)
1137 {
1138 /* set up an empty command to fill in */
1139 resetPQExpBuffer(query_buf);
1140 if (is_func)
1141 appendPQExpBufferStr(query_buf,
1142 "CREATE FUNCTION ( )\n"
1143 " RETURNS \n"
1144 " LANGUAGE \n"
1145 " -- common options: IMMUTABLE STABLE STRICT SECURITY DEFINER\n"
1146 "AS $function$\n"
1147 "\n$function$\n");
1148 else
1149 appendPQExpBufferStr(query_buf,
1150 "CREATE VIEW AS\n"

Callers 1

exec_commandFunction · 0.85

Calls 8

formatPGVersionNumberFunction · 0.85
resetPQExpBufferFunction · 0.85
appendPQExpBufferStrFunction · 0.85
lookup_object_oidFunction · 0.85
get_create_object_cmdFunction · 0.85
do_editFunction · 0.85
ignore_slash_whole_lineFunction · 0.85

Tested by

no test coverage detected