mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-21 13:03:23 +02:00
from the other string-category types; this eliminates a lot of surprising interpretations that the parser could formerly make when there was no directly applicable operator. Create a general mechanism that supports casts to and from the standard string types (text,varchar,bpchar) for *every* datatype, by invoking the datatype's I/O functions. These new casts are assignment-only in the to-string direction, explicit-only in the other, and therefore should create no surprising behavior. Remove a bunch of thereby-obsoleted datatype-specific casting functions. The "general mechanism" is a new expression node type CoerceViaIO that can actually convert between *any* two datatypes if their external text representations are compatible. This is more general than needed for the immediate feature, but might be useful in plpgsql or other places in future. This commit does nothing about the issue that applying the concatenation operator || to non-text types will now fail, often with strange error messages due to misinterpreting the operator as array concatenation. Since it often (not always) worked before, we should either make it succeed or at least give a more user-friendly error; but details are still under debate. Peter Eisentraut and Tom Lane
55 lines
1.5 KiB
C
55 lines
1.5 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* isn.h
|
|
* PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC)
|
|
*
|
|
* Copyright (c) 2004-2006, Germán Méndez Bravo (Kronuz)
|
|
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
|
*
|
|
* IDENTIFICATION
|
|
* $PostgreSQL: pgsql/contrib/isn/isn.h,v 1.4 2007/06/05 21:31:03 tgl Exp $
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
#ifndef ISN_H
|
|
#define ISN_H
|
|
|
|
#include "fmgr.h"
|
|
|
|
#undef ISN_DEBUG
|
|
#define ISN_WEAK_MODE
|
|
|
|
/*
|
|
* uint64 is the internal storage format for ISNs.
|
|
*/
|
|
typedef uint64 ean13;
|
|
|
|
#define EAN13_FORMAT UINT64_FORMAT
|
|
|
|
#define PG_GETARG_EAN13(n) PG_GETARG_INT64((int64)n)
|
|
#define PG_RETURN_EAN13(x) PG_RETURN_INT64((int64)x)
|
|
|
|
extern Datum isn_out(PG_FUNCTION_ARGS);
|
|
extern Datum ean13_out(PG_FUNCTION_ARGS);
|
|
extern Datum ean13_in(PG_FUNCTION_ARGS);
|
|
extern Datum isbn_in(PG_FUNCTION_ARGS);
|
|
extern Datum ismn_in(PG_FUNCTION_ARGS);
|
|
extern Datum issn_in(PG_FUNCTION_ARGS);
|
|
extern Datum upc_in(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum isbn_cast_from_ean13(PG_FUNCTION_ARGS);
|
|
extern Datum ismn_cast_from_ean13(PG_FUNCTION_ARGS);
|
|
extern Datum issn_cast_from_ean13(PG_FUNCTION_ARGS);
|
|
extern Datum upc_cast_from_ean13(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum is_valid(PG_FUNCTION_ARGS);
|
|
extern Datum make_valid(PG_FUNCTION_ARGS);
|
|
|
|
extern Datum accept_weak_input(PG_FUNCTION_ARGS);
|
|
extern Datum weak_input_status(PG_FUNCTION_ARGS);
|
|
|
|
extern void initialize(void);
|
|
|
|
#endif /* ISN_H */
|