1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

MCOL-641 This commit adds support for SIGNED and ZEROFILL keywords in

CREATE TABLE. ZEROFILL is dummy though.

There is a new file with column width utilities.

Array access was replaced by a variable that is calculated only once in
TupleJoiner::updateCPData.
This commit is contained in:
drrtuy
2020-02-18 11:55:51 +03:00
committed by Roman Nozdrin
parent 93170c3b31
commit 2eb5af1d24
6 changed files with 115 additions and 58 deletions

View File

@ -156,6 +156,7 @@ REFERENCES {return REFERENCES;}
RENAME {return RENAME;}
RESTRICT {return RESTRICT;}
SESSION_USER {return SESSION_USER;}
SIGNED {return SIGNED;}
SYSTEM_USER {return SYSTEM_USER;}
SET {return SET;}
SMALLINT {return SMALLINT;}
@ -189,6 +190,7 @@ BOOL {return BOOL;}
BOOLEAN {return BOOLEAN;}
MEDIUMINT {return MEDIUMINT;}
BINARY {return BINARY;}
ZEROFILL {return ZEROFILL;}
\n { lineno++;}

View File

@ -63,6 +63,7 @@ char* copy_string(const char *str);
%pure-parser
%lex-param {void * scanner}
%parse-param {struct ddlpackage::pass_to_bison * x}
%debug
/* Bison uses this to generate a C union definition. This is used to
store the application created values associated with syntactic
@ -104,15 +105,17 @@ char* copy_string(const char *str);
%token ACTION ADD ALTER AUTO_INCREMENT BIGINT BIT BLOB IDB_BLOB CASCADE IDB_CHAR
CHARACTER CHECK CLOB COLUMN
BOOL BOOLEAN BINARY
COLUMNS COMMENT CONSTRAINT CONSTRAINTS CREATE CURRENT_USER DATETIME DEC
DECIMAL DEFAULT DEFERRABLE DEFERRED IDB_DELETE DROP ENGINE
FOREIGN FULL IMMEDIATE INDEX INITIALLY IDB_INT INTEGER KEY LONGBLOB LONGTEXT
MATCH MAX_ROWS MEDIUMBLOB MEDIUMTEXT
MATCH MAX_ROWS MEDIUMBLOB MEDIUMTEXT MEDIUMINT
MIN_ROWS MODIFY NO NOT NULL_TOK NUMBER NUMERIC ON PARTIAL PRECISION PRIMARY
REFERENCES RENAME RESTRICT SET SMALLINT TABLE TEXT TINYBLOB TINYTEXT
TINYINT TO UNIQUE UNSIGNED UPDATE USER SESSION_USER SYSTEM_USER VARCHAR VARBINARY
TINYINT TO UNIQUE UNSIGNED UPDATE USER SESSION_USER SIGNED SYSTEM_USER VARCHAR VARBINARY
VARYING WITH ZONE DOUBLE IDB_FLOAT REAL CHARSET COLLATE IDB_IF EXISTS CHANGE TRUNCATE
BOOL BOOLEAN MEDIUMINT TIMESTAMP BINARY
TIMESTAMP
ZEROFILL
%token <str> DQ_IDENT IDENT FCONST SCONST CP_SEARCH_CONDITION_TEXT ICONST DATE TIME
@ -197,6 +200,8 @@ BOOL BOOLEAN MEDIUMINT TIMESTAMP BINARY
%type <str> opt_display_precision_scale_null
%type <str> opt_if_exists
%type <str> opt_if_not_exists
%type <str> opt_signed
%type <str> opt_zerofill
%type <sqlStmt> trunc_table_statement
%type <sqlStmt> rename_table_statement
%type <str> ident
@ -1002,16 +1007,14 @@ exact_numeric_type:
$2->fLength = DDLDatatypeLength[DDL_UNSIGNED_NUMERIC];
$$ = $2;
}
| DECIMAL opt_precision_scale
| DECIMAL opt_precision_scale opt_signed opt_zerofill
{
$2->fType = DDL_DECIMAL;
/* $2->fLength = DDLDatatypeLength[DDL_DECIMAL]; */
$$ = $2;
}
| DECIMAL opt_precision_scale UNSIGNED
| DECIMAL opt_precision_scale UNSIGNED opt_zerofill
{
$2->fType = DDL_UNSIGNED_DECIMAL;
/* $3->fLength = DDLDatatypeLength[DDL_DECIMAL]; */
$$ = $2;
}
| NUMBER opt_precision_scale
@ -1106,6 +1109,14 @@ opt_precision_scale:
| {$$ = new ColumnType(10,0);}
;
opt_signed:
SIGNED {$$ = NULL;}
| {$$ = NULL;}
opt_zerofill:
ZEROFILL {$$ = NULL;}
| {$$ = NULL;}
opt_display_width:
'(' ICONST ')' {$$ = NULL;}
| {$$ = NULL;}

View File

@ -26,6 +26,7 @@
#define DDLPKG_DLLEXPORT
#include "ddlpkg.h"
#undef DDLPKG_DLLEXPORT
#include "../../utils/common/columnwidth.h"
namespace ddlpackage
{
@ -61,32 +62,6 @@ ostream& operator<<(ostream& os, const QualifiedName& qname)
return os;
}
/** @brief Map a DECIMAL precision to data width in bytes */
unsigned int precision_width(unsigned p)
{
switch (p)
{
case 1:
case 2:
return 1;
case 3:
case 4:
return 2;
case 5:
case 6:
case 7:
case 8:
case 9:
return 4;
default:
return 8;
}
}
ColumnType::ColumnType(int prec, int scale) :
fType(DDL_INVALID_DATATYPE),
fLength(0),
@ -94,7 +69,7 @@ ColumnType::ColumnType(int prec, int scale) :
fScale(scale),
fWithTimezone(false)
{
fLength = precision_width(fPrecision);
fLength = utils::widthByPrecision(fPrecision);
}
ColumnType::ColumnType(int type) :
@ -141,19 +116,6 @@ ColumnType::ColumnType(int type) :
break;
}
}
#if 0
ColumnType::ColumnType(int type, int length, int precision, int scale, int compressiontype, const char* autoIncrement, int64_t nextValue, bool withTimezone) :
fType(type),
fLength(length),
fPrecision(precision),
fScale(scale),
fWithTimezone(withTimezone),
fCompressiontype(compressiontype),
fAutoincrement(autoIncrement),
fNextvalue(nextValue)
{
}
#endif
ColumnConstraintDef::ColumnConstraintDef(DDL_CONSTRAINTS type) :
SchemaObject(),
fDeferrable(false),