* Lookup an existing query in the hash table. If the query does not * actually exist, throw ereport(ERROR) or return NULL per second parameter. * * Note: this does not force the referenced plancache entry to be valid, * since not all callers care. */
| 488 | * since not all callers care. |
| 489 | */ |
| 490 | PreparedStatement * |
| 491 | FetchPreparedStatement(const char *stmt_name, bool throwError) |
| 492 | { |
| 493 | PreparedStatement *entry; |
| 494 | |
| 495 | /* |
| 496 | * If the hash table hasn't been initialized, it can't be storing |
| 497 | * anything, therefore it couldn't possibly store our plan. |
| 498 | */ |
| 499 | if (prepared_queries) |
| 500 | entry = (PreparedStatement *) hash_search(prepared_queries, |
| 501 | stmt_name, |
| 502 | HASH_FIND, |
| 503 | NULL); |
| 504 | else |
| 505 | entry = NULL; |
| 506 | |
| 507 | if (!entry && throwError) |
| 508 | ereport(ERROR, |
| 509 | (errcode(ERRCODE_UNDEFINED_PSTATEMENT), |
| 510 | errmsg("prepared statement \"%s\" does not exist", |
| 511 | stmt_name))); |
| 512 | |
| 513 | return entry; |
| 514 | } |
| 515 | |
| 516 | /* |
| 517 | * Given a prepared statement, determine the result tupledesc it will |
no test coverage detected