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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
a1ad7121
Commit
a1ad7121
authored
May 07, 2015
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing connect.dbf test failures on big endian machines.
parent
5c833689
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
24 deletions
+38
-24
storage/connect/filamdbf.cpp
storage/connect/filamdbf.cpp
+38
-24
No files found.
storage/connect/filamdbf.cpp
View file @
a1ad7121
...
@@ -74,16 +74,28 @@ typedef struct _dbfheader {
...
@@ -74,16 +74,28 @@ typedef struct _dbfheader {
//uchar Dbfox :4; /* FoxPro if equal to 3 */
//uchar Dbfox :4; /* FoxPro if equal to 3 */
uchar
Version
;
/* Version information flags */
uchar
Version
;
/* Version information flags */
char
Filedate
[
3
];
/* date, YYMMDD, binary. YY=year-1900 */
char
Filedate
[
3
];
/* date, YYMMDD, binary. YY=year-1900 */
uint
Records
;
/* records in the file */
private:
ushort
Headlen
;
/* bytes in the header */
/* The following four members are stored in little-endian format on disk */
ushort
Reclen
;
/* bytes in a record */
char
m_RecordsBuf
[
4
];
/* records in the file */
ushort
Fields
;
/* Reserved but used to store fields */
char
m_HeadlenBuf
[
2
];
/* bytes in the header */
char
m_ReclenBuf
[
2
];
/* bytes in a record */
char
m_FieldsBuf
[
2
];
/* Reserved but used to store fields */
public:
char
Incompleteflag
;
/* 01 if incomplete, else 00 */
char
Incompleteflag
;
/* 01 if incomplete, else 00 */
char
Encryptflag
;
/* 01 if encrypted, else 00 */
char
Encryptflag
;
/* 01 if encrypted, else 00 */
char
Reserved2
[
12
];
/* for LAN use */
char
Reserved2
[
12
];
/* for LAN use */
char
Mdxflag
;
/* 01 if production .mdx, else 00 */
char
Mdxflag
;
/* 01 if production .mdx, else 00 */
char
Language
;
/* Codepage */
char
Language
;
/* Codepage */
char
Reserved3
[
2
];
char
Reserved3
[
2
];
uint
Records
()
const
{
return
uint4korr
(
m_RecordsBuf
);
}
ushort
Headlen
()
const
{
return
uint2korr
(
m_HeadlenBuf
);
}
ushort
Reclen
()
const
{
return
uint2korr
(
m_ReclenBuf
);
}
ushort
Fields
()
const
{
return
uint2korr
(
m_FieldsBuf
);
}
void
SetHeadlen
(
ushort
num
)
{
int2store
(
m_HeadlenBuf
,
num
);
}
void
SetReclen
(
ushort
num
)
{
int2store
(
m_ReclenBuf
,
num
);
}
void
SetFields
(
ushort
num
)
{
int2store
(
m_FieldsBuf
,
num
);
}
}
DBFHEADER
;
}
DBFHEADER
;
/****************************************************************************/
/****************************************************************************/
...
@@ -143,7 +155,7 @@ static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf)
...
@@ -143,7 +155,7 @@ static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf)
strcpy
(
g
->
Message
,
MSG
(
DBASE_FILE
));
strcpy
(
g
->
Message
,
MSG
(
DBASE_FILE
));
// Check last byte(s) of header
// Check last byte(s) of header
if
(
fseek
(
file
,
buf
->
Headlen
-
dbc
,
SEEK_SET
)
!=
0
)
{
if
(
fseek
(
file
,
buf
->
Headlen
()
-
dbc
,
SEEK_SET
)
!=
0
)
{
sprintf
(
g
->
Message
,
MSG
(
BAD_HEADER
),
fn
);
sprintf
(
g
->
Message
,
MSG
(
BAD_HEADER
),
fn
);
return
RC_FX
;
return
RC_FX
;
}
// endif fseek
}
// endif fseek
...
@@ -163,7 +175,7 @@ static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf)
...
@@ -163,7 +175,7 @@ static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf)
}
// endif endmark
}
// endif endmark
// Calculate here the number of fields while we have the dbc info
// Calculate here the number of fields while we have the dbc info
buf
->
Fields
=
(
buf
->
Headlen
-
dbc
-
1
)
/
32
;
buf
->
SetFields
((
buf
->
Headlen
()
-
dbc
-
1
)
/
32
)
;
fseek
(
file
,
HEADLEN
,
SEEK_SET
);
fseek
(
file
,
HEADLEN
,
SEEK_SET
);
return
rc
;
return
rc
;
}
// end of dbfhead
}
// end of dbfhead
...
@@ -219,7 +231,7 @@ PQRYRES DBFColumns(PGLOBAL g, char *dp, const char *fn, bool info)
...
@@ -219,7 +231,7 @@ PQRYRES DBFColumns(PGLOBAL g, char *dp, const char *fn, bool info)
/************************************************************************/
/************************************************************************/
/* Allocate the structures used to refer to the result set. */
/* Allocate the structures used to refer to the result set. */
/************************************************************************/
/************************************************************************/
fields
=
mainhead
.
Fields
;
fields
=
mainhead
.
Fields
()
;
}
else
}
else
fields
=
0
;
fields
=
0
;
...
@@ -236,11 +248,11 @@ PQRYRES DBFColumns(PGLOBAL g, char *dp, const char *fn, bool info)
...
@@ -236,11 +248,11 @@ PQRYRES DBFColumns(PGLOBAL g, char *dp, const char *fn, bool info)
if
(
trace
)
{
if
(
trace
)
{
htrc
(
"Structure of %s
\n
"
,
filename
);
htrc
(
"Structure of %s
\n
"
,
filename
);
htrc
(
"headlen=%hd reclen=%hd degree=%d
\n
"
,
htrc
(
"headlen=%hd reclen=%hd degree=%d
\n
"
,
mainhead
.
Headlen
,
mainhead
.
Reclen
,
fields
);
mainhead
.
Headlen
(),
mainhead
.
Reclen
()
,
fields
);
htrc
(
"flags(iem)=%d,%d,%d cp=%d
\n
"
,
mainhead
.
Incompleteflag
,
htrc
(
"flags(iem)=%d,%d,%d cp=%d
\n
"
,
mainhead
.
Incompleteflag
,
mainhead
.
Encryptflag
,
mainhead
.
Mdxflag
,
mainhead
.
Language
);
mainhead
.
Encryptflag
,
mainhead
.
Mdxflag
,
mainhead
.
Language
);
htrc
(
"%hd records, last changed %02d/%02d/%d
\n
"
,
htrc
(
"%hd records, last changed %02d/%02d/%d
\n
"
,
mainhead
.
Records
,
mainhead
.
Filedate
[
1
],
mainhead
.
Filedate
[
2
],
mainhead
.
Records
()
,
mainhead
.
Filedate
[
1
],
mainhead
.
Filedate
[
2
],
mainhead
.
Filedate
[
0
]
+
(
mainhead
.
Filedate
[
0
]
<=
30
)
?
2000
:
1900
);
mainhead
.
Filedate
[
0
]
+
(
mainhead
.
Filedate
[
0
]
<=
30
)
?
2000
:
1900
);
htrc
(
"Field Type Offset Len Dec Set Mdx
\n
"
);
htrc
(
"Field Type Offset Len Dec Set Mdx
\n
"
);
}
// endif trace
}
// endif trace
...
@@ -398,13 +410,13 @@ int DBFBASE::ScanHeader(PGLOBAL g, PSZ fname, int lrecl, char *defpath)
...
@@ -398,13 +410,13 @@ int DBFBASE::ScanHeader(PGLOBAL g, PSZ fname, int lrecl, char *defpath)
}
else
if
(
rc
==
RC_FX
)
}
else
if
(
rc
==
RC_FX
)
return
-
1
;
return
-
1
;
if
((
int
)
header
.
Reclen
!=
lrecl
)
{
if
((
int
)
header
.
Reclen
()
!=
lrecl
)
{
sprintf
(
g
->
Message
,
MSG
(
BAD_LRECL
),
lrecl
,
header
.
Reclen
);
sprintf
(
g
->
Message
,
MSG
(
BAD_LRECL
),
lrecl
,
header
.
Reclen
()
);
return
-
1
;
return
-
1
;
}
// endif Lrecl
}
// endif Lrecl
Records
=
(
int
)
header
.
Records
;
Records
=
(
int
)
header
.
Records
()
;
return
(
int
)
header
.
Headlen
;
return
(
int
)
header
.
Headlen
()
;
}
// end of ScanHeader
}
// end of ScanHeader
/* ---------------------------- Class DBFFAM ------------------------------ */
/* ---------------------------- Class DBFFAM ------------------------------ */
...
@@ -565,8 +577,8 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
...
@@ -565,8 +577,8 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
header
->
Filedate
[
0
]
=
datm
->
tm_year
-
100
;
header
->
Filedate
[
0
]
=
datm
->
tm_year
-
100
;
header
->
Filedate
[
1
]
=
datm
->
tm_mon
+
1
;
header
->
Filedate
[
1
]
=
datm
->
tm_mon
+
1
;
header
->
Filedate
[
2
]
=
datm
->
tm_mday
;
header
->
Filedate
[
2
]
=
datm
->
tm_mday
;
header
->
Headlen
=
(
ushort
)
hlen
;
header
->
SetHeadlen
((
ushort
)
hlen
)
;
header
->
Reclen
=
(
ushort
)
reclen
;
header
->
SetReclen
((
ushort
)
reclen
)
;
descp
=
(
DESCRIPTOR
*
)
header
;
descp
=
(
DESCRIPTOR
*
)
header
;
// Currently only standard Xbase types are supported
// Currently only standard Xbase types are supported
...
@@ -627,13 +639,13 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
...
@@ -627,13 +639,13 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
DBFHEADER
header
;
DBFHEADER
header
;
if
((
rc
=
dbfhead
(
g
,
Stream
,
Tdbp
->
GetFile
(
g
),
&
header
))
==
RC_OK
)
{
if
((
rc
=
dbfhead
(
g
,
Stream
,
Tdbp
->
GetFile
(
g
),
&
header
))
==
RC_OK
)
{
if
(
Lrecl
!=
(
int
)
header
.
Reclen
)
{
if
(
Lrecl
!=
(
int
)
header
.
Reclen
()
)
{
sprintf
(
g
->
Message
,
MSG
(
BAD_LRECL
),
Lrecl
,
header
.
Reclen
);
sprintf
(
g
->
Message
,
MSG
(
BAD_LRECL
),
Lrecl
,
header
.
Reclen
()
);
return
true
;
return
true
;
}
// endif Lrecl
}
// endif Lrecl
Records
=
(
int
)
header
.
Records
;
Records
=
(
int
)
header
.
Records
()
;
Headlen
=
(
int
)
header
.
Headlen
;
Headlen
=
(
int
)
header
.
Headlen
()
;
}
else
if
(
rc
==
RC_NF
)
{
}
else
if
(
rc
==
RC_NF
)
{
Records
=
0
;
Records
=
0
;
Headlen
=
0
;
Headlen
=
0
;
...
@@ -868,8 +880,10 @@ void DBFFAM::CloseTableFile(PGLOBAL g, bool abort)
...
@@ -868,8 +880,10 @@ void DBFFAM::CloseTableFile(PGLOBAL g, bool abort)
PlugSetPath
(
filename
,
To_File
,
Tdbp
->
GetPath
());
PlugSetPath
(
filename
,
To_File
,
Tdbp
->
GetPath
());
if
((
Stream
=
global_fopen
(
g
,
MSGID_OPEN_MODE_STRERROR
,
filename
,
"r+b"
)))
if
((
Stream
=
global_fopen
(
g
,
MSGID_OPEN_MODE_STRERROR
,
filename
,
"r+b"
)))
{
{
char
nRecords
[
4
];
int4store
(
&
nRecords
,
n
);
fseek
(
Stream
,
4
,
SEEK_SET
);
// Get header.Records position
fseek
(
Stream
,
4
,
SEEK_SET
);
// Get header.Records position
fwrite
(
&
n
,
sizeof
(
int
),
1
,
Stream
);
fwrite
(
&
n
Records
,
sizeof
(
nRecords
),
1
,
Stream
);
fclose
(
Stream
);
fclose
(
Stream
);
Stream
=
NULL
;
Stream
=
NULL
;
Records
=
n
;
// Update Records value
Records
=
n
;
// Update Records value
...
@@ -944,13 +958,13 @@ bool DBMFAM::AllocateBuffer(PGLOBAL g)
...
@@ -944,13 +958,13 @@ bool DBMFAM::AllocateBuffer(PGLOBAL g)
/************************************************************************/
/************************************************************************/
DBFHEADER
*
hp
=
(
DBFHEADER
*
)
Memory
;
DBFHEADER
*
hp
=
(
DBFHEADER
*
)
Memory
;
if
(
Lrecl
!=
(
int
)
hp
->
Reclen
)
{
if
(
Lrecl
!=
(
int
)
hp
->
Reclen
()
)
{
sprintf
(
g
->
Message
,
MSG
(
BAD_LRECL
),
Lrecl
,
hp
->
Reclen
);
sprintf
(
g
->
Message
,
MSG
(
BAD_LRECL
),
Lrecl
,
hp
->
Reclen
()
);
return
true
;
return
true
;
}
// endif Lrecl
}
// endif Lrecl
Records
=
(
int
)
hp
->
Records
;
Records
=
(
int
)
hp
->
Records
()
;
Headlen
=
(
int
)
hp
->
Headlen
;
Headlen
=
(
int
)
hp
->
Headlen
()
;
}
// endif Headlen
}
// endif Headlen
/**************************************************************************/
/**************************************************************************/
...
...
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