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