MySQL 8.0.30
Source Code Documentation
sql_cmd_srs.h
Go to the documentation of this file.
1// Copyright (c) 2017, 2022, Oracle and/or its affiliates.
2//
3// This program is free software; you can redistribute it and/or modify
4// it under the terms of the GNU General Public License, version 2.0,
5// as published by the Free Software Foundation.
6//
7// This program is also distributed with certain software (including
8// but not limited to OpenSSL) that is licensed under separate terms,
9// as designated in a particular file or component or in included license
10// documentation. The authors of MySQL hereby grant you an additional
11// permission to link the program and your derivative works with the
12// separately licensed software that they have included with MySQL.
13//
14// This program is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17// GNU General Public License, version 2.0, for more details.
18//
19// You should have received a copy of the GNU General Public License
20// along with this program; if not, write to the Free Software
21// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22
23/// @file
24///
25/// This file declares the interface of classes Sql_cmd_create_srs and
26/// Sql_cmd_drop_srs, which handles the CREATE/DROP SPATIAL REFERENCE
27/// SYSTEM statements, respectively.
28
29#ifndef SQL_SQL_CMD_SRS_H_INCLUDED
30#define SQL_SQL_CMD_SRS_H_INCLUDED
31
32#include "my_sqlcommand.h" // SQLCOM_CREATE_SRS, SQLCOM_DROP_SRS
33#include "mysql/mysql_lex_string.h" // MYSQL_LEX_STRING
35#include "sql/gis/srid.h" // gis::srid_t
36#include "sql/sql_cmd.h"
37
38class THD;
39
44 unsigned long long organization_coordsys_id;
46
48 : srs_name({nullptr, 0}),
49 definition({nullptr, 0}),
50 organization({nullptr, 0}),
52 description({nullptr, 0}) {}
53};
54
55class Sql_cmd_create_srs final : public Sql_cmd {
56 public:
57 Sql_cmd_create_srs() = default;
58 void init(bool or_replace, bool if_not_exists, gis::srid_t srid,
59 MYSQL_LEX_STRING srs_name, MYSQL_LEX_STRING definition,
60 MYSQL_LEX_STRING organization, gis::srid_t organization_coordsys_id,
61 MYSQL_LEX_STRING description) {
62 m_or_replace = or_replace;
63 m_if_not_exists = if_not_exists;
64 m_srid = srid;
65 m_srs_name = srs_name;
66 m_definition = definition;
67 m_organization = organization;
68 m_organization_coordsys_id = organization_coordsys_id;
69 m_description = description;
70 }
72 return SQLCOM_CREATE_SRS;
73 }
74 bool execute(THD *thd) override;
75
76 /// Fill an SRS with information from this CREATE statement (except the ID).
77 ///
78 /// @param[in,out] srs The SRS.
79 ///
80 /// @retval false Success.
81 /// @retval true An error occurred (i.e., invalid SRS definition). The error
82 /// has been reported with my_error.
84
85 private:
86 /// Whether OR REPLACE was specified.
87 bool m_or_replace = false;
88 /// Whether IF NOT EXISTS was specified
89 bool m_if_not_exists = false;
90 /// The SRID of the new SRS.
92 /// The name of the new SRS.
93 ///
94 /// The value is always a valid name (verified by PT_create_srs), but it may
95 /// be a duplicate of an existing one.
97 /// The definition of the new SRS.
98 ///
99 /// The definition is not parsed and validated until the SRS is created.
101 /// Organization that is the source of the SRS definition.
103 /// Source organization's SRS ID.
105 /// Description of the new SRS.
107};
108
109class Sql_cmd_drop_srs final : public Sql_cmd {
110 public:
111 Sql_cmd_drop_srs(gis::srid_t srid, bool if_exists)
112 : m_srid(srid), m_if_exists(if_exists) {}
114 bool execute(THD *thd) override;
115
116 private:
117 /// SRID of the SRS to drop.
119 /// Whether IF EXISTS was specified.
121};
122
123#endif // SQL_SQL_CMD_SRS_H_INCLUDED
Definition: sql_cmd_srs.h:55
Sql_cmd_create_srs()=default
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_cmd_srs.h:71
MYSQL_LEX_STRING m_definition
The definition of the new SRS.
Definition: sql_cmd_srs.h:100
MYSQL_LEX_STRING m_srs_name
The name of the new SRS.
Definition: sql_cmd_srs.h:96
MYSQL_LEX_STRING m_organization
Organization that is the source of the SRS definition.
Definition: sql_cmd_srs.h:102
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_cmd_srs.cc:164
void init(bool or_replace, bool if_not_exists, gis::srid_t srid, MYSQL_LEX_STRING srs_name, MYSQL_LEX_STRING definition, MYSQL_LEX_STRING organization, gis::srid_t organization_coordsys_id, MYSQL_LEX_STRING description)
Definition: sql_cmd_srs.h:58
bool fill_srs(dd::Spatial_reference_system *srs)
Fill an SRS with information from this CREATE statement (except the ID).
Definition: sql_cmd_srs.cc:109
bool m_or_replace
Whether OR REPLACE was specified.
Definition: sql_cmd_srs.h:87
bool m_if_not_exists
Whether IF NOT EXISTS was specified.
Definition: sql_cmd_srs.h:89
gis::srid_t m_organization_coordsys_id
Source organization's SRS ID.
Definition: sql_cmd_srs.h:104
MYSQL_LEX_STRING m_description
Description of the new SRS.
Definition: sql_cmd_srs.h:106
gis::srid_t m_srid
The SRID of the new SRS.
Definition: sql_cmd_srs.h:91
Definition: sql_cmd_srs.h:109
bool m_if_exists
Whether IF EXISTS was specified.
Definition: sql_cmd_srs.h:120
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_cmd_srs.cc:236
gis::srid_t m_srid
SRID of the SRS to drop.
Definition: sql_cmd_srs.h:118
Sql_cmd_drop_srs(gis::srid_t srid, bool if_exists)
Definition: sql_cmd_srs.h:111
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_cmd_srs.h:113
Representation of an SQL command.
Definition: sql_cmd.h:64
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:922
Definition: spatial_reference_system.h:52
enum_sql_command
Definition: my_sqlcommand.h:45
@ SQLCOM_CREATE_SRS
Definition: my_sqlcommand.h:203
@ SQLCOM_DROP_SRS
Definition: my_sqlcommand.h:204
std::uint32_t srid_t
A spatial reference system ID (SRID).
Definition: srid.h:32
Representation of an SQL command.
Definition: mysql_lex_string.h:34
Definition: sql_cmd_srs.h:40
MYSQL_LEX_STRING description
Definition: sql_cmd_srs.h:45
MYSQL_LEX_STRING definition
Definition: sql_cmd_srs.h:42
Sql_cmd_srs_attributes()
Definition: sql_cmd_srs.h:47
MYSQL_LEX_STRING srs_name
Definition: sql_cmd_srs.h:41
MYSQL_LEX_STRING organization
Definition: sql_cmd_srs.h:43
unsigned long long organization_coordsys_id
Definition: sql_cmd_srs.h:44