mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
get_seq_name should truncate name to NAMEDATALEN, so that this works:
create sequence a1234567890123456789012345678901234567890; select nextval('a1234567890123456789012345678901234567890');
This commit is contained in:
parent
b67fc0079c
commit
a6697b3614
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.57 2001/06/01 19:52:24 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.58 2001/06/06 22:03:48 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -22,6 +22,10 @@
|
|||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
#include "utils/acl.h"
|
#include "utils/acl.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
|
#ifdef MULTIBYTE
|
||||||
|
#include "mb/pg_wchar.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define SEQ_MAGIC 0x1717
|
#define SEQ_MAGIC 0x1717
|
||||||
|
|
||||||
@ -523,7 +527,8 @@ setval_and_iscalled(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Given a 'text' parameter to a sequence function, extract the actual
|
* Given a 'text' parameter to a sequence function, extract the actual
|
||||||
* sequence name. We downcase the name if it's not double-quoted.
|
* sequence name. We downcase the name if it's not double-quoted,
|
||||||
|
* and truncate it if it's too long.
|
||||||
*
|
*
|
||||||
* This is a kluge, really --- should be able to write nextval(seqrel).
|
* This is a kluge, really --- should be able to write nextval(seqrel).
|
||||||
*/
|
*/
|
||||||
@ -557,6 +562,20 @@ get_seq_name(text *seqin)
|
|||||||
*rawname = tolower((unsigned char) *rawname);
|
*rawname = tolower((unsigned char) *rawname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Truncate name if it's overlength; again, should match scan.l */
|
||||||
|
if (strlen(seqname) >= NAMEDATALEN)
|
||||||
|
{
|
||||||
|
#ifdef MULTIBYTE
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = pg_mbcliplen(seqname, i, NAMEDATALEN-1);
|
||||||
|
seqname[len] = '\0';
|
||||||
|
#else
|
||||||
|
seqname[NAMEDATALEN-1] = '\0';
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
return seqname;
|
return seqname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user