| Line | Hits | Source | Commit |
|---|---|---|---|
| 117 | - | bool is_nsp_name_unique; /* can the nsp/name combination (or name | - |
| 118 | - | * alone, if there's no namespace) be | - |
| 119 | - | * considered a unique identifier for an | - |
| 120 | - | * object of this class? */ | - |
| 121 | - | } ObjectPropertyType; | - |
| 122 | - | - | |
| 123 | - | static const ObjectPropertyType ObjectProperty[] = | - |
| 124 | - | { | - |
| 125 | - | { | - |
| 126 | - | "access method", | - |
| 127 | - | AccessMethodRelationId, | - |
| 128 | - | AmOidIndexId, | - |
| 129 | - | AMOID, | - |
| 130 | - | AMNAME, | - |
| 131 | - | Anum_pg_am_oid, | - |
| 132 | - | Anum_pg_am_amname, | - |
| 133 | - | InvalidAttrNumber, | - |
| 134 | - | InvalidAttrNumber, | - |
| 135 | - | InvalidAttrNumber, | - |
| 136 | - | OBJECT_ACCESS_METHOD, | - |
| 137 | - | true | - |
| 138 | - | }, | - |
| 139 | - | { | - |
| 140 | - | "access method operator", | - |
| 141 | - | AccessMethodOperatorRelationId, | - |
| 142 | - | AccessMethodOperatorOidIndexId, | - |
| 143 | - | -1, | - |
| 144 | - | -1, | - |
| 145 | - | Anum_pg_amop_oid, | - |
| 146 | - | InvalidAttrNumber, | - |
| 147 | - | InvalidAttrNumber, | - |
| 148 | - | InvalidAttrNumber, | - |
| 149 | - | InvalidAttrNumber, | - |
| 150 | - | OBJECT_AMOP, | - |
| 151 | - | false | - |
| 152 | - | }, | - |
| 153 | - | { | - |
| 154 | - | "access method procedure", | - |
| 155 | - | AccessMethodProcedureRelationId, | - |
| 156 | - | AccessMethodProcedureOidIndexId, | - |
| 157 | - | -1, | - |
| 158 | - | -1, | - |
| 159 | - | Anum_pg_amproc_oid, | - |
| 160 | - | InvalidAttrNumber, | - |
| 161 | - | InvalidAttrNumber, | - |
| 162 | - | InvalidAttrNumber, | - |
| 163 | - | InvalidAttrNumber, | - |
| 164 | - | OBJECT_AMPROC, | - |
| 165 | - | false | - |
| 166 | - | }, | - |
| 167 | - | { | - |
| 168 | - | "cast", | - |
| 169 | - | CastRelationId, | - |
| 170 | - | CastOidIndexId, | - |
| 171 | - | -1, | - |
| 172 | - | -1, | - |
| 173 | - | Anum_pg_cast_oid, | - |
| 174 | - | InvalidAttrNumber, | - |
| 175 | - | InvalidAttrNumber, | - |
| 176 | - | InvalidAttrNumber, | - |
| 177 | - | InvalidAttrNumber, | - |
| 178 | - | OBJECT_CAST, | - |
| 179 | - | false | - |
| 180 | - | }, | - |
| 181 | - | { | - |
| 182 | - | "collation", | - |
| 183 | - | CollationRelationId, | - |
| 184 | - | CollationOidIndexId, | - |
| 185 | - | COLLOID, | - |
| 186 | - | -1, /* COLLNAMEENCNSP also takes encoding */ | - |
| 187 | - | Anum_pg_collation_oid, | - |
| 188 | - | Anum_pg_collation_collname, | - |
| 189 | - | Anum_pg_collation_collnamespace, | - |
| 190 | - | Anum_pg_collation_collowner, | - |
| 191 | - | InvalidAttrNumber, | - |
| 192 | - | OBJECT_COLLATION, | - |
| 193 | - | true | - |
| 194 | - | }, | - |
| 195 | - | { | - |
| 196 | - | "constraint", | - |
| 197 | - | ConstraintRelationId, | - |
| 198 | - | ConstraintOidIndexId, | - |
| 199 | - | CONSTROID, | - |
| 200 | - | -1, | - |
| 201 | - | Anum_pg_constraint_oid, | - |
| 202 | - | Anum_pg_constraint_conname, | - |
| 203 | - | Anum_pg_constraint_connamespace, | - |
| 204 | - | InvalidAttrNumber, | - |
| 205 | - | InvalidAttrNumber, | - |
| 206 | - | -1, | - |
| 207 | - | false | - |
| 208 | - | }, | - |
| 209 | - | { | - |
| 210 | - | "conversion", | - |
| 211 | - | ConversionRelationId, | - |
| 212 | - | ConversionOidIndexId, | - |
| 213 | - | CONVOID, | - |
| 214 | - | CONNAMENSP, | - |
| 215 | - | Anum_pg_conversion_oid, | - |
| 216 | - | Anum_pg_conversion_conname, | - |
| 217 | - | Anum_pg_conversion_connamespace, | - |
| 218 | - | Anum_pg_conversion_conowner, | - |
| 219 | - | InvalidAttrNumber, | - |
| 220 | - | OBJECT_CONVERSION, | - |
| 221 | - | true | - |
| 222 | - | }, | - |
| 223 | - | { | - |
| 224 | - | "database", | - |
| 225 | - | DatabaseRelationId, | - |
| 226 | - | DatabaseOidIndexId, | - |
| 227 | - | DATABASEOID, | - |
| 228 | - | -1, | - |
| 229 | - | Anum_pg_database_oid, | - |
| 230 | - | Anum_pg_database_datname, | - |
| 231 | - | InvalidAttrNumber, | - |
| 232 | - | Anum_pg_database_datdba, | - |
| 233 | - | Anum_pg_database_datacl, | - |
| 234 | - | OBJECT_DATABASE, | - |
| 235 | - | true | - |
| 236 | - | }, | - |
| 237 | - | { | - |
| 238 | - | "default ACL", | - |
| 239 | - | DefaultAclRelationId, | - |
| 240 | - | DefaultAclOidIndexId, | - |
| 241 | - | -1, | - |
| 242 | - | -1, | - |
| 243 | - | Anum_pg_default_acl_oid, | - |
| 244 | - | InvalidAttrNumber, | - |
| 245 | - | InvalidAttrNumber, | - |
| 246 | - | InvalidAttrNumber, | - |
| 247 | - | InvalidAttrNumber, | - |
| 248 | - | OBJECT_DEFACL, | - |
| 249 | - | false | - |
| 250 | - | }, | - |
| 251 | - | { | - |
| 252 | - | "extension", | - |
| 253 | - | ExtensionRelationId, | - |
| 254 | - | ExtensionOidIndexId, | - |
| 255 | - | -1, | - |
| 256 | - | -1, | - |
| 257 | - | Anum_pg_extension_oid, | - |
| 258 | - | Anum_pg_extension_extname, | - |
| 259 | - | InvalidAttrNumber, /* extension doesn't belong to extnamespace */ | - |
| 260 | - | Anum_pg_extension_extowner, | - |
| 261 | - | InvalidAttrNumber, | - |
| 262 | - | OBJECT_EXTENSION, | - |
| 263 | - | true | - |
| 264 | - | }, | - |
| 265 | - | { | - |
| 266 | - | "foreign-data wrapper", | - |
| 267 | - | ForeignDataWrapperRelationId, | - |
| 268 | - | ForeignDataWrapperOidIndexId, | - |
| 269 | - | FOREIGNDATAWRAPPEROID, | - |
| 270 | - | FOREIGNDATAWRAPPERNAME, | - |
| 271 | - | Anum_pg_foreign_data_wrapper_oid, | - |
| 272 | - | Anum_pg_foreign_data_wrapper_fdwname, | - |
| 273 | - | InvalidAttrNumber, | - |
| 274 | - | Anum_pg_foreign_data_wrapper_fdwowner, | - |
| 275 | - | Anum_pg_foreign_data_wrapper_fdwacl, | - |
| 276 | - | OBJECT_FDW, | - |
| 277 | - | true | - |
| 278 | - | }, | - |
| 279 | - | { | - |
| 280 | - | "foreign server", | - |
| 281 | - | ForeignServerRelationId, | - |
| 282 | - | ForeignServerOidIndexId, | - |
| 283 | - | FOREIGNSERVEROID, | - |
| 284 | - | FOREIGNSERVERNAME, | - |
| 285 | - | Anum_pg_foreign_server_oid, | - |
| 286 | - | Anum_pg_foreign_server_srvname, | - |
| 287 | - | InvalidAttrNumber, | - |
| 288 | - | Anum_pg_foreign_server_srvowner, | - |
| 289 | - | Anum_pg_foreign_server_srvacl, | - |
| 290 | - | OBJECT_FOREIGN_SERVER, | - |
| 291 | - | true | - |
| 292 | - | }, | - |
| 293 | - | { | - |
| 294 | - | "function", | - |
| 295 | - | ProcedureRelationId, | - |
| 296 | - | ProcedureOidIndexId, | - |
| 297 | - | PROCOID, | - |
| 298 | - | -1, /* PROCNAMEARGSNSP also takes argument types */ | - |
| 299 | - | Anum_pg_proc_oid, | - |
| 300 | - | Anum_pg_proc_proname, | - |
| 301 | - | Anum_pg_proc_pronamespace, | - |
| 302 | - | Anum_pg_proc_proowner, | - |
| 303 | - | Anum_pg_proc_proacl, | - |
| 304 | - | OBJECT_FUNCTION, | - |
| 305 | - | false | - |
| 306 | - | }, | - |
| 307 | - | { | - |
| 308 | - | "language", | - |
| 309 | - | LanguageRelationId, | - |
| 310 | - | LanguageOidIndexId, | - |
| 311 | - | LANGOID, | - |
| 312 | - | LANGNAME, | - |
| 313 | - | Anum_pg_language_oid, | - |
| 314 | - | Anum_pg_language_lanname, | - |
| 315 | - | InvalidAttrNumber, | - |
| 316 | - | Anum_pg_language_lanowner, | - |
| 317 | - | Anum_pg_language_lanacl, | - |
| 318 | - | OBJECT_LANGUAGE, | - |
| 319 | - | true | - |
| 320 | - | }, | - |
| 321 | - | { | - |
| 322 | - | "large object metadata", | - |
| 323 | - | LargeObjectMetadataRelationId, | - |
| 324 | - | LargeObjectMetadataOidIndexId, | - |
| 325 | - | -1, | - |
| 326 | - | -1, | - |
| 327 | - | Anum_pg_largeobject_metadata_oid, | - |
| 328 | - | InvalidAttrNumber, | - |
| 329 | - | InvalidAttrNumber, | - |
| 330 | - | Anum_pg_largeobject_metadata_lomowner, | - |
| 331 | - | Anum_pg_largeobject_metadata_lomacl, | - |
| 332 | - | OBJECT_LARGEOBJECT, | - |
| 333 | - | false | - |
| 334 | - | }, | - |
| 335 | - | { | - |
| 336 | - | "operator class", | - |
| 337 | - | OperatorClassRelationId, | - |
| 338 | - | OpclassOidIndexId, | - |
| 339 | - | CLAOID, | - |
| 340 | - | -1, /* CLAAMNAMENSP also takes opcmethod */ | - |
| 341 | - | Anum_pg_opclass_oid, | - |
| 342 | - | Anum_pg_opclass_opcname, | - |
| 343 | - | Anum_pg_opclass_opcnamespace, | - |
| 344 | - | Anum_pg_opclass_opcowner, | - |
| 345 | - | InvalidAttrNumber, | - |
| 346 | - | OBJECT_OPCLASS, | - |
| 347 | - | true | - |
| 348 | - | }, | - |
| 349 | - | { | - |
| 350 | - | "operator", | - |
| 351 | - | OperatorRelationId, | - |
| 352 | - | OperatorOidIndexId, | - |
| 353 | - | OPEROID, | - |
| 354 | - | -1, /* OPERNAMENSP also takes left and right type */ | - |
| 355 | - | Anum_pg_operator_oid, | - |
| 356 | - | Anum_pg_operator_oprname, | - |
| 357 | - | Anum_pg_operator_oprnamespace, | - |
| 358 | - | Anum_pg_operator_oprowner, | - |
| 359 | - | InvalidAttrNumber, | - |
| 360 | - | OBJECT_OPERATOR, | - |
| 361 | - | false | - |
| 362 | - | }, | - |
| 363 | - | { | - |
| 364 | - | "operator family", | - |
| 365 | - | OperatorFamilyRelationId, | - |
| 366 | - | OpfamilyOidIndexId, | - |
| 367 | - | OPFAMILYOID, | - |
| 368 | - | -1, /* OPFAMILYAMNAMENSP also takes opfmethod */ | - |
| 369 | - | Anum_pg_opfamily_oid, | - |
| 370 | - | Anum_pg_opfamily_opfname, | - |
| 371 | - | Anum_pg_opfamily_opfnamespace, | - |
| 372 | - | Anum_pg_opfamily_opfowner, | - |
| 373 | - | InvalidAttrNumber, | - |
| 374 | - | OBJECT_OPFAMILY, | - |
| 375 | - | true | - |
| 376 | - | }, | - |
| 377 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 378 | - | "property graph element", | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 379 | - | PropgraphElementRelationId, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 380 | - | PropgraphElementObjectIndexId, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 381 | - | PROPGRAPHELOID, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 382 | - | PROPGRAPHELALIAS, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 383 | - | Anum_pg_propgraph_element_oid, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 384 | - | Anum_pg_propgraph_element_pgealias, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 385 | - | InvalidAttrNumber, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 386 | - | InvalidAttrNumber, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 387 | - | InvalidAttrNumber, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 388 | - | -1, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 389 | - | false | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 390 | - | }, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 391 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 392 | - | "property graph element label", | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 393 | - | PropgraphElementLabelRelationId, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 394 | - | PropgraphElementLabelObjectIndexId, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 395 | - | -1, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 396 | - | -1, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 397 | - | Anum_pg_propgraph_element_label_oid, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 398 | - | InvalidAttrNumber, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 399 | - | InvalidAttrNumber, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 400 | - | InvalidAttrNumber, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 401 | - | InvalidAttrNumber, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 402 | - | -1, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 403 | - | false | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 404 | - | }, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 405 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 406 | - | "property graph label", | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 407 | - | PropgraphLabelRelationId, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 408 | - | PropgraphLabelObjectIndexId, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 409 | - | PROPGRAPHLABELOID, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 410 | - | PROPGRAPHLABELNAME, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 411 | - | Anum_pg_propgraph_label_oid, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 412 | - | Anum_pg_propgraph_label_pgllabel, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 413 | - | InvalidAttrNumber, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 414 | - | InvalidAttrNumber, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 415 | - | InvalidAttrNumber, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 416 | - | -1, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 417 | - | false | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 418 | - | }, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 419 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 420 | - | "property graph label property", | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 421 | - | PropgraphLabelPropertyRelationId, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 422 | - | PropgraphLabelPropertyObjectIndexId, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 423 | - | -1, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 424 | - | -1, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 425 | - | Anum_pg_propgraph_label_property_oid, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 426 | - | InvalidAttrNumber, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 427 | - | InvalidAttrNumber, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 428 | - | InvalidAttrNumber, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 429 | - | InvalidAttrNumber, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 430 | - | -1, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 431 | - | false | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 432 | - | }, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 433 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 434 | - | "property graph property", | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 435 | - | PropgraphPropertyRelationId, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 436 | - | PropgraphPropertyObjectIndexId, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 437 | - | -1, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 438 | - | PROPGRAPHPROPNAME, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 439 | - | Anum_pg_propgraph_property_oid, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 440 | - | Anum_pg_propgraph_property_pgpname, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 441 | - | InvalidAttrNumber, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 442 | - | InvalidAttrNumber, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 443 | - | InvalidAttrNumber, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 444 | - | -1, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 445 | - | false | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 446 | - | }, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 447 | - | { | - |
| 448 | - | "role", | - |
| 449 | - | AuthIdRelationId, | - |
| 450 | - | AuthIdOidIndexId, | - |
| 451 | - | AUTHOID, | - |
| 452 | - | AUTHNAME, | - |
| 453 | - | Anum_pg_authid_oid, | - |
| 454 | - | Anum_pg_authid_rolname, | - |
| 455 | - | InvalidAttrNumber, | - |
| 456 | - | InvalidAttrNumber, | - |
| 457 | - | InvalidAttrNumber, | - |
| 458 | - | OBJECT_ROLE, | - |
| 459 | - | true | - |
| 460 | - | }, | - |
| 461 | - | { | - |
| 462 | - | "role membership", | - |
| 463 | - | AuthMemRelationId, | - |
| 464 | - | AuthMemOidIndexId, | - |
| 465 | - | -1, | - |
| 466 | - | -1, | - |
| 467 | - | Anum_pg_auth_members_oid, | - |
| 468 | - | InvalidAttrNumber, | - |
| 469 | - | InvalidAttrNumber, | - |
| 470 | - | Anum_pg_auth_members_grantor, | - |
| 471 | - | InvalidAttrNumber, | - |
| 472 | - | -1, | - |
| 473 | - | true | - |
| 474 | - | }, | - |
| 475 | - | { | - |
| 476 | - | "rule", | - |
| 477 | - | RewriteRelationId, | - |
| 478 | - | RewriteOidIndexId, | - |
| 479 | - | -1, | - |
| 480 | - | -1, | - |
| 481 | - | Anum_pg_rewrite_oid, | - |
| 482 | - | Anum_pg_rewrite_rulename, | - |
| 483 | - | InvalidAttrNumber, | - |
| 484 | - | InvalidAttrNumber, | - |
| 485 | - | InvalidAttrNumber, | - |
| 486 | - | OBJECT_RULE, | - |
| 487 | - | false | - |
| 488 | - | }, | - |
| 489 | - | { | - |
| 490 | - | "schema", | - |
| 491 | - | NamespaceRelationId, | - |
| 492 | - | NamespaceOidIndexId, | - |
| 493 | - | NAMESPACEOID, | - |
| 494 | - | NAMESPACENAME, | - |
| 495 | - | Anum_pg_namespace_oid, | - |
| 496 | - | Anum_pg_namespace_nspname, | - |
| 497 | - | InvalidAttrNumber, | - |
| 498 | - | Anum_pg_namespace_nspowner, | - |
| 499 | - | Anum_pg_namespace_nspacl, | - |
| 500 | - | OBJECT_SCHEMA, | - |
| 501 | - | true | - |
| 502 | - | }, | - |
| 503 | - | { | - |
| 504 | - | "relation", | - |
| 505 | - | RelationRelationId, | - |
| 506 | - | ClassOidIndexId, | - |
| 507 | - | RELOID, | - |
| 508 | - | RELNAMENSP, | - |
| 509 | - | Anum_pg_class_oid, | - |
| 510 | - | Anum_pg_class_relname, | - |
| 511 | - | Anum_pg_class_relnamespace, | - |
| 512 | - | Anum_pg_class_relowner, | - |
| 513 | - | Anum_pg_class_relacl, | - |
| 514 | - | OBJECT_TABLE, | - |
| 515 | - | true | - |
| 516 | - | }, | - |
| 517 | - | { | - |
| 518 | - | "tablespace", | - |
| 519 | - | TableSpaceRelationId, | - |
| 520 | - | TablespaceOidIndexId, | - |
| 521 | - | TABLESPACEOID, | - |
| 522 | - | -1, | - |
| 523 | - | Anum_pg_tablespace_oid, | - |
| 524 | - | Anum_pg_tablespace_spcname, | - |
| 525 | - | InvalidAttrNumber, | - |
| 526 | - | Anum_pg_tablespace_spcowner, | - |
| 527 | - | Anum_pg_tablespace_spcacl, | - |
| 528 | - | OBJECT_TABLESPACE, | - |
| 529 | - | true | - |
| 530 | - | }, | - |
| 531 | - | { | - |
| 532 | - | "transform", | - |
| 533 | - | TransformRelationId, | - |
| 534 | - | TransformOidIndexId, | - |
| 535 | - | TRFOID, | - |
| 536 | - | -1, | - |
| 537 | - | Anum_pg_transform_oid, | - |
| 538 | - | InvalidAttrNumber, | - |
| 539 | - | InvalidAttrNumber, | - |
| 540 | - | InvalidAttrNumber, | - |
| 541 | - | InvalidAttrNumber, | - |
| 542 | - | OBJECT_TRANSFORM, | - |
| 543 | - | false | - |
| 544 | - | }, | - |
| 545 | - | { | - |
| 546 | - | "trigger", | - |
| 547 | - | TriggerRelationId, | - |
| 548 | - | TriggerOidIndexId, | - |
| 549 | - | -1, | - |
| 550 | - | -1, | - |
| 551 | - | Anum_pg_trigger_oid, | - |
| 552 | - | Anum_pg_trigger_tgname, | - |
| 553 | - | InvalidAttrNumber, | - |
| 554 | - | InvalidAttrNumber, | - |
| 555 | - | InvalidAttrNumber, | - |
| 556 | - | OBJECT_TRIGGER, | - |
| 557 | - | false | - |
| 558 | - | }, | - |
| 559 | - | { | - |
| 560 | - | "policy", | - |
| 561 | - | PolicyRelationId, | - |
| 562 | - | PolicyOidIndexId, | - |
| 563 | - | -1, | - |
| 564 | - | -1, | - |
| 565 | - | Anum_pg_policy_oid, | - |
| 566 | - | Anum_pg_policy_polname, | - |
| 567 | - | InvalidAttrNumber, | - |
| 568 | - | InvalidAttrNumber, | - |
| 569 | - | InvalidAttrNumber, | - |
| 570 | - | OBJECT_POLICY, | - |
| 571 | - | false | - |
| 572 | - | }, | - |
| 573 | - | { | - |
| 574 | - | "event trigger", | - |
| 575 | - | EventTriggerRelationId, | - |
| 576 | - | EventTriggerOidIndexId, | - |
| 577 | - | EVENTTRIGGEROID, | - |
| 578 | - | EVENTTRIGGERNAME, | - |
| 579 | - | Anum_pg_event_trigger_oid, | - |
| 580 | - | Anum_pg_event_trigger_evtname, | - |
| 581 | - | InvalidAttrNumber, | - |
| 582 | - | Anum_pg_event_trigger_evtowner, | - |
| 583 | - | InvalidAttrNumber, | - |
| 584 | - | OBJECT_EVENT_TRIGGER, | - |
| 585 | - | true | - |
| 586 | - | }, | - |
| 587 | - | { | - |
| 588 | - | "text search configuration", | - |
| 589 | - | TSConfigRelationId, | - |
| 590 | - | TSConfigOidIndexId, | - |
| 591 | - | TSCONFIGOID, | - |
| 592 | - | TSCONFIGNAMENSP, | - |
| 593 | - | Anum_pg_ts_config_oid, | - |
| 594 | - | Anum_pg_ts_config_cfgname, | - |
| 595 | - | Anum_pg_ts_config_cfgnamespace, | - |
| 596 | - | Anum_pg_ts_config_cfgowner, | - |
| 597 | - | InvalidAttrNumber, | - |
| 598 | - | OBJECT_TSCONFIGURATION, | - |
| 599 | - | true | - |
| 600 | - | }, | - |
| 601 | - | { | - |
| 602 | - | "text search dictionary", | - |
| 603 | - | TSDictionaryRelationId, | - |
| 604 | - | TSDictionaryOidIndexId, | - |
| 605 | - | TSDICTOID, | - |
| 606 | - | TSDICTNAMENSP, | - |
| 607 | - | Anum_pg_ts_dict_oid, | - |
| 608 | - | Anum_pg_ts_dict_dictname, | - |
| 609 | - | Anum_pg_ts_dict_dictnamespace, | - |
| 610 | - | Anum_pg_ts_dict_dictowner, | - |
| 611 | - | InvalidAttrNumber, | - |
| 612 | - | OBJECT_TSDICTIONARY, | - |
| 613 | - | true | - |
| 614 | - | }, | - |
| 615 | - | { | - |
| 616 | - | "text search parser", | - |
| 617 | - | TSParserRelationId, | - |
| 618 | - | TSParserOidIndexId, | - |
| 619 | - | TSPARSEROID, | - |
| 620 | - | TSPARSERNAMENSP, | - |
| 621 | - | Anum_pg_ts_parser_oid, | - |
| 622 | - | Anum_pg_ts_parser_prsname, | - |
| 623 | - | Anum_pg_ts_parser_prsnamespace, | - |
| 624 | - | InvalidAttrNumber, | - |
| 625 | - | InvalidAttrNumber, | - |
| 626 | - | OBJECT_TSPARSER, | - |
| 627 | - | true | - |
| 628 | - | }, | - |
| 629 | - | { | - |
| 630 | - | "text search template", | - |
| 631 | - | TSTemplateRelationId, | - |
| 632 | - | TSTemplateOidIndexId, | - |
| 633 | - | TSTEMPLATEOID, | - |
| 634 | - | TSTEMPLATENAMENSP, | - |
| 635 | - | Anum_pg_ts_template_oid, | - |
| 636 | - | Anum_pg_ts_template_tmplname, | - |
| 637 | - | Anum_pg_ts_template_tmplnamespace, | - |
| 638 | - | InvalidAttrNumber, | - |
| 639 | - | InvalidAttrNumber, | - |
| 640 | - | OBJECT_TSTEMPLATE, | - |
| 641 | - | true, | - |
| 642 | - | }, | - |
| 643 | - | { | - |
| 644 | - | "type", | - |
| 645 | - | TypeRelationId, | - |
| 646 | - | TypeOidIndexId, | - |
| 647 | - | TYPEOID, | - |
| 648 | - | TYPENAMENSP, | - |
| 649 | - | Anum_pg_type_oid, | - |
| 650 | - | Anum_pg_type_typname, | - |
| 651 | - | Anum_pg_type_typnamespace, | - |
| 652 | - | Anum_pg_type_typowner, | - |
| 653 | - | Anum_pg_type_typacl, | - |
| 654 | - | OBJECT_TYPE, | - |
| 655 | - | true | - |
| 656 | - | }, | - |
| 657 | - | { | - |
| 658 | - | "publication", | - |
| 659 | - | PublicationRelationId, | - |
| 660 | - | PublicationObjectIndexId, | - |
| 661 | - | PUBLICATIONOID, | - |
| 662 | - | PUBLICATIONNAME, | - |
| 663 | - | Anum_pg_publication_oid, | - |
| 664 | - | Anum_pg_publication_pubname, | - |
| 665 | - | InvalidAttrNumber, | - |
| 666 | - | Anum_pg_publication_pubowner, | - |
| 667 | - | InvalidAttrNumber, | - |
| 668 | - | OBJECT_PUBLICATION, | - |
| 669 | - | true | - |
| 670 | - | }, | - |
| 671 | - | { | - |
| 672 | - | "subscription", | - |
| 673 | - | SubscriptionRelationId, | - |
| 674 | - | SubscriptionObjectIndexId, | - |
| 675 | - | SUBSCRIPTIONOID, | - |
| 676 | - | SUBSCRIPTIONNAME, | - |
| 677 | - | Anum_pg_subscription_oid, | - |
| 678 | - | Anum_pg_subscription_subname, | - |
| 679 | - | InvalidAttrNumber, | - |
| 680 | - | Anum_pg_subscription_subowner, | - |
| 681 | - | InvalidAttrNumber, | - |
| 682 | - | OBJECT_SUBSCRIPTION, | - |
| 683 | - | true | - |
| 684 | - | }, | - |
| 685 | - | { | - |
| 686 | - | "extended statistics", | - |
| 687 | - | StatisticExtRelationId, | - |
| 688 | - | StatisticExtOidIndexId, | - |
| 689 | - | STATEXTOID, | - |
| 690 | - | STATEXTNAMENSP, | - |
| 691 | - | Anum_pg_statistic_ext_oid, | - |
| 692 | - | Anum_pg_statistic_ext_stxname, | - |
| 693 | - | Anum_pg_statistic_ext_stxnamespace, | - |
| 694 | - | Anum_pg_statistic_ext_stxowner, | - |
| 695 | - | InvalidAttrNumber, /* no ACL (same as relation) */ | - |
| 696 | - | OBJECT_STATISTIC_EXT, | - |
| 697 | - | true | - |
| 698 | - | }, | - |
| 699 | - | { | - |
| 700 | - | "user mapping", | - |
| 701 | - | UserMappingRelationId, | - |
| 702 | - | UserMappingOidIndexId, | - |
| 703 | - | USERMAPPINGOID, | - |
| 704 | - | -1, | - |
| 705 | - | Anum_pg_user_mapping_oid, | - |
| 706 | - | InvalidAttrNumber, | - |
| 707 | - | InvalidAttrNumber, | - |
| 708 | - | InvalidAttrNumber, | - |
| 709 | - | InvalidAttrNumber, | - |
| 710 | - | OBJECT_USER_MAPPING, | - |
| 711 | - | false | - |
| 712 | - | }, | - |
| 713 | - | }; | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 1009 | - | get_object_address(ObjectType objtype, Node *object, | - |
| 1010 | - | Relation *relp, LOCKMODE lockmode, bool missing_ok) | - |
| 1011 | - | { | - |
| 1012 | - | ObjectAddress address = {InvalidOid, InvalidOid, 0}; | - |
| 1013 | - | ObjectAddress old_address = {InvalidOid, InvalidOid, 0}; | - |
| 1014 | - | Relation relation = NULL; | - |
| 1015 | - | uint64 inval_count; | - |
| 1016 | - | - | |
| 1017 | - | /* Some kind of lock must be taken. */ | - |
| 1018 | - | Assert(lockmode != NoLock); | - |
| 1019 | - | - | |
| 1020 | - | for (;;) | - |
| 1021 | - | { | - |
| 1022 | - | /* | - |
| 1023 | - | * Remember this value, so that, after looking up the object name and | - |
| 1024 | - | * locking it, we can check whether any invalidation messages have | - |
| 1025 | - | * been processed that might require a do-over. | - |
| 1026 | - | */ | - |
| 1027 | - | inval_count = SharedInvalidMessageCounter; | - |
| 1028 | - | - | |
| 1029 | - | /* Look up object address. */ | - |
| 1030 | - | switch (objtype) | - |
| 1031 | - | { | - |
| 1032 | - | case OBJECT_INDEX: | - |
| 1033 | - | case OBJECT_SEQUENCE: | - |
| 1034 | - | case OBJECT_TABLE: | - |
| 1035 | - | case OBJECT_VIEW: | - |
| 1036 | - | case OBJECT_MATVIEW: | - |
| 1037 | - | case OBJECT_FOREIGN_TABLE: | - |
| 1038 | - | case OBJECT_PROPGRAPH: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1039 | - | address = | - |
| 1040 | - | get_relation_by_qualified_name(objtype, castNode(List, object), | - |
| 1041 | - | &relation, lockmode, | - |
| 1042 | - | missing_ok); | - |
| 1043 | - | break; | - |
| 1044 | - | case OBJECT_ATTRIBUTE: | - |
| 1045 | - | case OBJECT_COLUMN: | - |
| 1046 | - | address = | - |
| 1047 | - | get_object_address_attribute(objtype, castNode(List, object), | - |
| 1048 | - | &relation, lockmode, | - |
| 1049 | - | missing_ok); | - |
| 1050 | - | break; | - |
| 1051 | - | case OBJECT_DEFAULT: | - |
| 1052 | - | address = | - |
| 1053 | - | get_object_address_attrdef(objtype, castNode(List, object), | - |
| 1054 | - | &relation, lockmode, | - |
| 1055 | - | missing_ok); | - |
| 1056 | - | break; | - |
| 1057 | - | case OBJECT_RULE: | - |
| 1058 | - | case OBJECT_TRIGGER: | - |
| 1059 | - | case OBJECT_TABCONSTRAINT: | - |
| 1060 | - | case OBJECT_POLICY: | - |
| 1061 | - | address = get_object_address_relobject(objtype, castNode(List, object), | - |
| 1062 | - | &relation, missing_ok); | - |
| 1063 | - | break; | - |
| 1064 | - | case OBJECT_DOMCONSTRAINT: | - |
| 1065 | - | { | - |
| 1066 | - | List *objlist; | - |
| 1067 | - | ObjectAddress domaddr; | - |
| 1068 | - | char *constrname; | - |
| 1069 | - | - | |
| 1070 | - | objlist = castNode(List, object); | - |
| 1071 | - | domaddr = get_object_address_type(OBJECT_DOMAIN, | - |
| 1072 | - | linitial_node(TypeName, objlist), | - |
| 1073 | - | missing_ok); | - |
| 1074 | - | constrname = strVal(lsecond(objlist)); | - |
| 1075 | - | - | |
| 1076 | - | address.classId = ConstraintRelationId; | - |
| 1077 | - | address.objectId = get_domain_constraint_oid(domaddr.objectId, | - |
| 1078 | - | constrname, missing_ok); | - |
| 1079 | - | address.objectSubId = 0; | - |
| 1080 | - | } | - |
| 1081 | - | break; | - |
| 1082 | - | case OBJECT_DATABASE: | - |
| 1083 | - | case OBJECT_EXTENSION: | - |
| 1084 | - | case OBJECT_TABLESPACE: | - |
| 1085 | - | case OBJECT_ROLE: | - |
| 1086 | - | case OBJECT_SCHEMA: | - |
| 1087 | - | case OBJECT_LANGUAGE: | - |
| 1088 | - | case OBJECT_FDW: | - |
| 1089 | - | case OBJECT_FOREIGN_SERVER: | - |
| 1090 | - | case OBJECT_EVENT_TRIGGER: | - |
| 1091 | - | case OBJECT_PARAMETER_ACL: | - |
| 1092 | - | case OBJECT_ACCESS_METHOD: | - |
| 1093 | - | case OBJECT_PUBLICATION: | - |
| 1094 | - | case OBJECT_SUBSCRIPTION: | - |
| 1095 | - | address = get_object_address_unqualified(objtype, | - |
| 1096 | - | castNode(String, object), missing_ok); | - |
| 1097 | - | break; | - |
| 1098 | - | case OBJECT_TYPE: | - |
| 1099 | - | case OBJECT_DOMAIN: | - |
| 1100 | - | address = get_object_address_type(objtype, castNode(TypeName, object), missing_ok); | - |
| 1101 | - | break; | - |
| 1102 | - | case OBJECT_AGGREGATE: | - |
| 1103 | - | case OBJECT_FUNCTION: | - |
| 1104 | - | case OBJECT_PROCEDURE: | - |
| 1105 | - | case OBJECT_ROUTINE: | - |
| 1106 | - | address.classId = ProcedureRelationId; | - |
| 1107 | - | address.objectId = LookupFuncWithArgs(objtype, castNode(ObjectWithArgs, object), missing_ok); | - |
| 1108 | - | address.objectSubId = 0; | - |
| 1109 | - | break; | - |
| 1110 | - | case OBJECT_OPERATOR: | - |
| 1111 | - | address.classId = OperatorRelationId; | - |
| 1112 | - | address.objectId = LookupOperWithArgs(castNode(ObjectWithArgs, object), missing_ok); | - |
| 1113 | - | address.objectSubId = 0; | - |
| 1114 | - | break; | - |
| 1115 | - | case OBJECT_COLLATION: | - |
| 1116 | - | address.classId = CollationRelationId; | - |
| 1117 | - | address.objectId = get_collation_oid(castNode(List, object), missing_ok); | - |
| 1118 | - | address.objectSubId = 0; | - |
| 1119 | - | break; | - |
| 1120 | - | case OBJECT_CONVERSION: | - |
| 1121 | - | address.classId = ConversionRelationId; | - |
| 1122 | - | address.objectId = get_conversion_oid(castNode(List, object), missing_ok); | - |
| 1123 | - | address.objectSubId = 0; | - |
| 1124 | - | break; | - |
| 1125 | - | case OBJECT_OPCLASS: | - |
| 1126 | - | case OBJECT_OPFAMILY: | - |
| 1127 | - | address = get_object_address_opcf(objtype, castNode(List, object), missing_ok); | - |
| 1128 | - | break; | - |
| 1129 | - | case OBJECT_AMOP: | - |
| 1130 | - | case OBJECT_AMPROC: | - |
| 1131 | - | address = get_object_address_opf_member(objtype, castNode(List, object), missing_ok); | - |
| 1132 | - | break; | - |
| 1133 | - | case OBJECT_LARGEOBJECT: | - |
| 1134 | - | address.classId = LargeObjectRelationId; | - |
| 1135 | - | address.objectId = oidparse(object); | - |
| 1136 | - | address.objectSubId = 0; | - |
| 1137 | - | if (!LargeObjectExists(address.objectId)) | - |
| 1138 | - | { | - |
| 1139 | - | if (!missing_ok) | - |
| 1140 | - | ereport(ERROR, | - |
| 1141 | - | (errcode(ERRCODE_UNDEFINED_OBJECT), | - |
| 1142 | - | errmsg("large object %u does not exist", | - |
| 1143 | - | address.objectId))); | - |
| 1144 | - | } | - |
| 1145 | - | break; | - |
| 1146 | - | case OBJECT_CAST: | - |
| 1147 | - | { | - |
| 1148 | - | TypeName *sourcetype = linitial_node(TypeName, castNode(List, object)); | - |
| 1149 | - | TypeName *targettype = lsecond_node(TypeName, castNode(List, object)); | - |
| 1150 | - | Oid sourcetypeid; | - |
| 1151 | - | Oid targettypeid; | - |
| 1152 | - | - | |
| 1153 | - | sourcetypeid = LookupTypeNameOid(NULL, sourcetype, missing_ok); | - |
| 1154 | - | targettypeid = LookupTypeNameOid(NULL, targettype, missing_ok); | - |
| 1155 | - | address.classId = CastRelationId; | - |
| 1156 | - | address.objectId = | - |
| 1157 | - | get_cast_oid(sourcetypeid, targettypeid, missing_ok); | - |
| 1158 | - | address.objectSubId = 0; | - |
| 1159 | - | } | - |
| 1160 | - | break; | - |
| 1161 | - | case OBJECT_TRANSFORM: | - |
| 1162 | - | { | - |
| 1163 | - | TypeName *typename = linitial_node(TypeName, castNode(List, object)); | - |
| 1164 | - | char *langname = strVal(lsecond(castNode(List, object))); | - |
| 1165 | - | Oid type_id = LookupTypeNameOid(NULL, typename, missing_ok); | - |
| 1166 | - | Oid lang_id = get_language_oid(langname, missing_ok); | - |
| 1167 | - | - | |
| 1168 | - | address.classId = TransformRelationId; | - |
| 1169 | - | address.objectId = | - |
| 1170 | - | get_transform_oid(type_id, lang_id, missing_ok); | - |
| 1171 | - | address.objectSubId = 0; | - |
| 1172 | - | } | - |
| 1173 | - | break; | - |
| 1174 | - | case OBJECT_TSPARSER: | - |
| 1175 | - | address.classId = TSParserRelationId; | - |
| 1176 | - | address.objectId = get_ts_parser_oid(castNode(List, object), missing_ok); | - |
| 1177 | - | address.objectSubId = 0; | - |
| 1178 | - | break; | - |
| 1179 | - | case OBJECT_TSDICTIONARY: | - |
| 1180 | - | address.classId = TSDictionaryRelationId; | - |
| 1181 | - | address.objectId = get_ts_dict_oid(castNode(List, object), missing_ok); | - |
| 1182 | - | address.objectSubId = 0; | - |
| 1183 | - | break; | - |
| 1184 | - | case OBJECT_TSTEMPLATE: | - |
| 1185 | - | address.classId = TSTemplateRelationId; | - |
| 1186 | - | address.objectId = get_ts_template_oid(castNode(List, object), missing_ok); | - |
| 1187 | - | address.objectSubId = 0; | - |
| 1188 | - | break; | - |
| 1189 | - | case OBJECT_TSCONFIGURATION: | - |
| 1190 | - | address.classId = TSConfigRelationId; | - |
| 1191 | - | address.objectId = get_ts_config_oid(castNode(List, object), missing_ok); | - |
| 1192 | - | address.objectSubId = 0; | - |
| 1193 | - | break; | - |
| 1194 | - | case OBJECT_USER_MAPPING: | - |
| 1195 | - | address = get_object_address_usermapping(castNode(List, object), | - |
| 1196 | - | missing_ok); | - |
| 1197 | - | break; | - |
| 1198 | - | case OBJECT_PUBLICATION_NAMESPACE: | - |
| 1199 | - | address = get_object_address_publication_schema(castNode(List, object), | - |
| 1200 | - | missing_ok); | - |
| 1201 | - | break; | - |
| 1202 | - | case OBJECT_PUBLICATION_REL: | - |
| 1203 | - | address = get_object_address_publication_rel(castNode(List, object), | - |
| 1204 | - | &relation, | - |
| 1205 | - | missing_ok); | - |
| 1206 | - | break; | - |
| 1207 | - | case OBJECT_DEFACL: | - |
| 1208 | - | address = get_object_address_defacl(castNode(List, object), | - |
| 1209 | - | missing_ok); | - |
| 1210 | - | break; | - |
| 1211 | - | case OBJECT_STATISTIC_EXT: | - |
| 1212 | - | address.classId = StatisticExtRelationId; | - |
| 1213 | - | address.objectId = get_statistics_object_oid(castNode(List, object), | - |
| 1214 | - | missing_ok); | - |
| 1215 | - | address.objectSubId = 0; | - |
| 1216 | - | break; | - |
| 1217 | - | /* no default, to let compiler warn about missing case */ | - |
| 1218 | - | } | - |
| 1219 | - | - | |
| 1220 | - | if (!address.classId) | - |
| 1221 | - | elog(ERROR, "unrecognized object type: %d", (int) objtype); | - |
| 1222 | - | - | |
| 1223 | - | /* | - |
| 1224 | - | * If we could not find the supplied object, return without locking. | - |
| 1225 | - | */ | - |
| 1226 | - | if (!OidIsValid(address.objectId)) | - |
| 1227 | - | { | - |
| 1228 | - | Assert(missing_ok); | - |
| 1229 | - | return address; | - |
| 1230 | - | } | - |
| 1231 | - | - | |
| 1232 | - | /* | - |
| 1233 | - | * If we're retrying, see if we got the same answer as last time. If | - |
| 1234 | - | * so, we're done; if not, we locked the wrong thing, so give up our | - |
| 1235 | - | * lock. | - |
| 1236 | - | */ | - |
| 1237 | - | if (OidIsValid(old_address.classId)) | - |
| 1238 | - | { | - |
| 1239 | - | if (old_address.classId == address.classId | - |
| 1240 | - | && old_address.objectId == address.objectId | - |
| 1241 | - | && old_address.objectSubId == address.objectSubId) | - |
| 1242 | - | break; | - |
| 1243 | - | if (old_address.classId != RelationRelationId) | - |
| 1244 | - | { | - |
| 1245 | - | if (IsSharedRelation(old_address.classId)) | - |
| 1246 | - | UnlockSharedObject(old_address.classId, | - |
| 1247 | - | old_address.objectId, | - |
| 1248 | - | 0, lockmode); | - |
| 1249 | - | else | - |
| 1250 | - | UnlockDatabaseObject(old_address.classId, | - |
| 1251 | - | old_address.objectId, | - |
| 1252 | - | 0, lockmode); | - |
| 1253 | - | } | - |
| 1254 | - | } | - |
| 1255 | - | - | |
| 1256 | - | /* | - |
| 1257 | - | * If we're dealing with a relation or attribute, then the relation is | - |
| 1258 | - | * already locked. Otherwise, we lock it now. | - |
| 1259 | - | */ | - |
| 1260 | - | if (address.classId != RelationRelationId) | - |
| 1261 | - | { | - |
| 1262 | - | if (IsSharedRelation(address.classId)) | - |
| 1263 | - | LockSharedObject(address.classId, address.objectId, 0, | - |
| 1264 | - | lockmode); | - |
| 1265 | - | else | - |
| 1266 | - | LockDatabaseObject(address.classId, address.objectId, 0, | - |
| 1267 | - | lockmode); | - |
| 1268 | - | } | - |
| 1269 | - | - | |
| 1270 | - | /* | - |
| 1271 | - | * At this point, we've resolved the name to an OID and locked the | - |
| 1272 | - | * corresponding database object. However, it's possible that by the | - |
| 1273 | - | * time we acquire the lock on the object, concurrent DDL has modified | - |
| 1274 | - | * the database in such a way that the name we originally looked up no | - |
| 1275 | - | * longer resolves to that OID. | - |
| 1276 | - | * | - |
| 1277 | - | * We can be certain that this isn't an issue if (a) no shared | - |
| 1278 | - | * invalidation messages have been processed or (b) we've locked a | - |
| 1279 | - | * relation somewhere along the line. All the relation name lookups | - |
| 1280 | - | * in this module ultimately use RangeVarGetRelid() to acquire a | - |
| 1281 | - | * relation lock, and that function protects against the same kinds of | - |
| 1282 | - | * races we're worried about here. Even when operating on a | - |
| 1283 | - | * constraint, rule, or trigger, we still acquire AccessShareLock on | - |
| 1284 | - | * the relation, which is enough to freeze out any concurrent DDL. | - |
| 1285 | - | * | - |
| 1286 | - | * In all other cases, however, it's possible that the name we looked | - |
| 1287 | - | * up no longer refers to the object we locked, so we retry the lookup | - |
| 1288 | - | * and see whether we get the same answer. | - |
| 1289 | - | */ | - |
| 1290 | - | if (inval_count == SharedInvalidMessageCounter || relation != NULL) | - |
| 1291 | - | break; | - |
| 1292 | - | old_address = address; | - |
| 1293 | - | } | - |
| 1294 | - | - | |
| 1295 | - | /* relp must be given if it's a relation */ | - |
| 1296 | - | Assert(!relation || relp); | - |
| 1297 | - | - | |
| 1298 | - | /* Return the object address and the relation. */ | - |
| 1299 | - | if (relp) | - |
| 1300 | - | *relp = relation; | - |
| 1301 | - | return address; | - |
| 1302 | - | } | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 1425 | - | get_relation_by_qualified_name(ObjectType objtype, List *object, | - |
| 1426 | - | Relation *relp, LOCKMODE lockmode, | - |
| 1427 | - | bool missing_ok) | - |
| 1428 | - | { | - |
| 1429 | - | Relation relation; | - |
| 1430 | - | ObjectAddress address; | - |
| 1431 | - | - | |
| 1432 | - | address.classId = RelationRelationId; | - |
| 1433 | - | address.objectId = InvalidOid; | - |
| 1434 | - | address.objectSubId = 0; | - |
| 1435 | - | - | |
| 1436 | - | relation = relation_openrv_extended(makeRangeVarFromNameList(object), | - |
| 1437 | - | lockmode, missing_ok); | - |
| 1438 | - | if (!relation) | - |
| 1439 | - | return address; | - |
| 1440 | - | - | |
| 1441 | - | switch (objtype) | - |
| 1442 | - | { | - |
| 1443 | - | case OBJECT_INDEX: | - |
| 1444 | - | if (relation->rd_rel->relkind != RELKIND_INDEX && | - |
| 1445 | - | relation->rd_rel->relkind != RELKIND_PARTITIONED_INDEX) | - |
| 1446 | - | ereport(ERROR, | - |
| 1447 | - | (errcode(ERRCODE_WRONG_OBJECT_TYPE), | - |
| 1448 | - | errmsg("\"%s\" is not an index", | - |
| 1449 | - | RelationGetRelationName(relation)))); | - |
| 1450 | - | break; | - |
| 1451 | 37 | case OBJECT_PROPGRAPH: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1452 | 37 | if (relation->rd_rel->relkind != RELKIND_PROPGRAPH) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1453 | 0 | ereport(ERROR, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1454 | - | (errcode(ERRCODE_WRONG_OBJECT_TYPE), | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1455 | - | errmsg("\"%s\" is not a property graph", | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1456 | - | RelationGetRelationName(relation)))); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1457 | - | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1458 | - | case OBJECT_SEQUENCE: | - |
| 1459 | - | if (relation->rd_rel->relkind != RELKIND_SEQUENCE) | - |
| 1460 | - | ereport(ERROR, | - |
| 1461 | - | (errcode(ERRCODE_WRONG_OBJECT_TYPE), | - |
| 1462 | - | errmsg("\"%s\" is not a sequence", | - |
| 1463 | - | RelationGetRelationName(relation)))); | - |
| 1464 | - | break; | - |
| 1465 | - | case OBJECT_TABLE: | - |
| 1466 | - | if (relation->rd_rel->relkind != RELKIND_RELATION && | - |
| 1467 | - | relation->rd_rel->relkind != RELKIND_PARTITIONED_TABLE) | - |
| 1468 | - | ereport(ERROR, | - |
| 1469 | - | (errcode(ERRCODE_WRONG_OBJECT_TYPE), | - |
| 1470 | - | errmsg("\"%s\" is not a table", | - |
| 1471 | - | RelationGetRelationName(relation)))); | - |
| 1472 | - | break; | - |
| 1473 | - | case OBJECT_VIEW: | - |
| 1474 | - | if (relation->rd_rel->relkind != RELKIND_VIEW) | - |
| 1475 | - | ereport(ERROR, | - |
| 1476 | - | (errcode(ERRCODE_WRONG_OBJECT_TYPE), | - |
| 1477 | - | errmsg("\"%s\" is not a view", | - |
| 1478 | - | RelationGetRelationName(relation)))); | - |
| 1479 | - | break; | - |
| 1480 | - | case OBJECT_MATVIEW: | - |
| 1481 | - | if (relation->rd_rel->relkind != RELKIND_MATVIEW) | - |
| 1482 | - | ereport(ERROR, | - |
| 1483 | - | (errcode(ERRCODE_WRONG_OBJECT_TYPE), | - |
| 1484 | - | errmsg("\"%s\" is not a materialized view", | - |
| 1485 | - | RelationGetRelationName(relation)))); | - |
| 1486 | - | break; | - |
| 1487 | - | case OBJECT_FOREIGN_TABLE: | - |
| 1488 | - | if (relation->rd_rel->relkind != RELKIND_FOREIGN_TABLE) | - |
| 1489 | - | ereport(ERROR, | - |
| 1490 | - | (errcode(ERRCODE_WRONG_OBJECT_TYPE), | - |
| 1491 | - | errmsg("\"%s\" is not a foreign table", | - |
| 1492 | - | RelationGetRelationName(relation)))); | - |
| 1493 | - | break; | - |
| 1494 | - | default: | - |
| 1495 | - | elog(ERROR, "unrecognized object type: %d", (int) objtype); | - |
| 1496 | - | break; | - |
| 1497 | - | } | - |
| 1498 | - | - | |
| 1499 | - | /* Done. */ | - |
| 1500 | - | address.objectId = RelationGetRelid(relation); | - |
| 1501 | - | *relp = relation; | - |
| 1502 | - | - | |
| 1503 | - | return address; | - |
| 1504 | - | } | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 2203 | - | pg_get_object_address(PG_FUNCTION_ARGS) | - |
| 2204 | - | { | - |
| 2205 | - | char *ttype = TextDatumGetCString(PG_GETARG_DATUM(0)); | - |
| 2206 | - | ArrayType *namearr = PG_GETARG_ARRAYTYPE_P(1); | - |
| 2207 | - | ArrayType *argsarr = PG_GETARG_ARRAYTYPE_P(2); | - |
| 2208 | - | int itype; | - |
| 2209 | - | ObjectType type; | - |
| 2210 | - | List *name = NIL; | - |
| 2211 | - | TypeName *typename = NULL; | - |
| 2212 | - | List *args = NIL; | - |
| 2213 | - | Node *objnode = NULL; | - |
| 2214 | - | ObjectAddress addr; | - |
| 2215 | - | TupleDesc tupdesc; | - |
| 2216 | - | Datum values[3]; | - |
| 2217 | - | bool nulls[3]; | - |
| 2218 | - | HeapTuple htup; | - |
| 2219 | - | Relation relation; | - |
| 2220 | - | - | |
| 2221 | - | /* Decode object type, raise error if unknown */ | - |
| 2222 | - | itype = read_objtype_from_string(ttype); | - |
| 2223 | - | if (itype < 0) | - |
| 2224 | - | ereport(ERROR, | - |
| 2225 | - | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), | - |
| 2226 | - | errmsg("unsupported object type \"%s\"", ttype))); | - |
| 2227 | - | type = (ObjectType) itype; | - |
| 2228 | - | - | |
| 2229 | - | /* | - |
| 2230 | - | * Convert the text array to the representation appropriate for the given | - |
| 2231 | - | * object type. Most use a simple string Values list, but there are some | - |
| 2232 | - | * exceptions. | - |
| 2233 | - | */ | - |
| 2234 | - | if (type == OBJECT_TYPE || type == OBJECT_DOMAIN || type == OBJECT_CAST || | - |
| 2235 | - | type == OBJECT_TRANSFORM || type == OBJECT_DOMCONSTRAINT) | - |
| 2236 | - | { | - |
| 2237 | - | Datum *elems; | - |
| 2238 | - | bool *nulls; | - |
| 2239 | - | int nelems; | - |
| 2240 | - | - | |
| 2241 | - | deconstruct_array_builtin(namearr, TEXTOID, &elems, &nulls, &nelems); | - |
| 2242 | - | if (nelems != 1) | - |
| 2243 | - | ereport(ERROR, | - |
| 2244 | - | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), | - |
| 2245 | - | errmsg("name list length must be exactly %d", 1))); | - |
| 2246 | - | if (nulls[0]) | - |
| 2247 | - | ereport(ERROR, | - |
| 2248 | - | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), | - |
| 2249 | - | errmsg("name or argument lists may not contain nulls"))); | - |
| 2250 | - | typename = typeStringToTypeName(TextDatumGetCString(elems[0]), NULL); | - |
| 2251 | - | } | - |
| 2252 | - | else if (type == OBJECT_LARGEOBJECT) | - |
| 2253 | - | { | - |
| 2254 | - | Datum *elems; | - |
| 2255 | - | bool *nulls; | - |
| 2256 | - | int nelems; | - |
| 2257 | - | - | |
| 2258 | - | deconstruct_array_builtin(namearr, TEXTOID, &elems, &nulls, &nelems); | - |
| 2259 | - | if (nelems != 1) | - |
| 2260 | - | ereport(ERROR, | - |
| 2261 | - | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), | - |
| 2262 | - | errmsg("name list length must be exactly %d", 1))); | - |
| 2263 | - | if (nulls[0]) | - |
| 2264 | - | ereport(ERROR, | - |
| 2265 | - | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), | - |
| 2266 | - | errmsg("large object OID may not be null"))); | - |
| 2267 | - | objnode = (Node *) makeFloat(TextDatumGetCString(elems[0])); | - |
| 2268 | - | } | - |
| 2269 | - | else | - |
| 2270 | - | { | - |
| 2271 | - | name = textarray_to_strvaluelist(namearr); | - |
| 2272 | - | if (name == NIL) | - |
| 2273 | - | ereport(ERROR, | - |
| 2274 | - | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), | - |
| 2275 | - | errmsg("name list length must be at least %d", 1))); | - |
| 2276 | - | } | - |
| 2277 | - | - | |
| 2278 | - | /* | - |
| 2279 | - | * If args are given, decode them according to the object type. | - |
| 2280 | - | */ | - |
| 2281 | - | if (type == OBJECT_AGGREGATE || | - |
| 2282 | - | type == OBJECT_FUNCTION || | - |
| 2283 | - | type == OBJECT_PROCEDURE || | - |
| 2284 | - | type == OBJECT_ROUTINE || | - |
| 2285 | - | type == OBJECT_OPERATOR || | - |
| 2286 | - | type == OBJECT_CAST || | - |
| 2287 | - | type == OBJECT_AMOP || | - |
| 2288 | - | type == OBJECT_AMPROC) | - |
| 2289 | - | { | - |
| 2290 | - | /* in these cases, the args list must be of TypeName */ | - |
| 2291 | - | Datum *elems; | - |
| 2292 | - | bool *nulls; | - |
| 2293 | - | int nelems; | - |
| 2294 | - | int i; | - |
| 2295 | - | - | |
| 2296 | - | deconstruct_array_builtin(argsarr, TEXTOID, &elems, &nulls, &nelems); | - |
| 2297 | - | - | |
| 2298 | - | args = NIL; | - |
| 2299 | - | for (i = 0; i < nelems; i++) | - |
| 2300 | - | { | - |
| 2301 | - | if (nulls[i]) | - |
| 2302 | - | ereport(ERROR, | - |
| 2303 | - | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), | - |
| 2304 | - | errmsg("name or argument lists may not contain nulls"))); | - |
| 2305 | - | args = lappend(args, | - |
| 2306 | - | typeStringToTypeName(TextDatumGetCString(elems[i]), | - |
| 2307 | - | NULL)); | - |
| 2308 | - | } | - |
| 2309 | - | } | - |
| 2310 | - | else | - |
| 2311 | - | { | - |
| 2312 | - | /* For all other object types, use string Values */ | - |
| 2313 | - | args = textarray_to_strvaluelist(argsarr); | - |
| 2314 | - | } | - |
| 2315 | - | - | |
| 2316 | - | /* | - |
| 2317 | - | * get_object_address is pretty sensitive to the length of its input | - |
| 2318 | - | * lists; check that they're what it wants. | - |
| 2319 | - | */ | - |
| 2320 | - | switch (type) | - |
| 2321 | - | { | - |
| 2322 | - | case OBJECT_PUBLICATION_NAMESPACE: | - |
| 2323 | - | case OBJECT_USER_MAPPING: | - |
| 2324 | - | if (list_length(name) != 1) | - |
| 2325 | - | ereport(ERROR, | - |
| 2326 | - | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), | - |
| 2327 | - | errmsg("name list length must be exactly %d", 1))); | - |
| 2328 | - | /* fall through to check args length */ | - |
| 2329 | - | /* FALLTHROUGH */ | - |
| 2330 | - | case OBJECT_DOMCONSTRAINT: | - |
| 2331 | - | case OBJECT_CAST: | - |
| 2332 | - | case OBJECT_PUBLICATION_REL: | - |
| 2333 | - | case OBJECT_DEFACL: | - |
| 2334 | - | case OBJECT_TRANSFORM: | - |
| 2335 | - | if (list_length(args) != 1) | - |
| 2336 | - | ereport(ERROR, | - |
| 2337 | - | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), | - |
| 2338 | - | errmsg("argument list length must be exactly %d", 1))); | - |
| 2339 | - | break; | - |
| 2340 | - | case OBJECT_OPFAMILY: | - |
| 2341 | - | case OBJECT_OPCLASS: | - |
| 2342 | - | if (list_length(name) < 2) | - |
| 2343 | - | ereport(ERROR, | - |
| 2344 | - | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), | - |
| 2345 | - | errmsg("name list length must be at least %d", 2))); | - |
| 2346 | - | break; | - |
| 2347 | - | case OBJECT_AMOP: | - |
| 2348 | - | case OBJECT_AMPROC: | - |
| 2349 | - | if (list_length(name) < 3) | - |
| 2350 | - | ereport(ERROR, | - |
| 2351 | - | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), | - |
| 2352 | - | errmsg("name list length must be at least %d", 3))); | - |
| 2353 | - | /* fall through to check args length */ | - |
| 2354 | - | /* FALLTHROUGH */ | - |
| 2355 | - | case OBJECT_OPERATOR: | - |
| 2356 | - | if (list_length(args) != 2) | - |
| 2357 | - | ereport(ERROR, | - |
| 2358 | - | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), | - |
| 2359 | - | errmsg("argument list length must be exactly %d", 2))); | - |
| 2360 | - | break; | - |
| 2361 | - | default: | - |
| 2362 | - | break; | - |
| 2363 | - | } | - |
| 2364 | - | - | |
| 2365 | - | /* | - |
| 2366 | - | * Now build the Node type that get_object_address() expects for the given | - |
| 2367 | - | * type. | - |
| 2368 | - | */ | - |
| 2369 | - | switch (type) | - |
| 2370 | - | { | - |
| 2371 | - | case OBJECT_TABLE: | - |
| 2372 | - | case OBJECT_SEQUENCE: | - |
| 2373 | - | case OBJECT_VIEW: | - |
| 2374 | - | case OBJECT_MATVIEW: | - |
| 2375 | - | case OBJECT_INDEX: | - |
| 2376 | - | case OBJECT_FOREIGN_TABLE: | - |
| 2377 | - | case OBJECT_PROPGRAPH: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2378 | - | case OBJECT_COLUMN: | - |
| 2379 | - | case OBJECT_ATTRIBUTE: | - |
| 2380 | - | case OBJECT_COLLATION: | - |
| 2381 | - | case OBJECT_CONVERSION: | - |
| 2382 | - | case OBJECT_STATISTIC_EXT: | - |
| 2383 | - | case OBJECT_TSPARSER: | - |
| 2384 | - | case OBJECT_TSDICTIONARY: | - |
| 2385 | - | case OBJECT_TSTEMPLATE: | - |
| 2386 | - | case OBJECT_TSCONFIGURATION: | - |
| 2387 | - | case OBJECT_DEFAULT: | - |
| 2388 | - | case OBJECT_POLICY: | - |
| 2389 | - | case OBJECT_RULE: | - |
| 2390 | - | case OBJECT_TRIGGER: | - |
| 2391 | - | case OBJECT_TABCONSTRAINT: | - |
| 2392 | - | case OBJECT_OPCLASS: | - |
| 2393 | - | case OBJECT_OPFAMILY: | - |
| 2394 | - | objnode = (Node *) name; | - |
| 2395 | - | break; | - |
| 2396 | - | case OBJECT_ACCESS_METHOD: | - |
| 2397 | - | case OBJECT_DATABASE: | - |
| 2398 | - | case OBJECT_EVENT_TRIGGER: | - |
| 2399 | - | case OBJECT_EXTENSION: | - |
| 2400 | - | case OBJECT_FDW: | - |
| 2401 | - | case OBJECT_FOREIGN_SERVER: | - |
| 2402 | - | case OBJECT_LANGUAGE: | - |
| 2403 | - | case OBJECT_PARAMETER_ACL: | - |
| 2404 | - | case OBJECT_PUBLICATION: | - |
| 2405 | - | case OBJECT_ROLE: | - |
| 2406 | - | case OBJECT_SCHEMA: | - |
| 2407 | - | case OBJECT_SUBSCRIPTION: | - |
| 2408 | - | case OBJECT_TABLESPACE: | - |
| 2409 | - | if (list_length(name) != 1) | - |
| 2410 | - | ereport(ERROR, | - |
| 2411 | - | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), | - |
| 2412 | - | errmsg("name list length must be exactly %d", 1))); | - |
| 2413 | - | objnode = linitial(name); | - |
| 2414 | - | break; | - |
| 2415 | - | case OBJECT_TYPE: | - |
| 2416 | - | case OBJECT_DOMAIN: | - |
| 2417 | - | objnode = (Node *) typename; | - |
| 2418 | - | break; | - |
| 2419 | - | case OBJECT_CAST: | - |
| 2420 | - | case OBJECT_DOMCONSTRAINT: | - |
| 2421 | - | case OBJECT_TRANSFORM: | - |
| 2422 | - | objnode = (Node *) list_make2(typename, linitial(args)); | - |
| 2423 | - | break; | - |
| 2424 | - | case OBJECT_PUBLICATION_REL: | - |
| 2425 | - | objnode = (Node *) list_make2(name, linitial(args)); | - |
| 2426 | - | break; | - |
| 2427 | - | case OBJECT_PUBLICATION_NAMESPACE: | - |
| 2428 | - | case OBJECT_USER_MAPPING: | - |
| 2429 | - | objnode = (Node *) list_make2(linitial(name), linitial(args)); | - |
| 2430 | - | break; | - |
| 2431 | - | case OBJECT_DEFACL: | - |
| 2432 | - | objnode = (Node *) lcons(linitial(args), name); | - |
| 2433 | - | break; | - |
| 2434 | - | case OBJECT_AMOP: | - |
| 2435 | - | case OBJECT_AMPROC: | - |
| 2436 | - | objnode = (Node *) list_make2(name, args); | - |
| 2437 | - | break; | - |
| 2438 | - | case OBJECT_FUNCTION: | - |
| 2439 | - | case OBJECT_PROCEDURE: | - |
| 2440 | - | case OBJECT_ROUTINE: | - |
| 2441 | - | case OBJECT_AGGREGATE: | - |
| 2442 | - | case OBJECT_OPERATOR: | - |
| 2443 | - | { | - |
| 2444 | - | ObjectWithArgs *owa = makeNode(ObjectWithArgs); | - |
| 2445 | - | - | |
| 2446 | - | owa->objname = name; | - |
| 2447 | - | owa->objargs = args; | - |
| 2448 | - | objnode = (Node *) owa; | - |
| 2449 | - | break; | - |
| 2450 | - | } | - |
| 2451 | - | case OBJECT_LARGEOBJECT: | - |
| 2452 | - | /* already handled above */ | - |
| 2453 | - | break; | - |
| 2454 | - | /* no default, to let compiler warn about missing case */ | - |
| 2455 | - | } | - |
| 2456 | - | - | |
| 2457 | - | if (objnode == NULL) | - |
| 2458 | - | elog(ERROR, "unrecognized object type: %d", type); | - |
| 2459 | - | - | |
| 2460 | - | addr = get_object_address(type, objnode, | - |
| 2461 | - | &relation, AccessShareLock, false); | - |
| 2462 | - | - | |
| 2463 | - | /* We don't need the relcache entry, thank you very much */ | - |
| 2464 | - | if (relation) | - |
| 2465 | - | relation_close(relation, AccessShareLock); | - |
| 2466 | - | - | |
| 2467 | - | if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) | - |
| 2468 | - | elog(ERROR, "return type must be a row type"); | - |
| 2469 | - | - | |
| 2470 | - | values[0] = ObjectIdGetDatum(addr.classId); | - |
| 2471 | - | values[1] = ObjectIdGetDatum(addr.objectId); | - |
| 2472 | - | values[2] = Int32GetDatum(addr.objectSubId); | - |
| 2473 | - | nulls[0] = false; | - |
| 2474 | - | nulls[1] = false; | - |
| 2475 | - | nulls[2] = false; | - |
| 2476 | - | - | |
| 2477 | - | htup = heap_form_tuple(tupdesc, values, nulls); | - |
| 2478 | - | - | |
| 2479 | - | PG_RETURN_DATUM(HeapTupleGetDatum(htup)); | - |
| 2480 | - | } | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 2486 | - | check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address, | - |
| 2487 | - | Node *object, Relation relation) | - |
| 2488 | - | { | - |
| 2489 | - | switch (objtype) | - |
| 2490 | - | { | - |
| 2491 | - | case OBJECT_INDEX: | - |
| 2492 | - | case OBJECT_SEQUENCE: | - |
| 2493 | - | case OBJECT_TABLE: | - |
| 2494 | - | case OBJECT_VIEW: | - |
| 2495 | - | case OBJECT_MATVIEW: | - |
| 2496 | - | case OBJECT_FOREIGN_TABLE: | - |
| 2497 | - | case OBJECT_PROPGRAPH: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 2498 | - | case OBJECT_COLUMN: | - |
| 2499 | - | case OBJECT_RULE: | - |
| 2500 | - | case OBJECT_TRIGGER: | - |
| 2501 | - | case OBJECT_POLICY: | - |
| 2502 | - | case OBJECT_TABCONSTRAINT: | - |
| 2503 | - | if (!object_ownercheck(RelationRelationId, RelationGetRelid(relation), roleid)) | - |
| 2504 | - | aclcheck_error(ACLCHECK_NOT_OWNER, objtype, | - |
| 2505 | - | RelationGetRelationName(relation)); | - |
| 2506 | - | break; | - |
| 2507 | - | case OBJECT_TYPE: | - |
| 2508 | - | case OBJECT_DOMAIN: | - |
| 2509 | - | case OBJECT_ATTRIBUTE: | - |
| 2510 | - | if (!object_ownercheck(address.classId, address.objectId, roleid)) | - |
| 2511 | - | aclcheck_error_type(ACLCHECK_NOT_OWNER, address.objectId); | - |
| 2512 | - | break; | - |
| 2513 | - | case OBJECT_DOMCONSTRAINT: | - |
| 2514 | - | { | - |
| 2515 | - | HeapTuple tuple; | - |
| 2516 | - | Oid contypid; | - |
| 2517 | - | - | |
| 2518 | - | tuple = SearchSysCache1(CONSTROID, | - |
| 2519 | - | ObjectIdGetDatum(address.objectId)); | - |
| 2520 | - | if (!HeapTupleIsValid(tuple)) | - |
| 2521 | - | elog(ERROR, "constraint with OID %u does not exist", | - |
| 2522 | - | address.objectId); | - |
| 2523 | - | - | |
| 2524 | - | contypid = ((Form_pg_constraint) GETSTRUCT(tuple))->contypid; | - |
| 2525 | - | - | |
| 2526 | - | ReleaseSysCache(tuple); | - |
| 2527 | - | - | |
| 2528 | - | /* | - |
| 2529 | - | * Fallback to type ownership check in this case as this is | - |
| 2530 | - | * what domain constraints rely on. | - |
| 2531 | - | */ | - |
| 2532 | - | if (!object_ownercheck(TypeRelationId, contypid, roleid)) | - |
| 2533 | - | aclcheck_error_type(ACLCHECK_NOT_OWNER, contypid); | - |
| 2534 | - | } | - |
| 2535 | - | break; | - |
| 2536 | - | case OBJECT_AGGREGATE: | - |
| 2537 | - | case OBJECT_FUNCTION: | - |
| 2538 | - | case OBJECT_PROCEDURE: | - |
| 2539 | - | case OBJECT_ROUTINE: | - |
| 2540 | - | case OBJECT_OPERATOR: | - |
| 2541 | - | if (!object_ownercheck(address.classId, address.objectId, roleid)) | - |
| 2542 | - | aclcheck_error(ACLCHECK_NOT_OWNER, objtype, | - |
| 2543 | - | NameListToString((castNode(ObjectWithArgs, object))->objname)); | - |
| 2544 | - | break; | - |
| 2545 | - | case OBJECT_DATABASE: | - |
| 2546 | - | case OBJECT_EVENT_TRIGGER: | - |
| 2547 | - | case OBJECT_EXTENSION: | - |
| 2548 | - | case OBJECT_FDW: | - |
| 2549 | - | case OBJECT_FOREIGN_SERVER: | - |
| 2550 | - | case OBJECT_LANGUAGE: | - |
| 2551 | - | case OBJECT_PUBLICATION: | - |
| 2552 | - | case OBJECT_SCHEMA: | - |
| 2553 | - | case OBJECT_SUBSCRIPTION: | - |
| 2554 | - | case OBJECT_TABLESPACE: | - |
| 2555 | - | if (!object_ownercheck(address.classId, address.objectId, roleid)) | - |
| 2556 | - | aclcheck_error(ACLCHECK_NOT_OWNER, objtype, | - |
| 2557 | - | strVal(object)); | - |
| 2558 | - | break; | - |
| 2559 | - | case OBJECT_COLLATION: | - |
| 2560 | - | case OBJECT_CONVERSION: | - |
| 2561 | - | case OBJECT_OPCLASS: | - |
| 2562 | - | case OBJECT_OPFAMILY: | - |
| 2563 | - | case OBJECT_STATISTIC_EXT: | - |
| 2564 | - | case OBJECT_TSDICTIONARY: | - |
| 2565 | - | case OBJECT_TSCONFIGURATION: | - |
| 2566 | - | if (!object_ownercheck(address.classId, address.objectId, roleid)) | - |
| 2567 | - | aclcheck_error(ACLCHECK_NOT_OWNER, objtype, | - |
| 2568 | - | NameListToString(castNode(List, object))); | - |
| 2569 | - | break; | - |
| 2570 | - | case OBJECT_LARGEOBJECT: | - |
| 2571 | - | if (!lo_compat_privileges && | - |
| 2572 | - | !object_ownercheck(address.classId, address.objectId, roleid)) | - |
| 2573 | - | ereport(ERROR, | - |
| 2574 | - | (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), | - |
| 2575 | - | errmsg("must be owner of large object %u", | - |
| 2576 | - | address.objectId))); | - |
| 2577 | - | break; | - |
| 2578 | - | case OBJECT_CAST: | - |
| 2579 | - | { | - |
| 2580 | - | /* We can only check permissions on the source/target types */ | - |
| 2581 | - | TypeName *sourcetype = linitial_node(TypeName, castNode(List, object)); | - |
| 2582 | - | TypeName *targettype = lsecond_node(TypeName, castNode(List, object)); | - |
| 2583 | - | Oid sourcetypeid = typenameTypeId(NULL, sourcetype); | - |
| 2584 | - | Oid targettypeid = typenameTypeId(NULL, targettype); | - |
| 2585 | - | - | |
| 2586 | - | if (!object_ownercheck(TypeRelationId, sourcetypeid, roleid) | - |
| 2587 | - | && !object_ownercheck(TypeRelationId, targettypeid, roleid)) | - |
| 2588 | - | ereport(ERROR, | - |
| 2589 | - | (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), | - |
| 2590 | - | errmsg("must be owner of type %s or type %s", | - |
| 2591 | - | format_type_be(sourcetypeid), | - |
| 2592 | - | format_type_be(targettypeid)))); | - |
| 2593 | - | } | - |
| 2594 | - | break; | - |
| 2595 | - | case OBJECT_TRANSFORM: | - |
| 2596 | - | { | - |
| 2597 | - | TypeName *typename = linitial_node(TypeName, castNode(List, object)); | - |
| 2598 | - | Oid typeid = typenameTypeId(NULL, typename); | - |
| 2599 | - | - | |
| 2600 | - | if (!object_ownercheck(TypeRelationId, typeid, roleid)) | - |
| 2601 | - | aclcheck_error_type(ACLCHECK_NOT_OWNER, typeid); | - |
| 2602 | - | } | - |
| 2603 | - | break; | - |
| 2604 | - | case OBJECT_ROLE: | - |
| 2605 | - | - | |
| 2606 | - | /* | - |
| 2607 | - | * We treat roles as being "owned" by those with CREATEROLE priv, | - |
| 2608 | - | * provided that they also have admin option on the role. | - |
| 2609 | - | * | - |
| 2610 | - | * However, superusers are only owned by superusers. | - |
| 2611 | - | */ | - |
| 2612 | - | if (superuser_arg(address.objectId)) | - |
| 2613 | - | { | - |
| 2614 | - | if (!superuser_arg(roleid)) | - |
| 2615 | - | ereport(ERROR, | - |
| 2616 | - | (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), | - |
| 2617 | - | errmsg("permission denied"), | - |
| 2618 | - | errdetail("The current user must have the %s attribute.", | - |
| 2619 | - | "SUPERUSER"))); | - |
| 2620 | - | } | - |
| 2621 | - | else | - |
| 2622 | - | { | - |
| 2623 | - | if (!has_createrole_privilege(roleid)) | - |
| 2624 | - | ereport(ERROR, | - |
| 2625 | - | (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), | - |
| 2626 | - | errmsg("permission denied"), | - |
| 2627 | - | errdetail("The current user must have the %s attribute.", | - |
| 2628 | - | "CREATEROLE"))); | - |
| 2629 | - | if (!is_admin_of_role(roleid, address.objectId)) | - |
| 2630 | - | ereport(ERROR, | - |
| 2631 | - | (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), | - |
| 2632 | - | errmsg("permission denied"), | - |
| 2633 | - | errdetail("The current user must have the %s option on role \"%s\".", | - |
| 2634 | - | "ADMIN", | - |
| 2635 | - | GetUserNameFromId(address.objectId, | - |
| 2636 | - | true)))); | - |
| 2637 | - | } | - |
| 2638 | - | break; | - |
| 2639 | - | case OBJECT_TSPARSER: | - |
| 2640 | - | case OBJECT_TSTEMPLATE: | - |
| 2641 | - | case OBJECT_ACCESS_METHOD: | - |
| 2642 | - | case OBJECT_PARAMETER_ACL: | - |
| 2643 | - | /* We treat these object types as being owned by superusers */ | - |
| 2644 | - | if (!superuser_arg(roleid)) | - |
| 2645 | - | ereport(ERROR, | - |
| 2646 | - | (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), | - |
| 2647 | - | errmsg("must be superuser"))); | - |
| 2648 | - | break; | - |
| 2649 | - | case OBJECT_AMOP: | - |
| 2650 | - | case OBJECT_AMPROC: | - |
| 2651 | - | case OBJECT_DEFAULT: | - |
| 2652 | - | case OBJECT_DEFACL: | - |
| 2653 | - | case OBJECT_PUBLICATION_NAMESPACE: | - |
| 2654 | - | case OBJECT_PUBLICATION_REL: | - |
| 2655 | - | case OBJECT_USER_MAPPING: | - |
| 2656 | - | /* These are currently not supported or don't make sense here. */ | - |
| 2657 | - | elog(ERROR, "unsupported object type: %d", (int) objtype); | - |
| 2658 | - | break; | - |
| 2659 | - | } | - |
| 2660 | - | } | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 3008 | - | getObjectDescription(const ObjectAddress *object, bool missing_ok) | - |
| 3009 | - | { | - |
| 3010 | - | StringInfoData buffer; | - |
| 3011 | - | - | |
| 3012 | - | initStringInfo(&buffer); | - |
| 3013 | - | - | |
| 3014 | - | switch (object->classId) | - |
| 3015 | - | { | - |
| 3016 | - | case RelationRelationId: | - |
| 3017 | - | if (object->objectSubId == 0) | - |
| 3018 | - | getRelationDescription(&buffer, object->objectId, missing_ok); | - |
| 3019 | - | else | - |
| 3020 | - | { | - |
| 3021 | - | /* column, not whole relation */ | - |
| 3022 | - | StringInfoData rel; | - |
| 3023 | - | char *attname = get_attname(object->objectId, | - |
| 3024 | - | object->objectSubId, | - |
| 3025 | - | missing_ok); | - |
| 3026 | - | - | |
| 3027 | - | if (!attname) | - |
| 3028 | - | break; | - |
| 3029 | - | - | |
| 3030 | - | initStringInfo(&rel); | - |
| 3031 | - | getRelationDescription(&rel, object->objectId, missing_ok); | - |
| 3032 | - | /* translator: second %s is, e.g., "table %s" */ | - |
| 3033 | - | appendStringInfo(&buffer, _("column %s of %s"), | - |
| 3034 | - | attname, rel.data); | - |
| 3035 | - | pfree(rel.data); | - |
| 3036 | - | } | - |
| 3037 | - | break; | - |
| 3038 | - | - | |
| 3039 | - | case ProcedureRelationId: | - |
| 3040 | - | { | - |
| 3041 | - | bits16 flags = FORMAT_PROC_INVALID_AS_NULL; | - |
| 3042 | - | char *proname = format_procedure_extended(object->objectId, | - |
| 3043 | - | flags); | - |
| 3044 | - | - | |
| 3045 | - | if (proname == NULL) | - |
| 3046 | - | break; | - |
| 3047 | - | - | |
| 3048 | - | appendStringInfo(&buffer, _("function %s"), proname); | - |
| 3049 | - | break; | - |
| 3050 | - | } | - |
| 3051 | - | - | |
| 3052 | - | case TypeRelationId: | - |
| 3053 | - | { | - |
| 3054 | - | bits16 flags = FORMAT_TYPE_INVALID_AS_NULL; | - |
| 3055 | - | char *typname = format_type_extended(object->objectId, -1, | - |
| 3056 | - | flags); | - |
| 3057 | - | - | |
| 3058 | - | if (typname == NULL) | - |
| 3059 | - | break; | - |
| 3060 | - | - | |
| 3061 | - | appendStringInfo(&buffer, _("type %s"), typname); | - |
| 3062 | - | break; | - |
| 3063 | - | } | - |
| 3064 | - | - | |
| 3065 | - | case CastRelationId: | - |
| 3066 | - | { | - |
| 3067 | - | Relation castDesc; | - |
| 3068 | - | ScanKeyData skey[1]; | - |
| 3069 | - | SysScanDesc rcscan; | - |
| 3070 | - | HeapTuple tup; | - |
| 3071 | - | Form_pg_cast castForm; | - |
| 3072 | - | - | |
| 3073 | - | castDesc = table_open(CastRelationId, AccessShareLock); | - |
| 3074 | - | - | |
| 3075 | - | ScanKeyInit(&skey[0], | - |
| 3076 | - | Anum_pg_cast_oid, | - |
| 3077 | - | BTEqualStrategyNumber, F_OIDEQ, | - |
| 3078 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3079 | - | - | |
| 3080 | - | rcscan = systable_beginscan(castDesc, CastOidIndexId, true, | - |
| 3081 | - | NULL, 1, skey); | - |
| 3082 | - | - | |
| 3083 | - | tup = systable_getnext(rcscan); | - |
| 3084 | - | - | |
| 3085 | - | if (!HeapTupleIsValid(tup)) | - |
| 3086 | - | { | - |
| 3087 | - | if (!missing_ok) | - |
| 3088 | - | elog(ERROR, "could not find tuple for cast %u", | - |
| 3089 | - | object->objectId); | - |
| 3090 | - | - | |
| 3091 | - | systable_endscan(rcscan); | - |
| 3092 | - | table_close(castDesc, AccessShareLock); | - |
| 3093 | - | break; | - |
| 3094 | - | } | - |
| 3095 | - | - | |
| 3096 | - | castForm = (Form_pg_cast) GETSTRUCT(tup); | - |
| 3097 | - | - | |
| 3098 | - | appendStringInfo(&buffer, _("cast from %s to %s"), | - |
| 3099 | - | format_type_be(castForm->castsource), | - |
| 3100 | - | format_type_be(castForm->casttarget)); | - |
| 3101 | - | - | |
| 3102 | - | systable_endscan(rcscan); | - |
| 3103 | - | table_close(castDesc, AccessShareLock); | - |
| 3104 | - | break; | - |
| 3105 | - | } | - |
| 3106 | - | - | |
| 3107 | - | case CollationRelationId: | - |
| 3108 | - | { | - |
| 3109 | - | HeapTuple collTup; | - |
| 3110 | - | Form_pg_collation coll; | - |
| 3111 | - | char *nspname; | - |
| 3112 | - | - | |
| 3113 | - | collTup = SearchSysCache1(COLLOID, | - |
| 3114 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3115 | - | if (!HeapTupleIsValid(collTup)) | - |
| 3116 | - | { | - |
| 3117 | - | if (!missing_ok) | - |
| 3118 | - | elog(ERROR, "cache lookup failed for collation %u", | - |
| 3119 | - | object->objectId); | - |
| 3120 | - | break; | - |
| 3121 | - | } | - |
| 3122 | - | - | |
| 3123 | - | coll = (Form_pg_collation) GETSTRUCT(collTup); | - |
| 3124 | - | - | |
| 3125 | - | /* Qualify the name if not visible in search path */ | - |
| 3126 | - | if (CollationIsVisible(object->objectId)) | - |
| 3127 | - | nspname = NULL; | - |
| 3128 | - | else | - |
| 3129 | - | nspname = get_namespace_name(coll->collnamespace); | - |
| 3130 | - | - | |
| 3131 | - | appendStringInfo(&buffer, _("collation %s"), | - |
| 3132 | - | quote_qualified_identifier(nspname, | - |
| 3133 | - | NameStr(coll->collname))); | - |
| 3134 | - | ReleaseSysCache(collTup); | - |
| 3135 | - | break; | - |
| 3136 | - | } | - |
| 3137 | - | - | |
| 3138 | - | case ConstraintRelationId: | - |
| 3139 | - | { | - |
| 3140 | - | HeapTuple conTup; | - |
| 3141 | - | Form_pg_constraint con; | - |
| 3142 | - | - | |
| 3143 | - | conTup = SearchSysCache1(CONSTROID, | - |
| 3144 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3145 | - | if (!HeapTupleIsValid(conTup)) | - |
| 3146 | - | { | - |
| 3147 | - | if (!missing_ok) | - |
| 3148 | - | elog(ERROR, "cache lookup failed for constraint %u", | - |
| 3149 | - | object->objectId); | - |
| 3150 | - | break; | - |
| 3151 | - | } | - |
| 3152 | - | - | |
| 3153 | - | con = (Form_pg_constraint) GETSTRUCT(conTup); | - |
| 3154 | - | - | |
| 3155 | - | if (OidIsValid(con->conrelid)) | - |
| 3156 | - | { | - |
| 3157 | - | StringInfoData rel; | - |
| 3158 | - | - | |
| 3159 | - | initStringInfo(&rel); | - |
| 3160 | - | getRelationDescription(&rel, con->conrelid, false); | - |
| 3161 | - | /* translator: second %s is, e.g., "table %s" */ | - |
| 3162 | - | appendStringInfo(&buffer, _("constraint %s on %s"), | - |
| 3163 | - | NameStr(con->conname), rel.data); | - |
| 3164 | - | pfree(rel.data); | - |
| 3165 | - | } | - |
| 3166 | - | else | - |
| 3167 | - | { | - |
| 3168 | - | appendStringInfo(&buffer, _("constraint %s"), | - |
| 3169 | - | NameStr(con->conname)); | - |
| 3170 | - | } | - |
| 3171 | - | - | |
| 3172 | - | ReleaseSysCache(conTup); | - |
| 3173 | - | break; | - |
| 3174 | - | } | - |
| 3175 | - | - | |
| 3176 | - | case ConversionRelationId: | - |
| 3177 | - | { | - |
| 3178 | - | HeapTuple conTup; | - |
| 3179 | - | Form_pg_conversion conv; | - |
| 3180 | - | char *nspname; | - |
| 3181 | - | - | |
| 3182 | - | conTup = SearchSysCache1(CONVOID, | - |
| 3183 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3184 | - | if (!HeapTupleIsValid(conTup)) | - |
| 3185 | - | { | - |
| 3186 | - | if (!missing_ok) | - |
| 3187 | - | elog(ERROR, "cache lookup failed for conversion %u", | - |
| 3188 | - | object->objectId); | - |
| 3189 | - | break; | - |
| 3190 | - | } | - |
| 3191 | - | - | |
| 3192 | - | conv = (Form_pg_conversion) GETSTRUCT(conTup); | - |
| 3193 | - | - | |
| 3194 | - | /* Qualify the name if not visible in search path */ | - |
| 3195 | - | if (ConversionIsVisible(object->objectId)) | - |
| 3196 | - | nspname = NULL; | - |
| 3197 | - | else | - |
| 3198 | - | nspname = get_namespace_name(conv->connamespace); | - |
| 3199 | - | - | |
| 3200 | - | appendStringInfo(&buffer, _("conversion %s"), | - |
| 3201 | - | quote_qualified_identifier(nspname, | - |
| 3202 | - | NameStr(conv->conname))); | - |
| 3203 | - | ReleaseSysCache(conTup); | - |
| 3204 | - | break; | - |
| 3205 | - | } | - |
| 3206 | - | - | |
| 3207 | - | case AttrDefaultRelationId: | - |
| 3208 | - | { | - |
| 3209 | - | ObjectAddress colobject; | - |
| 3210 | - | - | |
| 3211 | - | colobject = GetAttrDefaultColumnAddress(object->objectId); | - |
| 3212 | - | - | |
| 3213 | - | if (!OidIsValid(colobject.objectId)) | - |
| 3214 | - | { | - |
| 3215 | - | if (!missing_ok) | - |
| 3216 | - | elog(ERROR, "could not find tuple for attrdef %u", | - |
| 3217 | - | object->objectId); | - |
| 3218 | - | break; | - |
| 3219 | - | } | - |
| 3220 | - | - | |
| 3221 | - | /* translator: %s is typically "column %s of table %s" */ | - |
| 3222 | - | appendStringInfo(&buffer, _("default value for %s"), | - |
| 3223 | - | getObjectDescription(&colobject, false)); | - |
| 3224 | - | break; | - |
| 3225 | - | } | - |
| 3226 | - | - | |
| 3227 | - | case LanguageRelationId: | - |
| 3228 | - | { | - |
| 3229 | - | char *langname = get_language_name(object->objectId, | - |
| 3230 | - | missing_ok); | - |
| 3231 | - | - | |
| 3232 | - | if (langname) | - |
| 3233 | - | appendStringInfo(&buffer, _("language %s"), | - |
| 3234 | - | get_language_name(object->objectId, false)); | - |
| 3235 | - | break; | - |
| 3236 | - | } | - |
| 3237 | - | - | |
| 3238 | - | case LargeObjectRelationId: | - |
| 3239 | - | if (!LargeObjectExists(object->objectId)) | - |
| 3240 | - | break; | - |
| 3241 | - | appendStringInfo(&buffer, _("large object %u"), | - |
| 3242 | - | object->objectId); | - |
| 3243 | - | break; | - |
| 3244 | - | - | |
| 3245 | - | case OperatorRelationId: | - |
| 3246 | - | { | - |
| 3247 | - | bits16 flags = FORMAT_OPERATOR_INVALID_AS_NULL; | - |
| 3248 | - | char *oprname = format_operator_extended(object->objectId, | - |
| 3249 | - | flags); | - |
| 3250 | - | - | |
| 3251 | - | if (oprname == NULL) | - |
| 3252 | - | break; | - |
| 3253 | - | - | |
| 3254 | - | appendStringInfo(&buffer, _("operator %s"), oprname); | - |
| 3255 | - | break; | - |
| 3256 | - | } | - |
| 3257 | - | - | |
| 3258 | - | case OperatorClassRelationId: | - |
| 3259 | - | { | - |
| 3260 | - | HeapTuple opcTup; | - |
| 3261 | - | Form_pg_opclass opcForm; | - |
| 3262 | - | HeapTuple amTup; | - |
| 3263 | - | Form_pg_am amForm; | - |
| 3264 | - | char *nspname; | - |
| 3265 | - | - | |
| 3266 | - | opcTup = SearchSysCache1(CLAOID, | - |
| 3267 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3268 | - | if (!HeapTupleIsValid(opcTup)) | - |
| 3269 | - | { | - |
| 3270 | - | if (!missing_ok) | - |
| 3271 | - | elog(ERROR, "cache lookup failed for opclass %u", | - |
| 3272 | - | object->objectId); | - |
| 3273 | - | break; | - |
| 3274 | - | } | - |
| 3275 | - | - | |
| 3276 | - | opcForm = (Form_pg_opclass) GETSTRUCT(opcTup); | - |
| 3277 | - | - | |
| 3278 | - | amTup = SearchSysCache1(AMOID, | - |
| 3279 | - | ObjectIdGetDatum(opcForm->opcmethod)); | - |
| 3280 | - | if (!HeapTupleIsValid(amTup)) | - |
| 3281 | - | elog(ERROR, "cache lookup failed for access method %u", | - |
| 3282 | - | opcForm->opcmethod); | - |
| 3283 | - | amForm = (Form_pg_am) GETSTRUCT(amTup); | - |
| 3284 | - | - | |
| 3285 | - | /* Qualify the name if not visible in search path */ | - |
| 3286 | - | if (OpclassIsVisible(object->objectId)) | - |
| 3287 | - | nspname = NULL; | - |
| 3288 | - | else | - |
| 3289 | - | nspname = get_namespace_name(opcForm->opcnamespace); | - |
| 3290 | - | - | |
| 3291 | - | appendStringInfo(&buffer, _("operator class %s for access method %s"), | - |
| 3292 | - | quote_qualified_identifier(nspname, | - |
| 3293 | - | NameStr(opcForm->opcname)), | - |
| 3294 | - | NameStr(amForm->amname)); | - |
| 3295 | - | - | |
| 3296 | - | ReleaseSysCache(amTup); | - |
| 3297 | - | ReleaseSysCache(opcTup); | - |
| 3298 | - | break; | - |
| 3299 | - | } | - |
| 3300 | - | - | |
| 3301 | - | case OperatorFamilyRelationId: | - |
| 3302 | - | getOpFamilyDescription(&buffer, object->objectId, missing_ok); | - |
| 3303 | - | break; | - |
| 3304 | - | - | |
| 3305 | - | case AccessMethodRelationId: | - |
| 3306 | - | { | - |
| 3307 | - | HeapTuple tup; | - |
| 3308 | - | - | |
| 3309 | - | tup = SearchSysCache1(AMOID, | - |
| 3310 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3311 | - | if (!HeapTupleIsValid(tup)) | - |
| 3312 | - | { | - |
| 3313 | - | if (!missing_ok) | - |
| 3314 | - | elog(ERROR, "cache lookup failed for access method %u", | - |
| 3315 | - | object->objectId); | - |
| 3316 | - | break; | - |
| 3317 | - | } | - |
| 3318 | - | - | |
| 3319 | - | appendStringInfo(&buffer, _("access method %s"), | - |
| 3320 | - | NameStr(((Form_pg_am) GETSTRUCT(tup))->amname)); | - |
| 3321 | - | ReleaseSysCache(tup); | - |
| 3322 | - | break; | - |
| 3323 | - | } | - |
| 3324 | - | - | |
| 3325 | - | case AccessMethodOperatorRelationId: | - |
| 3326 | - | { | - |
| 3327 | - | Relation amopDesc; | - |
| 3328 | - | HeapTuple tup; | - |
| 3329 | - | ScanKeyData skey[1]; | - |
| 3330 | - | SysScanDesc amscan; | - |
| 3331 | - | Form_pg_amop amopForm; | - |
| 3332 | - | StringInfoData opfam; | - |
| 3333 | - | - | |
| 3334 | - | amopDesc = table_open(AccessMethodOperatorRelationId, | - |
| 3335 | - | AccessShareLock); | - |
| 3336 | - | - | |
| 3337 | - | ScanKeyInit(&skey[0], | - |
| 3338 | - | Anum_pg_amop_oid, | - |
| 3339 | - | BTEqualStrategyNumber, F_OIDEQ, | - |
| 3340 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3341 | - | - | |
| 3342 | - | amscan = systable_beginscan(amopDesc, AccessMethodOperatorOidIndexId, true, | - |
| 3343 | - | NULL, 1, skey); | - |
| 3344 | - | - | |
| 3345 | - | tup = systable_getnext(amscan); | - |
| 3346 | - | - | |
| 3347 | - | if (!HeapTupleIsValid(tup)) | - |
| 3348 | - | { | - |
| 3349 | - | if (!missing_ok) | - |
| 3350 | - | elog(ERROR, "could not find tuple for amop entry %u", | - |
| 3351 | - | object->objectId); | - |
| 3352 | - | - | |
| 3353 | - | systable_endscan(amscan); | - |
| 3354 | - | table_close(amopDesc, AccessShareLock); | - |
| 3355 | - | break; | - |
| 3356 | - | } | - |
| 3357 | - | - | |
| 3358 | - | amopForm = (Form_pg_amop) GETSTRUCT(tup); | - |
| 3359 | - | - | |
| 3360 | - | initStringInfo(&opfam); | - |
| 3361 | - | getOpFamilyDescription(&opfam, amopForm->amopfamily, false); | - |
| 3362 | - | - | |
| 3363 | - | /* | - |
| 3364 | - | * We use FORMAT_TYPE_ALLOW_INVALID here so as not to fail | - |
| 3365 | - | * completely if the type links are dangling, which is a form | - |
| 3366 | - | * of catalog corruption that could occur due to old bugs. | - |
| 3367 | - | */ | - |
| 3368 | - | - | |
| 3369 | - | /*------ | - |
| 3370 | - | translator: %d is the operator strategy (a number), the | - |
| 3371 | - | first two %s's are data type names, the third %s is the | - |
| 3372 | - | description of the operator family, and the last %s is the | - |
| 3373 | - | textual form of the operator with arguments. */ | - |
| 3374 | - | appendStringInfo(&buffer, _("operator %d (%s, %s) of %s: %s"), | - |
| 3375 | - | amopForm->amopstrategy, | - |
| 3376 | - | format_type_extended(amopForm->amoplefttype, | - |
| 3377 | - | -1, FORMAT_TYPE_ALLOW_INVALID), | - |
| 3378 | - | format_type_extended(amopForm->amoprighttype, | - |
| 3379 | - | -1, FORMAT_TYPE_ALLOW_INVALID), | - |
| 3380 | - | opfam.data, | - |
| 3381 | - | format_operator(amopForm->amopopr)); | - |
| 3382 | - | - | |
| 3383 | - | pfree(opfam.data); | - |
| 3384 | - | - | |
| 3385 | - | systable_endscan(amscan); | - |
| 3386 | - | table_close(amopDesc, AccessShareLock); | - |
| 3387 | - | break; | - |
| 3388 | - | } | - |
| 3389 | - | - | |
| 3390 | - | case AccessMethodProcedureRelationId: | - |
| 3391 | - | { | - |
| 3392 | - | Relation amprocDesc; | - |
| 3393 | - | ScanKeyData skey[1]; | - |
| 3394 | - | SysScanDesc amscan; | - |
| 3395 | - | HeapTuple tup; | - |
| 3396 | - | Form_pg_amproc amprocForm; | - |
| 3397 | - | StringInfoData opfam; | - |
| 3398 | - | - | |
| 3399 | - | amprocDesc = table_open(AccessMethodProcedureRelationId, | - |
| 3400 | - | AccessShareLock); | - |
| 3401 | - | - | |
| 3402 | - | ScanKeyInit(&skey[0], | - |
| 3403 | - | Anum_pg_amproc_oid, | - |
| 3404 | - | BTEqualStrategyNumber, F_OIDEQ, | - |
| 3405 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3406 | - | - | |
| 3407 | - | amscan = systable_beginscan(amprocDesc, AccessMethodProcedureOidIndexId, true, | - |
| 3408 | - | NULL, 1, skey); | - |
| 3409 | - | - | |
| 3410 | - | tup = systable_getnext(amscan); | - |
| 3411 | - | - | |
| 3412 | - | if (!HeapTupleIsValid(tup)) | - |
| 3413 | - | { | - |
| 3414 | - | if (!missing_ok) | - |
| 3415 | - | elog(ERROR, "could not find tuple for amproc entry %u", | - |
| 3416 | - | object->objectId); | - |
| 3417 | - | - | |
| 3418 | - | systable_endscan(amscan); | - |
| 3419 | - | table_close(amprocDesc, AccessShareLock); | - |
| 3420 | - | break; | - |
| 3421 | - | } | - |
| 3422 | - | - | |
| 3423 | - | amprocForm = (Form_pg_amproc) GETSTRUCT(tup); | - |
| 3424 | - | - | |
| 3425 | - | initStringInfo(&opfam); | - |
| 3426 | - | getOpFamilyDescription(&opfam, amprocForm->amprocfamily, false); | - |
| 3427 | - | - | |
| 3428 | - | /* | - |
| 3429 | - | * We use FORMAT_TYPE_ALLOW_INVALID here so as not to fail | - |
| 3430 | - | * completely if the type links are dangling, which is a form | - |
| 3431 | - | * of catalog corruption that could occur due to old bugs. | - |
| 3432 | - | */ | - |
| 3433 | - | - | |
| 3434 | - | /*------ | - |
| 3435 | - | translator: %d is the function number, the first two %s's | - |
| 3436 | - | are data type names, the third %s is the description of the | - |
| 3437 | - | operator family, and the last %s is the textual form of the | - |
| 3438 | - | function with arguments. */ | - |
| 3439 | - | appendStringInfo(&buffer, _("function %d (%s, %s) of %s: %s"), | - |
| 3440 | - | amprocForm->amprocnum, | - |
| 3441 | - | format_type_extended(amprocForm->amproclefttype, | - |
| 3442 | - | -1, FORMAT_TYPE_ALLOW_INVALID), | - |
| 3443 | - | format_type_extended(amprocForm->amprocrighttype, | - |
| 3444 | - | -1, FORMAT_TYPE_ALLOW_INVALID), | - |
| 3445 | - | opfam.data, | - |
| 3446 | - | format_procedure(amprocForm->amproc)); | - |
| 3447 | - | - | |
| 3448 | - | pfree(opfam.data); | - |
| 3449 | - | - | |
| 3450 | - | systable_endscan(amscan); | - |
| 3451 | - | table_close(amprocDesc, AccessShareLock); | - |
| 3452 | - | break; | - |
| 3453 | - | } | - |
| 3454 | - | - | |
| 3455 | - | case RewriteRelationId: | - |
| 3456 | - | { | - |
| 3457 | - | Relation ruleDesc; | - |
| 3458 | - | ScanKeyData skey[1]; | - |
| 3459 | - | SysScanDesc rcscan; | - |
| 3460 | - | HeapTuple tup; | - |
| 3461 | - | Form_pg_rewrite rule; | - |
| 3462 | - | StringInfoData rel; | - |
| 3463 | - | - | |
| 3464 | - | ruleDesc = table_open(RewriteRelationId, AccessShareLock); | - |
| 3465 | - | - | |
| 3466 | - | ScanKeyInit(&skey[0], | - |
| 3467 | - | Anum_pg_rewrite_oid, | - |
| 3468 | - | BTEqualStrategyNumber, F_OIDEQ, | - |
| 3469 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3470 | - | - | |
| 3471 | - | rcscan = systable_beginscan(ruleDesc, RewriteOidIndexId, true, | - |
| 3472 | - | NULL, 1, skey); | - |
| 3473 | - | - | |
| 3474 | - | tup = systable_getnext(rcscan); | - |
| 3475 | - | - | |
| 3476 | - | if (!HeapTupleIsValid(tup)) | - |
| 3477 | - | { | - |
| 3478 | - | if (!missing_ok) | - |
| 3479 | - | elog(ERROR, "could not find tuple for rule %u", | - |
| 3480 | - | object->objectId); | - |
| 3481 | - | - | |
| 3482 | - | systable_endscan(rcscan); | - |
| 3483 | - | table_close(ruleDesc, AccessShareLock); | - |
| 3484 | - | break; | - |
| 3485 | - | } | - |
| 3486 | - | - | |
| 3487 | - | rule = (Form_pg_rewrite) GETSTRUCT(tup); | - |
| 3488 | - | - | |
| 3489 | - | initStringInfo(&rel); | - |
| 3490 | - | getRelationDescription(&rel, rule->ev_class, false); | - |
| 3491 | - | - | |
| 3492 | - | /* translator: second %s is, e.g., "table %s" */ | - |
| 3493 | - | appendStringInfo(&buffer, _("rule %s on %s"), | - |
| 3494 | - | NameStr(rule->rulename), rel.data); | - |
| 3495 | - | pfree(rel.data); | - |
| 3496 | - | systable_endscan(rcscan); | - |
| 3497 | - | table_close(ruleDesc, AccessShareLock); | - |
| 3498 | - | break; | - |
| 3499 | - | } | - |
| 3500 | - | - | |
| 3501 | - | case TriggerRelationId: | - |
| 3502 | - | { | - |
| 3503 | - | Relation trigDesc; | - |
| 3504 | - | ScanKeyData skey[1]; | - |
| 3505 | - | SysScanDesc tgscan; | - |
| 3506 | - | HeapTuple tup; | - |
| 3507 | - | Form_pg_trigger trig; | - |
| 3508 | - | StringInfoData rel; | - |
| 3509 | - | - | |
| 3510 | - | trigDesc = table_open(TriggerRelationId, AccessShareLock); | - |
| 3511 | - | - | |
| 3512 | - | ScanKeyInit(&skey[0], | - |
| 3513 | - | Anum_pg_trigger_oid, | - |
| 3514 | - | BTEqualStrategyNumber, F_OIDEQ, | - |
| 3515 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3516 | - | - | |
| 3517 | - | tgscan = systable_beginscan(trigDesc, TriggerOidIndexId, true, | - |
| 3518 | - | NULL, 1, skey); | - |
| 3519 | - | - | |
| 3520 | - | tup = systable_getnext(tgscan); | - |
| 3521 | - | - | |
| 3522 | - | if (!HeapTupleIsValid(tup)) | - |
| 3523 | - | { | - |
| 3524 | - | if (!missing_ok) | - |
| 3525 | - | elog(ERROR, "could not find tuple for trigger %u", | - |
| 3526 | - | object->objectId); | - |
| 3527 | - | - | |
| 3528 | - | systable_endscan(tgscan); | - |
| 3529 | - | table_close(trigDesc, AccessShareLock); | - |
| 3530 | - | break; | - |
| 3531 | - | } | - |
| 3532 | - | - | |
| 3533 | - | trig = (Form_pg_trigger) GETSTRUCT(tup); | - |
| 3534 | - | - | |
| 3535 | - | initStringInfo(&rel); | - |
| 3536 | - | getRelationDescription(&rel, trig->tgrelid, false); | - |
| 3537 | - | - | |
| 3538 | - | /* translator: second %s is, e.g., "table %s" */ | - |
| 3539 | - | appendStringInfo(&buffer, _("trigger %s on %s"), | - |
| 3540 | - | NameStr(trig->tgname), rel.data); | - |
| 3541 | - | pfree(rel.data); | - |
| 3542 | - | systable_endscan(tgscan); | - |
| 3543 | - | table_close(trigDesc, AccessShareLock); | - |
| 3544 | - | break; | - |
| 3545 | - | } | - |
| 3546 | - | - | |
| 3547 | - | case NamespaceRelationId: | - |
| 3548 | - | { | - |
| 3549 | - | char *nspname; | - |
| 3550 | - | - | |
| 3551 | - | nspname = get_namespace_name(object->objectId); | - |
| 3552 | - | if (!nspname) | - |
| 3553 | - | { | - |
| 3554 | - | if (!missing_ok) | - |
| 3555 | - | elog(ERROR, "cache lookup failed for namespace %u", | - |
| 3556 | - | object->objectId); | - |
| 3557 | - | break; | - |
| 3558 | - | } | - |
| 3559 | - | appendStringInfo(&buffer, _("schema %s"), nspname); | - |
| 3560 | - | break; | - |
| 3561 | - | } | - |
| 3562 | - | - | |
| 3563 | - | case StatisticExtRelationId: | - |
| 3564 | - | { | - |
| 3565 | - | HeapTuple stxTup; | - |
| 3566 | - | Form_pg_statistic_ext stxForm; | - |
| 3567 | - | char *nspname; | - |
| 3568 | - | - | |
| 3569 | - | stxTup = SearchSysCache1(STATEXTOID, | - |
| 3570 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3571 | - | if (!HeapTupleIsValid(stxTup)) | - |
| 3572 | - | { | - |
| 3573 | - | if (!missing_ok) | - |
| 3574 | - | elog(ERROR, "could not find tuple for statistics object %u", | - |
| 3575 | - | object->objectId); | - |
| 3576 | - | break; | - |
| 3577 | - | } | - |
| 3578 | - | - | |
| 3579 | - | stxForm = (Form_pg_statistic_ext) GETSTRUCT(stxTup); | - |
| 3580 | - | - | |
| 3581 | - | /* Qualify the name if not visible in search path */ | - |
| 3582 | - | if (StatisticsObjIsVisible(object->objectId)) | - |
| 3583 | - | nspname = NULL; | - |
| 3584 | - | else | - |
| 3585 | - | nspname = get_namespace_name(stxForm->stxnamespace); | - |
| 3586 | - | - | |
| 3587 | - | appendStringInfo(&buffer, _("statistics object %s"), | - |
| 3588 | - | quote_qualified_identifier(nspname, | - |
| 3589 | - | NameStr(stxForm->stxname))); | - |
| 3590 | - | - | |
| 3591 | - | ReleaseSysCache(stxTup); | - |
| 3592 | - | break; | - |
| 3593 | - | } | - |
| 3594 | - | - | |
| 3595 | - | case TSParserRelationId: | - |
| 3596 | - | { | - |
| 3597 | - | HeapTuple tup; | - |
| 3598 | - | Form_pg_ts_parser prsForm; | - |
| 3599 | - | char *nspname; | - |
| 3600 | - | - | |
| 3601 | - | tup = SearchSysCache1(TSPARSEROID, | - |
| 3602 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3603 | - | if (!HeapTupleIsValid(tup)) | - |
| 3604 | - | { | - |
| 3605 | - | if (!missing_ok) | - |
| 3606 | - | elog(ERROR, "cache lookup failed for text search parser %u", | - |
| 3607 | - | object->objectId); | - |
| 3608 | - | break; | - |
| 3609 | - | } | - |
| 3610 | - | prsForm = (Form_pg_ts_parser) GETSTRUCT(tup); | - |
| 3611 | - | - | |
| 3612 | - | /* Qualify the name if not visible in search path */ | - |
| 3613 | - | if (TSParserIsVisible(object->objectId)) | - |
| 3614 | - | nspname = NULL; | - |
| 3615 | - | else | - |
| 3616 | - | nspname = get_namespace_name(prsForm->prsnamespace); | - |
| 3617 | - | - | |
| 3618 | - | appendStringInfo(&buffer, _("text search parser %s"), | - |
| 3619 | - | quote_qualified_identifier(nspname, | - |
| 3620 | - | NameStr(prsForm->prsname))); | - |
| 3621 | - | ReleaseSysCache(tup); | - |
| 3622 | - | break; | - |
| 3623 | - | } | - |
| 3624 | - | - | |
| 3625 | - | case TSDictionaryRelationId: | - |
| 3626 | - | { | - |
| 3627 | - | HeapTuple tup; | - |
| 3628 | - | Form_pg_ts_dict dictForm; | - |
| 3629 | - | char *nspname; | - |
| 3630 | - | - | |
| 3631 | - | tup = SearchSysCache1(TSDICTOID, | - |
| 3632 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3633 | - | if (!HeapTupleIsValid(tup)) | - |
| 3634 | - | { | - |
| 3635 | - | if (!missing_ok) | - |
| 3636 | - | elog(ERROR, "cache lookup failed for text search dictionary %u", | - |
| 3637 | - | object->objectId); | - |
| 3638 | - | break; | - |
| 3639 | - | } | - |
| 3640 | - | - | |
| 3641 | - | dictForm = (Form_pg_ts_dict) GETSTRUCT(tup); | - |
| 3642 | - | - | |
| 3643 | - | /* Qualify the name if not visible in search path */ | - |
| 3644 | - | if (TSDictionaryIsVisible(object->objectId)) | - |
| 3645 | - | nspname = NULL; | - |
| 3646 | - | else | - |
| 3647 | - | nspname = get_namespace_name(dictForm->dictnamespace); | - |
| 3648 | - | - | |
| 3649 | - | appendStringInfo(&buffer, _("text search dictionary %s"), | - |
| 3650 | - | quote_qualified_identifier(nspname, | - |
| 3651 | - | NameStr(dictForm->dictname))); | - |
| 3652 | - | ReleaseSysCache(tup); | - |
| 3653 | - | break; | - |
| 3654 | - | } | - |
| 3655 | - | - | |
| 3656 | - | case TSTemplateRelationId: | - |
| 3657 | - | { | - |
| 3658 | - | HeapTuple tup; | - |
| 3659 | - | Form_pg_ts_template tmplForm; | - |
| 3660 | - | char *nspname; | - |
| 3661 | - | - | |
| 3662 | - | tup = SearchSysCache1(TSTEMPLATEOID, | - |
| 3663 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3664 | - | if (!HeapTupleIsValid(tup)) | - |
| 3665 | - | { | - |
| 3666 | - | if (!missing_ok) | - |
| 3667 | - | elog(ERROR, "cache lookup failed for text search template %u", | - |
| 3668 | - | object->objectId); | - |
| 3669 | - | break; | - |
| 3670 | - | } | - |
| 3671 | - | - | |
| 3672 | - | tmplForm = (Form_pg_ts_template) GETSTRUCT(tup); | - |
| 3673 | - | - | |
| 3674 | - | /* Qualify the name if not visible in search path */ | - |
| 3675 | - | if (TSTemplateIsVisible(object->objectId)) | - |
| 3676 | - | nspname = NULL; | - |
| 3677 | - | else | - |
| 3678 | - | nspname = get_namespace_name(tmplForm->tmplnamespace); | - |
| 3679 | - | - | |
| 3680 | - | appendStringInfo(&buffer, _("text search template %s"), | - |
| 3681 | - | quote_qualified_identifier(nspname, | - |
| 3682 | - | NameStr(tmplForm->tmplname))); | - |
| 3683 | - | ReleaseSysCache(tup); | - |
| 3684 | - | break; | - |
| 3685 | - | } | - |
| 3686 | - | - | |
| 3687 | - | case TSConfigRelationId: | - |
| 3688 | - | { | - |
| 3689 | - | HeapTuple tup; | - |
| 3690 | - | Form_pg_ts_config cfgForm; | - |
| 3691 | - | char *nspname; | - |
| 3692 | - | - | |
| 3693 | - | tup = SearchSysCache1(TSCONFIGOID, | - |
| 3694 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3695 | - | if (!HeapTupleIsValid(tup)) | - |
| 3696 | - | { | - |
| 3697 | - | if (!missing_ok) | - |
| 3698 | - | elog(ERROR, "cache lookup failed for text search configuration %u", | - |
| 3699 | - | object->objectId); | - |
| 3700 | - | break; | - |
| 3701 | - | } | - |
| 3702 | - | - | |
| 3703 | - | cfgForm = (Form_pg_ts_config) GETSTRUCT(tup); | - |
| 3704 | - | - | |
| 3705 | - | /* Qualify the name if not visible in search path */ | - |
| 3706 | - | if (TSConfigIsVisible(object->objectId)) | - |
| 3707 | - | nspname = NULL; | - |
| 3708 | - | else | - |
| 3709 | - | nspname = get_namespace_name(cfgForm->cfgnamespace); | - |
| 3710 | - | - | |
| 3711 | - | appendStringInfo(&buffer, _("text search configuration %s"), | - |
| 3712 | - | quote_qualified_identifier(nspname, | - |
| 3713 | - | NameStr(cfgForm->cfgname))); | - |
| 3714 | - | ReleaseSysCache(tup); | - |
| 3715 | - | break; | - |
| 3716 | - | } | - |
| 3717 | - | - | |
| 3718 | - | case AuthIdRelationId: | - |
| 3719 | - | { | - |
| 3720 | - | char *username = GetUserNameFromId(object->objectId, | - |
| 3721 | - | missing_ok); | - |
| 3722 | - | - | |
| 3723 | - | if (username) | - |
| 3724 | - | appendStringInfo(&buffer, _("role %s"), username); | - |
| 3725 | - | break; | - |
| 3726 | - | } | - |
| 3727 | - | - | |
| 3728 | - | case AuthMemRelationId: | - |
| 3729 | - | { | - |
| 3730 | - | Relation amDesc; | - |
| 3731 | - | ScanKeyData skey[1]; | - |
| 3732 | - | SysScanDesc rcscan; | - |
| 3733 | - | HeapTuple tup; | - |
| 3734 | - | Form_pg_auth_members amForm; | - |
| 3735 | - | - | |
| 3736 | - | amDesc = table_open(AuthMemRelationId, AccessShareLock); | - |
| 3737 | - | - | |
| 3738 | - | ScanKeyInit(&skey[0], | - |
| 3739 | - | Anum_pg_auth_members_oid, | - |
| 3740 | - | BTEqualStrategyNumber, F_OIDEQ, | - |
| 3741 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3742 | - | - | |
| 3743 | - | rcscan = systable_beginscan(amDesc, AuthMemOidIndexId, true, | - |
| 3744 | - | NULL, 1, skey); | - |
| 3745 | - | - | |
| 3746 | - | tup = systable_getnext(rcscan); | - |
| 3747 | - | - | |
| 3748 | - | if (!HeapTupleIsValid(tup)) | - |
| 3749 | - | { | - |
| 3750 | - | if (!missing_ok) | - |
| 3751 | - | elog(ERROR, "could not find tuple for role membership %u", | - |
| 3752 | - | object->objectId); | - |
| 3753 | - | - | |
| 3754 | - | systable_endscan(rcscan); | - |
| 3755 | - | table_close(amDesc, AccessShareLock); | - |
| 3756 | - | break; | - |
| 3757 | - | } | - |
| 3758 | - | - | |
| 3759 | - | amForm = (Form_pg_auth_members) GETSTRUCT(tup); | - |
| 3760 | - | - | |
| 3761 | - | appendStringInfo(&buffer, _("membership of role %s in role %s"), | - |
| 3762 | - | GetUserNameFromId(amForm->member, false), | - |
| 3763 | - | GetUserNameFromId(amForm->roleid, false)); | - |
| 3764 | - | - | |
| 3765 | - | systable_endscan(rcscan); | - |
| 3766 | - | table_close(amDesc, AccessShareLock); | - |
| 3767 | - | break; | - |
| 3768 | - | } | - |
| 3769 | - | - | |
| 3770 | - | case DatabaseRelationId: | - |
| 3771 | - | { | - |
| 3772 | - | char *datname; | - |
| 3773 | - | - | |
| 3774 | - | datname = get_database_name(object->objectId); | - |
| 3775 | - | if (!datname) | - |
| 3776 | - | { | - |
| 3777 | - | if (!missing_ok) | - |
| 3778 | - | elog(ERROR, "cache lookup failed for database %u", | - |
| 3779 | - | object->objectId); | - |
| 3780 | - | break; | - |
| 3781 | - | } | - |
| 3782 | - | appendStringInfo(&buffer, _("database %s"), datname); | - |
| 3783 | - | break; | - |
| 3784 | - | } | - |
| 3785 | - | - | |
| 3786 | - | case TableSpaceRelationId: | - |
| 3787 | - | { | - |
| 3788 | - | char *tblspace; | - |
| 3789 | - | - | |
| 3790 | - | tblspace = get_tablespace_name(object->objectId); | - |
| 3791 | - | if (!tblspace) | - |
| 3792 | - | { | - |
| 3793 | - | if (!missing_ok) | - |
| 3794 | - | elog(ERROR, "cache lookup failed for tablespace %u", | - |
| 3795 | - | object->objectId); | - |
| 3796 | - | break; | - |
| 3797 | - | } | - |
| 3798 | - | appendStringInfo(&buffer, _("tablespace %s"), tblspace); | - |
| 3799 | - | break; | - |
| 3800 | - | } | - |
| 3801 | - | - | |
| 3802 | - | case ForeignDataWrapperRelationId: | - |
| 3803 | - | { | - |
| 3804 | - | ForeignDataWrapper *fdw; | - |
| 3805 | - | - | |
| 3806 | - | fdw = GetForeignDataWrapperExtended(object->objectId, | - |
| 3807 | - | missing_ok); | - |
| 3808 | - | if (fdw) | - |
| 3809 | - | appendStringInfo(&buffer, _("foreign-data wrapper %s"), fdw->fdwname); | - |
| 3810 | - | break; | - |
| 3811 | - | } | - |
| 3812 | - | - | |
| 3813 | - | case ForeignServerRelationId: | - |
| 3814 | - | { | - |
| 3815 | - | ForeignServer *srv; | - |
| 3816 | - | - | |
| 3817 | - | srv = GetForeignServerExtended(object->objectId, missing_ok); | - |
| 3818 | - | if (srv) | - |
| 3819 | - | appendStringInfo(&buffer, _("server %s"), srv->servername); | - |
| 3820 | - | break; | - |
| 3821 | - | } | - |
| 3822 | - | - | |
| 3823 | - | case UserMappingRelationId: | - |
| 3824 | - | { | - |
| 3825 | - | HeapTuple tup; | - |
| 3826 | - | Oid useid; | - |
| 3827 | - | char *usename; | - |
| 3828 | - | Form_pg_user_mapping umform; | - |
| 3829 | - | ForeignServer *srv; | - |
| 3830 | - | - | |
| 3831 | - | tup = SearchSysCache1(USERMAPPINGOID, | - |
| 3832 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3833 | - | if (!HeapTupleIsValid(tup)) | - |
| 3834 | - | { | - |
| 3835 | - | if (!missing_ok) | - |
| 3836 | - | elog(ERROR, "cache lookup failed for user mapping %u", | - |
| 3837 | - | object->objectId); | - |
| 3838 | - | break; | - |
| 3839 | - | } | - |
| 3840 | - | - | |
| 3841 | - | umform = (Form_pg_user_mapping) GETSTRUCT(tup); | - |
| 3842 | - | useid = umform->umuser; | - |
| 3843 | - | srv = GetForeignServer(umform->umserver); | - |
| 3844 | - | - | |
| 3845 | - | ReleaseSysCache(tup); | - |
| 3846 | - | - | |
| 3847 | - | if (OidIsValid(useid)) | - |
| 3848 | - | usename = GetUserNameFromId(useid, false); | - |
| 3849 | - | else | - |
| 3850 | - | usename = "public"; | - |
| 3851 | - | - | |
| 3852 | - | appendStringInfo(&buffer, _("user mapping for %s on server %s"), usename, | - |
| 3853 | - | srv->servername); | - |
| 3854 | - | break; | - |
| 3855 | - | } | - |
| 3856 | - | - | |
| 3857 | - | case DefaultAclRelationId: | - |
| 3858 | - | { | - |
| 3859 | - | Relation defaclrel; | - |
| 3860 | - | ScanKeyData skey[1]; | - |
| 3861 | - | SysScanDesc rcscan; | - |
| 3862 | - | HeapTuple tup; | - |
| 3863 | - | Form_pg_default_acl defacl; | - |
| 3864 | - | char *rolename; | - |
| 3865 | - | char *nspname; | - |
| 3866 | - | - | |
| 3867 | - | defaclrel = table_open(DefaultAclRelationId, AccessShareLock); | - |
| 3868 | - | - | |
| 3869 | - | ScanKeyInit(&skey[0], | - |
| 3870 | - | Anum_pg_default_acl_oid, | - |
| 3871 | - | BTEqualStrategyNumber, F_OIDEQ, | - |
| 3872 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3873 | - | - | |
| 3874 | - | rcscan = systable_beginscan(defaclrel, DefaultAclOidIndexId, | - |
| 3875 | - | true, NULL, 1, skey); | - |
| 3876 | - | - | |
| 3877 | - | tup = systable_getnext(rcscan); | - |
| 3878 | - | - | |
| 3879 | - | if (!HeapTupleIsValid(tup)) | - |
| 3880 | - | { | - |
| 3881 | - | if (!missing_ok) | - |
| 3882 | - | elog(ERROR, "could not find tuple for default ACL %u", | - |
| 3883 | - | object->objectId); | - |
| 3884 | - | - | |
| 3885 | - | systable_endscan(rcscan); | - |
| 3886 | - | table_close(defaclrel, AccessShareLock); | - |
| 3887 | - | break; | - |
| 3888 | - | } | - |
| 3889 | - | - | |
| 3890 | - | defacl = (Form_pg_default_acl) GETSTRUCT(tup); | - |
| 3891 | - | - | |
| 3892 | - | rolename = GetUserNameFromId(defacl->defaclrole, false); | - |
| 3893 | - | - | |
| 3894 | - | if (OidIsValid(defacl->defaclnamespace)) | - |
| 3895 | - | nspname = get_namespace_name(defacl->defaclnamespace); | - |
| 3896 | - | else | - |
| 3897 | - | nspname = NULL; | - |
| 3898 | - | - | |
| 3899 | - | switch (defacl->defaclobjtype) | - |
| 3900 | - | { | - |
| 3901 | - | case DEFACLOBJ_RELATION: | - |
| 3902 | - | if (nspname) | - |
| 3903 | - | appendStringInfo(&buffer, | - |
| 3904 | - | _("default privileges on new relations belonging to role %s in schema %s"), | - |
| 3905 | - | rolename, nspname); | - |
| 3906 | - | else | - |
| 3907 | - | appendStringInfo(&buffer, | - |
| 3908 | - | _("default privileges on new relations belonging to role %s"), | - |
| 3909 | - | rolename); | - |
| 3910 | - | break; | - |
| 3911 | - | case DEFACLOBJ_SEQUENCE: | - |
| 3912 | - | if (nspname) | - |
| 3913 | - | appendStringInfo(&buffer, | - |
| 3914 | - | _("default privileges on new sequences belonging to role %s in schema %s"), | - |
| 3915 | - | rolename, nspname); | - |
| 3916 | - | else | - |
| 3917 | - | appendStringInfo(&buffer, | - |
| 3918 | - | _("default privileges on new sequences belonging to role %s"), | - |
| 3919 | - | rolename); | - |
| 3920 | - | break; | - |
| 3921 | - | case DEFACLOBJ_FUNCTION: | - |
| 3922 | - | if (nspname) | - |
| 3923 | - | appendStringInfo(&buffer, | - |
| 3924 | - | _("default privileges on new functions belonging to role %s in schema %s"), | - |
| 3925 | - | rolename, nspname); | - |
| 3926 | - | else | - |
| 3927 | - | appendStringInfo(&buffer, | - |
| 3928 | - | _("default privileges on new functions belonging to role %s"), | - |
| 3929 | - | rolename); | - |
| 3930 | - | break; | - |
| 3931 | - | case DEFACLOBJ_TYPE: | - |
| 3932 | - | if (nspname) | - |
| 3933 | - | appendStringInfo(&buffer, | - |
| 3934 | - | _("default privileges on new types belonging to role %s in schema %s"), | - |
| 3935 | - | rolename, nspname); | - |
| 3936 | - | else | - |
| 3937 | - | appendStringInfo(&buffer, | - |
| 3938 | - | _("default privileges on new types belonging to role %s"), | - |
| 3939 | - | rolename); | - |
| 3940 | - | break; | - |
| 3941 | - | case DEFACLOBJ_NAMESPACE: | - |
| 3942 | - | Assert(!nspname); | - |
| 3943 | - | appendStringInfo(&buffer, | - |
| 3944 | - | _("default privileges on new schemas belonging to role %s"), | - |
| 3945 | - | rolename); | - |
| 3946 | - | break; | - |
| 3947 | - | case DEFACLOBJ_LARGEOBJECT: | - |
| 3948 | - | Assert(!nspname); | - |
| 3949 | - | appendStringInfo(&buffer, | - |
| 3950 | - | _("default privileges on new large objects belonging to role %s"), | - |
| 3951 | - | rolename); | - |
| 3952 | - | break; | - |
| 3953 | - | default: | - |
| 3954 | - | /* shouldn't get here */ | - |
| 3955 | - | if (nspname) | - |
| 3956 | - | appendStringInfo(&buffer, | - |
| 3957 | - | _("default privileges belonging to role %s in schema %s"), | - |
| 3958 | - | rolename, nspname); | - |
| 3959 | - | else | - |
| 3960 | - | appendStringInfo(&buffer, | - |
| 3961 | - | _("default privileges belonging to role %s"), | - |
| 3962 | - | rolename); | - |
| 3963 | - | break; | - |
| 3964 | - | } | - |
| 3965 | - | - | |
| 3966 | - | systable_endscan(rcscan); | - |
| 3967 | - | table_close(defaclrel, AccessShareLock); | - |
| 3968 | - | break; | - |
| 3969 | - | } | - |
| 3970 | - | - | |
| 3971 | - | case ExtensionRelationId: | - |
| 3972 | - | { | - |
| 3973 | - | char *extname; | - |
| 3974 | - | - | |
| 3975 | - | extname = get_extension_name(object->objectId); | - |
| 3976 | - | if (!extname) | - |
| 3977 | - | { | - |
| 3978 | - | if (!missing_ok) | - |
| 3979 | - | elog(ERROR, "cache lookup failed for extension %u", | - |
| 3980 | - | object->objectId); | - |
| 3981 | - | break; | - |
| 3982 | - | } | - |
| 3983 | - | appendStringInfo(&buffer, _("extension %s"), extname); | - |
| 3984 | - | break; | - |
| 3985 | - | } | - |
| 3986 | - | - | |
| 3987 | - | case EventTriggerRelationId: | - |
| 3988 | - | { | - |
| 3989 | - | HeapTuple tup; | - |
| 3990 | - | - | |
| 3991 | - | tup = SearchSysCache1(EVENTTRIGGEROID, | - |
| 3992 | - | ObjectIdGetDatum(object->objectId)); | - |
| 3993 | - | if (!HeapTupleIsValid(tup)) | - |
| 3994 | - | { | - |
| 3995 | - | if (!missing_ok) | - |
| 3996 | - | elog(ERROR, "cache lookup failed for event trigger %u", | - |
| 3997 | - | object->objectId); | - |
| 3998 | - | break; | - |
| 3999 | - | } | - |
| 4000 | - | appendStringInfo(&buffer, _("event trigger %s"), | - |
| 4001 | - | NameStr(((Form_pg_event_trigger) GETSTRUCT(tup))->evtname)); | - |
| 4002 | - | ReleaseSysCache(tup); | - |
| 4003 | - | break; | - |
| 4004 | - | } | - |
| 4005 | - | - | |
| 4006 | - | case ParameterAclRelationId: | - |
| 4007 | - | { | - |
| 4008 | - | HeapTuple tup; | - |
| 4009 | - | Datum nameDatum; | - |
| 4010 | - | char *parname; | - |
| 4011 | - | - | |
| 4012 | - | tup = SearchSysCache1(PARAMETERACLOID, | - |
| 4013 | - | ObjectIdGetDatum(object->objectId)); | - |
| 4014 | - | if (!HeapTupleIsValid(tup)) | - |
| 4015 | - | { | - |
| 4016 | - | if (!missing_ok) | - |
| 4017 | - | elog(ERROR, "cache lookup failed for parameter ACL %u", | - |
| 4018 | - | object->objectId); | - |
| 4019 | - | break; | - |
| 4020 | - | } | - |
| 4021 | - | nameDatum = SysCacheGetAttrNotNull(PARAMETERACLOID, tup, | - |
| 4022 | - | Anum_pg_parameter_acl_parname); | - |
| 4023 | - | parname = TextDatumGetCString(nameDatum); | - |
| 4024 | - | appendStringInfo(&buffer, _("parameter %s"), parname); | - |
| 4025 | - | ReleaseSysCache(tup); | - |
| 4026 | - | break; | - |
| 4027 | - | } | - |
| 4028 | - | - | |
| 4029 | - | case PolicyRelationId: | - |
| 4030 | - | { | - |
| 4031 | - | Relation policy_rel; | - |
| 4032 | - | ScanKeyData skey[1]; | - |
| 4033 | - | SysScanDesc sscan; | - |
| 4034 | - | HeapTuple tuple; | - |
| 4035 | - | Form_pg_policy form_policy; | - |
| 4036 | - | StringInfoData rel; | - |
| 4037 | - | - | |
| 4038 | - | policy_rel = table_open(PolicyRelationId, AccessShareLock); | - |
| 4039 | - | - | |
| 4040 | - | ScanKeyInit(&skey[0], | - |
| 4041 | - | Anum_pg_policy_oid, | - |
| 4042 | - | BTEqualStrategyNumber, F_OIDEQ, | - |
| 4043 | - | ObjectIdGetDatum(object->objectId)); | - |
| 4044 | - | - | |
| 4045 | - | sscan = systable_beginscan(policy_rel, PolicyOidIndexId, | - |
| 4046 | - | true, NULL, 1, skey); | - |
| 4047 | - | - | |
| 4048 | - | tuple = systable_getnext(sscan); | - |
| 4049 | - | - | |
| 4050 | - | if (!HeapTupleIsValid(tuple)) | - |
| 4051 | - | { | - |
| 4052 | - | if (!missing_ok) | - |
| 4053 | - | elog(ERROR, "could not find tuple for policy %u", | - |
| 4054 | - | object->objectId); | - |
| 4055 | - | - | |
| 4056 | - | systable_endscan(sscan); | - |
| 4057 | - | table_close(policy_rel, AccessShareLock); | - |
| 4058 | - | break; | - |
| 4059 | - | } | - |
| 4060 | - | - | |
| 4061 | - | form_policy = (Form_pg_policy) GETSTRUCT(tuple); | - |
| 4062 | - | - | |
| 4063 | - | initStringInfo(&rel); | - |
| 4064 | - | getRelationDescription(&rel, form_policy->polrelid, false); | - |
| 4065 | - | - | |
| 4066 | - | /* translator: second %s is, e.g., "table %s" */ | - |
| 4067 | - | appendStringInfo(&buffer, _("policy %s on %s"), | - |
| 4068 | - | NameStr(form_policy->polname), rel.data); | - |
| 4069 | - | pfree(rel.data); | - |
| 4070 | - | systable_endscan(sscan); | - |
| 4071 | - | table_close(policy_rel, AccessShareLock); | - |
| 4072 | - | break; | - |
| 4073 | - | } | - |
| 4074 | - | - | |
| 4075 | 444 | case PropgraphElementRelationId: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4076 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4077 | 444 | HeapTuple tup; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4078 | 444 | Form_pg_propgraph_element pgeform; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4079 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4080 | 444 | tup = SearchSysCache1(PROPGRAPHELOID, ObjectIdGetDatum(object->objectId)); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4081 | 444 | if (!HeapTupleIsValid(tup)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4082 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4083 | 3 | if (!missing_ok) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4084 | 0 | elog(ERROR, "cache lookup failed for property graph element %u", | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4085 | - | object->objectId); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4086 | - | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4087 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4088 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4089 | 441 | pgeform = (Form_pg_propgraph_element) GETSTRUCT(tup); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4090 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4091 | 441 | if (pgeform->pgekind == PGEKIND_VERTEX) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4092 | - | /* translator: followed by, e.g., "property graph %s" */ | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4093 | 243 | appendStringInfo(&buffer, _("vertex %s of "), NameStr(pgeform->pgealias)); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4094 | 198 | else if (pgeform->pgekind == PGEKIND_EDGE) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4095 | - | /* translator: followed by, e.g., "property graph %s" */ | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4096 | 198 | appendStringInfo(&buffer, _("edge %s of "), NameStr(pgeform->pgealias)); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4097 | - | else | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4098 | 0 | appendStringInfo(&buffer, "??? element %s of ", NameStr(pgeform->pgealias)); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4099 | 441 | getRelationDescription(&buffer, pgeform->pgepgid, false); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4100 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4101 | 441 | ReleaseSysCache(tup); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4102 | 441 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4103 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4104 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4105 | 348 | case PropgraphElementLabelRelationId: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4106 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4107 | 348 | Relation rel; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4108 | 348 | SysScanDesc scan; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4109 | 348 | ScanKeyData key[1]; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4110 | 348 | HeapTuple tuple; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4111 | 348 | Form_pg_propgraph_element_label pgelform; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4112 | 348 | ObjectAddress oa; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4113 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4114 | 348 | rel = table_open(PropgraphElementLabelRelationId, AccessShareLock); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4115 | 348 | ScanKeyInit(&key[0], | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4116 | - | Anum_pg_propgraph_element_label_oid, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4117 | - | BTEqualStrategyNumber, F_OIDEQ, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4118 | 348 | ObjectIdGetDatum(object->objectId)); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4119 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4120 | 348 | scan = systable_beginscan(rel, PropgraphElementLabelObjectIndexId, true, NULL, 1, key); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4121 | 348 | tuple = systable_getnext(scan); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4122 | 348 | if (!HeapTupleIsValid(tuple)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4123 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4124 | 0 | if (!missing_ok) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4125 | 0 | elog(ERROR, "could not find tuple for element label %u", object->objectId); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4126 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4127 | 0 | systable_endscan(scan); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4128 | 0 | table_close(rel, AccessShareLock); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4129 | 0 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4130 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4131 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4132 | 348 | pgelform = (Form_pg_propgraph_element_label) GETSTRUCT(tuple); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4133 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4134 | 348 | appendStringInfo(&buffer, _("label %s of "), get_propgraph_label_name(pgelform->pgellabelid)); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4135 | 348 | ObjectAddressSet(oa, PropgraphElementRelationId, pgelform->pgelelid); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4136 | 348 | appendStringInfoString(&buffer, getObjectDescription(&oa, false)); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4137 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4138 | 348 | systable_endscan(scan); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4139 | 348 | table_close(rel, AccessShareLock); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4140 | 348 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4141 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4142 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4143 | 75 | case PropgraphLabelRelationId: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4144 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4145 | 75 | HeapTuple tuple; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4146 | 75 | Form_pg_propgraph_label pglform; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4147 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4148 | 75 | tuple = SearchSysCache1(PROPGRAPHLABELOID, object->objectId); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4149 | 75 | if (!HeapTupleIsValid(tuple)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4150 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4151 | 3 | if (!missing_ok) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4152 | 0 | elog(ERROR, "could not find tuple for label %u", object->objectId); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4153 | - | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4154 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4155 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4156 | 72 | pglform = (Form_pg_propgraph_label) GETSTRUCT(tuple); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4157 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4158 | - | /* translator: followed by, e.g., "property graph %s" */ | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4159 | 72 | appendStringInfo(&buffer, _("label %s of "), NameStr(pglform->pgllabel)); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4160 | 72 | getRelationDescription(&buffer, pglform->pglpgid, false); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4161 | 72 | ReleaseSysCache(tuple); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4162 | 72 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4163 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4164 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4165 | 246 | case PropgraphLabelPropertyRelationId: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4166 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4167 | 246 | Relation rel; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4168 | 246 | SysScanDesc scan; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4169 | 246 | ScanKeyData key[1]; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4170 | 246 | HeapTuple tuple; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4171 | 246 | Form_pg_propgraph_label_property plpform; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4172 | 246 | ObjectAddress oa; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4173 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4174 | 246 | rel = table_open(PropgraphLabelPropertyRelationId, AccessShareLock); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4175 | 246 | ScanKeyInit(&key[0], | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4176 | - | Anum_pg_propgraph_label_property_oid, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4177 | - | BTEqualStrategyNumber, F_OIDEQ, | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4178 | 246 | ObjectIdGetDatum(object->objectId)); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4179 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4180 | 246 | scan = systable_beginscan(rel, PropgraphLabelPropertyObjectIndexId, true, NULL, 1, key); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4181 | 246 | tuple = systable_getnext(scan); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4182 | 246 | if (!HeapTupleIsValid(tuple)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4183 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4184 | 0 | if (!missing_ok) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4185 | 0 | elog(ERROR, "could not find tuple for label property %u", object->objectId); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4186 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4187 | 0 | systable_endscan(scan); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4188 | 0 | table_close(rel, AccessShareLock); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4189 | 0 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4190 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4191 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4192 | 246 | plpform = (Form_pg_propgraph_label_property) GETSTRUCT(tuple); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4193 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4194 | 246 | appendStringInfo(&buffer, _("property %s of "), get_propgraph_property_name(plpform->plppropid)); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4195 | 246 | ObjectAddressSet(oa, PropgraphElementLabelRelationId, plpform->plpellabelid); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4196 | 246 | appendStringInfoString(&buffer, getObjectDescription(&oa, false)); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4197 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4198 | 246 | systable_endscan(scan); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4199 | 246 | table_close(rel, AccessShareLock); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4200 | 246 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4201 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4202 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4203 | 111 | case PropgraphPropertyRelationId: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4204 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4205 | 111 | HeapTuple tuple; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4206 | 111 | Form_pg_propgraph_property pgpform; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4207 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4208 | 111 | tuple = SearchSysCache1(PROPGRAPHPROPOID, object->objectId); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4209 | 111 | if (!HeapTupleIsValid(tuple)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4210 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4211 | 3 | if (!missing_ok) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4212 | 0 | elog(ERROR, "could not find tuple for property %u", object->objectId); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4213 | - | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4214 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4215 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4216 | 108 | pgpform = (Form_pg_propgraph_property) GETSTRUCT(tuple); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4217 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4218 | - | /* translator: followed by, e.g., "property graph %s" */ | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4219 | 108 | appendStringInfo(&buffer, _("property %s of "), NameStr(pgpform->pgpname)); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4220 | 108 | getRelationDescription(&buffer, pgpform->pgppgid, false); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4221 | 108 | ReleaseSysCache(tuple); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4222 | 108 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4223 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4224 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4225 | - | case PublicationRelationId: | - |
| 4226 | - | { | - |
| 4227 | - | char *pubname = get_publication_name(object->objectId, | - |
| 4228 | - | missing_ok); | - |
| 4229 | - | - | |
| 4230 | - | if (pubname) | - |
| 4231 | - | appendStringInfo(&buffer, _("publication %s"), pubname); | - |
| 4232 | - | break; | - |
| 4233 | - | } | - |
| 4234 | - | - | |
| 4235 | - | case PublicationNamespaceRelationId: | - |
| 4236 | - | { | - |
| 4237 | - | char *pubname; | - |
| 4238 | - | char *nspname; | - |
| 4239 | - | - | |
| 4240 | - | if (!getPublicationSchemaInfo(object, missing_ok, | - |
| 4241 | - | &pubname, &nspname)) | - |
| 4242 | - | break; | - |
| 4243 | - | - | |
| 4244 | - | appendStringInfo(&buffer, _("publication of schema %s in publication %s"), | - |
| 4245 | - | nspname, pubname); | - |
| 4246 | - | pfree(pubname); | - |
| 4247 | - | pfree(nspname); | - |
| 4248 | - | break; | - |
| 4249 | - | } | - |
| 4250 | - | - | |
| 4251 | - | case PublicationRelRelationId: | - |
| 4252 | - | { | - |
| 4253 | - | HeapTuple tup; | - |
| 4254 | - | char *pubname; | - |
| 4255 | - | Form_pg_publication_rel prform; | - |
| 4256 | - | StringInfoData rel; | - |
| 4257 | - | - | |
| 4258 | - | tup = SearchSysCache1(PUBLICATIONREL, | - |
| 4259 | - | ObjectIdGetDatum(object->objectId)); | - |
| 4260 | - | if (!HeapTupleIsValid(tup)) | - |
| 4261 | - | { | - |
| 4262 | - | if (!missing_ok) | - |
| 4263 | - | elog(ERROR, "cache lookup failed for publication table %u", | - |
| 4264 | - | object->objectId); | - |
| 4265 | - | break; | - |
| 4266 | - | } | - |
| 4267 | - | - | |
| 4268 | - | prform = (Form_pg_publication_rel) GETSTRUCT(tup); | - |
| 4269 | - | pubname = get_publication_name(prform->prpubid, false); | - |
| 4270 | - | - | |
| 4271 | - | initStringInfo(&rel); | - |
| 4272 | - | getRelationDescription(&rel, prform->prrelid, false); | - |
| 4273 | - | - | |
| 4274 | - | /* translator: first %s is, e.g., "table %s" */ | - |
| 4275 | - | appendStringInfo(&buffer, _("publication of %s in publication %s"), | - |
| 4276 | - | rel.data, pubname); | - |
| 4277 | - | pfree(rel.data); | - |
| 4278 | - | ReleaseSysCache(tup); | - |
| 4279 | - | break; | - |
| 4280 | - | } | - |
| 4281 | - | - | |
| 4282 | - | case SubscriptionRelationId: | - |
| 4283 | - | { | - |
| 4284 | - | char *subname = get_subscription_name(object->objectId, | - |
| 4285 | - | missing_ok); | - |
| 4286 | - | - | |
| 4287 | - | if (subname) | - |
| 4288 | - | appendStringInfo(&buffer, _("subscription %s"), subname); | - |
| 4289 | - | break; | - |
| 4290 | - | } | - |
| 4291 | - | - | |
| 4292 | - | case TransformRelationId: | - |
| 4293 | - | { | - |
| 4294 | - | HeapTuple trfTup; | - |
| 4295 | - | Form_pg_transform trfForm; | - |
| 4296 | - | - | |
| 4297 | - | trfTup = SearchSysCache1(TRFOID, | - |
| 4298 | - | ObjectIdGetDatum(object->objectId)); | - |
| 4299 | - | if (!HeapTupleIsValid(trfTup)) | - |
| 4300 | - | { | - |
| 4301 | - | if (!missing_ok) | - |
| 4302 | - | elog(ERROR, "could not find tuple for transform %u", | - |
| 4303 | - | object->objectId); | - |
| 4304 | - | break; | - |
| 4305 | - | } | - |
| 4306 | - | - | |
| 4307 | - | trfForm = (Form_pg_transform) GETSTRUCT(trfTup); | - |
| 4308 | - | - | |
| 4309 | - | appendStringInfo(&buffer, _("transform for %s language %s"), | - |
| 4310 | - | format_type_be(trfForm->trftype), | - |
| 4311 | - | get_language_name(trfForm->trflang, false)); | - |
| 4312 | - | - | |
| 4313 | - | ReleaseSysCache(trfTup); | - |
| 4314 | - | break; | - |
| 4315 | - | } | - |
| 4316 | - | - | |
| 4317 | - | default: | - |
| 4318 | - | elog(ERROR, "unsupported object class: %u", object->classId); | - |
| 4319 | - | } | - |
| 4320 | - | - | |
| 4321 | - | /* an empty buffer is equivalent to no object found */ | - |
| 4322 | - | if (buffer.len == 0) | - |
| 4323 | - | return NULL; | - |
| 4324 | - | - | |
| 4325 | - | return buffer.data; | - |
| 4326 | - | } | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 4349 | - | getRelationDescription(StringInfo buffer, Oid relid, bool missing_ok) | - |
| 4350 | - | { | - |
| 4351 | - | HeapTuple relTup; | - |
| 4352 | - | Form_pg_class relForm; | - |
| 4353 | - | char *nspname; | - |
| 4354 | - | char *relname; | - |
| 4355 | - | - | |
| 4356 | - | relTup = SearchSysCache1(RELOID, | - |
| 4357 | - | ObjectIdGetDatum(relid)); | - |
| 4358 | - | if (!HeapTupleIsValid(relTup)) | - |
| 4359 | - | { | - |
| 4360 | - | if (!missing_ok) | - |
| 4361 | - | elog(ERROR, "cache lookup failed for relation %u", relid); | - |
| 4362 | - | return; | - |
| 4363 | - | } | - |
| 4364 | - | relForm = (Form_pg_class) GETSTRUCT(relTup); | - |
| 4365 | - | - | |
| 4366 | - | /* Qualify the name if not visible in search path */ | - |
| 4367 | - | if (RelationIsVisible(relid)) | - |
| 4368 | - | nspname = NULL; | - |
| 4369 | - | else | - |
| 4370 | - | nspname = get_namespace_name(relForm->relnamespace); | - |
| 4371 | - | - | |
| 4372 | - | relname = quote_qualified_identifier(nspname, NameStr(relForm->relname)); | - |
| 4373 | - | - | |
| 4374 | - | switch (relForm->relkind) | - |
| 4375 | - | { | - |
| 4376 | - | case RELKIND_RELATION: | - |
| 4377 | - | case RELKIND_PARTITIONED_TABLE: | - |
| 4378 | - | appendStringInfo(buffer, _("table %s"), | - |
| 4379 | - | relname); | - |
| 4380 | - | break; | - |
| 4381 | - | case RELKIND_INDEX: | - |
| 4382 | - | case RELKIND_PARTITIONED_INDEX: | - |
| 4383 | - | appendStringInfo(buffer, _("index %s"), | - |
| 4384 | - | relname); | - |
| 4385 | - | break; | - |
| 4386 | - | case RELKIND_SEQUENCE: | - |
| 4387 | - | appendStringInfo(buffer, _("sequence %s"), | - |
| 4388 | - | relname); | - |
| 4389 | - | break; | - |
| 4390 | - | case RELKIND_TOASTVALUE: | - |
| 4391 | - | appendStringInfo(buffer, _("toast table %s"), | - |
| 4392 | - | relname); | - |
| 4393 | - | break; | - |
| 4394 | - | case RELKIND_VIEW: | - |
| 4395 | - | appendStringInfo(buffer, _("view %s"), | - |
| 4396 | - | relname); | - |
| 4397 | - | break; | - |
| 4398 | - | case RELKIND_MATVIEW: | - |
| 4399 | - | appendStringInfo(buffer, _("materialized view %s"), | - |
| 4400 | - | relname); | - |
| 4401 | - | break; | - |
| 4402 | - | case RELKIND_COMPOSITE_TYPE: | - |
| 4403 | - | appendStringInfo(buffer, _("composite type %s"), | - |
| 4404 | - | relname); | - |
| 4405 | - | break; | - |
| 4406 | - | case RELKIND_FOREIGN_TABLE: | - |
| 4407 | - | appendStringInfo(buffer, _("foreign table %s"), | - |
| 4408 | - | relname); | - |
| 4409 | - | break; | - |
| 4410 | 699 | case RELKIND_PROPGRAPH: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4411 | 699 | appendStringInfo(buffer, _("property graph %s"), | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4412 | - | relname); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4413 | 699 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4414 | - | default: | - |
| 4415 | - | /* shouldn't get here */ | - |
| 4416 | - | appendStringInfo(buffer, _("relation %s"), | - |
| 4417 | - | relname); | - |
| 4418 | - | break; | - |
| 4419 | - | } | - |
| 4420 | - | - | |
| 4421 | - | ReleaseSysCache(relTup); | - |
| 4422 | - | } | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 4747 | - | getObjectTypeDescription(const ObjectAddress *object, bool missing_ok) | - |
| 4748 | - | { | - |
| 4749 | - | StringInfoData buffer; | - |
| 4750 | - | - | |
| 4751 | - | initStringInfo(&buffer); | - |
| 4752 | - | - | |
| 4753 | - | switch (object->classId) | - |
| 4754 | - | { | - |
| 4755 | - | case RelationRelationId: | - |
| 4756 | - | getRelationTypeDescription(&buffer, object->objectId, | - |
| 4757 | - | object->objectSubId, | - |
| 4758 | - | missing_ok); | - |
| 4759 | - | break; | - |
| 4760 | - | - | |
| 4761 | - | case ProcedureRelationId: | - |
| 4762 | - | getProcedureTypeDescription(&buffer, object->objectId, | - |
| 4763 | - | missing_ok); | - |
| 4764 | - | break; | - |
| 4765 | - | - | |
| 4766 | - | case TypeRelationId: | - |
| 4767 | - | appendStringInfoString(&buffer, "type"); | - |
| 4768 | - | break; | - |
| 4769 | - | - | |
| 4770 | - | case CastRelationId: | - |
| 4771 | - | appendStringInfoString(&buffer, "cast"); | - |
| 4772 | - | break; | - |
| 4773 | - | - | |
| 4774 | - | case CollationRelationId: | - |
| 4775 | - | appendStringInfoString(&buffer, "collation"); | - |
| 4776 | - | break; | - |
| 4777 | - | - | |
| 4778 | - | case ConstraintRelationId: | - |
| 4779 | - | getConstraintTypeDescription(&buffer, object->objectId, | - |
| 4780 | - | missing_ok); | - |
| 4781 | - | break; | - |
| 4782 | - | - | |
| 4783 | - | case ConversionRelationId: | - |
| 4784 | - | appendStringInfoString(&buffer, "conversion"); | - |
| 4785 | - | break; | - |
| 4786 | - | - | |
| 4787 | - | case AttrDefaultRelationId: | - |
| 4788 | - | appendStringInfoString(&buffer, "default value"); | - |
| 4789 | - | break; | - |
| 4790 | - | - | |
| 4791 | - | case LanguageRelationId: | - |
| 4792 | - | appendStringInfoString(&buffer, "language"); | - |
| 4793 | - | break; | - |
| 4794 | - | - | |
| 4795 | - | case LargeObjectRelationId: | - |
| 4796 | - | appendStringInfoString(&buffer, "large object"); | - |
| 4797 | - | break; | - |
| 4798 | - | - | |
| 4799 | - | case OperatorRelationId: | - |
| 4800 | - | appendStringInfoString(&buffer, "operator"); | - |
| 4801 | - | break; | - |
| 4802 | - | - | |
| 4803 | - | case OperatorClassRelationId: | - |
| 4804 | - | appendStringInfoString(&buffer, "operator class"); | - |
| 4805 | - | break; | - |
| 4806 | - | - | |
| 4807 | - | case OperatorFamilyRelationId: | - |
| 4808 | - | appendStringInfoString(&buffer, "operator family"); | - |
| 4809 | - | break; | - |
| 4810 | - | - | |
| 4811 | - | case AccessMethodRelationId: | - |
| 4812 | - | appendStringInfoString(&buffer, "access method"); | - |
| 4813 | - | break; | - |
| 4814 | - | - | |
| 4815 | - | case AccessMethodOperatorRelationId: | - |
| 4816 | - | appendStringInfoString(&buffer, "operator of access method"); | - |
| 4817 | - | break; | - |
| 4818 | - | - | |
| 4819 | - | case AccessMethodProcedureRelationId: | - |
| 4820 | - | appendStringInfoString(&buffer, "function of access method"); | - |
| 4821 | - | break; | - |
| 4822 | - | - | |
| 4823 | - | case RewriteRelationId: | - |
| 4824 | - | appendStringInfoString(&buffer, "rule"); | - |
| 4825 | - | break; | - |
| 4826 | - | - | |
| 4827 | - | case TriggerRelationId: | - |
| 4828 | - | appendStringInfoString(&buffer, "trigger"); | - |
| 4829 | - | break; | - |
| 4830 | - | - | |
| 4831 | - | case NamespaceRelationId: | - |
| 4832 | - | appendStringInfoString(&buffer, "schema"); | - |
| 4833 | - | break; | - |
| 4834 | - | - | |
| 4835 | - | case StatisticExtRelationId: | - |
| 4836 | - | appendStringInfoString(&buffer, "statistics object"); | - |
| 4837 | - | break; | - |
| 4838 | - | - | |
| 4839 | - | case TSParserRelationId: | - |
| 4840 | - | appendStringInfoString(&buffer, "text search parser"); | - |
| 4841 | - | break; | - |
| 4842 | - | - | |
| 4843 | - | case TSDictionaryRelationId: | - |
| 4844 | - | appendStringInfoString(&buffer, "text search dictionary"); | - |
| 4845 | - | break; | - |
| 4846 | - | - | |
| 4847 | - | case TSTemplateRelationId: | - |
| 4848 | - | appendStringInfoString(&buffer, "text search template"); | - |
| 4849 | - | break; | - |
| 4850 | - | - | |
| 4851 | - | case TSConfigRelationId: | - |
| 4852 | - | appendStringInfoString(&buffer, "text search configuration"); | - |
| 4853 | - | break; | - |
| 4854 | - | - | |
| 4855 | - | case AuthIdRelationId: | - |
| 4856 | - | appendStringInfoString(&buffer, "role"); | - |
| 4857 | - | break; | - |
| 4858 | - | - | |
| 4859 | - | case AuthMemRelationId: | - |
| 4860 | - | appendStringInfoString(&buffer, "role membership"); | - |
| 4861 | - | break; | - |
| 4862 | - | - | |
| 4863 | - | case DatabaseRelationId: | - |
| 4864 | - | appendStringInfoString(&buffer, "database"); | - |
| 4865 | - | break; | - |
| 4866 | - | - | |
| 4867 | - | case TableSpaceRelationId: | - |
| 4868 | - | appendStringInfoString(&buffer, "tablespace"); | - |
| 4869 | - | break; | - |
| 4870 | - | - | |
| 4871 | - | case ForeignDataWrapperRelationId: | - |
| 4872 | - | appendStringInfoString(&buffer, "foreign-data wrapper"); | - |
| 4873 | - | break; | - |
| 4874 | - | - | |
| 4875 | - | case ForeignServerRelationId: | - |
| 4876 | - | appendStringInfoString(&buffer, "server"); | - |
| 4877 | - | break; | - |
| 4878 | - | - | |
| 4879 | - | case UserMappingRelationId: | - |
| 4880 | - | appendStringInfoString(&buffer, "user mapping"); | - |
| 4881 | - | break; | - |
| 4882 | - | - | |
| 4883 | - | case DefaultAclRelationId: | - |
| 4884 | - | appendStringInfoString(&buffer, "default acl"); | - |
| 4885 | - | break; | - |
| 4886 | - | - | |
| 4887 | - | case ExtensionRelationId: | - |
| 4888 | - | appendStringInfoString(&buffer, "extension"); | - |
| 4889 | - | break; | - |
| 4890 | - | - | |
| 4891 | - | case EventTriggerRelationId: | - |
| 4892 | - | appendStringInfoString(&buffer, "event trigger"); | - |
| 4893 | - | break; | - |
| 4894 | - | - | |
| 4895 | - | case ParameterAclRelationId: | - |
| 4896 | - | appendStringInfoString(&buffer, "parameter ACL"); | - |
| 4897 | - | break; | - |
| 4898 | - | - | |
| 4899 | - | case PolicyRelationId: | - |
| 4900 | - | appendStringInfoString(&buffer, "policy"); | - |
| 4901 | - | break; | - |
| 4902 | - | - | |
| 4903 | 111 | case PropgraphElementRelationId: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4904 | 111 | appendStringInfoString(&buffer, "property graph element"); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4905 | 111 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4906 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4907 | 132 | case PropgraphLabelRelationId: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4908 | 132 | appendStringInfoString(&buffer, "property graph label"); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4909 | 132 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4910 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4911 | 195 | case PropgraphPropertyRelationId: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4912 | 195 | appendStringInfoString(&buffer, "property graph property"); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4913 | 195 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4914 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 4915 | - | case PublicationRelationId: | - |
| 4916 | - | appendStringInfoString(&buffer, "publication"); | - |
| 4917 | - | break; | - |
| 4918 | - | - | |
| 4919 | - | case PublicationNamespaceRelationId: | - |
| 4920 | - | appendStringInfoString(&buffer, "publication namespace"); | - |
| 4921 | - | break; | - |
| 4922 | - | - | |
| 4923 | - | case PublicationRelRelationId: | - |
| 4924 | - | appendStringInfoString(&buffer, "publication relation"); | - |
| 4925 | - | break; | - |
| 4926 | - | - | |
| 4927 | - | case SubscriptionRelationId: | - |
| 4928 | - | appendStringInfoString(&buffer, "subscription"); | - |
| 4929 | - | break; | - |
| 4930 | - | - | |
| 4931 | - | case TransformRelationId: | - |
| 4932 | - | appendStringInfoString(&buffer, "transform"); | - |
| 4933 | - | break; | - |
| 4934 | - | - | |
| 4935 | - | default: | - |
| 4936 | - | elog(ERROR, "unsupported object class: %u", object->classId); | - |
| 4937 | - | } | - |
| 4938 | - | - | |
| 4939 | - | /* the result can never be empty */ | - |
| 4940 | - | Assert(buffer.len > 0); | - |
| 4941 | - | - | |
| 4942 | - | return buffer.data; | - |
| 4943 | - | } | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 4949 | - | getRelationTypeDescription(StringInfo buffer, Oid relid, int32 objectSubId, | - |
| 4950 | - | bool missing_ok) | - |
| 4951 | - | { | - |
| 4952 | - | HeapTuple relTup; | - |
| 4953 | - | Form_pg_class relForm; | - |
| 4954 | - | - | |
| 4955 | - | relTup = SearchSysCache1(RELOID, | - |
| 4956 | - | ObjectIdGetDatum(relid)); | - |
| 4957 | - | if (!HeapTupleIsValid(relTup)) | - |
| 4958 | - | { | - |
| 4959 | - | if (!missing_ok) | - |
| 4960 | - | elog(ERROR, "cache lookup failed for relation %u", relid); | - |
| 4961 | - | - | |
| 4962 | - | /* fallback to "relation" for an undefined object */ | - |
| 4963 | - | appendStringInfoString(buffer, "relation"); | - |
| 4964 | - | return; | - |
| 4965 | - | } | - |
| 4966 | - | relForm = (Form_pg_class) GETSTRUCT(relTup); | - |
| 4967 | - | - | |
| 4968 | - | switch (relForm->relkind) | - |
| 4969 | - | { | - |
| 4970 | - | case RELKIND_RELATION: | - |
| 4971 | - | case RELKIND_PARTITIONED_TABLE: | - |
| 4972 | - | appendStringInfoString(buffer, "table"); | - |
| 4973 | - | break; | - |
| 4974 | - | case RELKIND_INDEX: | - |
| 4975 | - | case RELKIND_PARTITIONED_INDEX: | - |
| 4976 | - | appendStringInfoString(buffer, "index"); | - |
| 4977 | - | break; | - |
| 4978 | - | case RELKIND_SEQUENCE: | - |
| 4979 | - | appendStringInfoString(buffer, "sequence"); | - |
| 4980 | - | break; | - |
| 4981 | - | case RELKIND_TOASTVALUE: | - |
| 4982 | - | appendStringInfoString(buffer, "toast table"); | - |
| 4983 | - | break; | - |
| 4984 | - | case RELKIND_VIEW: | - |
| 4985 | - | appendStringInfoString(buffer, "view"); | - |
| 4986 | - | break; | - |
| 4987 | - | case RELKIND_MATVIEW: | - |
| 4988 | - | appendStringInfoString(buffer, "materialized view"); | - |
| 4989 | - | break; | - |
| 4990 | - | case RELKIND_COMPOSITE_TYPE: | - |
| 4991 | - | appendStringInfoString(buffer, "composite type"); | - |
| 4992 | - | break; | - |
| 4993 | - | case RELKIND_FOREIGN_TABLE: | - |
| 4994 | - | appendStringInfoString(buffer, "foreign table"); | - |
| 4995 | - | break; | - |
| 4996 | 21 | case RELKIND_PROPGRAPH: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4997 | 21 | appendStringInfoString(buffer, "property graph"); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4998 | 21 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 4999 | - | default: | - |
| 5000 | - | /* shouldn't get here */ | - |
| 5001 | - | appendStringInfoString(buffer, "relation"); | - |
| 5002 | - | break; | - |
| 5003 | - | } | - |
| 5004 | - | - | |
| 5005 | - | if (objectSubId != 0) | - |
| 5006 | - | appendStringInfoString(buffer, " column"); | - |
| 5007 | - | - | |
| 5008 | - | ReleaseSysCache(relTup); | - |
| 5009 | - | } | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 5104 | - | getObjectIdentityParts(const ObjectAddress *object, | - |
| 5105 | - | List **objname, List **objargs, | - |
| 5106 | - | bool missing_ok) | - |
| 5107 | - | { | - |
| 5108 | - | StringInfoData buffer; | - |
| 5109 | - | - | |
| 5110 | - | initStringInfo(&buffer); | - |
| 5111 | - | - | |
| 5112 | - | /* | - |
| 5113 | - | * Make sure that both objname and objargs were passed, or none was; and | - |
| 5114 | - | * initialize them to empty lists. For objname this is useless because it | - |
| 5115 | - | * will be initialized in all cases inside the switch; but we do it anyway | - |
| 5116 | - | * so that we can test below that no branch leaves it unset. | - |
| 5117 | - | */ | - |
| 5118 | - | Assert((objname != NULL) == (objargs != NULL)); | - |
| 5119 | - | if (objname) | - |
| 5120 | - | { | - |
| 5121 | - | *objname = NIL; | - |
| 5122 | - | *objargs = NIL; | - |
| 5123 | - | } | - |
| 5124 | - | - | |
| 5125 | - | switch (object->classId) | - |
| 5126 | - | { | - |
| 5127 | - | case RelationRelationId: | - |
| 5128 | - | { | - |
| 5129 | - | char *attr = NULL; | - |
| 5130 | - | - | |
| 5131 | - | /* | - |
| 5132 | - | * Check for the attribute first, so as if it is missing we | - |
| 5133 | - | * can skip the entire relation description. | - |
| 5134 | - | */ | - |
| 5135 | - | if (object->objectSubId != 0) | - |
| 5136 | - | { | - |
| 5137 | - | attr = get_attname(object->objectId, | - |
| 5138 | - | object->objectSubId, | - |
| 5139 | - | missing_ok); | - |
| 5140 | - | - | |
| 5141 | - | if (missing_ok && attr == NULL) | - |
| 5142 | - | break; | - |
| 5143 | - | } | - |
| 5144 | - | - | |
| 5145 | - | getRelationIdentity(&buffer, object->objectId, objname, | - |
| 5146 | - | missing_ok); | - |
| 5147 | - | if (objname && *objname == NIL) | - |
| 5148 | - | break; | - |
| 5149 | - | - | |
| 5150 | - | if (attr) | - |
| 5151 | - | { | - |
| 5152 | - | appendStringInfo(&buffer, ".%s", | - |
| 5153 | - | quote_identifier(attr)); | - |
| 5154 | - | if (objname) | - |
| 5155 | - | *objname = lappend(*objname, attr); | - |
| 5156 | - | } | - |
| 5157 | - | } | - |
| 5158 | - | break; | - |
| 5159 | - | - | |
| 5160 | - | case ProcedureRelationId: | - |
| 5161 | - | { | - |
| 5162 | - | bits16 flags = FORMAT_PROC_FORCE_QUALIFY | FORMAT_PROC_INVALID_AS_NULL; | - |
| 5163 | - | char *proname = format_procedure_extended(object->objectId, | - |
| 5164 | - | flags); | - |
| 5165 | - | - | |
| 5166 | - | if (proname == NULL) | - |
| 5167 | - | break; | - |
| 5168 | - | - | |
| 5169 | - | appendStringInfoString(&buffer, proname); | - |
| 5170 | - | if (objname) | - |
| 5171 | - | format_procedure_parts(object->objectId, objname, objargs, | - |
| 5172 | - | missing_ok); | - |
| 5173 | - | break; | - |
| 5174 | - | } | - |
| 5175 | - | - | |
| 5176 | - | case TypeRelationId: | - |
| 5177 | - | { | - |
| 5178 | - | bits16 flags = FORMAT_TYPE_INVALID_AS_NULL | FORMAT_TYPE_FORCE_QUALIFY; | - |
| 5179 | - | char *typeout; | - |
| 5180 | - | - | |
| 5181 | - | typeout = format_type_extended(object->objectId, -1, flags); | - |
| 5182 | - | - | |
| 5183 | - | if (typeout == NULL) | - |
| 5184 | - | break; | - |
| 5185 | - | - | |
| 5186 | - | appendStringInfoString(&buffer, typeout); | - |
| 5187 | - | if (objname) | - |
| 5188 | - | *objname = list_make1(typeout); | - |
| 5189 | - | } | - |
| 5190 | - | break; | - |
| 5191 | - | - | |
| 5192 | - | case CastRelationId: | - |
| 5193 | - | { | - |
| 5194 | - | Relation castRel; | - |
| 5195 | - | HeapTuple tup; | - |
| 5196 | - | Form_pg_cast castForm; | - |
| 5197 | - | - | |
| 5198 | - | castRel = table_open(CastRelationId, AccessShareLock); | - |
| 5199 | - | - | |
| 5200 | - | tup = get_catalog_object_by_oid(castRel, Anum_pg_cast_oid, | - |
| 5201 | - | object->objectId); | - |
| 5202 | - | - | |
| 5203 | - | if (!HeapTupleIsValid(tup)) | - |
| 5204 | - | { | - |
| 5205 | - | if (!missing_ok) | - |
| 5206 | - | elog(ERROR, "could not find tuple for cast %u", | - |
| 5207 | - | object->objectId); | - |
| 5208 | - | - | |
| 5209 | - | table_close(castRel, AccessShareLock); | - |
| 5210 | - | break; | - |
| 5211 | - | } | - |
| 5212 | - | - | |
| 5213 | - | castForm = (Form_pg_cast) GETSTRUCT(tup); | - |
| 5214 | - | - | |
| 5215 | - | appendStringInfo(&buffer, "(%s AS %s)", | - |
| 5216 | - | format_type_be_qualified(castForm->castsource), | - |
| 5217 | - | format_type_be_qualified(castForm->casttarget)); | - |
| 5218 | - | - | |
| 5219 | - | if (objname) | - |
| 5220 | - | { | - |
| 5221 | - | *objname = list_make1(format_type_be_qualified(castForm->castsource)); | - |
| 5222 | - | *objargs = list_make1(format_type_be_qualified(castForm->casttarget)); | - |
| 5223 | - | } | - |
| 5224 | - | - | |
| 5225 | - | table_close(castRel, AccessShareLock); | - |
| 5226 | - | break; | - |
| 5227 | - | } | - |
| 5228 | - | - | |
| 5229 | - | case CollationRelationId: | - |
| 5230 | - | { | - |
| 5231 | - | HeapTuple collTup; | - |
| 5232 | - | Form_pg_collation coll; | - |
| 5233 | - | char *schema; | - |
| 5234 | - | - | |
| 5235 | - | collTup = SearchSysCache1(COLLOID, | - |
| 5236 | - | ObjectIdGetDatum(object->objectId)); | - |
| 5237 | - | if (!HeapTupleIsValid(collTup)) | - |
| 5238 | - | { | - |
| 5239 | - | if (!missing_ok) | - |
| 5240 | - | elog(ERROR, "cache lookup failed for collation %u", | - |
| 5241 | - | object->objectId); | - |
| 5242 | - | break; | - |
| 5243 | - | } | - |
| 5244 | - | coll = (Form_pg_collation) GETSTRUCT(collTup); | - |
| 5245 | - | schema = get_namespace_name_or_temp(coll->collnamespace); | - |
| 5246 | - | appendStringInfoString(&buffer, | - |
| 5247 | - | quote_qualified_identifier(schema, | - |
| 5248 | - | NameStr(coll->collname))); | - |
| 5249 | - | if (objname) | - |
| 5250 | - | *objname = list_make2(schema, | - |
| 5251 | - | pstrdup(NameStr(coll->collname))); | - |
| 5252 | - | ReleaseSysCache(collTup); | - |
| 5253 | - | break; | - |
| 5254 | - | } | - |
| 5255 | - | - | |
| 5256 | - | case ConstraintRelationId: | - |
| 5257 | - | { | - |
| 5258 | - | HeapTuple conTup; | - |
| 5259 | - | Form_pg_constraint con; | - |
| 5260 | - | - | |
| 5261 | - | conTup = SearchSysCache1(CONSTROID, | - |
| 5262 | - | ObjectIdGetDatum(object->objectId)); | - |
| 5263 | - | if (!HeapTupleIsValid(conTup)) | - |
| 5264 | - | { | - |
| 5265 | - | if (!missing_ok) | - |
| 5266 | - | elog(ERROR, "cache lookup failed for constraint %u", | - |
| 5267 | - | object->objectId); | - |
| 5268 | - | break; | - |
| 5269 | - | } | - |
| 5270 | - | con = (Form_pg_constraint) GETSTRUCT(conTup); | - |
| 5271 | - | - | |
| 5272 | - | if (OidIsValid(con->conrelid)) | - |
| 5273 | - | { | - |
| 5274 | - | appendStringInfo(&buffer, "%s on ", | - |
| 5275 | - | quote_identifier(NameStr(con->conname))); | - |
| 5276 | - | getRelationIdentity(&buffer, con->conrelid, objname, | - |
| 5277 | - | false); | - |
| 5278 | - | if (objname) | - |
| 5279 | - | *objname = lappend(*objname, pstrdup(NameStr(con->conname))); | - |
| 5280 | - | } | - |
| 5281 | - | else | - |
| 5282 | - | { | - |
| 5283 | - | ObjectAddress domain; | - |
| 5284 | - | - | |
| 5285 | - | Assert(OidIsValid(con->contypid)); | - |
| 5286 | - | domain.classId = TypeRelationId; | - |
| 5287 | - | domain.objectId = con->contypid; | - |
| 5288 | - | domain.objectSubId = 0; | - |
| 5289 | - | - | |
| 5290 | - | appendStringInfo(&buffer, "%s on %s", | - |
| 5291 | - | quote_identifier(NameStr(con->conname)), | - |
| 5292 | - | getObjectIdentityParts(&domain, objname, | - |
| 5293 | - | objargs, false)); | - |
| 5294 | - | - | |
| 5295 | - | if (objname) | - |
| 5296 | - | *objargs = lappend(*objargs, pstrdup(NameStr(con->conname))); | - |
| 5297 | - | } | - |
| 5298 | - | - | |
| 5299 | - | ReleaseSysCache(conTup); | - |
| 5300 | - | break; | - |
| 5301 | - | } | - |
| 5302 | - | - | |
| 5303 | - | case ConversionRelationId: | - |
| 5304 | - | { | - |
| 5305 | - | HeapTuple conTup; | - |
| 5306 | - | Form_pg_conversion conForm; | - |
| 5307 | - | char *schema; | - |
| 5308 | - | - | |
| 5309 | - | conTup = SearchSysCache1(CONVOID, | - |
| 5310 | - | ObjectIdGetDatum(object->objectId)); | - |
| 5311 | - | if (!HeapTupleIsValid(conTup)) | - |
| 5312 | - | { | - |
| 5313 | - | if (!missing_ok) | - |
| 5314 | - | elog(ERROR, "cache lookup failed for conversion %u", | - |
| 5315 | - | object->objectId); | - |
| 5316 | - | break; | - |
| 5317 | - | } | - |
| 5318 | - | conForm = (Form_pg_conversion) GETSTRUCT(conTup); | - |
| 5319 | - | schema = get_namespace_name_or_temp(conForm->connamespace); | - |
| 5320 | - | appendStringInfoString(&buffer, | - |
| 5321 | - | quote_qualified_identifier(schema, | - |
| 5322 | - | NameStr(conForm->conname))); | - |
| 5323 | - | if (objname) | - |
| 5324 | - | *objname = list_make2(schema, | - |
| 5325 | - | pstrdup(NameStr(conForm->conname))); | - |
| 5326 | - | ReleaseSysCache(conTup); | - |
| 5327 | - | break; | - |
| 5328 | - | } | - |
| 5329 | - | - | |
| 5330 | - | case AttrDefaultRelationId: | - |
| 5331 | - | { | - |
| 5332 | - | ObjectAddress colobject; | - |
| 5333 | - | - | |
| 5334 | - | colobject = GetAttrDefaultColumnAddress(object->objectId); | - |
| 5335 | - | - | |
| 5336 | - | if (!OidIsValid(colobject.objectId)) | - |
| 5337 | - | { | - |
| 5338 | - | if (!missing_ok) | - |
| 5339 | - | elog(ERROR, "could not find tuple for attrdef %u", | - |
| 5340 | - | object->objectId); | - |
| 5341 | - | break; | - |
| 5342 | - | } | - |
| 5343 | - | - | |
| 5344 | - | appendStringInfo(&buffer, "for %s", | - |
| 5345 | - | getObjectIdentityParts(&colobject, | - |
| 5346 | - | objname, objargs, | - |
| 5347 | - | false)); | - |
| 5348 | - | break; | - |
| 5349 | - | } | - |
| 5350 | - | - | |
| 5351 | - | case LanguageRelationId: | - |
| 5352 | - | { | - |
| 5353 | - | HeapTuple langTup; | - |
| 5354 | - | Form_pg_language langForm; | - |
| 5355 | - | - | |
| 5356 | - | langTup = SearchSysCache1(LANGOID, | - |
| 5357 | - | ObjectIdGetDatum(object->objectId)); | - |
| 5358 | - | if (!HeapTupleIsValid(langTup)) | - |
| 5359 | - | { | - |
| 5360 | - | if (!missing_ok) | - |
| 5361 | - | elog(ERROR, "cache lookup failed for language %u", | - |
| 5362 | - | object->objectId); | - |
| 5363 | - | break; | - |
| 5364 | - | } | - |
| 5365 | - | langForm = (Form_pg_language) GETSTRUCT(langTup); | - |
| 5366 | - | appendStringInfoString(&buffer, | - |
| 5367 | - | quote_identifier(NameStr(langForm->lanname))); | - |
| 5368 | - | if (objname) | - |
| 5369 | - | *objname = list_make1(pstrdup(NameStr(langForm->lanname))); | - |
| 5370 | - | ReleaseSysCache(langTup); | - |
| 5371 | - | break; | - |
| 5372 | - | } | - |
| 5373 | - | - | |
| 5374 | - | case LargeObjectRelationId: | - |
| 5375 | - | if (!LargeObjectExists(object->objectId)) | - |
| 5376 | - | break; | - |
| 5377 | - | appendStringInfo(&buffer, "%u", | - |
| 5378 | - | object->objectId); | - |
| 5379 | - | if (objname) | - |
| 5380 | - | *objname = list_make1(psprintf("%u", object->objectId)); | - |
| 5381 | - | break; | - |
| 5382 | - | - | |
| 5383 | - | case OperatorRelationId: | - |
| 5384 | - | { | - |
| 5385 | - | bits16 flags = FORMAT_OPERATOR_FORCE_QUALIFY | FORMAT_OPERATOR_INVALID_AS_NULL; | - |
| 5386 | - | char *oprname = format_operator_extended(object->objectId, | - |
| 5387 | - | flags); | - |
| 5388 | - | - | |
| 5389 | - | if (oprname == NULL) | - |
| 5390 | - | break; | - |
| 5391 | - | - | |
| 5392 | - | appendStringInfoString(&buffer, oprname); | - |
| 5393 | - | if (objname) | - |
| 5394 | - | format_operator_parts(object->objectId, objname, objargs, missing_ok); | - |
| 5395 | - | break; | - |
| 5396 | - | } | - |
| 5397 | - | - | |
| 5398 | - | case OperatorClassRelationId: | - |
| 5399 | - | { | - |
| 5400 | - | HeapTuple opcTup; | - |
| 5401 | - | Form_pg_opclass opcForm; | - |
| 5402 | - | HeapTuple amTup; | - |
| 5403 | - | Form_pg_am amForm; | - |
| 5404 | - | char *schema; | - |
| 5405 | - | - | |
| 5406 | - | opcTup = SearchSysCache1(CLAOID, | - |
| 5407 | - | ObjectIdGetDatum(object->objectId)); | - |
| 5408 | - | if (!HeapTupleIsValid(opcTup)) | - |
| 5409 | - | { | - |
| 5410 | - | if (!missing_ok) | - |
| 5411 | - | elog(ERROR, "cache lookup failed for opclass %u", | - |
| 5412 | - | object->objectId); | - |
| 5413 | - | break; | - |
| 5414 | - | } | - |
| 5415 | - | opcForm = (Form_pg_opclass) GETSTRUCT(opcTup); | - |
| 5416 | - | schema = get_namespace_name_or_temp(opcForm->opcnamespace); | - |
| 5417 | - | - | |
| 5418 | - | amTup = SearchSysCache1(AMOID, | - |
| 5419 | - | ObjectIdGetDatum(opcForm->opcmethod)); | - |
| 5420 | - | if (!HeapTupleIsValid(amTup)) | - |
| 5421 | - | elog(ERROR, "cache lookup failed for access method %u", | - |
| 5422 | - | opcForm->opcmethod); | - |
| 5423 | - | amForm = (Form_pg_am) GETSTRUCT(amTup); | - |
| 5424 | - | - | |
| 5425 | - | appendStringInfo(&buffer, "%s USING %s", | - |
| 5426 | - | quote_qualified_identifier(schema, | - |
| 5427 | - | NameStr(opcForm->opcname)), | - |
| 5428 | - | quote_identifier(NameStr(amForm->amname))); | - |
| 5429 | - | if (objname) | - |
| 5430 | - | *objname = list_make3(pstrdup(NameStr(amForm->amname)), | - |
| 5431 | - | schema, | - |
| 5432 | - | pstrdup(NameStr(opcForm->opcname))); | - |
| 5433 | - | - | |
| 5434 | - | ReleaseSysCache(amTup); | - |
| 5435 | - | ReleaseSysCache(opcTup); | - |
| 5436 | - | break; | - |
| 5437 | - | } | - |
| 5438 | - | - | |
| 5439 | - | case OperatorFamilyRelationId: | - |
| 5440 | - | getOpFamilyIdentity(&buffer, object->objectId, objname, | - |
| 5441 | - | missing_ok); | - |
| 5442 | - | break; | - |
| 5443 | - | - | |
| 5444 | - | case AccessMethodRelationId: | - |
| 5445 | - | { | - |
| 5446 | - | char *amname; | - |
| 5447 | - | - | |
| 5448 | - | amname = get_am_name(object->objectId); | - |
| 5449 | - | if (!amname) | - |
| 5450 | - | { | - |
| 5451 | - | if (!missing_ok) | - |
| 5452 | - | elog(ERROR, "cache lookup failed for access method %u", | - |
| 5453 | - | object->objectId); | - |
| 5454 | - | break; | - |
| 5455 | - | } | - |
| 5456 | - | appendStringInfoString(&buffer, quote_identifier(amname)); | - |
| 5457 | - | if (objname) | - |
| 5458 | - | *objname = list_make1(amname); | - |
| 5459 | - | } | - |
| 5460 | - | break; | - |
| 5461 | - | - | |
| 5462 | - | case AccessMethodOperatorRelationId: | - |
| 5463 | - | { | - |
| 5464 | - | Relation amopDesc; | - |
| 5465 | - | HeapTuple tup; | - |
| 5466 | - | ScanKeyData skey[1]; | - |
| 5467 | - | SysScanDesc amscan; | - |
| 5468 | - | Form_pg_amop amopForm; | - |
| 5469 | - | StringInfoData opfam; | - |
| 5470 | - | char *ltype; | - |
| 5471 | - | char *rtype; | - |
| 5472 | - | - | |
| 5473 | - | amopDesc = table_open(AccessMethodOperatorRelationId, | - |
| 5474 | - | AccessShareLock); | - |
| 5475 | - | - | |
| 5476 | - | ScanKeyInit(&skey[0], | - |
| 5477 | - | Anum_pg_amop_oid, | - |
| 5478 | - | BTEqualStrategyNumber, F_OIDEQ, | - |
| 5479 | - | ObjectIdGetDatum(object->objectId)); | - |
| 5480 | - | - | |
| 5481 | - | amscan = systable_beginscan(amopDesc, AccessMethodOperatorOidIndexId, true, | - |
| 5482 | - | NULL, 1, skey); | - |
| 5483 | - | - | |
| 5484 | - | tup = systable_getnext(amscan); | - |
| 5485 | - | - | |
| 5486 | - | if (!HeapTupleIsValid(tup)) | - |
| 5487 | - | { | - |
| 5488 | - | if (!missing_ok) | - |
| 5489 | - | elog(ERROR, "could not find tuple for amop entry %u", | - |
| 5490 | - | object->objectId); | - |
| 5491 | - | - | |
| 5492 | - | systable_endscan(amscan); | - |
| 5493 | - | table_close(amopDesc, AccessShareLock); | - |
| 5494 | - | break; | - |
| 5495 | - | } | - |
| 5496 | - | - | |
| 5497 | - | amopForm = (Form_pg_amop) GETSTRUCT(tup); | - |
| 5498 | - | - | |
| 5499 | - | initStringInfo(&opfam); | - |
| 5500 | - | getOpFamilyIdentity(&opfam, amopForm->amopfamily, objname, | - |
| 5501 | - | false); | - |
| 5502 | - | - | |
| 5503 | - | ltype = format_type_be_qualified(amopForm->amoplefttype); | - |
| 5504 | - | rtype = format_type_be_qualified(amopForm->amoprighttype); | - |
| 5505 | - | - | |
| 5506 | - | if (objname) | - |
| 5507 | - | { | - |
| 5508 | - | *objname = lappend(*objname, | - |
| 5509 | - | psprintf("%d", amopForm->amopstrategy)); | - |
| 5510 | - | *objargs = list_make2(ltype, rtype); | - |
| 5511 | - | } | - |
| 5512 | - | - | |
| 5513 | - | appendStringInfo(&buffer, "operator %d (%s, %s) of %s", | - |
| 5514 | - | amopForm->amopstrategy, | - |
| 5515 | - | ltype, rtype, opfam.data); | - |
| 5516 | - | - | |
| 5517 | - | pfree(opfam.data); | - |
| 5518 | - | - | |
| 5519 | - | systable_endscan(amscan); | - |
| 5520 | - | table_close(amopDesc, AccessShareLock); | - |
| 5521 | - | break; | - |
| 5522 | - | } | - |
| 5523 | - | - | |
| 5524 | - | case AccessMethodProcedureRelationId: | - |
| 5525 | - | { | - |
| 5526 | - | Relation amprocDesc; | - |
| 5527 | - | ScanKeyData skey[1]; | - |
| 5528 | - | SysScanDesc amscan; | - |
| 5529 | - | HeapTuple tup; | - |
| 5530 | - | Form_pg_amproc amprocForm; | - |
| 5531 | - | StringInfoData opfam; | - |
| 5532 | - | char *ltype; | - |
| 5533 | - | char *rtype; | - |
| 5534 | - | - | |
| 5535 | - | amprocDesc = table_open(AccessMethodProcedureRelationId, | - |
| 5536 | - | AccessShareLock); | - |
| 5537 | - | - | |
| 5538 | - | ScanKeyInit(&skey[0], | - |
| 5539 | - | Anum_pg_amproc_oid, | - |
| 5540 | - | BTEqualStrategyNumber, F_OIDEQ, | - |
| 5541 | - | ObjectIdGetDatum(object->objectId)); | - |
| 5542 | - | - | |
| 5543 | - | amscan = systable_beginscan(amprocDesc, AccessMethodProcedureOidIndexId, true, | - |
| 5544 | - | NULL, 1, skey); | - |
| 5545 | - | - | |
| 5546 | - | tup = systable_getnext(amscan); | - |
| 5547 | - | - | |
| 5548 | - | if (!HeapTupleIsValid(tup)) | - |
| 5549 | - | { | - |
| 5550 | - | if (!missing_ok) | - |
| 5551 | - | elog(ERROR, "could not find tuple for amproc entry %u", | - |
| 5552 | - | object->objectId); | - |
| 5553 | - | - | |
| 5554 | - | systable_endscan(amscan); | - |
| 5555 | - | table_close(amprocDesc, AccessShareLock); | - |
| 5556 | - | break; | - |
| 5557 | - | } | - |
| 5558 | - | - | |
| 5559 | - | amprocForm = (Form_pg_amproc) GETSTRUCT(tup); | - |
| 5560 | - | - | |
| 5561 | - | initStringInfo(&opfam); | - |
| 5562 | - | getOpFamilyIdentity(&opfam, amprocForm->amprocfamily, objname, | - |
| 5563 | - | false); | - |
| 5564 | - | - | |
| 5565 | - | ltype = format_type_be_qualified(amprocForm->amproclefttype); | - |
| 5566 | - | rtype = format_type_be_qualified(amprocForm->amprocrighttype); | - |
| 5567 | - | - | |
| 5568 | - | if (objname) | - |
| 5569 | - | { | - |
| 5570 | - | *objname = lappend(*objname, | - |
| 5571 | - | psprintf("%d", amprocForm->amprocnum)); | - |
| 5572 | - | *objargs = list_make2(ltype, rtype); | - |
| 5573 | - | } | - |
| 5574 | - | - | |
| 5575 | - | appendStringInfo(&buffer, "function %d (%s, %s) of %s", | - |
| 5576 | - | amprocForm->amprocnum, | - |
| 5577 | - | ltype, rtype, opfam.data); | - |
| 5578 | - | - | |
| 5579 | - | pfree(opfam.data); | - |
| 5580 | - | - | |
| 5581 | - | systable_endscan(amscan); | - |
| 5582 | - | table_close(amprocDesc, AccessShareLock); | - |
| 5583 | - | break; | - |
| 5584 | - | } | - |
| 5585 | - | - | |
| 5586 | - | case RewriteRelationId: | - |
| 5587 | - | { | - |
| 5588 | - | Relation ruleDesc; | - |
| 5589 | - | HeapTuple tup; | - |
| 5590 | - | Form_pg_rewrite rule; | - |
| 5591 | - | - | |
| 5592 | - | ruleDesc = table_open(RewriteRelationId, AccessShareLock); | - |
| 5593 | - | - | |
| 5594 | - | tup = get_catalog_object_by_oid(ruleDesc, Anum_pg_rewrite_oid, | - |
| 5595 | - | object->objectId); | - |
| 5596 | - | - | |
| 5597 | - | if (!HeapTupleIsValid(tup)) | - |
| 5598 | - | { | - |
| 5599 | - | if (!missing_ok) | - |
| 5600 | - | elog(ERROR, "could not find tuple for rule %u", | - |
| 5601 | - | object->objectId); | - |
| 5602 | - | - | |
| 5603 | - | table_close(ruleDesc, AccessShareLock); | - |
| 5604 | - | break; | - |
| 5605 | - | } | - |
| 5606 | - | - | |
| 5607 | - | rule = (Form_pg_rewrite) GETSTRUCT(tup); | - |
| 5608 | - | - | |
| 5609 | - | appendStringInfo(&buffer, "%s on ", | - |
| 5610 | - | quote_identifier(NameStr(rule->rulename))); | - |
| 5611 | - | getRelationIdentity(&buffer, rule->ev_class, objname, false); | - |
| 5612 | - | if (objname) | - |
| 5613 | - | *objname = lappend(*objname, pstrdup(NameStr(rule->rulename))); | - |
| 5614 | - | - | |
| 5615 | - | table_close(ruleDesc, AccessShareLock); | - |
| 5616 | - | break; | - |
| 5617 | - | } | - |
| 5618 | - | - | |
| 5619 | - | case TriggerRelationId: | - |
| 5620 | - | { | - |
| 5621 | - | Relation trigDesc; | - |
| 5622 | - | HeapTuple tup; | - |
| 5623 | - | Form_pg_trigger trig; | - |
| 5624 | - | - | |
| 5625 | - | trigDesc = table_open(TriggerRelationId, AccessShareLock); | - |
| 5626 | - | - | |
| 5627 | - | tup = get_catalog_object_by_oid(trigDesc, Anum_pg_trigger_oid, | - |
| 5628 | - | object->objectId); | - |
| 5629 | - | - | |
| 5630 | - | if (!HeapTupleIsValid(tup)) | - |
| 5631 | - | { | - |
| 5632 | - | if (!missing_ok) | - |
| 5633 | - | elog(ERROR, "could not find tuple for trigger %u", | - |
| 5634 | - | object->objectId); | - |
| 5635 | - | - | |
| 5636 | - | table_close(trigDesc, AccessShareLock); | - |
| 5637 | - | break; | - |
| 5638 | - | } | - |
| 5639 | - | - | |
| 5640 | - | trig = (Form_pg_trigger) GETSTRUCT(tup); | - |
| 5641 | - | - | |
| 5642 | - | appendStringInfo(&buffer, "%s on ", | - |
| 5643 | - | quote_identifier(NameStr(trig->tgname))); | - |
| 5644 | - | getRelationIdentity(&buffer, trig->tgrelid, objname, false); | - |
| 5645 | - | if (objname) | - |
| 5646 | - | *objname = lappend(*objname, pstrdup(NameStr(trig->tgname))); | - |
| 5647 | - | - | |
| 5648 | - | table_close(trigDesc, AccessShareLock); | - |
| 5649 | - | break; | - |
| 5650 | - | } | - |
| 5651 | - | - | |
| 5652 | - | case NamespaceRelationId: | - |
| 5653 | - | { | - |
| 5654 | - | char *nspname; | - |
| 5655 | - | - | |
| 5656 | - | nspname = get_namespace_name_or_temp(object->objectId); | - |
| 5657 | - | if (!nspname) | - |
| 5658 | - | { | - |
| 5659 | - | if (!missing_ok) | - |
| 5660 | - | elog(ERROR, "cache lookup failed for namespace %u", | - |
| 5661 | - | object->objectId); | - |
| 5662 | - | break; | - |
| 5663 | - | } | - |
| 5664 | - | appendStringInfoString(&buffer, | - |
| 5665 | - | quote_identifier(nspname)); | - |
| 5666 | - | if (objname) | - |
| 5667 | - | *objname = list_make1(nspname); | - |
| 5668 | - | break; | - |
| 5669 | - | } | - |
| 5670 | - | - | |
| 5671 | - | case StatisticExtRelationId: | - |
| 5672 | - | { | - |
| 5673 | - | HeapTuple tup; | - |
| 5674 | - | Form_pg_statistic_ext formStatistic; | - |
| 5675 | - | char *schema; | - |
| 5676 | - | - | |
| 5677 | - | tup = SearchSysCache1(STATEXTOID, | - |
| 5678 | - | ObjectIdGetDatum(object->objectId)); | - |
| 5679 | - | if (!HeapTupleIsValid(tup)) | - |
| 5680 | - | { | - |
| 5681 | - | if (!missing_ok) | - |
| 5682 | - | elog(ERROR, "cache lookup failed for statistics object %u", | - |
| 5683 | - | object->objectId); | - |
| 5684 | - | break; | - |
| 5685 | - | } | - |
| 5686 | - | formStatistic = (Form_pg_statistic_ext) GETSTRUCT(tup); | - |
| 5687 | - | schema = get_namespace_name_or_temp(formStatistic->stxnamespace); | - |
| 5688 | - | appendStringInfoString(&buffer, | - |
| 5689 | - | quote_qualified_identifier(schema, | - |
| 5690 | - | NameStr(formStatistic->stxname))); | - |
| 5691 | - | if (objname) | - |
| 5692 | - | *objname = list_make2(schema, | - |
| 5693 | - | pstrdup(NameStr(formStatistic->stxname))); | - |
| 5694 | - | ReleaseSysCache(tup); | - |
| 5695 | - | } | - |
| 5696 | - | break; | - |
| 5697 | - | - | |
| 5698 | - | case TSParserRelationId: | - |
| 5699 | - | { | - |
| 5700 | - | HeapTuple tup; | - |
| 5701 | - | Form_pg_ts_parser formParser; | - |
| 5702 | - | char *schema; | - |
| 5703 | - | - | |
| 5704 | - | tup = SearchSysCache1(TSPARSEROID, | - |
| 5705 | - | ObjectIdGetDatum(object->objectId)); | - |
| 5706 | - | if (!HeapTupleIsValid(tup)) | - |
| 5707 | - | { | - |
| 5708 | - | if (!missing_ok) | - |
| 5709 | - | elog(ERROR, "cache lookup failed for text search parser %u", | - |
| 5710 | - | object->objectId); | - |
| 5711 | - | break; | - |
| 5712 | - | } | - |
| 5713 | - | formParser = (Form_pg_ts_parser) GETSTRUCT(tup); | - |
| 5714 | - | schema = get_namespace_name_or_temp(formParser->prsnamespace); | - |
| 5715 | - | appendStringInfoString(&buffer, | - |
| 5716 | - | quote_qualified_identifier(schema, | - |
| 5717 | - | NameStr(formParser->prsname))); | - |
| 5718 | - | if (objname) | - |
| 5719 | - | *objname = list_make2(schema, | - |
| 5720 | - | pstrdup(NameStr(formParser->prsname))); | - |
| 5721 | - | ReleaseSysCache(tup); | - |
| 5722 | - | break; | - |
| 5723 | - | } | - |
| 5724 | - | - | |
| 5725 | - | case TSDictionaryRelationId: | - |
| 5726 | - | { | - |
| 5727 | - | HeapTuple tup; | - |
| 5728 | - | Form_pg_ts_dict formDict; | - |
| 5729 | - | char *schema; | - |
| 5730 | - | - | |
| 5731 | - | tup = SearchSysCache1(TSDICTOID, | - |
| 5732 | - | ObjectIdGetDatum(object->objectId)); | - |
| 5733 | - | if (!HeapTupleIsValid(tup)) | - |
| 5734 | - | { | - |
| 5735 | - | if (!missing_ok) | - |
| 5736 | - | elog(ERROR, "cache lookup failed for text search dictionary %u", | - |
| 5737 | - | object->objectId); | - |
| 5738 | - | break; | - |
| 5739 | - | } | - |
| 5740 | - | formDict = (Form_pg_ts_dict) GETSTRUCT(tup); | - |
| 5741 | - | schema = get_namespace_name_or_temp(formDict->dictnamespace); | - |
| 5742 | - | appendStringInfoString(&buffer, | - |
| 5743 | - | quote_qualified_identifier(schema, | - |
| 5744 | - | NameStr(formDict->dictname))); | - |
| 5745 | - | if (objname) | - |
| 5746 | - | *objname = list_make2(schema, | - |
| 5747 | - | pstrdup(NameStr(formDict->dictname))); | - |
| 5748 | - | ReleaseSysCache(tup); | - |
| 5749 | - | break; | - |
| 5750 | - | } | - |
| 5751 | - | - | |
| 5752 | - | case TSTemplateRelationId: | - |
| 5753 | - | { | - |
| 5754 | - | HeapTuple tup; | - |
| 5755 | - | Form_pg_ts_template formTmpl; | - |
| 5756 | - | char *schema; | - |
| 5757 | - | - | |
| 5758 | - | tup = SearchSysCache1(TSTEMPLATEOID, | - |
| 5759 | - | ObjectIdGetDatum(object->objectId)); | - |
| 5760 | - | if (!HeapTupleIsValid(tup)) | - |
| 5761 | - | { | - |
| 5762 | - | if (!missing_ok) | - |
| 5763 | - | elog(ERROR, "cache lookup failed for text search template %u", | - |
| 5764 | - | object->objectId); | - |
| 5765 | - | break; | - |
| 5766 | - | } | - |
| 5767 | - | formTmpl = (Form_pg_ts_template) GETSTRUCT(tup); | - |
| 5768 | - | schema = get_namespace_name_or_temp(formTmpl->tmplnamespace); | - |
| 5769 | - | appendStringInfoString(&buffer, | - |
| 5770 | - | quote_qualified_identifier(schema, | - |
| 5771 | - | NameStr(formTmpl->tmplname))); | - |
| 5772 | - | if (objname) | - |
| 5773 | - | *objname = list_make2(schema, | - |
| 5774 | - | pstrdup(NameStr(formTmpl->tmplname))); | - |
| 5775 | - | ReleaseSysCache(tup); | - |
| 5776 | - | break; | - |
| 5777 | - | } | - |
| 5778 | - | - | |
| 5779 | - | case TSConfigRelationId: | - |
| 5780 | - | { | - |
| 5781 | - | HeapTuple tup; | - |
| 5782 | - | Form_pg_ts_config formCfg; | - |
| 5783 | - | char *schema; | - |
| 5784 | - | - | |
| 5785 | - | tup = SearchSysCache1(TSCONFIGOID, | - |
| 5786 | - | ObjectIdGetDatum(object->objectId)); | - |
| 5787 | - | if (!HeapTupleIsValid(tup)) | - |
| 5788 | - | { | - |
| 5789 | - | if (!missing_ok) | - |
| 5790 | - | elog(ERROR, "cache lookup failed for text search configuration %u", | - |
| 5791 | - | object->objectId); | - |
| 5792 | - | break; | - |
| 5793 | - | } | - |
| 5794 | - | formCfg = (Form_pg_ts_config) GETSTRUCT(tup); | - |
| 5795 | - | schema = get_namespace_name_or_temp(formCfg->cfgnamespace); | - |
| 5796 | - | appendStringInfoString(&buffer, | - |
| 5797 | - | quote_qualified_identifier(schema, | - |
| 5798 | - | NameStr(formCfg->cfgname))); | - |
| 5799 | - | if (objname) | - |
| 5800 | - | *objname = list_make2(schema, | - |
| 5801 | - | pstrdup(NameStr(formCfg->cfgname))); | - |
| 5802 | - | ReleaseSysCache(tup); | - |
| 5803 | - | break; | - |
| 5804 | - | } | - |
| 5805 | - | - | |
| 5806 | - | case AuthIdRelationId: | - |
| 5807 | - | { | - |
| 5808 | - | char *username; | - |
| 5809 | - | - | |
| 5810 | - | username = GetUserNameFromId(object->objectId, missing_ok); | - |
| 5811 | - | if (!username) | - |
| 5812 | - | break; | - |
| 5813 | - | if (objname) | - |
| 5814 | - | *objname = list_make1(username); | - |
| 5815 | - | appendStringInfoString(&buffer, | - |
| 5816 | - | quote_identifier(username)); | - |
| 5817 | - | break; | - |
| 5818 | - | } | - |
| 5819 | - | - | |
| 5820 | - | case AuthMemRelationId: | - |
| 5821 | - | { | - |
| 5822 | - | Relation authMemDesc; | - |
| 5823 | - | ScanKeyData skey[1]; | - |
| 5824 | - | SysScanDesc amscan; | - |
| 5825 | - | HeapTuple tup; | - |
| 5826 | - | Form_pg_auth_members amForm; | - |
| 5827 | - | - | |
| 5828 | - | authMemDesc = table_open(AuthMemRelationId, | - |
| 5829 | - | AccessShareLock); | - |
| 5830 | - | - | |
| 5831 | - | ScanKeyInit(&skey[0], | - |
| 5832 | - | Anum_pg_auth_members_oid, | - |
| 5833 | - | BTEqualStrategyNumber, F_OIDEQ, | - |
| 5834 | - | ObjectIdGetDatum(object->objectId)); | - |
| 5835 | - | - | |
| 5836 | - | amscan = systable_beginscan(authMemDesc, AuthMemOidIndexId, true, | - |
| 5837 | - | NULL, 1, skey); | - |
| 5838 | - | - | |
| 5839 | - | tup = systable_getnext(amscan); | - |
| 5840 | - | - | |
| 5841 | - | if (!HeapTupleIsValid(tup)) | - |
| 5842 | - | { | - |
| 5843 | - | if (!missing_ok) | - |
| 5844 | - | elog(ERROR, "could not find tuple for pg_auth_members entry %u", | - |
| 5845 | - | object->objectId); | - |
| 5846 | - | - | |
| 5847 | - | systable_endscan(amscan); | - |
| 5848 | - | table_close(authMemDesc, AccessShareLock); | - |
| 5849 | - | break; | - |
| 5850 | - | } | - |
| 5851 | - | - | |
| 5852 | - | amForm = (Form_pg_auth_members) GETSTRUCT(tup); | - |
| 5853 | - | - | |
| 5854 | - | appendStringInfo(&buffer, _("membership of role %s in role %s"), | - |
| 5855 | - | GetUserNameFromId(amForm->member, false), | - |
| 5856 | - | GetUserNameFromId(amForm->roleid, false)); | - |
| 5857 | - | - | |
| 5858 | - | systable_endscan(amscan); | - |
| 5859 | - | table_close(authMemDesc, AccessShareLock); | - |
| 5860 | - | break; | - |
| 5861 | - | } | - |
| 5862 | - | - | |
| 5863 | - | case DatabaseRelationId: | - |
| 5864 | - | { | - |
| 5865 | - | char *datname; | - |
| 5866 | - | - | |
| 5867 | - | datname = get_database_name(object->objectId); | - |
| 5868 | - | if (!datname) | - |
| 5869 | - | { | - |
| 5870 | - | if (!missing_ok) | - |
| 5871 | - | elog(ERROR, "cache lookup failed for database %u", | - |
| 5872 | - | object->objectId); | - |
| 5873 | - | break; | - |
| 5874 | - | } | - |
| 5875 | - | if (objname) | - |
| 5876 | - | *objname = list_make1(datname); | - |
| 5877 | - | appendStringInfoString(&buffer, | - |
| 5878 | - | quote_identifier(datname)); | - |
| 5879 | - | break; | - |
| 5880 | - | } | - |
| 5881 | - | - | |
| 5882 | - | case TableSpaceRelationId: | - |
| 5883 | - | { | - |
| 5884 | - | char *tblspace; | - |
| 5885 | - | - | |
| 5886 | - | tblspace = get_tablespace_name(object->objectId); | - |
| 5887 | - | if (!tblspace) | - |
| 5888 | - | { | - |
| 5889 | - | if (!missing_ok) | - |
| 5890 | - | elog(ERROR, "cache lookup failed for tablespace %u", | - |
| 5891 | - | object->objectId); | - |
| 5892 | - | break; | - |
| 5893 | - | } | - |
| 5894 | - | if (objname) | - |
| 5895 | - | *objname = list_make1(tblspace); | - |
| 5896 | - | appendStringInfoString(&buffer, | - |
| 5897 | - | quote_identifier(tblspace)); | - |
| 5898 | - | break; | - |
| 5899 | - | } | - |
| 5900 | - | - | |
| 5901 | - | case ForeignDataWrapperRelationId: | - |
| 5902 | - | { | - |
| 5903 | - | ForeignDataWrapper *fdw; | - |
| 5904 | - | - | |
| 5905 | - | fdw = GetForeignDataWrapperExtended(object->objectId, | - |
| 5906 | - | missing_ok); | - |
| 5907 | - | if (fdw) | - |
| 5908 | - | { | - |
| 5909 | - | appendStringInfoString(&buffer, quote_identifier(fdw->fdwname)); | - |
| 5910 | - | if (objname) | - |
| 5911 | - | *objname = list_make1(pstrdup(fdw->fdwname)); | - |
| 5912 | - | } | - |
| 5913 | - | break; | - |
| 5914 | - | } | - |
| 5915 | - | - | |
| 5916 | - | case ForeignServerRelationId: | - |
| 5917 | - | { | - |
| 5918 | - | ForeignServer *srv; | - |
| 5919 | - | - | |
| 5920 | - | srv = GetForeignServerExtended(object->objectId, | - |
| 5921 | - | missing_ok); | - |
| 5922 | - | if (srv) | - |
| 5923 | - | { | - |
| 5924 | - | appendStringInfoString(&buffer, | - |
| 5925 | - | quote_identifier(srv->servername)); | - |
| 5926 | - | if (objname) | - |
| 5927 | - | *objname = list_make1(pstrdup(srv->servername)); | - |
| 5928 | - | } | - |
| 5929 | - | break; | - |
| 5930 | - | } | - |
| 5931 | - | - | |
| 5932 | - | case UserMappingRelationId: | - |
| 5933 | - | { | - |
| 5934 | - | HeapTuple tup; | - |
| 5935 | - | Oid useid; | - |
| 5936 | - | Form_pg_user_mapping umform; | - |
| 5937 | - | ForeignServer *srv; | - |
| 5938 | - | const char *usename; | - |
| 5939 | - | - | |
| 5940 | - | tup = SearchSysCache1(USERMAPPINGOID, | - |
| 5941 | - | ObjectIdGetDatum(object->objectId)); | - |
| 5942 | - | if (!HeapTupleIsValid(tup)) | - |
| 5943 | - | { | - |
| 5944 | - | if (!missing_ok) | - |
| 5945 | - | elog(ERROR, "cache lookup failed for user mapping %u", | - |
| 5946 | - | object->objectId); | - |
| 5947 | - | break; | - |
| 5948 | - | } | - |
| 5949 | - | umform = (Form_pg_user_mapping) GETSTRUCT(tup); | - |
| 5950 | - | useid = umform->umuser; | - |
| 5951 | - | srv = GetForeignServer(umform->umserver); | - |
| 5952 | - | - | |
| 5953 | - | ReleaseSysCache(tup); | - |
| 5954 | - | - | |
| 5955 | - | if (OidIsValid(useid)) | - |
| 5956 | - | usename = GetUserNameFromId(useid, false); | - |
| 5957 | - | else | - |
| 5958 | - | usename = "public"; | - |
| 5959 | - | - | |
| 5960 | - | if (objname) | - |
| 5961 | - | { | - |
| 5962 | - | *objname = list_make1(pstrdup(usename)); | - |
| 5963 | - | *objargs = list_make1(pstrdup(srv->servername)); | - |
| 5964 | - | } | - |
| 5965 | - | - | |
| 5966 | - | appendStringInfo(&buffer, "%s on server %s", | - |
| 5967 | - | quote_identifier(usename), | - |
| 5968 | - | srv->servername); | - |
| 5969 | - | break; | - |
| 5970 | - | } | - |
| 5971 | - | - | |
| 5972 | - | case DefaultAclRelationId: | - |
| 5973 | - | { | - |
| 5974 | - | Relation defaclrel; | - |
| 5975 | - | ScanKeyData skey[1]; | - |
| 5976 | - | SysScanDesc rcscan; | - |
| 5977 | - | HeapTuple tup; | - |
| 5978 | - | Form_pg_default_acl defacl; | - |
| 5979 | - | char *schema; | - |
| 5980 | - | char *username; | - |
| 5981 | - | - | |
| 5982 | - | defaclrel = table_open(DefaultAclRelationId, AccessShareLock); | - |
| 5983 | - | - | |
| 5984 | - | ScanKeyInit(&skey[0], | - |
| 5985 | - | Anum_pg_default_acl_oid, | - |
| 5986 | - | BTEqualStrategyNumber, F_OIDEQ, | - |
| 5987 | - | ObjectIdGetDatum(object->objectId)); | - |
| 5988 | - | - | |
| 5989 | - | rcscan = systable_beginscan(defaclrel, DefaultAclOidIndexId, | - |
| 5990 | - | true, NULL, 1, skey); | - |
| 5991 | - | - | |
| 5992 | - | tup = systable_getnext(rcscan); | - |
| 5993 | - | - | |
| 5994 | - | if (!HeapTupleIsValid(tup)) | - |
| 5995 | - | { | - |
| 5996 | - | if (!missing_ok) | - |
| 5997 | - | elog(ERROR, "could not find tuple for default ACL %u", | - |
| 5998 | - | object->objectId); | - |
| 5999 | - | - | |
| 6000 | - | systable_endscan(rcscan); | - |
| 6001 | - | table_close(defaclrel, AccessShareLock); | - |
| 6002 | - | break; | - |
| 6003 | - | } | - |
| 6004 | - | - | |
| 6005 | - | defacl = (Form_pg_default_acl) GETSTRUCT(tup); | - |
| 6006 | - | - | |
| 6007 | - | username = GetUserNameFromId(defacl->defaclrole, false); | - |
| 6008 | - | appendStringInfo(&buffer, | - |
| 6009 | - | "for role %s", | - |
| 6010 | - | quote_identifier(username)); | - |
| 6011 | - | - | |
| 6012 | - | if (OidIsValid(defacl->defaclnamespace)) | - |
| 6013 | - | { | - |
| 6014 | - | schema = get_namespace_name_or_temp(defacl->defaclnamespace); | - |
| 6015 | - | appendStringInfo(&buffer, | - |
| 6016 | - | " in schema %s", | - |
| 6017 | - | quote_identifier(schema)); | - |
| 6018 | - | } | - |
| 6019 | - | else | - |
| 6020 | - | schema = NULL; | - |
| 6021 | - | - | |
| 6022 | - | switch (defacl->defaclobjtype) | - |
| 6023 | - | { | - |
| 6024 | - | case DEFACLOBJ_RELATION: | - |
| 6025 | - | appendStringInfoString(&buffer, | - |
| 6026 | - | " on tables"); | - |
| 6027 | - | break; | - |
| 6028 | - | case DEFACLOBJ_SEQUENCE: | - |
| 6029 | - | appendStringInfoString(&buffer, | - |
| 6030 | - | " on sequences"); | - |
| 6031 | - | break; | - |
| 6032 | - | case DEFACLOBJ_FUNCTION: | - |
| 6033 | - | appendStringInfoString(&buffer, | - |
| 6034 | - | " on functions"); | - |
| 6035 | - | break; | - |
| 6036 | - | case DEFACLOBJ_TYPE: | - |
| 6037 | - | appendStringInfoString(&buffer, | - |
| 6038 | - | " on types"); | - |
| 6039 | - | break; | - |
| 6040 | - | case DEFACLOBJ_NAMESPACE: | - |
| 6041 | - | appendStringInfoString(&buffer, | - |
| 6042 | - | " on schemas"); | - |
| 6043 | - | break; | - |
| 6044 | - | case DEFACLOBJ_LARGEOBJECT: | - |
| 6045 | - | appendStringInfoString(&buffer, | - |
| 6046 | - | " on large objects"); | - |
| 6047 | - | break; | - |
| 6048 | - | } | - |
| 6049 | - | - | |
| 6050 | - | if (objname) | - |
| 6051 | - | { | - |
| 6052 | - | *objname = list_make1(username); | - |
| 6053 | - | if (schema) | - |
| 6054 | - | *objname = lappend(*objname, schema); | - |
| 6055 | - | *objargs = list_make1(psprintf("%c", defacl->defaclobjtype)); | - |
| 6056 | - | } | - |
| 6057 | - | - | |
| 6058 | - | systable_endscan(rcscan); | - |
| 6059 | - | table_close(defaclrel, AccessShareLock); | - |
| 6060 | - | break; | - |
| 6061 | - | } | - |
| 6062 | - | - | |
| 6063 | - | case ExtensionRelationId: | - |
| 6064 | - | { | - |
| 6065 | - | char *extname; | - |
| 6066 | - | - | |
| 6067 | - | extname = get_extension_name(object->objectId); | - |
| 6068 | - | if (!extname) | - |
| 6069 | - | { | - |
| 6070 | - | if (!missing_ok) | - |
| 6071 | - | elog(ERROR, "cache lookup failed for extension %u", | - |
| 6072 | - | object->objectId); | - |
| 6073 | - | break; | - |
| 6074 | - | } | - |
| 6075 | - | appendStringInfoString(&buffer, quote_identifier(extname)); | - |
| 6076 | - | if (objname) | - |
| 6077 | - | *objname = list_make1(extname); | - |
| 6078 | - | break; | - |
| 6079 | - | } | - |
| 6080 | - | - | |
| 6081 | - | case EventTriggerRelationId: | - |
| 6082 | - | { | - |
| 6083 | - | HeapTuple tup; | - |
| 6084 | - | Form_pg_event_trigger trigForm; | - |
| 6085 | - | char *evtname; | - |
| 6086 | - | - | |
| 6087 | - | tup = SearchSysCache1(EVENTTRIGGEROID, | - |
| 6088 | - | ObjectIdGetDatum(object->objectId)); | - |
| 6089 | - | if (!HeapTupleIsValid(tup)) | - |
| 6090 | - | { | - |
| 6091 | - | if (!missing_ok) | - |
| 6092 | - | elog(ERROR, "cache lookup failed for event trigger %u", | - |
| 6093 | - | object->objectId); | - |
| 6094 | - | break; | - |
| 6095 | - | } | - |
| 6096 | - | trigForm = (Form_pg_event_trigger) GETSTRUCT(tup); | - |
| 6097 | - | evtname = pstrdup(NameStr(trigForm->evtname)); | - |
| 6098 | - | appendStringInfoString(&buffer, quote_identifier(evtname)); | - |
| 6099 | - | if (objname) | - |
| 6100 | - | *objname = list_make1(evtname); | - |
| 6101 | - | ReleaseSysCache(tup); | - |
| 6102 | - | break; | - |
| 6103 | - | } | - |
| 6104 | - | - | |
| 6105 | - | case ParameterAclRelationId: | - |
| 6106 | - | { | - |
| 6107 | - | HeapTuple tup; | - |
| 6108 | - | Datum nameDatum; | - |
| 6109 | - | char *parname; | - |
| 6110 | - | - | |
| 6111 | - | tup = SearchSysCache1(PARAMETERACLOID, | - |
| 6112 | - | ObjectIdGetDatum(object->objectId)); | - |
| 6113 | - | if (!HeapTupleIsValid(tup)) | - |
| 6114 | - | { | - |
| 6115 | - | if (!missing_ok) | - |
| 6116 | - | elog(ERROR, "cache lookup failed for parameter ACL %u", | - |
| 6117 | - | object->objectId); | - |
| 6118 | - | break; | - |
| 6119 | - | } | - |
| 6120 | - | nameDatum = SysCacheGetAttrNotNull(PARAMETERACLOID, tup, | - |
| 6121 | - | Anum_pg_parameter_acl_parname); | - |
| 6122 | - | parname = TextDatumGetCString(nameDatum); | - |
| 6123 | - | appendStringInfoString(&buffer, parname); | - |
| 6124 | - | if (objname) | - |
| 6125 | - | *objname = list_make1(parname); | - |
| 6126 | - | ReleaseSysCache(tup); | - |
| 6127 | - | break; | - |
| 6128 | - | } | - |
| 6129 | - | - | |
| 6130 | - | case PolicyRelationId: | - |
| 6131 | - | { | - |
| 6132 | - | Relation polDesc; | - |
| 6133 | - | HeapTuple tup; | - |
| 6134 | - | Form_pg_policy policy; | - |
| 6135 | - | - | |
| 6136 | - | polDesc = table_open(PolicyRelationId, AccessShareLock); | - |
| 6137 | - | - | |
| 6138 | - | tup = get_catalog_object_by_oid(polDesc, Anum_pg_policy_oid, | - |
| 6139 | - | object->objectId); | - |
| 6140 | - | - | |
| 6141 | - | if (!HeapTupleIsValid(tup)) | - |
| 6142 | - | { | - |
| 6143 | - | if (!missing_ok) | - |
| 6144 | - | elog(ERROR, "could not find tuple for policy %u", | - |
| 6145 | - | object->objectId); | - |
| 6146 | - | - | |
| 6147 | - | table_close(polDesc, AccessShareLock); | - |
| 6148 | - | break; | - |
| 6149 | - | } | - |
| 6150 | - | - | |
| 6151 | - | policy = (Form_pg_policy) GETSTRUCT(tup); | - |
| 6152 | - | - | |
| 6153 | - | appendStringInfo(&buffer, "%s on ", | - |
| 6154 | - | quote_identifier(NameStr(policy->polname))); | - |
| 6155 | - | getRelationIdentity(&buffer, policy->polrelid, objname, false); | - |
| 6156 | - | if (objname) | - |
| 6157 | - | *objname = lappend(*objname, pstrdup(NameStr(policy->polname))); | - |
| 6158 | - | - | |
| 6159 | - | table_close(polDesc, AccessShareLock); | - |
| 6160 | - | break; | - |
| 6161 | - | } | - |
| 6162 | - | - | |
| 6163 | 111 | case PropgraphElementRelationId: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6164 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6165 | 111 | HeapTuple tup; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6166 | 111 | Form_pg_propgraph_element pge; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6167 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 6168 | 111 | tup = SearchSysCache1(PROPGRAPHELOID, object->objectId); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6169 | 111 | if (!HeapTupleIsValid(tup)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6170 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6171 | 6 | if (!missing_ok) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6172 | 0 | elog(ERROR, "cache lookup failed for property graph element %u", object->objectId); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6173 | - | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6174 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6175 | 105 | pge = (Form_pg_propgraph_element) GETSTRUCT(tup); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6176 | 105 | appendStringInfo(&buffer, "%s of ", quote_identifier(NameStr(pge->pgealias))); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6177 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 6178 | 105 | getRelationIdentity(&buffer, pge->pgepgid, objname, false); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6179 | 105 | if (objname) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6180 | 45 | *objname = lappend(*objname, pstrdup(NameStr(pge->pgealias))); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6181 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 6182 | 105 | ReleaseSysCache(tup); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6183 | 105 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6184 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6185 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 6186 | 132 | case PropgraphLabelRelationId: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6187 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6188 | 132 | HeapTuple tup; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6189 | 132 | Form_pg_propgraph_label pgl; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6190 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 6191 | 132 | tup = SearchSysCache1(PROPGRAPHLABELOID, object->objectId); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6192 | 132 | if (!HeapTupleIsValid(tup)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6193 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6194 | 6 | if (!missing_ok) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6195 | 0 | elog(ERROR, "cache lookup failed for property graph label %u", object->objectId); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6196 | - | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6197 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6198 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 6199 | 126 | pgl = (Form_pg_propgraph_label) GETSTRUCT(tup); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6200 | 126 | appendStringInfo(&buffer, "%s of ", quote_identifier(NameStr(pgl->pgllabel))); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6201 | 126 | getRelationIdentity(&buffer, pgl->pglpgid, objname, false); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6202 | 126 | if (objname) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6203 | 54 | *objname = lappend(*objname, pstrdup(NameStr(pgl->pgllabel))); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6204 | 126 | ReleaseSysCache(tup); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6205 | 126 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6206 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6207 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 6208 | 195 | case PropgraphPropertyRelationId: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6209 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6210 | 195 | HeapTuple tup; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6211 | 195 | Form_pg_propgraph_property pgp; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6212 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 6213 | 195 | tup = SearchSysCache1(PROPGRAPHPROPOID, object->objectId); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6214 | 195 | if (!HeapTupleIsValid(tup)) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6215 | - | { | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6216 | 6 | if (!missing_ok) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6217 | 0 | elog(ERROR, "cache lookup failed for property graph property %u", object->objectId); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6218 | - | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6219 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6220 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 6221 | 189 | pgp = (Form_pg_propgraph_property) GETSTRUCT(tup); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6222 | 189 | appendStringInfo(&buffer, "%s of ", quote_identifier(NameStr(pgp->pgpname))); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6223 | 189 | getRelationIdentity(&buffer, pgp->pgppgid, objname, false); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6224 | 189 | if (objname) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6225 | 81 | *objname = lappend(*objname, pstrdup(NameStr(pgp->pgpname))); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6226 | 189 | ReleaseSysCache(tup); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6227 | 189 | break; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6228 | - | } | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6229 | - | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) | |
| 6230 | - | case PublicationRelationId: | - |
| 6231 | - | { | - |
| 6232 | - | char *pubname; | - |
| 6233 | - | - | |
| 6234 | - | pubname = get_publication_name(object->objectId, missing_ok); | - |
| 6235 | - | if (pubname) | - |
| 6236 | - | { | - |
| 6237 | - | appendStringInfoString(&buffer, | - |
| 6238 | - | quote_identifier(pubname)); | - |
| 6239 | - | if (objname) | - |
| 6240 | - | *objname = list_make1(pubname); | - |
| 6241 | - | } | - |
| 6242 | - | break; | - |
| 6243 | - | } | - |
| 6244 | - | - | |
| 6245 | - | case PublicationNamespaceRelationId: | - |
| 6246 | - | { | - |
| 6247 | - | char *pubname; | - |
| 6248 | - | char *nspname; | - |
| 6249 | - | - | |
| 6250 | - | if (!getPublicationSchemaInfo(object, missing_ok, &pubname, | - |
| 6251 | - | &nspname)) | - |
| 6252 | - | break; | - |
| 6253 | - | appendStringInfo(&buffer, "%s in publication %s", | - |
| 6254 | - | nspname, pubname); | - |
| 6255 | - | - | |
| 6256 | - | if (objargs) | - |
| 6257 | - | *objargs = list_make1(pubname); | - |
| 6258 | - | else | - |
| 6259 | - | pfree(pubname); | - |
| 6260 | - | - | |
| 6261 | - | if (objname) | - |
| 6262 | - | *objname = list_make1(nspname); | - |
| 6263 | - | else | - |
| 6264 | - | pfree(nspname); | - |
| 6265 | - | - | |
| 6266 | - | break; | - |
| 6267 | - | } | - |
| 6268 | - | - | |
| 6269 | - | case PublicationRelRelationId: | - |
| 6270 | - | { | - |
| 6271 | - | HeapTuple tup; | - |
| 6272 | - | char *pubname; | - |
| 6273 | - | Form_pg_publication_rel prform; | - |
| 6274 | - | - | |
| 6275 | - | tup = SearchSysCache1(PUBLICATIONREL, | - |
| 6276 | - | ObjectIdGetDatum(object->objectId)); | - |
| 6277 | - | if (!HeapTupleIsValid(tup)) | - |
| 6278 | - | { | - |
| 6279 | - | if (!missing_ok) | - |
| 6280 | - | elog(ERROR, "cache lookup failed for publication table %u", | - |
| 6281 | - | object->objectId); | - |
| 6282 | - | break; | - |
| 6283 | - | } | - |
| 6284 | - | - | |
| 6285 | - | prform = (Form_pg_publication_rel) GETSTRUCT(tup); | - |
| 6286 | - | pubname = get_publication_name(prform->prpubid, false); | - |
| 6287 | - | - | |
| 6288 | - | getRelationIdentity(&buffer, prform->prrelid, objname, false); | - |
| 6289 | - | appendStringInfo(&buffer, " in publication %s", pubname); | - |
| 6290 | - | - | |
| 6291 | - | if (objargs) | - |
| 6292 | - | *objargs = list_make1(pubname); | - |
| 6293 | - | - | |
| 6294 | - | ReleaseSysCache(tup); | - |
| 6295 | - | break; | - |
| 6296 | - | } | - |
| 6297 | - | - | |
| 6298 | - | case SubscriptionRelationId: | - |
| 6299 | - | { | - |
| 6300 | - | char *subname; | - |
| 6301 | - | - | |
| 6302 | - | subname = get_subscription_name(object->objectId, missing_ok); | - |
| 6303 | - | if (subname) | - |
| 6304 | - | { | - |
| 6305 | - | appendStringInfoString(&buffer, | - |
| 6306 | - | quote_identifier(subname)); | - |
| 6307 | - | if (objname) | - |
| 6308 | - | *objname = list_make1(subname); | - |
| 6309 | - | } | - |
| 6310 | - | break; | - |
| 6311 | - | } | - |
| 6312 | - | - | |
| 6313 | - | case TransformRelationId: | - |
| 6314 | - | { | - |
| 6315 | - | Relation transformDesc; | - |
| 6316 | - | HeapTuple tup; | - |
| 6317 | - | Form_pg_transform transform; | - |
| 6318 | - | char *transformLang; | - |
| 6319 | - | char *transformType; | - |
| 6320 | - | - | |
| 6321 | - | transformDesc = table_open(TransformRelationId, AccessShareLock); | - |
| 6322 | - | - | |
| 6323 | - | tup = get_catalog_object_by_oid(transformDesc, | - |
| 6324 | - | Anum_pg_transform_oid, | - |
| 6325 | - | object->objectId); | - |
| 6326 | - | - | |
| 6327 | - | if (!HeapTupleIsValid(tup)) | - |
| 6328 | - | { | - |
| 6329 | - | if (!missing_ok) | - |
| 6330 | - | elog(ERROR, "could not find tuple for transform %u", | - |
| 6331 | - | object->objectId); | - |
| 6332 | - | - | |
| 6333 | - | table_close(transformDesc, AccessShareLock); | - |
| 6334 | - | break; | - |
| 6335 | - | } | - |
| 6336 | - | - | |
| 6337 | - | transform = (Form_pg_transform) GETSTRUCT(tup); | - |
| 6338 | - | - | |
| 6339 | - | transformType = format_type_be_qualified(transform->trftype); | - |
| 6340 | - | transformLang = get_language_name(transform->trflang, false); | - |
| 6341 | - | - | |
| 6342 | - | appendStringInfo(&buffer, "for %s language %s", | - |
| 6343 | - | transformType, | - |
| 6344 | - | transformLang); | - |
| 6345 | - | if (objname) | - |
| 6346 | - | { | - |
| 6347 | - | *objname = list_make1(transformType); | - |
| 6348 | - | *objargs = list_make1(pstrdup(transformLang)); | - |
| 6349 | - | } | - |
| 6350 | - | - | |
| 6351 | - | table_close(transformDesc, AccessShareLock); | - |
| 6352 | - | } | - |
| 6353 | - | break; | - |
| 6354 | - | - | |
| 6355 | - | default: | - |
| 6356 | - | elog(ERROR, "unsupported object class: %u", object->classId); | - |
| 6357 | - | } | - |
| 6358 | - | - | |
| 6359 | - | if (!missing_ok) | - |
| 6360 | - | { | - |
| 6361 | - | /* | - |
| 6362 | - | * If a get_object_address() representation was requested, make sure | - |
| 6363 | - | * we are providing one. We don't check objargs, because many of the | - |
| 6364 | - | * cases above leave it as NIL. | - |
| 6365 | - | */ | - |
| 6366 | - | if (objname && *objname == NIL) | - |
| 6367 | - | elog(ERROR, "requested object address for unsupported object class %u: text result \"%s\"", | - |
| 6368 | - | object->classId, buffer.data); | - |
| 6369 | - | } | - |
| 6370 | - | else | - |
| 6371 | - | { | - |
| 6372 | - | /* an empty buffer is equivalent to no object found */ | - |
| 6373 | - | if (buffer.len == 0) | - |
| 6374 | - | { | - |
| 6375 | - | Assert((objname == NULL || *objname == NIL) && | - |
| 6376 | - | (objargs == NULL || *objargs == NIL)); | - |
| 6377 | - | return NULL; | - |
| 6378 | - | } | - |
| 6379 | - | } | - |
| 6380 | - | - | |
| 6381 | - | return buffer.data; | - |
| 6382 | - | } | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 6518 | - | get_relkind_objtype(char relkind) | - |
| 6519 | - | { | - |
| 6520 | - | switch (relkind) | - |
| 6521 | - | { | - |
| 6522 | - | case RELKIND_RELATION: | - |
| 6523 | - | case RELKIND_PARTITIONED_TABLE: | - |
| 6524 | - | return OBJECT_TABLE; | - |
| 6525 | - | case RELKIND_INDEX: | - |
| 6526 | - | case RELKIND_PARTITIONED_INDEX: | - |
| 6527 | - | return OBJECT_INDEX; | - |
| 6528 | - | case RELKIND_SEQUENCE: | - |
| 6529 | - | return OBJECT_SEQUENCE; | - |
| 6530 | - | case RELKIND_VIEW: | - |
| 6531 | - | return OBJECT_VIEW; | - |
| 6532 | - | case RELKIND_MATVIEW: | - |
| 6533 | - | return OBJECT_MATVIEW; | - |
| 6534 | - | case RELKIND_FOREIGN_TABLE: | - |
| 6535 | - | return OBJECT_FOREIGN_TABLE; | - |
| 6536 | 15 | case RELKIND_PROPGRAPH: | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6537 | 15 | return OBJECT_PROPGRAPH; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 6538 | - | case RELKIND_TOASTVALUE: | - |
| 6539 | - | return OBJECT_TABLE; | - |
| 6540 | - | default: | - |
| 6541 | - | /* Per above, don't raise an error */ | - |
| 6542 | - | return OBJECT_TABLE; | - |
| 6543 | - | } | - |
| 6544 | - | } | - |