MySQL 9.1.0
Source Code Documentation
parse_tree_column_attrs.h
Go to the documentation of this file.
1/* Copyright (c) 2016, 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#ifndef PARSE_TREE_COL_ATTRS_INCLUDED
25#define PARSE_TREE_COL_ATTRS_INCLUDED
26
27#include <assert.h>
28#include <sys/types.h> // ulong, uint. TODO: replace with cstdint
29
30#include <optional>
31#include <type_traits>
32#include <vector>
33
34#include "field_types.h"
35#include "lex_string.h"
36#include "my_alloc.h"
37#include "my_base.h"
38#include "my_compiler.h"
39
40#include "my_inttypes.h"
41#include "my_sys.h"
43#include "mysql_com.h"
44#include "mysqld_error.h"
45#include "sql/derror.h"
46#include "sql/field.h"
47#include "sql/gis/srid.h"
48#include "sql/item.h"
49#include "sql/item_timefunc.h"
50#include "sql/mem_root_array.h"
51#include "sql/parse_location.h"
52#include "sql/parse_tree_helpers.h" // move_cf_appliers
54#include "sql/parser_yystype.h"
55#include "sql/sql_alter.h"
56#include "sql/sql_check_constraint.h" // Sql_check_constraint_spec
57#include "sql/sql_class.h"
58#include "sql/sql_error.h"
59#include "sql/sql_lex.h"
60#include "sql/sql_list.h"
61#include "sql/sql_parse.h"
63
64class String;
65
66/**
67 Parse context for column type attribute specific parse tree nodes.
68
69 For internal use in the contextualization code.
70
71 @ingroup ptn_column_attrs ptn_gcol_attrs
72*/
74 const bool is_generated; ///< Owner column is a generated one.
75 std::vector<CreateFieldApplier> cf_appliers;
76 Column_parse_context(THD *thd_arg, Query_block *select_arg, bool is_generated)
77 : Parse_context(thd_arg, select_arg), is_generated(is_generated) {}
78};
79
80/**
81 Base class for all column attributes in @SQL{CREATE/ALTER TABLE}
82
83 @ingroup ptn_column_attrs ptn_gcol_attrs
84*/
85class PT_column_attr_base : public Parse_tree_node_tmpl<Column_parse_context> {
86 protected:
87 explicit PT_column_attr_base(const POS &pos)
89
90 public:
92
93 virtual void apply_type_flags(ulong *) const {}
94 virtual void apply_alter_info_flags(ulonglong *) const {}
95 virtual void apply_comment(LEX_CSTRING *) const {}
96 virtual void apply_default_value(Item **) const {}
98 virtual void apply_on_update_value(Item **) const {}
99 virtual void apply_srid_modifier(std::optional<gis::srid_t> *) const {}
101 const CHARSET_INFO **to [[maybe_unused]],
102 bool *has_explicit_collation
103 [[maybe_unused]]) const {
104 return false;
105 }
107 Sql_check_constraint_spec_list *check_const_list [[maybe_unused]]) {
108 return false;
109 }
110
111 /**
112 Check for the [NOT] ENFORCED characteristic.
113
114 @returns true if the [NOT] ENFORCED follows the CHECK(...) clause,
115 false otherwise.
116 */
117 virtual bool has_constraint_enforcement() const { return false; }
118
119 /**
120 Check if constraint is enforced.
121 Method must be called only when has_constraint_enforcement() is true (i.e
122 when [NOT] ENFORCED follows the CHECK(...) clause).
123
124 @returns true if constraint is enforced.
125 false otherwise.
126 */
127 virtual bool is_constraint_enforced() const { return false; }
128
129 /**
130 Update the ENFORCED/NOT ENFORCED state of the CHECK constraint.
131
132 @param enforced true if ENFORCED, false if NOT ENFORCED.
133
134 @returns false if success, true if error (e.g. if [NOT] ENFORCED follows
135 something other than the CHECK clause.)
136 */
137 virtual bool set_constraint_enforcement(bool enforced [[maybe_unused]]) {
138 return true; // error
139 }
140};
141
142/**
143 Node for the @SQL{NULL} column attribute
144
145 @ingroup ptn_column_attrs
146*/
148 public:
149 explicit PT_null_column_attr(const POS &pos) : PT_column_attr_base(pos) {}
150 void apply_type_flags(ulong *type_flags) const override {
151 *type_flags &= ~NOT_NULL_FLAG;
152 *type_flags |= EXPLICIT_NULL_FLAG;
153 }
154};
155
156/**
157 Node for the @SQL{NOT NULL} column attribute
158
159 @ingroup ptn_column_attrs
160*/
162 public:
163 explicit PT_not_null_column_attr(const POS &pos) : PT_column_attr_base(pos) {}
164 void apply_type_flags(ulong *type_flags) const override {
165 *type_flags |= NOT_NULL_FLAG;
166 }
167};
168
169/**
170 Node for the @SQL{NOT SECONDARY} column attribute
171
172 @ingroup ptn_column_attrs
173*/
175 public:
176 explicit PT_secondary_column_attr(const POS &pos)
177 : PT_column_attr_base(pos) {}
178 void apply_type_flags(unsigned long *type_flags) const override {
179 *type_flags |= NOT_SECONDARY_FLAG;
180 }
181};
182
183/**
184 Node for the @SQL{UNIQUE [KEY]} column attribute
185
186 @ingroup ptn_column_attrs
187*/
189 public:
190 explicit PT_unique_key_column_attr(const POS &pos)
191 : PT_column_attr_base(pos) {}
192
193 void apply_type_flags(ulong *type_flags) const override {
194 *type_flags |= UNIQUE_FLAG;
195 }
196
197 void apply_alter_info_flags(ulonglong *flags) const override {
199 }
200};
201
202/**
203 Node for the @SQL{PRIMARY [KEY]} column attribute
204
205 @ingroup ptn_column_attrs
206*/
208 public:
209 explicit PT_primary_key_column_attr(const POS &pos)
210 : PT_column_attr_base(pos) {}
211
212 void apply_type_flags(ulong *type_flags) const override {
213 *type_flags |= PRI_KEY_FLAG | NOT_NULL_FLAG;
214 }
215
216 void apply_alter_info_flags(ulonglong *flags) const override {
218 }
219};
220
221/**
222 Node for the @SQL{[CONSTRAINT [symbol]] CHECK '(' expr ')'} column attribute.
223
224 @ingroup ptn_column_attrs
225*/
229
230 public:
232 Item *expr)
233 : super(pos) {
235 col_cc_spec.check_expr = expr;
236 }
237
238 bool set_constraint_enforcement(bool enforced) override {
239 col_cc_spec.is_enforced = enforced;
240 return false;
241 }
242
243 void apply_alter_info_flags(ulonglong *flags) const override {
245 }
246
248 Sql_check_constraint_spec_list *check_const_list) override {
249 assert(check_const_list != nullptr);
250 return (check_const_list->push_back(&col_cc_spec));
251 }
252
254 return (super::do_contextualize(pc) ||
256 }
257};
258
259/**
260 Node for the @SQL{[NOT] ENFORCED} column attribute.
261
262 @ingroup ptn_column_attrs
263*/
265 public:
266 explicit PT_constraint_enforcement_attr(const POS &pos, bool enforced)
267 : PT_column_attr_base(pos), m_enforced(enforced) {}
268
269 bool has_constraint_enforcement() const override { return true; }
270
271 bool is_constraint_enforced() const override { return m_enforced; }
272
273 private:
274 const bool m_enforced;
275};
276
277/**
278 Node for the @SQL{COMMENT @<comment@>} column attribute
279
280 @ingroup ptn_column_attrs
281*/
284
285 public:
286 explicit PT_comment_column_attr(const POS &pos, const LEX_CSTRING &comment)
288
289 void apply_comment(LEX_CSTRING *to) const override { *to = comment; }
290};
291
292/**
293 Node for the @SQL{COLLATE @<collation@>} column attribute
294
295 @ingroup ptn_column_attrs
296*/
298 public:
301 assert(m_collation != nullptr);
302 }
303
305 bool *has_explicit_collation) const override {
306 if (*has_explicit_collation) {
307 pc->thd->syntax_error_at(m_pos, ER_INVALID_MULTIPLE_CLAUSES, "COLLATE");
308 return true;
309 }
310 *has_explicit_collation = true;
312 }
313
314 private:
316};
317
318// Specific to non-generated columns only:
319
320/**
321 Node for the @SQL{DEFAULT @<expression@>} column attribute
322
323 @ingroup ptn_not_gcol_attr
324*/
327
329
330 public:
331 explicit PT_default_column_attr(const POS &pos, Item *item)
332 : super(pos), item(item) {}
333 void apply_default_value(Item **value) const override { *value = item; }
334
336 if (pc->is_generated) {
337 my_error(ER_WRONG_USAGE, MYF(0), "DEFAULT", "generated column");
338 return true;
339 }
340 return super::do_contextualize(pc) || item->itemize(pc, &item);
341 }
342 void apply_type_flags(ulong *type_flags) const override {
343 if (item->type() == Item::NULL_ITEM) *type_flags |= EXPLICIT_NULL_FLAG;
344 }
345};
346
347/**
348 Node for the @SQL{UPDATE NOW[([@<precision@>])]} column attribute
349
350 @ingroup ptn_not_gcol_attr
351*/
354
356 Item *item = nullptr;
357
358 public:
360 : super(pos), precision(precision) {}
361 void apply_on_update_value(Item **value) const override { *value = item; }
362
364 if (pc->is_generated) {
365 my_error(ER_WRONG_USAGE, MYF(0), "ON UPDATE", "generated column");
366 return true;
367 }
368 if (super::do_contextualize(pc)) return true;
369
371 return item == nullptr;
372 }
373};
374
375/**
376 Node for the @SQL{AUTO_INCREMENT} column attribute
377
378 @ingroup ptn_not_gcol_attr
379*/
382
383 public:
385 : PT_column_attr_base(pos) {}
386
387 void apply_type_flags(ulong *type_flags) const override {
388 *type_flags |= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG;
389 }
391 if (pc->is_generated) {
392 my_error(ER_WRONG_USAGE, MYF(0), "AUTO_INCREMENT", "generated column");
393 return true;
394 }
395 return super::do_contextualize(pc);
396 }
397};
398
399/**
400 Node for the @SQL{SERIAL DEFAULT VALUE} column attribute
401
402 @ingroup ptn_not_gcol_attr
403*/
406
407 public:
408 explicit PT_serial_default_value_column_attr(const POS &pos) : super(pos) {}
409
410 void apply_type_flags(ulong *type_flags) const override {
412 }
413 void apply_alter_info_flags(ulonglong *flags) const override {
415 }
417 if (pc->is_generated) {
418 my_error(ER_WRONG_USAGE, MYF(0), "SERIAL DEFAULT VALUE",
419 "generated column");
420 return true;
421 }
422 return super::do_contextualize(pc);
423 }
424};
425
426/**
427 Node for the @SQL{COLUMN_FORMAT @<DEFAULT|FIXED|DYNAMIC@>} column attribute
428
429 @ingroup ptn_not_gcol_attr
430*/
433
435
436 public:
439 : super(pos), format(format) {}
440
441 void apply_type_flags(ulong *type_flags) const override {
442 *type_flags &= ~(FIELD_FLAGS_COLUMN_FORMAT_MASK);
443 *type_flags |= format << FIELD_FLAGS_COLUMN_FORMAT;
444 }
446 if (pc->is_generated) {
447 my_error(ER_WRONG_USAGE, MYF(0), "COLUMN_FORMAT", "generated column");
448 return true;
449 }
450 return super::do_contextualize(pc);
451 }
452};
453
454/**
455 Node for the @SQL{STORAGE @<DEFAULT|DISK|MEMORY@>} column attribute
456
457 @ingroup ptn_not_gcol_attr
458*/
461
463
464 public:
466 : super(pos), media(media) {}
467
468 void apply_type_flags(ulong *type_flags) const override {
469 *type_flags &= ~(FIELD_FLAGS_STORAGE_MEDIA_MASK);
470 *type_flags |= media << FIELD_FLAGS_STORAGE_MEDIA;
471 }
473 if (pc->is_generated) {
474 my_error(ER_WRONG_USAGE, MYF(0), "STORAGE", "generated column");
475 return true;
476 }
477 return super::do_contextualize(pc);
478 }
479};
480
481/// Node for the SRID column attribute
484
486
487 public:
488 explicit PT_srid_column_attr(const POS &pos, gis::srid_t srid)
489 : super(pos), m_srid(srid) {}
490
491 void apply_srid_modifier(std::optional<gis::srid_t> *srid) const override {
492 *srid = m_srid;
493 }
494};
495
496/// Node for the generated default value, column attribute
499
500 public:
502 : super(pos) {
505 }
506
508 Value_generator **default_value_expression) override {
509 *default_value_expression = &m_default_value_expression;
510 }
511
513 // GC and default value expressions are mutually exclusive and thus only
514 // one is allowed to be present on the same column definition.
515 if (pc->is_generated) {
516 my_error(ER_WRONG_USAGE, MYF(0), "DEFAULT", "generated column");
517 return true;
518 }
519 Parse_context expr_pc(pc->thd, pc->select);
520 return super::do_contextualize(pc) ||
523 }
524
525 private:
527};
528
529/**
530 Node for the @SQL{VISIBLE|INVISIBLE} column attribute
531
532 @ingroup ptn_column_attrs
533*/
536
537 public:
538 explicit PT_column_visibility_attr(const POS &pos, bool is_visible)
539 : super(pos), m_is_visible(is_visible) {}
540 void apply_type_flags(unsigned long *type_flags) const override {
541 *type_flags &= ~FIELD_IS_INVISIBLE;
542 if (!m_is_visible) *type_flags |= FIELD_IS_INVISIBLE;
543 }
544
545 private:
546 const bool m_is_visible;
547};
548
549// Type nodes:
550
551/**
552 Base class for all column type nodes
553
554 @ingroup ptn_column_types
555*/
556class PT_type : public Parse_tree_node {
557 public:
559
560 protected:
561 explicit PT_type(const POS &pos, enum_field_types type)
562 : Parse_tree_node(pos), type(type) {}
563
564 public:
565 virtual ulong get_type_flags() const { return 0; }
566 virtual const char *get_length() const { return nullptr; }
567 virtual const char *get_dec() const { return nullptr; }
568 virtual const CHARSET_INFO *get_charset() const { return nullptr; }
569 virtual uint get_uint_geom_type() const { return 0; }
570 virtual List<String> *get_interval_list() const { return nullptr; }
571 virtual bool is_serial_type() const { return false; }
572};
573
574/**
575 Node for numeric types
576
577 Type list:
578 * NUMERIC, REAL, DOUBLE, DECIMAL and FIXED,
579 * INTEGER, INT, INT1, INT2, INT3, INT4, TINYINT, SMALLINT, MEDIUMINT and
580 BIGINT.
581
582 @ingroup ptn_column_types
583*/
584class PT_numeric_type : public PT_type {
585 const char *length;
586 const char *dec;
587 ulong options;
588
589 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
590
591 public:
592 PT_numeric_type(const POS &pos, THD *thd, Numeric_type type_arg,
593 const char *length, const char *dec, ulong options)
594 : PT_type(pos, static_cast<Parent_type>(type_arg)),
595 length(length),
596 dec(dec),
598 assert((options & ~(UNSIGNED_FLAG | ZEROFILL_FLAG)) == 0);
599
600 if (type_arg != Numeric_type::DECIMAL && dec != nullptr) {
602 ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT,
603 ER_THD(thd, ER_WARN_DEPRECATED_FLOAT_DIGITS));
604 }
605 if (options & UNSIGNED_FLAG) {
607 ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT,
608 ER_THD(thd, ER_WARN_DEPRECATED_FLOAT_UNSIGNED));
609 }
610 }
611 PT_numeric_type(const POS &pos, THD *thd, Int_type type_arg,
612 const char *length, ulong options)
613 : PT_type(pos, static_cast<enum_field_types>(type_arg)),
614 length(length),
615 dec(nullptr),
617 assert((options & ~(UNSIGNED_FLAG | ZEROFILL_FLAG)) == 0);
618
619 if (length != nullptr) {
621 ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT,
622 ER_THD(thd, ER_WARN_DEPRECATED_INTEGER_DISPLAY_WIDTH));
623 }
624 }
625
626 ulong get_type_flags() const override {
628 }
629 const char *get_length() const override { return length; }
630 const char *get_dec() const override { return dec; }
631};
632
633/**
634 Node for the BIT type
635
636 @ingroup ptn_column_types
637*/
638class PT_bit_type : public PT_type {
639 const char *length;
640
641 public:
642 explicit PT_bit_type(const POS &pos)
643 : PT_type(pos, MYSQL_TYPE_BIT), length("1") {}
644 explicit PT_bit_type(const POS &pos, const char *length)
646
647 const char *get_length() const override { return length; }
648};
649
650/**
651 Node for the BOOL/BOOLEAN type
652
653 @ingroup ptn_column_types
654*/
655class PT_boolean_type : public PT_type {
656 public:
657 explicit PT_boolean_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_TINY) {}
658 const char *get_length() const override { return "1"; }
659};
660
661enum class Char_type : ulong {
665};
666
667class PT_char_type : public PT_type {
668 const char *length;
670 const bool force_binary;
671
672 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
673
674 public:
675 PT_char_type(const POS &pos, Char_type char_type, const char *length,
676 const CHARSET_INFO *charset, bool force_binary = false)
677 : PT_type(pos, static_cast<Parent_type>(char_type)),
678 length(length),
681 assert(charset == nullptr || !force_binary);
682 }
683 PT_char_type(const POS &pos, Char_type char_type, const CHARSET_INFO *charset,
684 bool force_binary = false)
685 : PT_char_type(pos, char_type, "1", charset, force_binary) {}
686 ulong get_type_flags() const override {
687 return force_binary ? BINCMP_FLAG : 0;
688 }
689 const char *get_length() const override { return length; }
690 const CHARSET_INFO *get_charset() const override { return charset; }
691};
692
693class PT_vector_type : public PT_type {
695
696 public:
697 PT_vector_type(const POS &pos, const char *length)
698 : PT_type(pos, MYSQL_TYPE_VECTOR) {
699 const char *length_arg = length == nullptr ? "2048" : length;
700 uint vector_length = atoi(length_arg) * sizeof(float);
701 sprintf(vector_length_buffer, "%u", vector_length);
702 }
703
704 const char *get_length() const override { return vector_length_buffer; }
705 const CHARSET_INFO *get_charset() const override { return &my_charset_bin; }
706};
707
708enum class Blob_type {
712};
713
714/**
715 Node for BLOB types
716
717 Types: BLOB, TINYBLOB, MEDIUMBLOB, LONGBLOB, LONG, LONG VARBINARY,
718 LONG VARCHAR, TEXT, TINYTEXT, MEDIUMTEXT, LONGTEXT.
719
720 @ingroup ptn_column_types
721*/
722class PT_blob_type : public PT_type {
723 const char *length;
725 const bool force_binary;
726
727 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
728
729 public:
730 PT_blob_type(const POS &pos, Blob_type blob_type, const CHARSET_INFO *charset,
731 bool force_binary = false)
732 : PT_type(pos, static_cast<Parent_type>(blob_type)),
736 assert(charset == nullptr || !force_binary);
737 }
738 explicit PT_blob_type(const POS &pos, const char *length)
739 : PT_type(pos, MYSQL_TYPE_BLOB),
740 length(length),
742 force_binary(false) {}
743
744 ulong get_type_flags() const override {
745 return force_binary ? BINCMP_FLAG : 0;
746 }
747 const CHARSET_INFO *get_charset() const override { return charset; }
748 const char *get_length() const override { return length; }
749};
750
751/**
752 Node for the YEAR type
753
754 @ingroup ptn_column_types
755*/
756class PT_year_type : public PT_type {
757 public:
758 explicit PT_year_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_YEAR) {}
759};
760
761/**
762 Node for the DATE type
763
764 @ingroup ptn_column_types
765*/
766class PT_date_type : public PT_type {
767 public:
768 explicit PT_date_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_DATE) {}
769};
770
771enum class Time_type : ulong {
774};
775
776/**
777 Node for the TIME, TIMESTAMP and DATETIME types
778
779 @ingroup ptn_column_types
780*/
781class PT_time_type : public PT_type {
782 const char *dec;
783
784 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
785
786 public:
787 PT_time_type(const POS &pos, Time_type time_type, const char *dec)
788 : PT_type(pos, static_cast<Parent_type>(time_type)), dec(dec) {}
789
790 const char *get_dec() const override { return dec; }
791};
792
793/**
794 Node for the TIMESTAMP type
795
796 @ingroup ptn_column_types
797*/
799 typedef PT_type super;
800
801 const char *dec;
803
804 public:
805 explicit PT_timestamp_type(const POS &pos, const char *dec)
807
808 const char *get_dec() const override { return dec; }
809 ulong get_type_flags() const override { return type_flags; }
810
811 bool do_contextualize(Parse_context *pc) override {
812 if (super::do_contextualize(pc)) return true;
813 /*
814 TIMESTAMP fields are NOT NULL by default, unless the variable
815 explicit_defaults_for_timestamp is true.
816 */
817 if (!pc->thd->variables.explicit_defaults_for_timestamp)
819 /*
820 To flag the current statement as dependent for binary
821 logging on the session var. Extra copying to Lex is
822 done in case prepared stmt.
823 */
826
827 return false;
828 }
829};
830
831/**
832 Node for spatial types
833
834 Types: GEOMETRY, GEOMCOLLECTION/GEOMETRYCOLLECTION, POINT, MULTIPOINT,
835 LINESTRING, MULTILINESTRING, POLYGON, MULTIPOLYGON
836
837 @ingroup ptn_column_types
838*/
839class PT_spacial_type : public PT_type {
841
842 public:
845
846 const CHARSET_INFO *get_charset() const override { return &my_charset_bin; }
847 uint get_uint_geom_type() const override { return geo_type; }
848 const char *get_length() const override { return nullptr; }
849};
850
852
853template <Enum_type enum_type>
857 const bool force_binary;
858
859 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
860
861 public:
863 const CHARSET_INFO *charset, bool force_binary)
864 : PT_type(pos, static_cast<Parent_type>(enum_type)),
868 assert(charset == nullptr || !force_binary);
869 }
870
871 const CHARSET_INFO *get_charset() const override { return charset; }
872 ulong get_type_flags() const override {
873 return force_binary ? BINCMP_FLAG : 0;
874 }
875 List<String> *get_interval_list() const override { return interval_list; }
876};
877
878/**
879 Node for the ENUM type
880
881 @ingroup ptn_column_types
882*/
884
885/**
886 Node for the SET type
887
888 @ingroup ptn_column_types
889*/
891
892class PT_serial_type : public PT_type {
893 public:
894 explicit PT_serial_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_LONGLONG) {}
895
896 ulong get_type_flags() const override {
898 }
899 bool is_serial_type() const override { return true; }
900};
901
902/**
903 Node for the JSON type
904
905 @ingroup ptn_column_types
906*/
907class PT_json_type : public PT_type {
908 public:
909 explicit PT_json_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_JSON) {}
910 const CHARSET_INFO *get_charset() const override { return &my_charset_bin; }
911};
912
913/**
914 Base class for both generated and regular column definitions
915
916 @ingroup ptn_create_table
917*/
921
922 public:
924 ulong type_flags = 0;
925 const char *length = nullptr;
926 const char *dec = nullptr;
927 const CHARSET_INFO *charset = nullptr;
933 Item *default_value = nullptr;
936 /// Holds the expression to generate default values
938 std::optional<gis::srid_t> m_srid{};
939 // List of column check constraint's specification.
941
942 protected:
944
945 explicit PT_field_def_base(const POS &pos, PT_type *type_node)
946 : super(pos), type_node(type_node) {}
947
948 public:
949 bool do_contextualize(Parse_context *pc) override {
951 return true;
952
956 dec = type_node->get_dec();
962 if (check_const_spec_list == nullptr) return true; // OOM
963 return false;
964 }
965
966 protected:
967 template <class T>
969 Mem_root_array<T *> *attrs) {
970 if (attrs != nullptr) {
971 for (auto attr : *attrs) {
972 if (attr->contextualize(pc)) return true;
973 attr->apply_type_flags(&type_flags);
974 attr->apply_alter_info_flags(&alter_info_flags);
975 attr->apply_comment(&comment);
976 attr->apply_default_value(&default_value);
977 attr->apply_gen_default_value(&default_val_info);
978 attr->apply_on_update_value(&on_update_value);
979 attr->apply_srid_modifier(&m_srid);
980 if (attr->apply_collation(pc, &charset, &has_explicit_collation))
981 return true;
982 if (attr->add_check_constraints(check_const_spec_list)) return true;
983 }
984 }
985 return false;
986 }
987};
988
989/**
990 Base class for regular (non-generated) column definition nodes
991
992 @ingroup ptn_create_table
993*/
996
998
999 public:
1000 PT_field_def(const POS &pos, PT_type *type_node_arg,
1002 : super(pos, type_node_arg), opt_attrs(opt_attrs) {}
1003
1004 bool do_contextualize(Parse_context *pc_arg) override {
1005 Column_parse_context pc(pc_arg->thd, pc_arg->select, false);
1007 return true;
1008
1009 move_cf_appliers(pc_arg, &pc);
1010 return false;
1011 }
1012};
1013
1014/**
1015 Base class for generated column definition nodes
1016
1017 @ingroup ptn_create_table
1018*/
1021
1025
1026 public:
1027 PT_generated_field_def(const POS &pos, PT_type *type_node_arg, Item *expr,
1030 : super(pos, type_node_arg),
1032 expr(expr),
1034
1035 bool do_contextualize(Parse_context *pc_arg) override {
1036 Column_parse_context pc(pc_arg->thd, pc_arg->select, true);
1038 expr->itemize(&pc, &expr))
1039 return true;
1040
1041 // column of type serial cannot be generated
1042 if (type_node->is_serial_type()) {
1043 my_error(ER_WRONG_USAGE, MYF(0), "SERIAL", "generated column");
1044 return true;
1045 }
1046
1048 if (gcol_info == nullptr) return true; // OOM
1053
1054 return false;
1055 }
1056};
1057
1059
1060#endif /* PARSE_TREE_COL_ATTRS_INCLUDED */
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
ulonglong flags
Definition: sql_alter.h:429
@ ADD_CHECK_CONSTRAINT
Set for add check constraint.
Definition: sql_alter.h:319
@ ALTER_ADD_INDEX
Set for ADD INDEX | ADD KEY | ADD PRIMARY KEY | ADD UNIQUE KEY | ADD UNIQUE INDEX | ALTER ADD [COLUMN...
Definition: sql_alter.h:229
geometry_type
Definition: field.h:720
Definition: item_timefunc.h:1187
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:930
@ NULL_ITEM
A NULL value.
Definition: item.h:975
virtual bool itemize(Parse_context *pc, Item **res) final
The same as contextualize() but with additional parameter.
Definition: item.h:1249
virtual enum Type type() const =0
Definition: sql_list.h:494
bool push_back(const Element_type &element)
Adds a new element at the end of the array, after its current last element.
Definition: mem_root_array.h:186
Node for the AUTO_INCREMENT column attribute.
Definition: parse_tree_column_attrs.h:380
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:381
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:387
PT_auto_increment_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:384
bool do_contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:390
Node for the BIT type.
Definition: parse_tree_column_attrs.h:638
PT_bit_type(const POS &pos)
Definition: parse_tree_column_attrs.h:642
const char * get_length() const override
Definition: parse_tree_column_attrs.h:647
const char * length
Definition: parse_tree_column_attrs.h:639
PT_bit_type(const POS &pos, const char *length)
Definition: parse_tree_column_attrs.h:644
Node for BLOB types.
Definition: parse_tree_column_attrs.h:722
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:724
PT_blob_type(const POS &pos, Blob_type blob_type, const CHARSET_INFO *charset, bool force_binary=false)
Definition: parse_tree_column_attrs.h:730
const char * length
Definition: parse_tree_column_attrs.h:723
PT_blob_type(const POS &pos, const char *length)
Definition: parse_tree_column_attrs.h:738
const char * get_length() const override
Definition: parse_tree_column_attrs.h:748
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:747
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:744
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:727
const bool force_binary
Definition: parse_tree_column_attrs.h:725
Node for the BOOL/BOOLEAN type.
Definition: parse_tree_column_attrs.h:655
const char * get_length() const override
Definition: parse_tree_column_attrs.h:658
PT_boolean_type(const POS &pos)
Definition: parse_tree_column_attrs.h:657
Definition: parse_tree_column_attrs.h:667
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:672
PT_char_type(const POS &pos, Char_type char_type, const char *length, const CHARSET_INFO *charset, bool force_binary=false)
Definition: parse_tree_column_attrs.h:675
const char * length
Definition: parse_tree_column_attrs.h:668
const char * get_length() const override
Definition: parse_tree_column_attrs.h:689
PT_char_type(const POS &pos, Char_type char_type, const CHARSET_INFO *charset, bool force_binary=false)
Definition: parse_tree_column_attrs.h:683
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:686
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:690
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:669
const bool force_binary
Definition: parse_tree_column_attrs.h:670
Node for the [CONSTRAINT [symbol]] CHECK '(' expr ')' column attribute.
Definition: parse_tree_column_attrs.h:226
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:243
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:227
bool add_check_constraints(Sql_check_constraint_spec_list *check_const_list) override
Definition: parse_tree_column_attrs.h:247
bool set_constraint_enforcement(bool enforced) override
Update the ENFORCED/NOT ENFORCED state of the CHECK constraint.
Definition: parse_tree_column_attrs.h:238
PT_check_constraint_column_attr(const POS &pos, LEX_STRING &name, Item *expr)
Definition: parse_tree_column_attrs.h:231
Sql_check_constraint_spec col_cc_spec
Definition: parse_tree_column_attrs.h:228
bool do_contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:253
Node for the COLLATE <collation> column attribute.
Definition: parse_tree_column_attrs.h:297
bool apply_collation(Column_parse_context *pc, const CHARSET_INFO **to, bool *has_explicit_collation) const override
Definition: parse_tree_column_attrs.h:304
PT_collate_column_attr(const POS &pos, const CHARSET_INFO *collation)
Definition: parse_tree_column_attrs.h:299
const CHARSET_INFO *const m_collation
Definition: parse_tree_column_attrs.h:315
Base class for all column attributes in CREATE/ALTER TABLE
Definition: parse_tree_column_attrs.h:85
decltype(Alter_info::flags) alter_info_flags_t
Definition: parse_tree_column_attrs.h:91
virtual bool is_constraint_enforced() const
Check if constraint is enforced.
Definition: parse_tree_column_attrs.h:127
virtual bool set_constraint_enforcement(bool enforced)
Update the ENFORCED/NOT ENFORCED state of the CHECK constraint.
Definition: parse_tree_column_attrs.h:137
virtual void apply_alter_info_flags(ulonglong *) const
Definition: parse_tree_column_attrs.h:94
virtual void apply_srid_modifier(std::optional< gis::srid_t > *) const
Definition: parse_tree_column_attrs.h:99
virtual bool apply_collation(Column_parse_context *, const CHARSET_INFO **to, bool *has_explicit_collation) const
Definition: parse_tree_column_attrs.h:100
virtual void apply_gen_default_value(Value_generator **)
Definition: parse_tree_column_attrs.h:97
PT_column_attr_base(const POS &pos)
Definition: parse_tree_column_attrs.h:87
virtual void apply_on_update_value(Item **) const
Definition: parse_tree_column_attrs.h:98
virtual void apply_type_flags(ulong *) const
Definition: parse_tree_column_attrs.h:93
virtual void apply_comment(LEX_CSTRING *) const
Definition: parse_tree_column_attrs.h:95
virtual bool add_check_constraints(Sql_check_constraint_spec_list *check_const_list)
Definition: parse_tree_column_attrs.h:106
virtual bool has_constraint_enforcement() const
Check for the [NOT] ENFORCED characteristic.
Definition: parse_tree_column_attrs.h:117
virtual void apply_default_value(Item **) const
Definition: parse_tree_column_attrs.h:96
Node for the COLUMN_FORMAT <DEFAULT|FIXED|DYNAMIC> column attribute.
Definition: parse_tree_column_attrs.h:431
bool do_contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:445
PT_column_format_column_attr(const POS &pos, column_format_type format)
Definition: parse_tree_column_attrs.h:437
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:432
column_format_type format
Definition: parse_tree_column_attrs.h:434
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:441
Node for the VISIBLE|INVISIBLE column attribute.
Definition: parse_tree_column_attrs.h:534
PT_column_visibility_attr(const POS &pos, bool is_visible)
Definition: parse_tree_column_attrs.h:538
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:535
void apply_type_flags(unsigned long *type_flags) const override
Definition: parse_tree_column_attrs.h:540
const bool m_is_visible
Definition: parse_tree_column_attrs.h:546
Node for the COMMENT <comment> column attribute.
Definition: parse_tree_column_attrs.h:282
void apply_comment(LEX_CSTRING *to) const override
Definition: parse_tree_column_attrs.h:289
PT_comment_column_attr(const POS &pos, const LEX_CSTRING &comment)
Definition: parse_tree_column_attrs.h:286
const LEX_CSTRING comment
Definition: parse_tree_column_attrs.h:283
Node for the [NOT] ENFORCED column attribute.
Definition: parse_tree_column_attrs.h:264
bool has_constraint_enforcement() const override
Check for the [NOT] ENFORCED characteristic.
Definition: parse_tree_column_attrs.h:269
bool is_constraint_enforced() const override
Check if constraint is enforced.
Definition: parse_tree_column_attrs.h:271
PT_constraint_enforcement_attr(const POS &pos, bool enforced)
Definition: parse_tree_column_attrs.h:266
const bool m_enforced
Definition: parse_tree_column_attrs.h:274
Node for the DATE type.
Definition: parse_tree_column_attrs.h:766
PT_date_type(const POS &pos)
Definition: parse_tree_column_attrs.h:768
Node for the DEFAULT <expression> column attribute.
Definition: parse_tree_column_attrs.h:325
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:342
void apply_default_value(Item **value) const override
Definition: parse_tree_column_attrs.h:333
PT_default_column_attr(const POS &pos, Item *item)
Definition: parse_tree_column_attrs.h:331
bool do_contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:335
Item * item
Definition: parse_tree_column_attrs.h:328
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:326
Definition: parse_tree_column_attrs.h:854
PT_enum_type_tmpl(const POS &pos, List< String > *interval_list, const CHARSET_INFO *charset, bool force_binary)
Definition: parse_tree_column_attrs.h:862
List< String > *const interval_list
Definition: parse_tree_column_attrs.h:855
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:856
const bool force_binary
Definition: parse_tree_column_attrs.h:857
List< String > * get_interval_list() const override
Definition: parse_tree_column_attrs.h:875
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:871
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:872
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:859
Base class for both generated and regular column definitions.
Definition: parse_tree_column_attrs.h:918
bool do_contextualize(Parse_context *pc) override
Definition: parse_tree_column_attrs.h:949
bool contextualize_attrs(Column_parse_context *pc, Mem_root_array< T * > *attrs)
Definition: parse_tree_column_attrs.h:968
LEX_CSTRING comment
Definition: parse_tree_column_attrs.h:932
enum_field_types type
Definition: parse_tree_column_attrs.h:923
decltype(Alter_info::flags) alter_info_flags_t
Definition: parse_tree_column_attrs.h:920
Value_generator * gcol_info
Definition: parse_tree_column_attrs.h:935
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:927
List< String > * interval_list
Definition: parse_tree_column_attrs.h:930
const char * dec
Definition: parse_tree_column_attrs.h:926
bool has_explicit_collation
Definition: parse_tree_column_attrs.h:928
Item * on_update_value
Definition: parse_tree_column_attrs.h:934
std::optional< gis::srid_t > m_srid
Definition: parse_tree_column_attrs.h:938
const char * length
Definition: parse_tree_column_attrs.h:925
Parse_tree_node super
Definition: parse_tree_column_attrs.h:919
PT_type * type_node
Definition: parse_tree_column_attrs.h:943
alter_info_flags_t alter_info_flags
Definition: parse_tree_column_attrs.h:931
Item * default_value
Definition: parse_tree_column_attrs.h:933
Value_generator * default_val_info
Holds the expression to generate default values.
Definition: parse_tree_column_attrs.h:937
PT_field_def_base(const POS &pos, PT_type *type_node)
Definition: parse_tree_column_attrs.h:945
Sql_check_constraint_spec_list * check_const_spec_list
Definition: parse_tree_column_attrs.h:940
ulong type_flags
Definition: parse_tree_column_attrs.h:924
uint uint_geom_type
Definition: parse_tree_column_attrs.h:929
Base class for regular (non-generated) column definition nodes.
Definition: parse_tree_column_attrs.h:994
PT_field_def_base super
Definition: parse_tree_column_attrs.h:995
Mem_root_array< PT_column_attr_base * > * opt_attrs
Definition: parse_tree_column_attrs.h:997
bool do_contextualize(Parse_context *pc_arg) override
Definition: parse_tree_column_attrs.h:1004
PT_field_def(const POS &pos, PT_type *type_node_arg, Mem_root_array< PT_column_attr_base * > *opt_attrs)
Definition: parse_tree_column_attrs.h:1000
Node for the generated default value, column attribute.
Definition: parse_tree_column_attrs.h:497
Value_generator m_default_value_expression
Definition: parse_tree_column_attrs.h:526
void apply_gen_default_value(Value_generator **default_value_expression) override
Definition: parse_tree_column_attrs.h:507
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:498
PT_generated_default_val_column_attr(const POS &pos, Item *expr)
Definition: parse_tree_column_attrs.h:501
bool do_contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:512
Base class for generated column definition nodes.
Definition: parse_tree_column_attrs.h:1019
Item * expr
Definition: parse_tree_column_attrs.h:1023
Mem_root_array< PT_column_attr_base * > * opt_attrs
Definition: parse_tree_column_attrs.h:1024
bool do_contextualize(Parse_context *pc_arg) override
Definition: parse_tree_column_attrs.h:1035
PT_field_def_base super
Definition: parse_tree_column_attrs.h:1020
PT_generated_field_def(const POS &pos, PT_type *type_node_arg, Item *expr, Virtual_or_stored virtual_or_stored, Mem_root_array< PT_column_attr_base * > *opt_attrs)
Definition: parse_tree_column_attrs.h:1027
const Virtual_or_stored virtual_or_stored
Definition: parse_tree_column_attrs.h:1022
Node for the JSON type.
Definition: parse_tree_column_attrs.h:907
PT_json_type(const POS &pos)
Definition: parse_tree_column_attrs.h:909
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:910
Node for the NOT NULL column attribute.
Definition: parse_tree_column_attrs.h:161
PT_not_null_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:163
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:164
Node for the NULL column attribute.
Definition: parse_tree_column_attrs.h:147
PT_null_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:149
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:150
Node for numeric types.
Definition: parse_tree_column_attrs.h:584
const char * get_dec() const override
Definition: parse_tree_column_attrs.h:630
PT_numeric_type(const POS &pos, THD *thd, Numeric_type type_arg, const char *length, const char *dec, ulong options)
Definition: parse_tree_column_attrs.h:592
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:589
const char * dec
Definition: parse_tree_column_attrs.h:586
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:626
const char * get_length() const override
Definition: parse_tree_column_attrs.h:629
PT_numeric_type(const POS &pos, THD *thd, Int_type type_arg, const char *length, ulong options)
Definition: parse_tree_column_attrs.h:611
ulong options
Definition: parse_tree_column_attrs.h:587
const char * length
Definition: parse_tree_column_attrs.h:585
Node for the UPDATE NOW[([<precision>])] column attribute.
Definition: parse_tree_column_attrs.h:352
PT_on_update_column_attr(const POS &pos, uint8 precision)
Definition: parse_tree_column_attrs.h:359
bool do_contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:363
const uint8 precision
Definition: parse_tree_column_attrs.h:355
void apply_on_update_value(Item **value) const override
Definition: parse_tree_column_attrs.h:361
Item * item
Definition: parse_tree_column_attrs.h:356
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:353
Node for the PRIMARY [KEY] column attribute.
Definition: parse_tree_column_attrs.h:207
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:216
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:212
PT_primary_key_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:209
Node for the NOT SECONDARY column attribute.
Definition: parse_tree_column_attrs.h:174
PT_secondary_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:176
void apply_type_flags(unsigned long *type_flags) const override
Definition: parse_tree_column_attrs.h:178
Node for the SERIAL DEFAULT VALUE column attribute.
Definition: parse_tree_column_attrs.h:404
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:413
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:405
bool do_contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:416
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:410
PT_serial_default_value_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:408
Definition: parse_tree_column_attrs.h:892
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:896
bool is_serial_type() const override
Definition: parse_tree_column_attrs.h:899
PT_serial_type(const POS &pos)
Definition: parse_tree_column_attrs.h:894
Node for spatial types.
Definition: parse_tree_column_attrs.h:839
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:846
Field::geometry_type geo_type
Definition: parse_tree_column_attrs.h:840
PT_spacial_type(const POS &pos, Field::geometry_type geo_type)
Definition: parse_tree_column_attrs.h:843
uint get_uint_geom_type() const override
Definition: parse_tree_column_attrs.h:847
const char * get_length() const override
Definition: parse_tree_column_attrs.h:848
Node for the SRID column attribute.
Definition: parse_tree_column_attrs.h:482
PT_srid_column_attr(const POS &pos, gis::srid_t srid)
Definition: parse_tree_column_attrs.h:488
void apply_srid_modifier(std::optional< gis::srid_t > *srid) const override
Definition: parse_tree_column_attrs.h:491
gis::srid_t m_srid
Definition: parse_tree_column_attrs.h:485
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:483
Node for the STORAGE <DEFAULT|DISK|MEMORY> column attribute.
Definition: parse_tree_column_attrs.h:459
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:460
bool do_contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:472
ha_storage_media media
Definition: parse_tree_column_attrs.h:462
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:468
PT_storage_media_column_attr(const POS &pos, ha_storage_media media)
Definition: parse_tree_column_attrs.h:465
Node for the TIME, TIMESTAMP and DATETIME types.
Definition: parse_tree_column_attrs.h:781
PT_time_type(const POS &pos, Time_type time_type, const char *dec)
Definition: parse_tree_column_attrs.h:787
const char * dec
Definition: parse_tree_column_attrs.h:782
const char * get_dec() const override
Definition: parse_tree_column_attrs.h:790
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:784
Node for the TIMESTAMP type.
Definition: parse_tree_column_attrs.h:798
ulong type_flags
Definition: parse_tree_column_attrs.h:802
const char * dec
Definition: parse_tree_column_attrs.h:801
const char * get_dec() const override
Definition: parse_tree_column_attrs.h:808
bool do_contextualize(Parse_context *pc) override
Definition: parse_tree_column_attrs.h:811
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:809
PT_timestamp_type(const POS &pos, const char *dec)
Definition: parse_tree_column_attrs.h:805
PT_type super
Definition: parse_tree_column_attrs.h:799
Base class for all column type nodes.
Definition: parse_tree_column_attrs.h:556
virtual bool is_serial_type() const
Definition: parse_tree_column_attrs.h:571
virtual ulong get_type_flags() const
Definition: parse_tree_column_attrs.h:565
virtual const char * get_length() const
Definition: parse_tree_column_attrs.h:566
virtual const CHARSET_INFO * get_charset() const
Definition: parse_tree_column_attrs.h:568
virtual List< String > * get_interval_list() const
Definition: parse_tree_column_attrs.h:570
const enum_field_types type
Definition: parse_tree_column_attrs.h:558
virtual uint get_uint_geom_type() const
Definition: parse_tree_column_attrs.h:569
PT_type(const POS &pos, enum_field_types type)
Definition: parse_tree_column_attrs.h:561
virtual const char * get_dec() const
Definition: parse_tree_column_attrs.h:567
Node for the UNIQUE [KEY] column attribute.
Definition: parse_tree_column_attrs.h:188
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:197
PT_unique_key_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:190
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:193
Definition: parse_tree_column_attrs.h:693
char vector_length_buffer[33]
Definition: parse_tree_column_attrs.h:694
PT_vector_type(const POS &pos, const char *length)
Definition: parse_tree_column_attrs.h:697
const char * get_length() const override
Definition: parse_tree_column_attrs.h:704
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:705
Node for the YEAR type.
Definition: parse_tree_column_attrs.h:756
PT_year_type(const POS &pos)
Definition: parse_tree_column_attrs.h:758
Base class for parse tree nodes (excluding the Parse_tree_root hierarchy)
Definition: parse_tree_node_base.h:231
virtual bool contextualize(Context *pc) final
Definition: parse_tree_node_base.h:319
virtual bool do_contextualize(Column_parse_context *pc)
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_node_base.h:283
POS m_pos
Definition: parse_tree_node_base.h:244
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1159
Class to represent the check constraint specifications obtained from the SQL statement parse.
Definition: sql_check_constraint.h:43
Item * check_expr
Check constraint expression.
Definition: sql_check_constraint.h:80
bool is_enforced
Check constraint state (enforced/not enforced)
Definition: sql_check_constraint.h:86
LEX_STRING name
Name of the check constraint.
Definition: sql_check_constraint.h:77
@ SL_WARNING
Definition: sql_error.h:63
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
LEX * lex
Definition: sql_class.h:1001
void syntax_error_at(const POS &location)
Definition: sql_class.h:4484
System_variables variables
Definition: sql_lexer_thd.h:64
bool binlog_need_explicit_defaults_ts
The member is served for marking a query that CREATEs or ALTERs a table declared with a TIMESTAMP col...
Definition: sql_class.h:2658
MEM_ROOT * mem_root
Definition: sql_lexer_thd.h:40
Used for storing information associated with generated column, default values generated from expressi...
Definition: field.h:485
void set_field_stored(bool stored)
Definition: field.h:538
void set_field_type(enum_field_types fld_type)
Definition: field.h:521
Item * expr_item
Item representing the generation expression.
Definition: field.h:495
Mem_root_array< Sql_check_constraint_spec * > Sql_check_constraint_spec_list
Definition: dd_table.h:50
const char * ER_THD(const THD *thd, int mysql_errno)
Definition: derror.cc:104
This file contains the field type.
enum_field_types
Column types for MySQL Note: Keep include/mysql/components/services/bits/stored_program_bits....
Definition: field_types.h:55
@ MYSQL_TYPE_TIME2
Internal to MySQL.
Definition: field_types.h:75
@ MYSQL_TYPE_VARCHAR
Definition: field_types.h:71
@ MYSQL_TYPE_LONGLONG
Definition: field_types.h:64
@ MYSQL_TYPE_LONG_BLOB
Definition: field_types.h:86
@ MYSQL_TYPE_BLOB
Definition: field_types.h:87
@ MYSQL_TYPE_TINY
Definition: field_types.h:57
@ MYSQL_TYPE_SET
Definition: field_types.h:83
@ MYSQL_TYPE_VECTOR
Definition: field_types.h:77
@ MYSQL_TYPE_JSON
Definition: field_types.h:80
@ MYSQL_TYPE_STRING
Definition: field_types.h:89
@ MYSQL_TYPE_ENUM
Definition: field_types.h:82
@ MYSQL_TYPE_TINY_BLOB
Definition: field_types.h:84
@ MYSQL_TYPE_BIT
Definition: field_types.h:72
@ MYSQL_TYPE_INVALID
Definition: field_types.h:78
@ MYSQL_TYPE_GEOMETRY
Definition: field_types.h:90
@ MYSQL_TYPE_MEDIUM_BLOB
Definition: field_types.h:85
@ MYSQL_TYPE_DATETIME2
Internal to MySQL.
Definition: field_types.h:74
@ MYSQL_TYPE_DATE
Definition: field_types.h:66
@ MYSQL_TYPE_TIMESTAMP2
Definition: field_types.h:73
@ MYSQL_TYPE_YEAR
Definition: field_types.h:69
bool merge_charset_and_collation(const CHARSET_INFO *charset, const CHARSET_INFO *collation, const CHARSET_INFO **to)
(end of group Runtime_Environment)
Definition: sql_parse.cc:7219
void my_error(int nr, myf MyFlags,...)
Fill in and print a previously registered error message.
Definition: my_error.cc:216
#define PRI_KEY_FLAG
Field is part of a primary key.
Definition: mysql_com.h:155
#define FIELD_FLAGS_COLUMN_FORMAT
Field column format, bit 24-25.
Definition: mysql_com.h:187
#define ZEROFILL_FLAG
Field is zerofill.
Definition: mysql_com.h:160
#define UNSIGNED_FLAG
Field is unsigned.
Definition: mysql_com.h:159
#define UNIQUE_FLAG
Intern: Used by sql_yacc.
Definition: mysql_com.h:173
#define AUTO_INCREMENT_FLAG
field is a autoincrement field
Definition: mysql_com.h:165
#define FIELD_FLAGS_COLUMN_FORMAT_MASK
Definition: mysql_com.h:188
#define NOT_NULL_FLAG
Field can't be NULL.
Definition: mysql_com.h:154
#define BINCMP_FLAG
Intern: Used by sql_yacc.
Definition: mysql_com.h:174
#define FIELD_IS_INVISIBLE
Field is explicitly marked as invisible by the user.
Definition: mysql_com.h:198
#define EXPLICIT_NULL_FLAG
Field is explicitly specified as \ NULL by the user.
Definition: mysql_com.h:190
#define FIELD_FLAGS_STORAGE_MEDIA_MASK
Definition: mysql_com.h:186
#define NOT_SECONDARY_FLAG
Field will not be loaded in secondary engine.
Definition: mysql_com.h:196
#define FIELD_FLAGS_STORAGE_MEDIA
Field storage media, bit 22-23.
Definition: mysql_com.h:185
static int flags[50]
Definition: hp_test1.cc:40
constexpr const LEX_CSTRING EMPTY_CSTR
Definition: lex_string.h:48
A better implementation of the UNIX ctype(3) library.
MYSQL_STRINGS_EXPORT CHARSET_INFO my_charset_bin
Definition: ctype-bin.cc:500
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
This file includes constants used by all storage engines.
ha_storage_media
Definition: my_base.h:116
Header for compiler-dependent features.
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
uint8_t uint8
Definition: my_inttypes.h:63
#define MYF(v)
Definition: my_inttypes.h:97
Common header for many mysys elements.
Common definition between mysql server & client.
const char * collation
Definition: audit_api_message_emit.cc:184
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
std::uint32_t srid_t
A spatial reference system ID (SRID).
Definition: srid.h:33
Definition: options.cc:57
Blob_type
Definition: parse_tree_column_attrs.h:708
Enum_type
Definition: parse_tree_column_attrs.h:851
Char_type
Definition: parse_tree_column_attrs.h:661
PT_enum_type_tmpl< Enum_type::ENUM > PT_enum_type
Node for the ENUM type.
Definition: parse_tree_column_attrs.h:883
PT_enum_type_tmpl< Enum_type::SET > PT_set_type
Node for the SET type.
Definition: parse_tree_column_attrs.h:890
Time_type
Definition: parse_tree_column_attrs.h:771
void move_cf_appliers(Parse_context *tddlpc, Column_parse_context *cpc)
Definition: parse_tree_helpers.cc:439
Int_type
Definition: parser_yystype.h:247
Numeric_type
Definition: parser_yystype.h:255
Virtual_or_stored
Definition: parser_yystype.h:245
column_format_type
Definition: field.h:192
void push_warning(THD *thd, Sql_condition::enum_severity_level severity, uint code, const char *message_text)
Push the warning to error list if there is still room in the list.
Definition: sql_error.cc:659
case opt name
Definition: sslopt-case.h:29
Definition: m_ctype.h:421
Parse context for column type attribute specific parse tree nodes.
Definition: parse_tree_column_attrs.h:73
const bool is_generated
Owner column is a generated one.
Definition: parse_tree_column_attrs.h:74
std::vector< CreateFieldApplier > cf_appliers
Definition: parse_tree_column_attrs.h:75
Column_parse_context(THD *thd_arg, Query_block *select_arg, bool is_generated)
Definition: parse_tree_column_attrs.h:76
bool binlog_need_explicit_defaults_ts
Definition: sql_lex.h:4449
Definition: mysql_lex_string.h:40
Definition: mysql_lex_string.h:35
Bison "location" class.
Definition: parse_location.h:43
Environment data for the contextualization phase.
Definition: parse_tree_node_base.h:420
Query_block * select
Current Query_block object.
Definition: parse_tree_node_base.h:423
THD *const thd
Current thread handler.
Definition: parse_tree_node_base.h:421
MEM_ROOT * mem_root
Current MEM_ROOT.
Definition: parse_tree_node_base.h:422