Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008, 03:48 AM
Bruce Momjian
 
Posts: n/a
Default Feature Freeze

Now that it is August 1, we are in feature freeze. During the next
month, all outstanding patches will be reviewed and hopefully applied.
After that, we will start preparing for beta, hopefully to start in
September or October.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-12-2008, 03:49 AM
Alvaro Herrera
 
Posts: n/a
Default Re: GENERATED ... AS IDENTITY, Was: Re: Feature Freeze

Zoltan Boszormenyi wrote:

> BTW, is there anyone working on COPY FROM ( select ) feature?


I am, but it's in a too early stage to be in 8.2. Sorry :-(

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-12-2008, 03:49 AM
Rod Taylor
 
Posts: n/a
Default Re: GENERATED ... AS IDENTITY, Was: Re: Feature Freeze

On Tue, 2006-08-01 at 18:10 +0200, Zoltan Boszormenyi wrote:
> Hi,
>
> I have progressed a bit with my pet project, a.k.a $SUBJECT.
>
> Now GENERATED ALWAYS AS IDENTITY and
> GENERATED ALWAYS AS ( expr ) work as
> intended. Documentation was also extended.


I'm only commenting because I debated trying to implement this feature a
couple of times. The ugliness required for pg_dump put me off of doing
it.

I did not see a test for enforcement during COPY. UPDATE restrictions
appear to have been missed as well:

4) If <set clause> SC specifies an <object column> that
references a column of which some underlying column is either a
generated column or an identity column whose descriptor
indicates that values are always generated, then the <update
source> specified in SC shall consist of a <default
specification>.

<object column> is the <update target>, or the left hand side of the
equation. In short, if a column marked GENERATED ALWAYS is updated then
it must be to DEFAULT or not provided as an update target.

CREATE TABLE tab (col integer GENERATED ALWAYS AS IDENTITY);
UPDATE tab SET col = DEFAULT; -- ACCEPTED
UPDATE tab SET col = 1; -- ERROR


For db restoration (pg_dump), how do you restore to the same values as
previously if it is always regenerated? By making ALWAYS a suggestion
for some users instead of always enforced and providing an override
mechanism for it. I assume it only works for relation owners but I've
not figured out how the spec does permissions.

<override clause> ::=
OVERRIDING USER VALUE
| OVERRIDING SYSTEM VALUE

In short, pg_dump should append OVERRIDING SYSTEM VALUE to any insert or
copy for relations with an GENERATED ALWAYS identity column and the
backend will need to respect that.

ALWAYS is really only enforced for anyone who doesn't have permission to
specify otherwise.


Another one that got me is what do you do if you do this:

CREATE TABLE tab (col integer);
INSERT INTO tab VALUES (10);
ALTER TABLE tab ALTER col GENERATED ALWAYS AS IDENTITY;

What is the value for "tab"."col"? It would seem that the table should
be rewritten with all values for "col" recalculated -- thus it would be
'1'. But wait! Can we add the <override clause> here too to keep the old
values and change the enforcement for new tuples only?


> Some test cases are also included, that shows
> that ALTER TABLE ALTER TYPE keeps both
> the sequence and the GENERATED ALWAYS
> property. Gzipped patch is attached.
>
> Next steps are:
> - pg_dump support
> - more ALTER TABLE support for adding and
> dropping IDENTITY and GENERATED ALWAYS
> features
> - more testing
>
> I still maintain that I don't see any standard
> requirement between the GENERATED AS IDENTITY
> and NEXT VALUE FOR but obviously both
> require SEQUENCE as supported feature
> in parallel. I can be proven wrong, though,
> but please, quote section# and text where
> it can be found in the standard.
>
> As for why GENERATED ALWAYS AS IDENTITY
> is useful? Consider someone who is coming from
> another DBMS (Informix, Access, etc.) where
> "INSERT INTO table (id, ...) VALUES (0, ...);"
> inserts the next value for the autoincrementer field
> instead of 0. Leaving out fields from INSERT is
> not allowed in the source because of documentation
> reasons and writing DEFAULT is not handy or not
> found in that legacy DBMS' features.
> Multiply it with N applications that was written
> that way over the years of the lifespan of a large
> project, count in the human resistance to learn
> something new (say 2.5x multiplier, but that may be
> under-estimated :-) ) and a feature that help porting
> easier will be a cheered feature. IIRC Bruce Momjian
> himself wrote in this list that ease-of-use features
> can boost PostgreSQL userbase pretty quickly.
>
> So, please, review my patch in it's current state
> and decide whether it's a 8.2-worthy feature.
>
> BTW, is there anyone working on COPY FROM ( select ) feature?
>
> Thanks in advance and best regards,
> Zoltán Böszörményi
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match

--


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-12-2008, 03:49 AM
Zoltan Boszormenyi
 
Posts: n/a
Default Re: GENERATED ... AS IDENTITY, Was: Re: Feature Freeze

Rod Taylor írta:
> On Tue, 2006-08-01 at 18:10 +0200, Zoltan Boszormenyi wrote:
>
>> Hi,
>>
>> I have progressed a bit with my pet project, a.k.a $SUBJECT.
>>
>> Now GENERATED ALWAYS AS IDENTITY and
>> GENERATED ALWAYS AS ( expr ) work as
>> intended. Documentation was also extended.
>>

>
> I'm only commenting because I debated trying to implement this feature a
> couple of times.


Thanks for commenting it.

> The ugliness required for pg_dump put me off of doing
> it.
>


I haven't looked into it yet.

> I did not see a test for enforcement during COPY.


That was sort of intended, COPY is expected
to pull back the same record it wrote out.
But see below.

> UPDATE restrictions
> appear to have been missed as well:
>
> 4) If <set clause> SC specifies an <object column> that
> references a column of which some underlying column is either a
> generated column or an identity column whose descriptor
> indicates that values are always generated, then the <update
> source> specified in SC shall consist of a <default
> specification>.
>
> <object column> is the <update target>, or the left hand side of the
> equation. In short, if a column marked GENERATED ALWAYS is updated then
> it must be to DEFAULT or not provided as an update target.
>
> CREATE TABLE tab (col integer GENERATED ALWAYS AS IDENTITY);
> UPDATE tab SET col = DEFAULT; -- ACCEPTED
> UPDATE tab SET col = 1; -- ERROR
>


Yes, I have also read that detail but not yet implemented it.
I was too happy that I found a straightforward way to make
GENERATED ALWAYS work.

> For db restoration (pg_dump), how do you restore to the same values as
> previously if it is always regenerated? By making ALWAYS a suggestion
> for some users instead of always enforced and providing an override
> mechanism for it. I assume it only works for relation owners but I've
> not figured out how the spec does permissions.
>
> <override clause> ::=
> OVERRIDING USER VALUE
> | OVERRIDING SYSTEM VALUE
>
> In short, pg_dump should append OVERRIDING SYSTEM VALUE to any insert or
> copy for relations with an GENERATED ALWAYS identity column and the
> backend will need to respect that.
>


Aren't INSERT and COPY distinguished in code paths?
(I don't have too deep knowledge about PostgreSQL internals, yet.)
If they are, OVERRIDING SYSTEM VALUE will be
needed only when pg_dump produces INSERTs.

> ALWAYS is really only enforced for anyone who doesn't have permission to
> specify otherwise.
>
>
> Another one that got me is what do you do if you do this:
>
> CREATE TABLE tab (col integer);
> INSERT INTO tab VALUES (10);
> ALTER TABLE tab ALTER col GENERATED ALWAYS AS IDENTITY;
>
> What is the value for "tab"."col"? It would seem that the table should
> be rewritten with all values for "col" recalculated -- thus it would be
> '1'. But wait! Can we add the <override clause> here too to keep the old
> values and change the enforcement for new tuples only?
>


I don't think we should rewrite existing rows because
when it was inserted, the stored value was valid
according to the rules at that time. What if you
have more than one rows in that table?
Which record gets which value? You cannot know
which record was inserted first because subsequent
updates may ruin that order before the ALTER TABLE.
And recalculating the max value of col isn't too reliable
if another session is also inserting records.

And what about non-unique columns?
Plain SERIALs aren't declared unique automatically, either.
Consider the following:

CREATE TABLE tab (col integer);
INSERT INTO tab VALUES (10);
ALTER TABLE tab ALTER col GENERATED ALWAYS AS IDENTITY( MINVALUE 1 MAXVALUE 12 CYCLE );


Here I expect equal values and I don't want
existing rows rewritten.

E.g. if you want a new start value, you will also need to issue
ALTER TABLE tab ALTER col RESTART WITH n;
which I started to implement.

Also, for a unique SERIAL column, you can still
insert a record with an out-of-order number and
one of the INSERTs that reach that number will
fail with unique violation. e.g. it's not a real
autoincrementer field. Or you can alter a
sequence that supports such a column.
PostgreSQL documents both behaviour and
I wanted to keep it.

Thanks for the comments,
Zoltán Böszörményi

>> Some test cases are also included, that shows
>> that ALTER TABLE ALTER TYPE keeps both
>> the sequence and the GENERATED ALWAYS
>> property. Gzipped patch is attached.
>>
>> Next steps are:
>> - pg_dump support
>> - more ALTER TABLE support for adding and
>> dropping IDENTITY and GENERATED ALWAYS
>> features
>> - more testing
>>
>> I still maintain that I don't see any standard
>> requirement between the GENERATED AS IDENTITY
>> and NEXT VALUE FOR but obviously both
>> require SEQUENCE as supported feature
>> in parallel. I can be proven wrong, though,
>> but please, quote section# and text where
>> it can be found in the standard.
>>
>> As for why GENERATED ALWAYS AS IDENTITY
>> is useful? Consider someone who is coming from
>> another DBMS (Informix, Access, etc.) where
>> "INSERT INTO table (id, ...) VALUES (0, ...);"
>> inserts the next value for the autoincrementer field
>> instead of 0. Leaving out fields from INSERT is
>> not allowed in the source because of documentation
>> reasons and writing DEFAULT is not handy or not
>> found in that legacy DBMS' features.
>> Multiply it with N applications that was written
>> that way over the years of the lifespan of a large
>> project, count in the human resistance to learn
>> something new (say 2.5x multiplier, but that may be
>> under-estimated :-) ) and a feature that help porting
>> easier will be a cheered feature. IIRC Bruce Momjian
>> himself wrote in this list that ease-of-use features
>> can boost PostgreSQL userbase pretty quickly.
>>
>> So, please, review my patch in it's current state
>> and decide whether it's a 8.2-worthy feature.
>>
>> BTW, is there anyone working on COPY FROM ( select ) feature?
>>
>> Thanks in advance and best regards,
>> Zoltán Böszörményi
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 9: In versions below 8.0, the planner will ignore your desire to
>> choose an index scan if your joining column's datatypes do not
>> match
>>



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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-12-2008, 03:49 AM
Rod Taylor
 
Posts: n/a
Default Re: GENERATED ... AS IDENTITY, Was: Re: Feature Freeze

> > For db restoration (pg_dump), how do you restore to the same values as
> > previously if it is always regenerated? By making ALWAYS a suggestion
> > for some users instead of always enforced and providing an override
> > mechanism for it. I assume it only works for relation owners but I've
> > not figured out how the spec does permissions.
> >
> > <override clause> ::=
> > OVERRIDING USER VALUE
> > | OVERRIDING SYSTEM VALUE
> >
> > In short, pg_dump should append OVERRIDING SYSTEM VALUE to any insert or
> > copy for relations with an GENERATED ALWAYS identity column and the
> > backend will need to respect that.
> >

>
> Aren't INSERT and COPY distinguished in code paths?


Yes, they are separate but they also use the same permission set.

Any user can copy into a structure at any time and virtually every
restriction will be applied normally (CHECK, DEFAULT, etc.). Copy
bypasses Rules, significant parsing overhead since there is no need to
look for subselects, and possibly some triggers are bypassed. I'm fairly
sure that foreign key triggers fire.

In short, COPY doesn't bypass enforcement. GENERATED ALWAYS is part of
that enforcement and should be included in that.

If it is not included, we cannot recommend GENERATED ALWAYS for uses
like recording CURRENT_USER in an audit log since the data could be
fudged.

> > ALWAYS is really only enforced for anyone who doesn't have permission to
> > specify otherwise.
> >
> >
> > Another one that got me is what do you do if you do this:
> >
> > CREATE TABLE tab (col integer);
> > INSERT INTO tab VALUES (10);
> > ALTER TABLE tab ALTER col GENERATED ALWAYS AS IDENTITY;
> >
> > What is the value for "tab"."col"? It would seem that the table should
> > be rewritten with all values for "col" recalculated -- thus it would be
> > '1'. But wait! Can we add the <override clause> here too to keep the old
> > values and change the enforcement for new tuples only?
> >

>
> I don't think we should rewrite existing rows because
> when it was inserted, the stored value was valid
> according to the rules at that time. What if you
> have more than one rows in that table?


SERIAL has, until recently, been described as a macro. A tool for
setting things up quickly but many parts of which can be changed by hand
after-ward. It's not exactly a good source for information on how this
structure should work. For one, you can easily override the suggested
default a serial gives at any time as any user. The intention of ALWAYS
is to prevent exactly that behaviour.

I don't have an opinion on ALTER TABLE changes for this one way or the
other. It was my intention to advise that a group decision is required
and some research into what other databases do in this case. I believe
MSSQL and DB2 both implement this functionality.

Oh, and one more item. These expressions have the same abilities as a
CHECK constraint for referencing other columns.

This example comes from an IBM Guide:

CREATE TABLE T1(c1 INT, c2 DOUBLE,
c3 DOUBLE GENERATED ALWAYS AS (c1 + c2),
c4 SMALLINT GENERATED ALWAYS AS
(CASE
WHEN c1 > c2 THEN 1
ELSE NULL
END)
);

Here is what IBM has to say about ALTER TABLE and GENERATED ALWAYS:

GENERATED
Specifies that DB2 generates values for the column.

ALWAYS
Specifies that DB2 will always generate
a value for the column when a row is
inserted into the table, or whenever the
result value of the
generation-expression might change. The
result of the expression is stored in
the table. GENERATED ALWAYS is the
recommended option unless data
propagation or unload and reload
operations are being performed.
GENERATED ALWAYS is the required option
for generated columns.

BY DEFAULT
Specifies that DB2 will generate a value
for the column when a row is inserted
into the table, or updated, specifying
DEFAULT for the column, unless an
explicit value is specified. BY DEFAULT
is the recommended option when using
data propagation or performing unload
and reload operations.

identity-options
This clause cannot be specified when adding a column to
an existing table.

AS (generation-expression)
Specifies that the definition of the column is based on
an expression. Requires that the table be put in check
pending state, using the SET INTEGRITY statement. After
the ALTER TABLE statement, the SET INTEGRITY statement
with FORCE GENERATED must be used to update and check
all the values in that column against the new
expression. For details on specifying a column with a
generation-expression, see "CREATE TABLE".

I'm not sure what they're describing, actually. It appears they don't
require it to be updated but that the option is available to do so when
the equation changes.

> Which record gets which value? You cannot know


Note that when you add a new column with a default, including nextval of
a sequence, it is expected that those values will be assigned by tuple
order in the table.

CREATE SEQUENCE foo;
ALTER TABLE tab ADD col integer DEFAULT nextval('foo');

> which record was inserted first because subsequent
> updates may ruin that order before the ALTER TABLE.
> And recalculating the max value of col isn't too reliable
> if another session is also inserting records.
>
> And what about non-unique columns?


I'm not sure what unique versus non-unique has to do with this. The
question I have is what is the meaning of ALWAYS.

There is never a guarantee that alter table will succeed in all cases.

ALTER TABLE tab ALTER col TYPE bigint USING 2;

> Plain SERIALs aren't declared unique automatically, either.
> Consider the following:
>
> CREATE TABLE tab (col integer);
> INSERT INTO tab VALUES (10);
> ALTER TABLE tab ALTER col GENERATED ALWAYS AS IDENTITY( MINVALUE 1 MAXVALUE 12 CYCLE );


--


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-12-2008, 03:50 AM
Zoltan Boszormenyi
 
Posts: n/a
Default Re: GENERATED ... AS IDENTITY, Was: Re: Feature Freeze

Rod Taylor írta:
>>> For db restoration (pg_dump), how do you restore to the same values as
>>> previously if it is always regenerated? By making ALWAYS a suggestion
>>> for some users instead of always enforced and providing an override
>>> mechanism for it. I assume it only works for relation owners but I've
>>> not figured out how the spec does permissions.
>>>
>>> <override clause> ::=
>>> OVERRIDING USER VALUE
>>> | OVERRIDING SYSTEM VALUE
>>>
>>> In short, pg_dump should append OVERRIDING SYSTEM VALUE to any insert or
>>> copy for relations with an GENERATED ALWAYS identity column and the
>>> backend will need to respect that.
>>>
>>>

>> Aren't INSERT and COPY distinguished in code paths?
>>

>
> Yes, they are separate but they also use the same permission set.
>
> Any user can copy into a structure at any time and virtually every
> restriction will be applied normally (CHECK, DEFAULT, etc.). Copy
> bypasses Rules, significant parsing overhead since there is no need to
> look for subselects, and possibly some triggers are bypassed. I'm fairly
> sure that foreign key triggers fire.
>
> In short, COPY doesn't bypass enforcement. GENERATED ALWAYS is part of
> that enforcement and should be included in that.
>
> If it is not included, we cannot recommend GENERATED ALWAYS for uses
> like recording CURRENT_USER in an audit log since the data could be
> fudged.
>


OK. So COPY needs an OVERRIDING close, too, not just INSERT.
In the meantime I implemented the discussed restrictions on
UPDATE for GENERATED ALWAYS columns, allowing
"UPDATE tab SET col = default" only for
GENERATED ALWAYS AS. I also implemented
INSERT ... OVERRIDING { SYSTEM | USER } VALUE.
If I got it correctly, OVERRIDING USER VALUE
seems to be the same as omitting the OVERRIDING clause...

>>> ALWAYS is really only enforced for anyone who doesn't have permission to
>>> specify otherwise.
>>>
>>>
>>> Another one that got me is what do you do if you do this:
>>>
>>> CREATE TABLE tab (col integer);
>>> INSERT INTO tab VALUES (10);
>>> ALTER TABLE tab ALTER col GENERATED ALWAYS AS IDENTITY;
>>>
>>> What is the value for "tab"."col"? It would seem that the table should
>>> be rewritten with all values for "col" recalculated -- thus it would be
>>> '1'. But wait! Can we add the <override clause> here too to keep the old
>>> values and change the enforcement for new tuples only?
>>>
>>>

>> I don't think we should rewrite existing rows because
>> when it was inserted, the stored value was valid
>> according to the rules at that time. What if you
>> have more than one rows in that table?
>>

>
> SERIAL has, until recently, been described as a macro. A tool for
> setting things up quickly but many parts of which can be changed by hand
> after-ward. It's not exactly a good source for information on how this
> structure should work. For one, you can easily override the suggested
> default a serial gives at any time as any user. The intention of ALWAYS
> is to prevent exactly that behaviour.
>
> I don't have an opinion on ALTER TABLE changes for this one way or the
> other. It was my intention to advise that a group decision is required
> and some research into what other databases do in this case. I believe
> MSSQL and DB2 both implement this functionality.
>


I see.

I looked a bit into the TODO entry that's about
ALTER TABLE tab ALTER col RENAME newcol
should also rename the sequence. My question is:
is it legal to call pg_get_serial_sequence() from
src/backen/parser/analyze.c:transformAlterTableStmt()?
This would be the easiest way to issue an
ALTER TABLE oldseq RENAME newseq
command automatically.

And I think I found a bug in PostgreSQL.
If I do this:

create table tab1 (id serial, t text); -- creates tab1_id_seq
create table tab2 (id serial, t text) inherits (tab1); -- creates
tab2_id_seq
drop table tab1 cascade;

then tab1_id_seq gets also dropped but tab2_id_seq doesn't.
Both 8.1.4 and current 8.2CVS do this.

> Oh, and one more item. These expressions have the same abilities as a
> CHECK constraint for referencing other columns.
>
> This example comes from an IBM Guide:
>
> CREATE TABLE T1(c1 INT, c2 DOUBLE,
> c3 DOUBLE GENERATED ALWAYS AS (c1 + c2),
> c4 SMALLINT GENERATED ALWAYS AS
> (CASE
> WHEN c1 > c2 THEN 1
> ELSE NULL
> END)
> );
>
>


For this to work, we need to lift the restriction
on DEFAULT so cother columns can appear in the
expression. Dependencies must be tracked between
columns so GENERATED ALWAYS columns on UPDATE
and DEFAULT/ GENERATED ALWAYS columns on
INSERT get their computed values. Circular dependencies
must be avoided, etc. Hm.

> Here is what IBM has to say about ALTER TABLE and GENERATED ALWAYS:
>
> GENERATED
> Specifies that DB2 generates values for the column.
>
> ALWAYS
> Specifies that DB2 will always generate
> a value for the column when a row is
> inserted into the table, or whenever the
> result value of the
> generation-expression might change. The
> result of the expression is stored in
> the table. GENERATED ALWAYS is the
> recommended option unless data
> propagation or unload and reload
> operations are being performed.
> GENERATED ALWAYS is the required option
> for generated columns.
>
> BY DEFAULT
> Specifies that DB2 will generate a value
> for the column when a row is inserted
> into the table, or updated, specifying
> DEFAULT for the column, unless an
> explicit value is specified. BY DEFAULT
> is the recommended option when using
> data propagation or performing unload
> and reload operations.
>
> identity-options
> This clause cannot be specified when adding a column to
> an existing table.
>


This is even more strict then SQL2003 which allows
only one IDENTITY column at any time, so this is allowed:

CREATE TABLE tab (id serial, ...);
ALTER TABLE tab DROP id;
ALTER TABLE tab ADD id serial GENERATED AS IDENTITY (...);

I deliberately omitted the check to enforce it.

>
> AS (generation-expression)
> Specifies that the definition of the column is based on
> an expression. Requires that the table be put in check
> pending state, using the SET INTEGRITY statement. After
> the ALTER TABLE statement, the SET INTEGRITY statement
> with FORCE GENERATED must be used to update and check
> all the values in that column against the new
> expression. For details on specifying a column with a
> generation-expression, see "CREATE TABLE".
>
> I'm not sure what they're describing, actually. It appears they don't
> require it to be updated but that the option is available to do so when
> the equation changes.
>
>
>> Which record gets which value? You cannot know
>>

>
> Note that when you add a new column with a default, including nextval of
> a sequence, it is expected that those values will be assigned by tuple
> order in the table.
>
> CREATE SEQUENCE foo;
> ALTER TABLE tab ADD col integer DEFAULT nextval('foo');
>
>
>> which record was inserted first because subsequent
>> updates may ruin that order before the ALTER TABLE.
>> And recalculating the max value of col isn't too reliable
>> if another session is also inserting records.
>>
>> And what about non-unique columns?
>>

>
> I'm not sure what unique versus non-unique has to do with this. The
> question I have is what is the meaning of ALWAYS.
>
> There is never a guarantee that alter table will succeed in all cases.
>
> ALTER TABLE tab ALTER col TYPE bigint USING 2;
>
>
>> Plain SERIALs aren't declared unique automatically, either.
>> Consider the following:
>>
>> CREATE TABLE tab (col integer);
>> INSERT INTO tab VALUES (10);
>> ALTER TABLE tab ALTER col GENERATED ALWAYS AS IDENTITY( MINVALUE 1 MAXVALUE 12 CYCLE );
>>




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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:35 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560