- Notifications
You must be signed in to change notification settings - Fork5
Commitf478692
committed
The attached file: SerializePatch2.tgz, contains a patch for
org.postgresql.util.Serialize and org.postgresql.jdbc2.PreparedStatementthat fixes the ability to "serialize" a simple java class into apostgres table.The current cvs seems completely broken in this support, so the patchputs it into working condition, granted that there are many limitationswith serializing java classes into Postgres.The code to do serialize appears to have been in the driver sincePostgres 6.4, according to some comments in the source. My code is notadding any totally new ability to the driver, rather just fixing whatis there so that it actually is usable. I do not think that it shouldaffect any existing functions of the driver that people regularlydepend on.The code is activated if you use jdbc2.PreparedStatement and try tosetObject some java class type that is unrecognized, like not String ornot some other primitive type. This will cause a sequence of functioncalls that results in an instance of Serialize being instantiated forthe class type passed. The Serialize constructor will query pg_classto see if it can find an existing table that matches the name of thejava class. If found, it will continue and try to use the table tostore the object, otherwise an SQL exception is thrown and no harm isdone. Serialize.create() has to be used to setup the table for a javaclass before anything can really happen with this code other than anSQLException (unless by some freak chance a table exists that it thinksit can use).I saw a difference in Serialize.java between 7.1.3 and 7.2devel that Ididn't notice before, so I had to redo my changes from the 7.2develversion (why I had to resend this patch now). I was missing thefixString stuff, which is nice and is imporant to ensure the insertswill not fail due to embedded single quote or unescaped backslashes. Ichanged that fixString function in Serialize just a little since thereis no need to muddle with escaping newlines: only escaping single quoteand literal backslashes is needed. Postgres appears to insert newlineswithin strings without trouble.1 parentca86791 commitf478692
File tree
2 files changed
+360
-252
lines changed- src/interfaces/jdbc/org/postgresql
- jdbc2
- util
2 files changed
+360
-252
lines changedLines changed: 26 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
613 | 613 |
| |
614 | 614 |
| |
615 | 615 |
| |
616 |
| - | |
| 616 | + | |
| 617 | + | |
617 | 618 |
| |
618 | 619 |
| |
619 | 620 |
| |
| |||
674 | 675 |
| |
675 | 676 |
| |
676 | 677 |
| |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
677 | 701 |
| |
678 | 702 |
| |
679 | 703 |
| |
| |||
803 | 827 |
| |
804 | 828 |
| |
805 | 829 |
| |
| 830 | + |
0 commit comments
Comments
(0)