Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
5c33b3c6
Commit
5c33b3c6
authored
25 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Change a few routines into macros to improve speed of COPY IN inner loop.
parent
d32cd1bb
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/backend/commands/copy.c
+20
-33
20 additions, 33 deletions
src/backend/commands/copy.c
src/include/lib/stringinfo.h
+12
-2
12 additions, 2 deletions
src/include/lib/stringinfo.h
with
32 additions
and
35 deletions
src/backend/commands/copy.c
+
20
−
33
View file @
5c33b3c6
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.9
7
2000/01/
19 23:54:56
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.9
8
2000/01/
22 03:52:04
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -137,7 +137,8 @@ CopySendChar(char c, FILE *fp)
...
@@ -137,7 +137,8 @@ CopySendChar(char c, FILE *fp)
* backend->frontend functions
* backend->frontend functions
*
*
* CopyGetChar does the same for single characters
* CopyGetChar does the same for single characters
* CopyGetEof checks if it's EOF on the input
* CopyGetEof checks if it's EOF on the input (or, check for EOF result
* from CopyGetChar)
*
*
* NB: no data conversion is applied by these functions
* NB: no data conversion is applied by these functions
*/
*/
...
@@ -1106,18 +1107,6 @@ GetIndexRelations(Oid main_relation_oid,
...
@@ -1106,18 +1107,6 @@ GetIndexRelations(Oid main_relation_oid,
}
}
}
}
/*
returns 1 if c is in s
*/
static
bool
inString
(
char
c
,
char
*
s
)
{
if
(
s
&&
c
)
return
strchr
(
s
,
c
)
!=
NULL
;
return
0
;
}
/*
/*
* Reads input from fp until an end of line is seen.
* Reads input from fp until an end of line is seen.
*/
*/
...
@@ -1171,19 +1160,24 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
...
@@ -1171,19 +1160,24 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
*
isnull
=
(
bool
)
false
;
/* set default */
*
isnull
=
(
bool
)
false
;
/* set default */
if
(
CopyGetEof
(
fp
))
goto
endOfFile
;
for
(;;)
for
(;;)
{
{
c
=
CopyGetChar
(
fp
);
c
=
CopyGetChar
(
fp
);
if
(
CopyGetEof
(
fp
)
)
if
(
c
==
EOF
)
goto
endOfFile
;
goto
endOfFile
;
if
(
c
==
'\n'
)
{
*
newline
=
1
;
break
;
}
if
(
strchr
(
delim
,
c
))
{
break
;
}
if
(
c
==
'\\'
)
if
(
c
==
'\\'
)
{
{
c
=
CopyGetChar
(
fp
);
c
=
CopyGetChar
(
fp
);
if
(
CopyGetEof
(
fp
)
)
if
(
c
==
EOF
)
goto
endOfFile
;
goto
endOfFile
;
switch
(
c
)
switch
(
c
)
{
{
...
@@ -1213,14 +1207,14 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
...
@@ -1213,14 +1207,14 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
}
}
else
else
{
{
if
(
CopyGetEof
(
fp
)
)
if
(
c
==
EOF
)
goto
endOfFile
;
goto
endOfFile
;
CopyDonePeek
(
fp
,
c
,
0
);
/* Return to stream! */
CopyDonePeek
(
fp
,
c
,
0
);
/* Return to stream! */
}
}
}
}
else
else
{
{
if
(
CopyGetEof
(
fp
)
)
if
(
c
==
EOF
)
goto
endOfFile
;
goto
endOfFile
;
CopyDonePeek
(
fp
,
c
,
0
);
/* Return to stream! */
CopyDonePeek
(
fp
,
c
,
0
);
/* Return to stream! */
}
}
...
@@ -1231,7 +1225,7 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
...
@@ -1231,7 +1225,7 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
rather then just 'N' to provide compatibility with
rather then just 'N' to provide compatibility with
the default NULL output. -- pe */
the default NULL output. -- pe */
case
'N'
:
case
'N'
:
appendStringInfoChar
(
&
attribute_buf
,
'\\'
);
appendStringInfoChar
Macro
(
&
attribute_buf
,
'\\'
);
c
=
'N'
;
c
=
'N'
;
break
;
break
;
case
'b'
:
case
'b'
:
...
@@ -1257,16 +1251,9 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
...
@@ -1257,16 +1251,9 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
if
(
c
!=
'\n'
)
if
(
c
!=
'\n'
)
elog
(
ERROR
,
"CopyReadAttribute - end of record marker corrupted. line: %d"
,
lineno
);
elog
(
ERROR
,
"CopyReadAttribute - end of record marker corrupted. line: %d"
,
lineno
);
goto
endOfFile
;
goto
endOfFile
;
break
;
}
}
}
}
else
if
(
c
==
'\n'
||
inString
(
c
,
delim
))
appendStringInfoCharMacro
(
&
attribute_buf
,
c
);
{
if
(
c
==
'\n'
)
*
newline
=
1
;
break
;
}
appendStringInfoChar
(
&
attribute_buf
,
c
);
#ifdef MULTIBYTE
#ifdef MULTIBYTE
/* get additional bytes of the char, if any */
/* get additional bytes of the char, if any */
s
[
0
]
=
c
;
s
[
0
]
=
c
;
...
@@ -1274,9 +1261,9 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
...
@@ -1274,9 +1261,9 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
for
(
j
=
1
;
j
<
mblen
;
j
++
)
for
(
j
=
1
;
j
<
mblen
;
j
++
)
{
{
c
=
CopyGetChar
(
fp
);
c
=
CopyGetChar
(
fp
);
if
(
CopyGetEof
(
fp
)
)
if
(
c
==
EOF
)
goto
endOfFile
;
goto
endOfFile
;
appendStringInfoChar
(
&
attribute_buf
,
c
);
appendStringInfoChar
Macro
(
&
attribute_buf
,
c
);
}
}
#endif
#endif
}
}
...
...
This diff is collapsed.
Click to expand it.
src/include/lib/stringinfo.h
+
12
−
2
View file @
5c33b3c6
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
*
*
* Copyright (c) 1994, Regents of the University of California
* Copyright (c) 1994, Regents of the University of California
*
*
* $Id: stringinfo.h,v 1.1
4 1999/08/31 01:28:21
tgl Exp $
* $Id: stringinfo.h,v 1.1
5 2000/01/22 03:52:03
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -89,6 +89,16 @@ extern void appendStringInfo(StringInfo str, const char *fmt,...);
...
@@ -89,6 +89,16 @@ extern void appendStringInfo(StringInfo str, const char *fmt,...);
*/
*/
extern
void
appendStringInfoChar
(
StringInfo
str
,
char
ch
);
extern
void
appendStringInfoChar
(
StringInfo
str
,
char
ch
);
/*------------------------
* appendStringInfoCharMacro
* As above, but a macro for even more speed where it matters.
* Caution: str argument will be evaluated multiple times.
*/
#define appendStringInfoCharMacro(str,ch) \
(((str)->len + 1 >= (str)->maxlen) ? \
appendStringInfoChar(str, ch) : \
((str)->data[(str)->len] = (ch), (str)->data[++(str)->len] = '\0'))
/*------------------------
/*------------------------
* appendBinaryStringInfo
* appendBinaryStringInfo
* Append arbitrary binary data to a StringInfo, allocating more space
* Append arbitrary binary data to a StringInfo, allocating more space
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment