* CREATE TRANSFORM */
| 2305 | * CREATE TRANSFORM |
| 2306 | */ |
| 2307 | ObjectAddress |
| 2308 | CreateTransform(CreateTransformStmt *stmt) |
| 2309 | { |
| 2310 | Oid typeid; |
| 2311 | char typtype; |
| 2312 | Oid langid; |
| 2313 | Oid fromsqlfuncid; |
| 2314 | Oid tosqlfuncid; |
| 2315 | AclResult aclresult; |
| 2316 | Form_pg_proc procstruct; |
| 2317 | Datum values[Natts_pg_transform]; |
| 2318 | bool nulls[Natts_pg_transform]; |
| 2319 | bool replaces[Natts_pg_transform]; |
| 2320 | Oid transformid; |
| 2321 | HeapTuple tuple; |
| 2322 | HeapTuple newtuple; |
| 2323 | Relation relation; |
| 2324 | ObjectAddress myself, |
| 2325 | referenced; |
| 2326 | ObjectAddresses *addrs; |
| 2327 | bool is_replace; |
| 2328 | |
| 2329 | /* |
| 2330 | * Get the type |
| 2331 | */ |
| 2332 | typeid = typenameTypeId(NULL, stmt->type_name); |
| 2333 | typtype = get_typtype(typeid); |
| 2334 | |
| 2335 | if (typtype == TYPTYPE_PSEUDO) |
| 2336 | ereport(ERROR, |
| 2337 | (errcode(ERRCODE_WRONG_OBJECT_TYPE), |
| 2338 | errmsg("data type %s is a pseudo-type", |
| 2339 | TypeNameToString(stmt->type_name)))); |
| 2340 | |
| 2341 | if (typtype == TYPTYPE_DOMAIN) |
| 2342 | ereport(ERROR, |
| 2343 | (errcode(ERRCODE_WRONG_OBJECT_TYPE), |
| 2344 | errmsg("data type %s is a domain", |
| 2345 | TypeNameToString(stmt->type_name)))); |
| 2346 | |
| 2347 | if (!pg_type_ownercheck(typeid, GetUserId())) |
| 2348 | aclcheck_error_type(ACLCHECK_NOT_OWNER, typeid); |
| 2349 | |
| 2350 | aclresult = pg_type_aclcheck(typeid, GetUserId(), ACL_USAGE); |
| 2351 | if (aclresult != ACLCHECK_OK) |
| 2352 | aclcheck_error_type(aclresult, typeid); |
| 2353 | |
| 2354 | /* |
| 2355 | * Get the language |
| 2356 | */ |
| 2357 | langid = get_language_oid(stmt->lang, false); |
| 2358 | |
| 2359 | aclresult = pg_language_aclcheck(langid, GetUserId(), ACL_USAGE); |
| 2360 | if (aclresult != ACLCHECK_OK) |
| 2361 | aclcheck_error(aclresult, OBJECT_LANGUAGE, stmt->lang); |
| 2362 | |
| 2363 | /* |
| 2364 | * Get the functions |
no test coverage detected