473,770 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sequence behavior - is this correct

Hello,
I would like to ask if my problem with sequence is a proper behavior or
this is a bug (probably not)...

I have a table:

CREATE TABLE "testtable" (
"serialfiel d" SERIAL,
"someotherfield " TEXT,
PRIMARY KEY("serialfiel d")
) WITH OIDS;

After creation of this table, sequence "testtable_seri alfield_seq" is
automatically created, with start value set to "1".

CREATE SEQUENCE "public"."testt able_serialfiel d_seq"
INCREMENT 1 MINVALUE 1
MAXVALUE 922337203685477 5807 START 1
CACHE 1;

And now I have to insert into this table some records from other rdbms
(like MySQL) using sql inserts generated by e.g. mysqldump - it is a
simple import of data, where "serialfiel d" has got some value...

INSERT INTO testtable VALUES (1, 'sdsdsd');
INSERT INTO testtable VALUES (5, 'sdsdsd');
INSERT INTO testtable VALUES (10, 'sdsdsd');

And my question is: how sequence should react for this ? Right now start
value of the sequence is still "1", so if I will make a query like
"INSERT INTO testtable (someotherfield ) VALUES ('sdsdsd')" then new
record's serialfield will have value set to "1" - of course this record
will not be created, because of primary key - but next insert will
create a new record with serialfield set to "2".

I didn't notice this problem before, because I have never made any
imports of data in this way..

Window/Cygwin
PostgreSQL 8.0.0beta3
Regards,
ML


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

http://archives.postgresql.org

Nov 23 '05 #1
1 2212
That is correct behavior. The sequence value only updates when you use
the sequence value. If you put your own data into the sequence field,
as you would be doing in a conversion or import, the sequence does not
change.

To manually change the sequence values, refer to the script I posted
on Oct. 11, titled "[GENERAL] update sequence conversion script",
which will go through all your tables with sequences and
update them. (you can probably find the post in the archives,
http://archives.postgresql.org)

Sim Zacks
IT Manager
CompuLab
04-829-0145 - Office
04-832-5251 - Fax

_______________ _______________ _______________ _______________ _______________ _____

Hello,
I would like to ask if my problem with sequence is a proper behavior or
this is a bug (probably not)...

I have a table:

CREATE TABLE "testtable" (
"serialfiel d" SERIAL,
"someotherfield " TEXT,
PRIMARY KEY("serialfiel d")
) WITH OIDS;

After creation of this table, sequence "testtable_seri alfield_seq" is
automatically created, with start value set to "1".

CREATE SEQUENCE "public"."testt able_serialfiel d_seq"
INCREMENT 1 MINVALUE 1
MAXVALUE 922337203685477 5807 START 1
CACHE 1;

And now I have to insert into this table some records from other rdbms
(like MySQL) using sql inserts generated by e.g. mysqldump - it is a
simple import of data, where "serialfiel d" has got some value...

INSERT INTO testtable VALUES (1, 'sdsdsd');
INSERT INTO testtable VALUES (5, 'sdsdsd');
INSERT INTO testtable VALUES (10, 'sdsdsd');

And my question is: how sequence should react for this ? Right now start
value of the sequence is still "1", so if I will make a query like
"INSERT INTO testtable (someotherfield ) VALUES ('sdsdsd')" then new
record's serialfield will have value set to "1" - of course this record
will not be created, because of primary key - but next insert will
create a new record with serialfield set to "2".

I didn't notice this problem before, because I have never made any
imports of data in this way..

Window/Cygwin
PostgreSQL 8.0.0beta3
Regards,
ML


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

http://archives.postgresql.org
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org

Nov 23 '05 #2

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

Similar topics

8
2152
by: dan | last post by:
I was recently surprised, and quite shocked in fact, to find that Python treats negative indices into sequence types as if they were mod(length-of-sequence), at least up to -len(seq). This fact is *deeply* buried in the docs, and is not at all intuitive. One of the big advantages of a high-level language such as Python is the ability to provide run-time bounds checking on array-type constructs. To achieve this I will now have to...
3
2388
by: Sensorflo | last post by:
After browsing though many newsgroups articels I'm still not shure how operator precedence, operator associativity, sequence points, side effects go together. Currently I have the following view: An expression a = b() + c() * d++; can be transformed with the rules of operator associativity and operator precedence into a tree
4
8221
by: j | last post by:
In a footnote in the c99 standard the following is labeled as undefined: a = i; And in the second clause of section 6.5 the following is stated: "Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be read only to determine the value
53
4095
by: Deniz Bahar | last post by:
I know the basic definition of a sequence point (point where all side effects guaranteed to be finished), but I am confused about this statement: "Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be accessed only to determine the value to be stored." Can someone give me examples of expressions that "barely"...
7
2081
by: akarl | last post by:
Hi all, Why do I get a warning from gcc with the following program? $ cat test.c #include <stdio.h> int f(int n) { return n;
9
2510
by: John Smith | last post by:
I've been playing with splint, which returns the following warning for the code below: statlib.c: (in function log_norm_pdf) statlib.c(1054,31): Expression has undefined behavior (left operand uses errno, modified by right operand): (log(x) - mu) * (log(x) - mu) Code has unspecified behavior. Order of evaluation of function parameters or subexpressions is not defined, so if a value is used and
14
4802
by: pat270881 | last post by:
hello, I have to implement a sequence class, however the header file is predefined class sequence { public: // TYPEDEFS and MEMBER CONSTANTS
2
334
by: Kai-Uwe Bux | last post by:
Please consider #include <iostream> int main ( void ) { int a = 0; a = ( (a = 5), 4 ); // (*) std::cout << a << '\n'; }
4
2535
by: Tomás Ó hÉilidhe | last post by:
I'm writing a program currently that was working perfectly until I decided to compile it with "-O3" in gcc (-O3 specifies optimisation of the third level). Anyway, I found the problem. I had the following function: void StrToLower(char *p) { while ( *p++ = tolower( (char unsigned)*p ) ); }
0
9617
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
9453
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
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
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
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.