Errors, refused statements and known differences
PostgreSQL error codes, what is refused and how the behaviour differs from a real PostgreSQL.
Refused#
Refused clearly with PostgreSQL's SQLSTATE 0A000 (feature_not_supported: X is not supported by this server) or the syntax error PostgreSQL gives at the right position (42601); a script lists them with their output.
- Programmability:
CREATE TYPEof a base, shell or range type, range and multirange types (int4range,tstzrange, ...),CREATE RULE | AGGREGATE | OPERATOR | COLLATION | CAST | LANGUAGE | PUBLICATION | SUBSCRIPTION,CREATE EXTENSIONof anything butuuid-ossp,pgcryptoandpg_trgm(extension "x" is unavailable: hstore, citext, unaccent, PostGIS and other extensions written in C),crypt,gen_saltandpgp_*of pgcrypto,word_similarityof pg_trgm, large objects (lo_*), languages other thanplpgsqlandsql;ADD | DROP ATTRIBUTEof a composite type another composite type stores in a column; in the function of a row trigger of a table (it is translated into an engine trigger): conditions other thanothers,division_by_zero,raise_exception, the23xxxones and literal SQLSTATEs,FORover a query, record variables (the functions of statement-level,INSTEAD OFand transition-table triggers are interpreted and have none of these limits);RETURNINGandON CONFLICTon a view withINSTEAD OFtriggers; aformat()format that is not a constant;MERGE .. RETURNINGwith anINSERTthat does not give the primary key or withDEFAULT VALUES; a call of a function with arguments that read columns (except aLANGUAGE sqlfunction that is oneSELECTexpression), a user-defined set-returning function in the select list; privileges on functions. - Storage:
CREATE MATERIALIZED VIEW .. WITH NO DATA, declarative partitioning (PARTITION BY,PARTITION OF),INHERITS,CREATE TABLE .. (LIKE ..), index methods other than btree, hash and the text search GIN index,ALTER TABLE .. SET | ENABLE | DISABLE,ALTER .. SET DEFAULT ..of the system,COPYfrom or to a file or a program,COPYwithFORCE_NULL,ON_ERROR,DEFAULT,WHERE,SELECT .. INTO,ON DELETE SET DEFAULT,ALTER COLUMN TYPE .. USING,COMMIT PREPARED. - Query features:
tsvector/tsqueryvalues outside@@and the text search functions other than the ones above (ts_rank,ts_headline,setweight, ...),generate_subscriptsof a dimension other than 1, virtual generated columns,SIMILAR TOwith a pattern that is not a literal,INTERSECT ALL/EXCEPT ALL,WINDOWframes other than as written, comparison of a composite value with a text literal (as in PostgreSQL),SET client_encodingother thanUTF8,DateStyleother than ISO. - Everything else not listed in "Statements" is
42601or42883(an unknown function:function f(integer) has not been defined).
Known differences from PostgreSQL#
Everything that does not come out identical is listed here; a difference that could be removed was removed, not hidden.
DETAIL: Failing row contains (...)ofnot-nullandcheckviolations is not given; theDETAIL: Key (x)=(v) is not present in table .../is still referenced from ...of foreign-key violations is not given (the engine's error does not carry the row). TheERRORline, SQLSTATE, constraint and table names are PostgreSQL's. Unique violations carry theKey (..)=(..) already exists.detail.- Text is compared, sorted and matched by bytes (the
Ccollation:'a' = 'A'is false,Bsorts beforea); the comparison cluster is made with--locale=C.GROUP BY,DISTINCTand the unique indexes of text columns still ignore case, as the engine does (D102). - Numbers.
numericwithout a modifier is stored as the engine'sPGNUMERIC(D135): each value keeps its own scale, as in PostgreSQL, up to 30 digits after the point (a column of a table made before D135 is aDECIMAL(65,30)and is printed without trailing zeros);NaNandInfinityofnumericdo not exist. A quotient has PostgreSQL's scale (D125:1::numeric / 3is0.33333333333333333333,7::numeric / 2is3.5000000000000000;avgof integers and numerics too), also when stored in an unconstrainednumericcolumn or a table made byCREATE TABLE AS. The operands of a division count their own scale as the declared one (a numeric without modifier: the scale of the digits written). The engine'sSUMof decimals is exact when the digits fit 128 bits.float4arithmetic is done in double precision. - Fractions of seconds are kept by
timestamp,time,intervaland the engine's date functions since D123. - JSON.
jsonbcolumns print as PostgreSQL stores them; the values the operators->,->>,#>,@>return come from the engine's JSON and write1.50as1.5.json(notjsonb) is kept as text.?,?|and?&look at the keys of an object, the elements of an array and a string value (D125). bytea(D125) is the engine text\x+ hex digits, lower case (so comparison and ordering of the text are the byte order); input in the hex and the escape form with PostgreSQL's errors,bytea_output = 'escape'in text transfer,length,octet_length,bit_length,encodeanddecode(hex,base64,escape),||,substring,position,get_byte,set_byte,md5,convert_toandconvert_from(UTF8 only) count and work on bytes. A client that asks for the binary format gets the bytes whateverbytea_outputis (D135).timetz, intervals and time zones are done (D126, D123).- Arrays (D112.1) are JSON arrays: a number read out of an array has lost its scale unless the type has one (
numeric(10,2)[]); ordering comparison andORDER BYof arrays follow PostgreSQL (numbers compared as double precision); a lower bound other than 1 does not exist;unnestof two dimensions returns the sub-arrays; the array functions over an aggregate (array_length(array_agg(x), 1)) are refused (array_to_string(array_agg(..), sep)works);array_aggof arrays does not check dimensions. pg_dump(D112.2): the plain dump writes aCHECKconstraint and a view's query as they were written, where PostgreSQL writes its deparsed form (the restoring server deparses them itself, so the restored\d+is identical); privileges are not dumped (relaclisNULL); role passwords are not dumped;pg_dumpof materialized views, generated columns and objects of several owners was not checked.\d+of a view shows the stored query text, not PostgreSQL's deparsed text.pg_total_relation_sizeand friends answer 8192 for everything (so\dt+sizes differ).LISTEN/NOTIFY(D112.3) work inside oneraftdb-pgprocess; on a TLS connection an idle listener gets its notifications at its next statement;pg_notifyneeds constant arguments;LISTENinside an aborted transaction is not undone.- Cursors (D112.5) read their rows at
DECLARE(a large result is kept in the session);MERGE(D112.4) needs a target with a primary key and runs as several engine statements in one transaction; generated columns show the expression as written (generated always as (a + b) stored: PostgreSQL's deparse can differ for anything but simple expressions). - DDL is not transactional (the engine's DDL commits): a
CREATE TABLEin a rolled-back transaction stays;ALTER TABLE .. ADD CONSTRAINT .. CHECKfailed in the engine after otherALTERs of a table in a long script (cause not found; it works on fresh tables and inCREATE TABLE). - Transactions are atomic but not isolated;
SET TRANSACTION ISOLATION LEVELandBEGIN ISOLATION LEVELare reported bySHOW transaction_isolationbut have no effect; row locks (FOR UPDATE) are not taken;statement_timeoutandCancelRequestdo not interrupt a running statement (the request is counted). - Privileges (D110.1): privileges on functions do not exist; column privileges are enforced but
\dpdoes not show them;CONNECTon a database is not checked at login; the owner cannot revoke its own privileges;REVOKEwithoutCASCADEdoes not check privileges passed on;\dpandrelaclshow nothing; the lines of aDROP ROLEdetail list put a serial sequence before its table and otherwise sort by name (PostgreSQL's is by OID); the owner ofpublicis the server's superuser. Logins, passwords (SCRAM verifiers) andNOLOGINare enforced. Row-level security does not exist. - Functions and triggers (D110.3): (
\df,\sf,pg_procandpg_get_functiondefknow the functions since D112.2);(f(..)).colof a function withOUTparameters is not supported;EXECUTEon functions is not checked andSECURITY DEFINERhas no effect; variables shadow columns of the same name instead of raisingambiguous; errors raised by statements inside a trigger function lack theCONTEXT: SQL statementlines;UPDATE OFrow triggers fire for an update the engine makes by itself (a cascade) whatever columns it changes; transition tables keep the columns the table had when the trigger was made; PL/pgSQL cursors read their rows when opened and stay open after the transaction;pg_trigger_depth()counts the triggers the front-end runs, not the engine's row triggers; the order in which a multi-rowUPDATEtouches rows (and fires row triggers) is the engine's, not PostgreSQL's heap order;RAISE NOTICEin a trigger function is dropped. COPY(D110.2): no files or programs on the server, noFORCE_NULL,ON_ERROR,DEFAULT,WHERE.UPDATE .. RETURNINGreads the primary keys, updates, then reads the rows by key (three engine statements, not atomic with other sessions; the table needs a primary key;RETURNINGmay name only the target table; aSETof the key column is not followed).INSERT .. ON CONFLICT .. RETURNINGneeds literal values for the conflict key columns.ON CONFLICT (cols)takes any unique key as the conflict. Simple views are updatable (D126) andinformation_schemasays so (D135).WHERE CURRENT OFneeds a table with a primary key whose columns the cursor reads.EXPLAINprints a plausible plan (Seq Scan on t (cost=.. rows=.. width=..),Nested Loop,Append), not the engine's plan;EXPLAIN ANALYZEtimes are not measured.- Catalogs. Object identifiers are made from names;
pg_settingsis a short fixed list;pg_get_constraintdefof aCHECKprints the expression as written insideCHECK ((..))(PostgreSQL prints its own normal form:CHECK ((qty > (0)::numeric)));information_schema.table_constraintsdoes not list theNOT NULLconstraints PostgreSQL 18 shows asCHECK; the order of the objects in aDETAILlist of aDROP .. CASCADEis alphabetical (PostgreSQL's is by OID). SHOW ALLlists the parameters the front-end knows;SETof another name is42704.- Multi-statement simple queries (
Querymessage with several statements, whichpsqlsends only with\;) run in an implicit transaction made by the front-end with the engine'sSTART TRANSACTION/COMMIT. GENERATED ALWAYS AS IDENTITYdoes not refuse an explicit value.- Statistics views (
pg_stat_*) have PostgreSQL's columns and rows, but their counters are 0 and their times NULL: Raft DB does not keep them.pg_stat_statementsdoes not exist. TABLESAMPLEkeeps each row with the given chance (SYSTEMtoo: PostgreSQL samples pages); which rows are chosen differs from PostgreSQL's choice.jsonbfunctions work on the engine's JSON: a number written1.50comes back as1.5;json_strip_nullsof ajsonvalue writes it without blanks.WITHinside a subquery is rewritten into derived tables; a recursive one inside a subquery stops after 8 levels.
pgbench against PostgreSQL 18 (D110.5)#
pgbench -i and the built-in tpcb-like and select-only scripts run against raftdb-pg. The table below was made with Raft DB's own benchmark script (not part of the download) that runs a private raftdb-pg and a private PostgreSQL 18 on the same Windows laptop, one after the other, nothing else running, below-normal priority, scale 1, 15 s per cell, simple query mode, one run per cell. Caveats that matter: PostgreSQL with default settings and the Raft DB server with its default commit path (durability not made equal here); Raft DB's transactions are not isolated, so the 16-client tpcb-like row (one branch row everybody updates) does not wait for locks as PostgreSQL does and is not comparable; pgbench shares the CPU. This is Raft DB running as PostgreSQL: it is not a basis for speed claims on the website.
| workload | clients | Raft DB as PostgreSQL tps | latency ms | PostgreSQL 18 tps | latency ms |
|---|---|---|---|---|---|
| select-only | 1 | 9051 | 0.11 | 9157 | 0.11 |
| select-only | 4 | 25561 | 0.16 | 27428 | 0.15 |
| select-only | 16 | 45569 | 0.35 | 50249 | 0.32 |
| tpcb-like | 1 | 760 | 1.32 | 1318 | 0.76 |
| tpcb-like | 4 | 1906 | 2.10 | 3024 | 1.32 |
| tpcb-like | 16 | 4105 | 3.90 | 2432 | 6.58 |
pgbench -i -s 1: 18.3 s on raftdb-pg (the primary keys), 0.4 s on PostgreSQL.
Next#
Declarative partitioning, range types, tsvector values with ts_rank and the other text search functions, a deparser of expressions (so that plain dumps, CHECK constraints, views and index expressions are written exactly as PostgreSQL writes them), privileges on functions, row-level security, isolation.