Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
f0f29d33
Commit
f0f29d33
authored
Sep 15, 2004
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ndb: set column type sets column defaults
parent
d3f031e9
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
131 additions
and
46 deletions
+131
-46
ndb/examples/ndbapi_async_example/ndbapi_async.cpp
ndb/examples/ndbapi_async_example/ndbapi_async.cpp
+4
-6
ndb/examples/ndbapi_example1/ndbapi_example1.cpp
ndb/examples/ndbapi_example1/ndbapi_example1.cpp
+2
-2
ndb/examples/ndbapi_example4/ndbapi_example4.cpp
ndb/examples/ndbapi_example4/ndbapi_example4.cpp
+2
-2
ndb/examples/ndbapi_scan_example/ndbapi_scan.cpp
ndb/examples/ndbapi_scan_example/ndbapi_scan.cpp
+4
-5
ndb/include/ndbapi/NdbDictionary.hpp
ndb/include/ndbapi/NdbDictionary.hpp
+10
-6
ndb/src/ndbapi/NdbDictionary.cpp
ndb/src/ndbapi/NdbDictionary.cpp
+37
-1
ndb/src/ndbapi/NdbDictionaryImpl.cpp
ndb/src/ndbapi/NdbDictionaryImpl.cpp
+56
-7
ndb/src/ndbapi/NdbDictionaryImpl.hpp
ndb/src/ndbapi/NdbDictionaryImpl.hpp
+1
-1
ndb/test/include/NDBT_Table.hpp
ndb/test/include/NDBT_Table.hpp
+2
-2
ndb/test/ndbapi/index.cpp
ndb/test/ndbapi/index.cpp
+8
-8
ndb/test/ndbapi/index2.cpp
ndb/test/ndbapi/index2.cpp
+2
-2
ndb/test/ndbapi/testDict.cpp
ndb/test/ndbapi/testDict.cpp
+1
-1
ndb/test/ndbapi/testOIBasic.cpp
ndb/test/ndbapi/testOIBasic.cpp
+2
-3
No files found.
ndb/examples/ndbapi_async_example/ndbapi_async.cpp
View file @
f0f29d33
...
...
@@ -46,9 +46,9 @@
*
* NdbDictionary::Column
* setName()
* setPrimaryKey()
* setType()
* setLength()
* setPrimaryKey()
* setNullable()
*
* NdbDictionary::Table
...
...
@@ -234,9 +234,9 @@ int create_table(Ndb * myNdb)
* Column REG_NO
*/
myColumn
.
setName
(
"REG_NO"
);
myColumn
.
setPrimaryKey
(
true
);
myColumn
.
setType
(
NdbDictionary
::
Column
::
Unsigned
);
myColumn
.
setLength
(
1
);
myColumn
.
setPrimaryKey
(
true
);
myColumn
.
setNullable
(
false
);
myTable
.
addColumn
(
myColumn
);
...
...
@@ -244,9 +244,9 @@ int create_table(Ndb * myNdb)
* Column BRAND
*/
myColumn
.
setName
(
"BRAND"
);
myColumn
.
setPrimaryKey
(
false
);
myColumn
.
setType
(
NdbDictionary
::
Column
::
Char
);
myColumn
.
setLength
(
20
);
myColumn
.
setPrimaryKey
(
false
);
myColumn
.
setNullable
(
false
);
myTable
.
addColumn
(
myColumn
);
...
...
@@ -254,9 +254,9 @@ int create_table(Ndb * myNdb)
* Column COLOR
*/
myColumn
.
setName
(
"COLOR"
);
myColumn
.
setPrimaryKey
(
false
);
myColumn
.
setType
(
NdbDictionary
::
Column
::
Char
);
myColumn
.
setLength
(
20
);
myColumn
.
setPrimaryKey
(
false
);
myColumn
.
setNullable
(
false
);
myTable
.
addColumn
(
myColumn
);
...
...
@@ -494,5 +494,3 @@ int main()
std
::
cout
<<
"Number of temporary errors: "
<<
tempErrors
<<
std
::
endl
;
delete
myNdb
;
}
ndb/examples/ndbapi_example1/ndbapi_example1.cpp
View file @
f0f29d33
...
...
@@ -79,16 +79,16 @@ int main()
myTable
.
setName
(
"MYTABLENAME"
);
myColumn
.
setName
(
"ATTR1"
);
myColumn
.
setPrimaryKey
(
true
);
myColumn
.
setType
(
NdbDictionary
::
Column
::
Unsigned
);
myColumn
.
setLength
(
1
);
myColumn
.
setPrimaryKey
(
true
);
myColumn
.
setNullable
(
false
);
myTable
.
addColumn
(
myColumn
);
myColumn
.
setName
(
"ATTR2"
);
myColumn
.
setPrimaryKey
(
false
);
myColumn
.
setType
(
NdbDictionary
::
Column
::
Unsigned
);
myColumn
.
setLength
(
1
);
myColumn
.
setPrimaryKey
(
false
);
myColumn
.
setNullable
(
false
);
myTable
.
addColumn
(
myColumn
);
...
...
ndb/examples/ndbapi_example4/ndbapi_example4.cpp
View file @
f0f29d33
...
...
@@ -80,16 +80,16 @@ int main()
myTable
.
setName
(
"MYTABLENAME"
);
myColumn
.
setName
(
"ATTR1"
);
myColumn
.
setPrimaryKey
(
true
);
myColumn
.
setType
(
NdbDictionary
::
Column
::
Unsigned
);
myColumn
.
setLength
(
1
);
myColumn
.
setPrimaryKey
(
true
);
myColumn
.
setNullable
(
false
);
myTable
.
addColumn
(
myColumn
);
myColumn
.
setName
(
"ATTR2"
);
myColumn
.
setPrimaryKey
(
false
);
myColumn
.
setType
(
NdbDictionary
::
Column
::
Unsigned
);
myColumn
.
setLength
(
1
);
myColumn
.
setPrimaryKey
(
false
);
myColumn
.
setNullable
(
false
);
myTable
.
addColumn
(
myColumn
);
...
...
ndb/examples/ndbapi_scan_example/ndbapi_scan.cpp
View file @
f0f29d33
...
...
@@ -47,9 +47,9 @@
*
* NdbDictionary::Column
* setName()
* setPrimaryKey()
* setType()
* setLength()
* setPrimaryKey()
* setNullable()
*
* NdbDictionary::Table
...
...
@@ -165,24 +165,24 @@ int create_table(Ndb * myNdb)
myTable
.
setName
(
"GARAGE"
);
myColumn
.
setName
(
"REG_NO"
);
myColumn
.
setPrimaryKey
(
true
);
myColumn
.
setType
(
NdbDictionary
::
Column
::
Unsigned
);
myColumn
.
setLength
(
1
);
myColumn
.
setPrimaryKey
(
true
);
myColumn
.
setNullable
(
false
);
myTable
.
addColumn
(
myColumn
);
myColumn
.
setName
(
"BRAND"
);
myColumn
.
setPrimaryKey
(
false
);
myColumn
.
setType
(
NdbDictionary
::
Column
::
Char
);
myColumn
.
setLength
(
20
);
myColumn
.
setPrimaryKey
(
false
);
myColumn
.
setNullable
(
false
);
myTable
.
addColumn
(
myColumn
);
myColumn
.
setName
(
"COLOR"
);
myColumn
.
setPrimaryKey
(
false
);
myColumn
.
setType
(
NdbDictionary
::
Column
::
Char
);
myColumn
.
setLength
(
20
);
myColumn
.
setPrimaryKey
(
false
);
myColumn
.
setNullable
(
false
);
myTable
.
addColumn
(
myColumn
);
...
...
@@ -814,4 +814,3 @@ int main()
delete
myNdb
;
}
ndb/include/ndbapi/NdbDictionary.hpp
View file @
f0f29d33
...
...
@@ -257,6 +257,10 @@ public:
/**
* Set type of column
* @param type Type of column
*
* @note setType resets <em>all</em> column attributes
* to (type dependent) defaults and should be the first
* method to call. Default type is Unsigned.
*/
void
setType
(
Type
type
);
...
...
@@ -306,23 +310,23 @@ public:
* to store in table's blob attribute. This part is normally in
* main memory and can be indexed and interpreted.
*/
void
setInlineSize
(
int
size
)
{
setPrecision
(
size
);
}
int
getInlineSize
()
const
{
return
getPrecision
();
}
void
setInlineSize
(
int
size
)
;
int
getInlineSize
()
const
;
/**
* For blob, set or get "part size" i.e. number of bytes to store in
* each tuple of the "blob table". Can be set to zero to omit parts
* and to allow only inline bytes ("tinyblob").
*/
void
setPartSize
(
int
size
)
{
setScale
(
size
);
}
int
getPartSize
()
const
{
return
getScale
();
}
void
setPartSize
(
int
size
)
;
int
getPartSize
()
const
;
/**
* For blob, set or get "stripe size" i.e. number of consecutive
* <em>parts</em> to store in each node group.
*/
void
setStripeSize
(
int
size
)
{
setLength
(
size
);
}
int
getStripeSize
()
const
{
return
getLength
();
}
void
setStripeSize
(
int
size
)
;
int
getStripeSize
()
const
;
/**
* Get size of element
...
...
ndb/src/ndbapi/NdbDictionary.cpp
View file @
f0f29d33
...
...
@@ -65,7 +65,7 @@ NdbDictionary::Column::getName() const {
void
NdbDictionary
::
Column
::
setType
(
Type
t
){
m_impl
.
m_type
=
t
;
m_impl
.
init
(
t
)
;
}
NdbDictionary
::
Column
::
Type
...
...
@@ -103,6 +103,42 @@ NdbDictionary::Column::getLength() const{
return
m_impl
.
m_length
;
}
void
NdbDictionary
::
Column
::
setInlineSize
(
int
size
)
{
m_impl
.
m_precision
=
size
;
}
int
NdbDictionary
::
Column
::
getInlineSize
()
const
{
return
m_impl
.
m_precision
;
}
void
NdbDictionary
::
Column
::
setPartSize
(
int
size
)
{
m_impl
.
m_scale
=
size
;
}
int
NdbDictionary
::
Column
::
getPartSize
()
const
{
return
m_impl
.
m_scale
;
}
void
NdbDictionary
::
Column
::
setStripeSize
(
int
size
)
{
m_impl
.
m_length
=
size
;
}
int
NdbDictionary
::
Column
::
getStripeSize
()
const
{
return
m_impl
.
m_length
;
}
int
NdbDictionary
::
Column
::
getSize
()
const
{
return
m_impl
.
m_attrSize
;
...
...
ndb/src/ndbapi/NdbDictionaryImpl.cpp
View file @
f0f29d33
...
...
@@ -87,10 +87,57 @@ NdbColumnImpl::operator=(const NdbColumnImpl& col)
}
void
NdbColumnImpl
::
init
()
NdbColumnImpl
::
init
(
Type
t
)
{
m_attrId
=
-
1
;
m_type
=
NdbDictionary
::
Column
::
Unsigned
;
m_type
=
t
;
switch
(
m_type
)
{
case
Tinyint
:
case
Tinyunsigned
:
case
Smallint
:
case
Smallunsigned
:
case
Mediumint
:
case
Mediumunsigned
:
case
Int
:
case
Unsigned
:
case
Bigint
:
case
Bigunsigned
:
case
Float
:
case
Double
:
m_precision
=
0
;
m_scale
=
0
;
m_length
=
1
;
break
;
case
Decimal
:
m_precision
=
10
;
m_scale
=
0
;
m_length
=
1
;
break
;
case
Char
:
case
Varchar
:
m_precision
=
0
;
m_scale
=
0
;
m_length
=
1
;
break
;
case
Binary
:
case
Varbinary
:
case
Datetime
:
case
Timespec
:
m_precision
=
0
;
m_scale
=
0
;
m_length
=
1
;
break
;
case
Blob
:
m_precision
=
256
;
m_scale
=
8000
;
m_length
=
4
;
break
;
case
Text
:
m_precision
=
256
;
m_scale
=
8000
;
m_length
=
4
;
break
;
}
m_pk
=
false
;
m_nullable
=
false
;
m_tupleKey
=
false
;
...
...
@@ -98,12 +145,10 @@ NdbColumnImpl::init()
m_distributionKey
=
false
;
m_distributionGroup
=
false
;
m_distributionGroupBits
=
8
;
m_length
=
1
;
m_scale
=
5
;
m_precision
=
5
;
m_keyInfoPos
=
0
;
m_attrSize
=
4
,
m_arraySize
=
1
,
// next 2 are set at run time
m_attrSize
=
0
;
m_arraySize
=
0
;
m_autoIncrement
=
false
;
m_autoIncrementInitialValue
=
1
;
m_blobTable
=
NULL
;
...
...
@@ -209,14 +254,18 @@ NdbColumnImpl::create_psuedo(const char * name){
if
(
!
strcmp
(
name
,
"NDB$FRAGMENT"
)){
col
->
setType
(
NdbDictionary
::
Column
::
Unsigned
);
col
->
m_impl
.
m_attrId
=
AttributeHeader
::
FRAGMENT
;
col
->
m_impl
.
m_attrSize
=
4
;
col
->
m_impl
.
m_arraySize
=
1
;
}
else
if
(
!
strcmp
(
name
,
"NDB$ROW_COUNT"
)){
col
->
setType
(
NdbDictionary
::
Column
::
Bigunsigned
);
col
->
m_impl
.
m_attrId
=
AttributeHeader
::
ROW_COUNT
;
col
->
m_impl
.
m_attrSize
=
8
;
col
->
m_impl
.
m_arraySize
=
1
;
}
else
if
(
!
strcmp
(
name
,
"NDB$COMMIT_COUNT"
)){
col
->
setType
(
NdbDictionary
::
Column
::
Bigunsigned
);
col
->
m_impl
.
m_attrId
=
AttributeHeader
::
COMMIT_COUNT
;
col
->
m_impl
.
m_attrSize
=
8
;
col
->
m_impl
.
m_arraySize
=
1
;
}
else
{
abort
();
}
...
...
ndb/src/ndbapi/NdbDictionaryImpl.hpp
View file @
f0f29d33
...
...
@@ -52,7 +52,7 @@ public:
NdbColumnImpl
(
NdbDictionary
::
Column
&
);
// This is not a copy constructor
~
NdbColumnImpl
();
NdbColumnImpl
&
operator
=
(
const
NdbColumnImpl
&
);
void
init
();
void
init
(
Type
t
=
Unsigned
);
int
m_attrId
;
BaseString
m_name
;
...
...
ndb/test/include/NDBT_Table.hpp
View file @
f0f29d33
...
...
@@ -33,10 +33,10 @@ public:
{
assert
(
_name
!=
0
);
setType
(
_type
);
setLength
(
_length
);
setNullable
(
_nullable
);
setPrimaryKey
(
_pk
);
setLength
(
_length
);
setType
(
_type
);
}
};
...
...
ndb/test/ndbapi/index.cpp
View file @
f0f29d33
...
...
@@ -81,63 +81,63 @@ static void createTable(Ndb &myNdb, bool storeInACC, bool twoKey, bool longKey)
int
res
;
column
.
setName
(
"NAME"
);
column
.
setPrimaryKey
(
true
);
column
.
setType
(
NdbDictionary
::
Column
::
Char
);
column
.
setLength
((
longKey
)
?
1024
// 1KB => long key
:
12
);
column
.
setPrimaryKey
(
true
);
column
.
setNullable
(
false
);
table
.
addColumn
(
column
);
if
(
twoKey
)
{
column
.
setName
(
"KEY2"
);
column
.
setPrimaryKey
(
true
);
column
.
setType
(
NdbDictionary
::
Column
::
Unsigned
);
column
.
setLength
(
1
);
column
.
setPrimaryKey
(
true
);
column
.
setNullable
(
false
);
table
.
addColumn
(
column
);
}
column
.
setName
(
"PNUM1"
);
column
.
setPrimaryKey
(
false
);
column
.
setType
(
NdbDictionary
::
Column
::
Unsigned
);
column
.
setLength
(
1
);
column
.
setPrimaryKey
(
false
);
column
.
setNullable
(
false
);
table
.
addColumn
(
column
);
column
.
setName
(
"PNUM2"
);
column
.
setPrimaryKey
(
false
);
column
.
setType
(
NdbDictionary
::
Column
::
Unsigned
);
column
.
setLength
(
1
);
column
.
setPrimaryKey
(
false
);
column
.
setNullable
(
false
);
table
.
addColumn
(
column
);
column
.
setName
(
"PNUM3"
);
column
.
setPrimaryKey
(
false
);
column
.
setType
(
NdbDictionary
::
Column
::
Unsigned
);
column
.
setLength
(
1
);
column
.
setPrimaryKey
(
false
);
column
.
setNullable
(
false
);
table
.
addColumn
(
column
);
column
.
setName
(
"PNUM4"
);
column
.
setPrimaryKey
(
false
);
column
.
setType
(
NdbDictionary
::
Column
::
Unsigned
);
column
.
setLength
(
1
);
column
.
setPrimaryKey
(
false
);
column
.
setNullable
(
false
);
table
.
addColumn
(
column
);
column
.
setName
(
"AGE"
);
column
.
setPrimaryKey
(
false
);
column
.
setType
(
NdbDictionary
::
Column
::
Unsigned
);
column
.
setLength
(
1
);
column
.
setPrimaryKey
(
false
);
column
.
setNullable
(
false
);
table
.
addColumn
(
column
);
column
.
setName
(
"STRING_AGE"
);
column
.
setPrimaryKey
(
false
);
column
.
setType
(
NdbDictionary
::
Column
::
Char
);
column
.
setLength
(
1
);
column
.
setLength
(
256
);
column
.
setPrimaryKey
(
false
);
column
.
setNullable
(
false
);
table
.
addColumn
(
column
);
...
...
ndb/test/ndbapi/index2.cpp
View file @
f0f29d33
...
...
@@ -81,16 +81,16 @@ static void createTable(Ndb &myNdb, bool storeInACC, bool twoKey, bool longKey)
int
res
;
column
.
setName
(
"X"
);
column
.
setPrimaryKey
(
true
);
column
.
setType
(
NdbDictionary
::
Column
::
Unsigned
);
column
.
setLength
(
1
);
column
.
setPrimaryKey
(
true
);
column
.
setNullable
(
false
);
table
.
addColumn
(
column
);
column
.
setName
(
"Y"
);
column
.
setPrimaryKey
(
false
);
column
.
setType
(
NdbDictionary
::
Column
::
Unsigned
);
column
.
setLength
(
1
);
column
.
setPrimaryKey
(
false
);
column
.
setNullable
(
false
);
table
.
addColumn
(
column
);
...
...
ndb/test/ndbapi/testDict.cpp
View file @
f0f29d33
...
...
@@ -1128,9 +1128,9 @@ runCreateAutoincrementTable(NDBT_Context* ctx, NDBT_Step* step){
myTable
.
setName
(
tabname
);
myColumn
.
setName
(
"ATTR1"
);
myColumn
.
setPrimaryKey
(
true
);
myColumn
.
setType
(
NdbDictionary
::
Column
::
Unsigned
);
myColumn
.
setLength
(
1
);
myColumn
.
setPrimaryKey
(
true
);
myColumn
.
setNullable
(
false
);
myColumn
.
setAutoIncrement
(
true
);
if
(
startvalue
!=
~
0
)
// check that default value starts with 1
...
...
ndb/test/ndbapi/testOIBasic.cpp
View file @
f0f29d33
...
...
@@ -979,9 +979,9 @@ createtable(Par par)
for
(
unsigned
k
=
0
;
k
<
tab
.
m_cols
;
k
++
)
{
const
Col
&
col
=
tab
.
m_col
[
k
];
NdbDictionary
::
Column
c
(
col
.
m_name
);
c
.
setPrimaryKey
(
col
.
m_pk
);
c
.
setType
(
col
.
m_type
);
c
.
setLength
(
col
.
m_length
);
c
.
setPrimaryKey
(
col
.
m_pk
);
c
.
setNullable
(
col
.
m_nullable
);
t
.
addColumn
(
c
);
}
...
...
@@ -2236,9 +2236,8 @@ pkreadfast(Par par, unsigned count)
keyrow
.
calc
(
par
,
i
);
CHK
(
keyrow
.
selrow
(
par
)
==
0
);
NdbRecAttr
*
rec
;
CHK
(
con
.
getValue
((
Uint32
)
0
,
rec
)
==
0
);
CHK
(
con
.
executeScan
()
==
0
);
// get 1st column
CHK
(
con
.
getValue
((
Uint32
)
0
,
rec
)
==
0
);
CHK
(
con
.
execute
(
Commit
)
==
0
);
con
.
closeTransaction
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment