473,836 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

int1?

CSN
Is there any date type that can be used for 0-255
values? Like an "int1" or byte column.

CSN

_______________ _______________ ____
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05
35 4353
On Thu, 2003-10-09 at 14:46, Bruno Wolff III wrote:
On Thu, Oct 09, 2003 at 14:28:57 -0500,
Ron Johnson <ro***********@ cox.net> wrote:

http://www.postgresql.org/docs/7.3/s...atedomain.html
CREATE DOMAIN domainname [AS] data_type
[ DEFAULT default_expr ]
[ constraint [, ... ] ]

where constraint is:

[ CONSTRAINT constraint_name ]
{ NOT NULL | NULL }

test1=# create domain d_tinyint as smallint constraint chk_tinyint CHECK (smallint between 0 and 255);
ERROR: DefineDomain: CHECK Constraints not supported

So, how would I create a domain that limits a smallint?


You need to use 7.4. In 7.3 you couldn't use check constraints with domains.


So is there a documentation "bug", or, what kind of constraints
can be placed on domains besides { NOT NULL | NULL }?

--
-----------------------------------------------------------------
Ron Johnson, Jr. ro***********@c ox.net
Jefferson, LA USA

Causation does NOT equal correlation !!!!!!!!
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 12 '05 #11
Ron Johnson writes:
test1=# create domain d_tinyint as smallint constraint chk_tinyint CHECK (smallint between 0 and 255);
ERROR: DefineDomain: CHECK Constraints not supported

So, how would I create a domain that limits a smallint?


You would have to wait for PostgreSQL 7.4.

--
Peter Eisentraut pe*****@gmx.net
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #12
On Thu, Oct 09, 2003 at 14:46:08 -0500,
Ron Johnson <ro***********@ cox.net> wrote:
On Thu, 2003-10-09 at 14:46, Bruno Wolff III wrote:
On Thu, Oct 09, 2003 at 14:28:57 -0500,
Ron Johnson <ro***********@ cox.net> wrote:

http://www.postgresql.org/docs/7.3/s...atedomain.html
CREATE DOMAIN domainname [AS] data_type
[ DEFAULT default_expr ]
[ constraint [, ... ] ]

where constraint is:

[ CONSTRAINT constraint_name ]
{ NOT NULL | NULL }

test1=# create domain d_tinyint as smallint constraint chk_tinyint CHECK (smallint between 0 and 255);
ERROR: DefineDomain: CHECK Constraints not supported

So, how would I create a domain that limits a smallint?


You need to use 7.4. In 7.3 you couldn't use check constraints with domains.


So is there a documentation "bug", or, what kind of constraints
can be placed on domains besides { NOT NULL | NULL }?


I think the documentation is correct. As I read it it says that only NOT NULL
and NULL constraints are allowed. This is easy to overlook. I know I got
caught by this when I tried it.

I started using 7.4 pretty early on since I wanted to use check constraints
in earthdistance to have a domain that represented points on the surface of
the earth on top of the cube data type.

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #13
On Thu, 2003-10-09 at 15:13, Bruno Wolff III wrote:
On Thu, Oct 09, 2003 at 14:46:08 -0500,
Ron Johnson <ro***********@ cox.net> wrote:
On Thu, 2003-10-09 at 14:46, Bruno Wolff III wrote:
On Thu, Oct 09, 2003 at 14:28:57 -0500,
Ron Johnson <ro***********@ cox.net> wrote:
>
> http://www.postgresql.org/docs/7.3/s...atedomain.html
> CREATE DOMAIN domainname [AS] data_type
> [ DEFAULT default_expr ]
> [ constraint [, ... ] ]
>
> where constraint is:
>
> [ CONSTRAINT constraint_name ]
> { NOT NULL | NULL }
>
> test1=# create domain d_tinyint as smallint constraint chk_tinyint CHECK (smallint between 0 and 255);
> ERROR: DefineDomain: CHECK Constraints not supported
>
> So, how would I create a domain that limits a smallint?

You need to use 7.4. In 7.3 you couldn't use check constraints with domains.


So is there a documentation "bug", or, what kind of constraints
can be placed on domains besides { NOT NULL | NULL }?


I think the documentation is correct. As I read it it says that only NOT NULL
and NULL constraints are allowed. This is easy to overlook. I know I got
caught by this when I tried it.


test1=# create domain foo as smallint not null;
CREATE DOMAIN

test1=# create domain bar as smallint CONSTRAINT wiggle not null;
CREATE DOMAIN

Oh, ok. Stuff in [] is not necessary. Still confusing.

--
-----------------------------------------------------------------
Ron Johnson, Jr. ro***********@c ox.net
Jefferson, LA USA

The difference between drunken sailors and Congressmen is that
drunken sailors spend their own money.
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #14
Ron Johnson wrote:
On Thu, 2003-10-09 at 02:16, CSN wrote:
Is there any date type that can be used for 0-255
values? Like an "int1" or byte column.


An int2 with a constraint on it.


You can use the data type "char" (with the quotes, and without a (n)
decoration). See:
http://www.postgresql.org/docs/view....character.html
near the bottom of the page.

Joe
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #15
CSN

Would you be able to roll your own int1's with types?

http://www.postgresql.org/docs/7.3/i...ve/xtypes.html

CSN
_______________ _______________ ____
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 12 '05 #16
I don't think that you can create a genuine one byte datatype.
The resulting type would probably be four bytes long, even if
you create a one byte by-value data type. The one byte would
be packaged in a 4 byte container for passing around the server.

Can anyone confirm or deny this? This was certainly the
case in Informix and Illustra.

--elein
el***@varlena.c om

On Fri, Oct 10, 2003 at 11:37:14AM -0700, CSN wrote:

Would you be able to roll your own int1's with types?

http://www.postgresql.org/docs/7.3/i...ve/xtypes.html

CSN
_______________ _______________ ____
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #17
elein wrote:
I don't think that you can create a genuine one byte datatype.
The resulting type would probably be four bytes long, even if
you create a one byte by-value data type. The one byte would
be packaged in a 4 byte container for passing around the server.

Can anyone confirm or deny this?


See my other post. The type exists and is called "char". See the bottom
of this page:
http://www.postgresql.org/docs/view....character.html

Joe
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 12 '05 #18
The "char" type has special handling built into the server
if I recall correctly and that is part of the reason it
does not behave correctly in some cases. But I think it is
still schlepped around as a DATUM which is a four byte value.

What I meant was a user defined single byte data type.
I don't think it can be done since it needs to be packaged
as a DATUM.

elein

On Fri, Oct 10, 2003 at 06:07:00PM -0700, Joe Conway wrote:
elein wrote:
I don't think that you can create a genuine one byte datatype.
The resulting type would probably be four bytes long, even if
you create a one byte by-value data type. The one byte would
be packaged in a 4 byte container for passing around the server.

Can anyone confirm or deny this?


See my other post. The type exists and is called "char". See the bottom
of this page:
http://www.postgresql.org/docs/view....character.html

Joe
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 12 '05 #19
elein wrote:
The "char" type has special handling built into the server
if I recall correctly and that is part of the reason it
does not behave correctly in some cases. But I think it is
still schlepped around as a DATUM which is a four byte value.

What I meant was a user defined single byte data type.
I don't think it can be done since it needs to be packaged
as a DATUM.


No, "char" is exactly one byte. See the doc, or the source:
http://developer.postgresql.org/cvsw...-cvsweb-markup

Joe


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
1243
by: Xiangliang Meng | last post by:
The fragment code: #include <iostream> using namespace std; class Integer { int i; public: Integer() : i(0) {};
7
6711
by: Tweaxor | last post by:
I stuck with exerise in a Learning C book that I got. If I have the numbers as input. How can I determine which of the three is the smallest number, largest number and the range. Or would it be simpler to just find the range of the three numbers. Thanks in advance :D
1
2555
by: Primillo | last post by:
'Full source 'Insert, delete and update don't work Public Class WebForm1 Inherits System.Web.UI.Page Protected WithEvents Button1 As System.Web.UI.WebControls.Button Protected WithEvents Button2 As System.Web.UI.WebControls.Button Protected WithEvents Button3 As System.Web.UI.WebControls.Button
6
1627
by: AMDRIT | last post by:
Hello folks, I appologize for the cross post, but I really need an answer on this: I do not think that I am seeing the whole picture here. I would like to create a windows service and a management console, using Visual Basic 2003. The windows service part, I think, is easy enough. I am more concerned with the remoting aspect of the project. Below is the general idea of my approach, please correct my where I am wrong.
9
2584
by: Greg Strong | last post by:
Hello All, What is the maximum length of an ODBC pass through query? Things work fine with the code except when I try to create a view which is pretty complex in Oracle. I'm using a DSN provided with the Oracle Express Edition and using Access 2k2 as the front-end. When I debug print the SQL and paste it into SQLplus it works fine. The length of the debug print that works is 1988 characters. Since the exact same code works with...
6
1283
by: =?Utf-8?B?ZGljazIz?= | last post by:
I am just a beginner coding in VB6. I am trying to write a simple code to add 2 numbers together and put the answer in a text box I have one textbox open to accept each number, a textbox to accept the answer and a button where I am adding this code Dim intNumber1 As Integer Dim intNumber2 As Integer Dim intAnswer As Integer intAnswer = intNumber1 + intNumber2 txtAnswer.Text = intAnswer How come I keep getting 0 as an anwer
11
16588
by: ITprogramer17 | last post by:
Hi... How to add 4+6 when you use two textbox, the first textbox is for the input and the other one if for the output..
6
47674
by: Author | last post by:
I have class BaseClass { public BaseClass(string s1, string s2) { this.S1 = s1; this.S2 = s2; } public string S1 { get; set;}
0
9816
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10840
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10588
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9371
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7790
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5647
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5823
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3112
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.