void update()

in src/afs.cc [2046:2096]


	void update()
	{
		const char* tag = "update";
		pgstat_report_activity(STATE_RUNNING, (std::string(Tag) + ": updating").c_str());

		auto session = find_session();
		SharedSessionReleaser sessionReleaser(sessions_, session);
		if (!DsaPointerIsValid(session->updateQuery))
		{
			set_error_message(
				session,
				std::string(Tag) + ": " + tag_ + ": " + tag + ": query is missing",
				tag);
			return;
		}

		std::string query;
		{
			ProcessorLockGuard lock(this);
			query =
				static_cast<const char*>(dsa_get_address(area_, session->updateQuery));
			dsa_free(area_, session->updateQuery);
			session->updateQuery = InvalidDsaPointer;
		}
		P("%s: %s: %s: %s", Tag, tag_, tag, query.c_str());

		{
			ScopedTransaction scopedTransaction;
			ScopedSnapshot scopedSnapshot;

			SetCurrentStatementStartTimestamp();
			SPI_connect();
			needFinish_ = true;
			auto result = SPI_execute(query.c_str(), false, 0);
			if (result > 0)
			{
				session->nUpdatedRecords = SPI_processed;
			}
			else
			{
				set_error_message(session,
				                  std::string(Tag) + ": " + tag_ + ": " + tag +
				                      ": failed to run a query: <" + query +
				                      ">: " + SPI_result_code_string(result),
				                  tag);
			}
			SPI_finish();
			needFinish_ = false;
			signal_server(tag);
		}
	}