Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
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
Abuhujair Javed
Postgres FD Implementation
Commits
b4176e9f
Commit
b4176e9f
authored
May 27, 2005
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up bogus checking of date and numeric fields in DBF files,
per report from Boris van Schooten.
parent
fbdb203a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
38 deletions
+15
-38
contrib/dbase/dbf2pg.c
contrib/dbase/dbf2pg.c
+15
-38
No files found.
contrib/dbase/dbf2pg.c
View file @
b4176e9f
...
...
@@ -63,31 +63,8 @@ char *Escape_db(char *);
char
*
convert_charset
(
char
*
string
);
#endif
void
usage
(
void
);
unsigned
int
isinteger
(
char
*
);
unsigned
int
isinteger
(
char
*
buff
)
{
char
*
i
=
buff
;
while
(
*
i
!=
'\0'
)
{
if
(
i
==
buff
)
if
((
*
i
==
'-'
)
||
(
*
i
==
'+'
))
{
i
++
;
continue
;
}
if
(
!
isdigit
((
unsigned
char
)
*
i
))
return
0
;
i
++
;
}
return
1
;
}
static
inline
void
strtoupper
(
char
*
string
)
{
...
...
@@ -471,8 +448,15 @@ do_inserts(PGconn *conn, char *table, dbhead * dbh)
/* handle the date first - liuk */
if
(
fields
[
h
].
db_type
==
'D'
)
{
if
(
(
strlen
(
foo
)
==
8
)
&&
isinteger
(
foo
)
)
if
(
strlen
(
foo
)
==
0
)
{
/* assume empty string means a NULL */
strcat
(
query
,
"
\\
N"
);
}
else
if
(
strlen
(
foo
)
==
8
&&
strspn
(
foo
,
"0123456789"
)
==
8
)
{
/* transform YYYYMMDD to Postgres style */
snprintf
(
pgdate
,
11
,
"%c%c%c%c-%c%c-%c%c"
,
foo
[
0
],
foo
[
1
],
foo
[
2
],
foo
[
3
],
foo
[
4
],
foo
[
5
],
foo
[
6
],
foo
[
7
]);
...
...
@@ -480,26 +464,19 @@ do_inserts(PGconn *conn, char *table, dbhead * dbh)
}
else
{
/*
* empty field must be inserted as NULL value in
* this way
*/
strcat
(
query
,
"
\\
N"
);
/* try to insert it as-is */
strcat
(
query
,
foo
);
}
}
else
if
((
fields
[
h
].
db_type
==
'N'
)
&&
(
fields
[
h
].
db_dec
==
0
))
else
if
(
fields
[
h
].
db_type
==
'N'
)
{
if
(
isinteger
(
foo
))
strcat
(
query
,
foo
);
else
if
(
strlen
(
foo
)
==
0
)
{
/* assume empty string means a NULL */
strcat
(
query
,
"
\\
N"
);
if
(
verbose
)
fprintf
(
stderr
,
"Illegal numeric value found "
"in record %d, field
\"
%s
\"\n
"
,
i
,
fields
[
h
].
db_name
);
}
else
strcat
(
query
,
foo
);
}
else
{
...
...
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