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
d0667af9
Commit
d0667af9
authored
Oct 23, 2001
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for INTERVAL's new typmod values to format_type.
parent
01b73d3f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
4 deletions
+75
-4
src/backend/utils/adt/format_type.c
src/backend/utils/adt/format_type.c
+75
-4
No files found.
src/backend/utils/adt/format_type.c
View file @
d0667af9
...
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.
19 2001/10/08 19:55:07
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.
20 2001/10/23 20:12:54
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -20,12 +20,14 @@
#include "fmgr.h"
#include "catalog/pg_type.h"
#include "utils/builtins.h"
#include "utils/datetime.h"
#include "utils/numeric.h"
#include "utils/syscache.h"
#ifdef MULTIBYTE
#include "mb/pg_wchar.h"
#endif
#define MASK(b) (1 << (b))
#define MAX_INT32_LEN 11
#define _textin(str) DirectFunctionCall1(textin, CStringGetDatum(str))
...
...
@@ -132,7 +134,8 @@ format_type_internal(Oid type_oid, int32 typemod, bool allow_invalid)
if
(
allow_invalid
)
return
pstrdup
(
"???"
);
else
elog
(
ERROR
,
"could not locate data type with oid %u in catalog"
,
type_oid
);
elog
(
ERROR
,
"could not locate data type with oid %u in catalog"
,
type_oid
);
}
array_base_type
=
((
Form_pg_type
)
GETSTRUCT
(
tuple
))
->
typelem
;
...
...
@@ -149,7 +152,8 @@ format_type_internal(Oid type_oid, int32 typemod, bool allow_invalid)
if
(
allow_invalid
)
return
pstrdup
(
"???[]"
);
else
elog
(
ERROR
,
"could not locate data type with oid %u in catalog"
,
type_oid
);
elog
(
ERROR
,
"could not locate data type with oid %u in catalog"
,
type_oid
);
}
is_array
=
true
;
type_oid
=
array_base_type
;
...
...
@@ -209,6 +213,73 @@ format_type_internal(Oid type_oid, int32 typemod, bool allow_invalid)
buf
=
pstrdup
(
"numeric"
);
break
;
case
INTERVALOID
:
if
(
with_typemod
)
{
int
fields
=
typemod
>>
16
;
int
precision
=
typemod
&
0xFFFF
;
const
char
*
fieldstr
;
switch
(
fields
)
{
case
MASK
(
YEAR
):
fieldstr
=
" year"
;
break
;
case
MASK
(
MONTH
):
fieldstr
=
" month"
;
break
;
case
MASK
(
DAY
):
fieldstr
=
" day"
;
break
;
case
MASK
(
HOUR
):
fieldstr
=
" hour"
;
break
;
case
MASK
(
MINUTE
):
fieldstr
=
" minute"
;
break
;
case
MASK
(
SECOND
):
fieldstr
=
" second"
;
break
;
case
MASK
(
YEAR
)
|
MASK
(
MONTH
):
fieldstr
=
" year to month"
;
break
;
case
MASK
(
DAY
)
|
MASK
(
HOUR
):
fieldstr
=
" day to hour"
;
break
;
case
MASK
(
DAY
)
|
MASK
(
HOUR
)
|
MASK
(
MINUTE
):
fieldstr
=
" day to minute"
;
break
;
case
MASK
(
DAY
)
|
MASK
(
HOUR
)
|
MASK
(
MINUTE
)
|
MASK
(
SECOND
):
fieldstr
=
" day to second"
;
break
;
case
MASK
(
HOUR
)
|
MASK
(
MINUTE
):
fieldstr
=
" hour to minute"
;
break
;
case
MASK
(
HOUR
)
|
MASK
(
MINUTE
)
|
MASK
(
SECOND
):
fieldstr
=
" hour to second"
;
break
;
case
MASK
(
MINUTE
)
|
MASK
(
SECOND
):
fieldstr
=
" minute to second"
;
break
;
case
0x7FFF
:
fieldstr
=
""
;
break
;
default:
elog
(
DEBUG
,
"Invalid INTERVAL typmod 0x%x"
,
typemod
);
fieldstr
=
""
;
break
;
}
if
(
precision
!=
0xFFFF
)
buf
=
psnprintf
(
100
,
"interval(%d)%s"
,
precision
,
fieldstr
);
else
buf
=
psnprintf
(
100
,
"interval%s"
,
fieldstr
);
}
else
buf
=
pstrdup
(
"interval"
);
break
;
case
TIMEOID
:
if
(
with_typemod
)
buf
=
psnprintf
(
50
,
"time(%d) without time zone"
,
...
...
@@ -300,7 +371,7 @@ format_type_internal(Oid type_oid, int32 typemod, bool allow_invalid)
int32
type_maximum_size
(
Oid
type_oid
,
int32
typemod
)
{
if
(
typemod
<
=
0
)
if
(
typemod
<
0
)
return
-
1
;
switch
(
type_oid
)
...
...
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